AIR Cairngorm (AIR extensions for Cairngorm)

Monday, July 16th, 2007

I have developed an open source ActionScript 3 project called “AIR Cairngorm” which is intended to provide a framework for working with the new Adobe AIR services while utilizing the Cairngorm-micro architecture.

When I say AIR Services, I am referring to the SQLite and FileSystem APIs, which are available in Adobe AIR.

AIR Cairngorm provides a framework which developers can employee to build typical Cairngorm applications that utilize these services.

The following is a brief description of the AIR Cairngorm API:

AIRServiceLocator: The AIRServiceLocator is a sub class of Cairngorm ServiceLocator, therefore it inherits the same API as ServiceLocator, and adds an additional API for working with local databases.
view source

SQLService: The SQLService is essentially a wrapper class for the SQLStatement and SQLConnection classes. The SQLService class allows developers to create an mxml implementation just as one would with typical HTTPServices, WebService and so forth in a Cairngorm ServiceLocator.
view source

ISQLResponder: ISQLResponder provides a consistent API from which asynchronous SQLStatement execution results and faults can be handled. ISQLResponder is very similar to IResponder in that it defines both a result and fault handler with a slightly different signature which is specific to a SQLStatement result / fault, (i.e strongly typed parameters).
view source

ISQLStatementResource
: ISQLStatementResource is a marker interfaces which is intended to improve code readability by indicating that a class which implements this interface is to provide access to external SQL statements defined in a .properties file.
view source

SQLStatementHelper: SQLStatementHelper is an all static utility class which provides a mechanism for substituting tokens specified in a statement with arbitrary values.
view source

I am also releasing an update to Cairngen (though only a dot release) which supports the AIR Cairngorm API. Cairngen will now provide targets for generating business delegates which utilize the AIR Cairngorm services.

I suspect Adobe will release an updated version of Cairngorm which supports integration with AIR applications. AIR Cairngorm provides an interim solution which developers can use under the terms specified in the License.

I plan to update AIR Cairngorm to support the AIR File system API within the next week or so.

Below I have provided downloads for the source, binary, AIR Cairngen and usage example:
source
example
air-cairngen
air-cairngorm

{ 19 comments to read ... please submit one more! }

  1. Eric,
    You never cease to amaze. Nice work yet again. Looking forward to the Cairngen support for this as well.
    -Augie Marcello

  2. Thanks for this. I plan to use it in an upcoming project. I also will be using Cairngorm with LocalConnection, but I don’t think there is a LocalConnectionService class, is there? Perhaps I’ll make one up and pass it along for review.

    Looking forward to getting into Ant and Cairngen as well.

  3. I have recently started reading your blogs, they are amazing, and this AIR Cairngorm article is very helpful and SQLite admin is very good, I got one question on CF returning resultset with following type of VO

    sampleVO
    {
    id int,
    name string,
    addresses arrayCollection,
    offices arrayCollection
    }

    when I get my result back I loose the values coming in addresses and offices which are type array and coming as addressVO and officeVO,

    I can provide you with more detail or send you code if ou want, do you have any example of this? please let me know nif you need more info?

    Regards

    Philip

  4. Hi Eric,

    fantastic work you’ve done here! I was wondering
    if there is any contraindication to use your framework
    directly in a projet using the Cairngorm Universal Mind extension?

    Also I was wondering what could happen
    if we have two running services (so connections)
    on the same database that do read and update
    simultaneously? Could it throw any errors and
    is this manageable by your framework?

    Many thanks for your work
    I’m looking for your answer if you have the time
    Cédric

  5. Hey Cedric,

    Thanks for the compliments. I don’t see any reason why you couldn’t use the AIR Cairngorm extensions with UM’s extensions, however I haven’t tried that myself.

    Also, I updated the SQL Implementation, the version in this post is deprecated, so please see the following for the latest SQL Lite implementation:
    http://www.ericfeminella.com/blog/2008/09/29/air-sql-framework/

    Best,
    Eric

  6. good one keep it up

  7. i want use it in flex builder,can i?

  8. when i import your example into FB, a error occur:

    Severity and Description Path Resource Location Creation Time Id
    Design mode: Cannot load Cairngorm.swc (reason: ERROR: Load Verify). It may require classes (such as Adobe AIR components) that are not supported by design mode. Check the Eclipse error log for more details. AIRCairngormAsyncExample/src/air/cairngorm/async/example/business Services.mxml Unknown 1229672613828 6598

  9. really sorry
    i’m so careless
    forget air version in the config file

    to

    now i can run your examples

    thanks for your article very very muck~

  10. Eric –
    When the preinititialize function in my Services.mxml runs it creates the db successfully but I get a run-time error “Cannot create property version on flash.data.SQLConnection”.

    Inside your SQLService.as I see you wrote this function:

    private function openResult(result:SQLEvent) : void{
    databaseConnection.version = databaseVersion;
    }

    If databaseConnection is a flash.data.SQLConnection type then where does this property “version” come from? Am I missing something obvious here?

    Thanks

  11. Hey Chris,

    I originally developed this API back on July 16th, 2007. At that time AIR was still in beta. I believe in the time since the version property is either deprecated or no longer exists. Try removing it from the source and the RTE should be resolved.

    I created a new AIR SQL framework in September based on the DAO pattern, I recommend utilizing this implementation if possible, which can be found at:
    http://www.ericfeminella.com/blog/2008/09/29/air-sql-framework/

    Best,
    Eric

  12. Thanks. Great work it really helps

  13. Hi Eric,
    Testing implementation of SWC into project. Trouble getting head around how CreateTableEvent is getting called. I was looking for something obvious in preinitialize. Anyway – if you have a couple to layout how that event is being dispatched and listened for – that would be appreciated.
    Thanks much!

  14. Hi Eric, great work except now that you have dumbed down the use of the statement(by ony allowing a text property as an argument) i cannot seem to set parameters on my statement as before when using my home built sql services.

    Perhaps I am missing something but I got round the problem by extending your class and adding a similar method for executing the statement but this time passing the statement (thus giving me more control before injecting) and not the string which effectively only serves as the text property of the statement. I am guessing your choice to do this was to keep it simple but I actaully had no choice as the string I was passing contained characters that were not accepted in the string but were accepted in the parameters object of the statement. Forward slash was the problem character.

    if you have a solution for this please post it so I can keep my code simple.

    Keep up the good work

{ 4 Pingbacks/Trackbacks }

  1. Sönke Rohde » AIR Cairngorm
  1. AIR Cairngorm | Adobe AIR Tutorials
  1. reintroducing.com Blogging Receptacle » Blog Archive » AIR Cairngorm
  1. Sönke Rohde » AIR examples/links, Desktop 2.0 and Adobe Developer Connection