Packagecom.ericfeminella.air.cairngorm.business
Classpublic class AIRServiceLocator
InheritanceAIRServiceLocator Inheritance com.adobe.cairngorm.business.ServiceLocator

AIRServiceLocator provides a mechanism from which AIR APIs, specifically SQLConnection, SQLStatement) can be located (referenced) from the Cairngorm ServiceLocator as a Service via SQLService.

AIRServiceLocator allows for Adobe AIR specific APIs to be retrieved from a Cairngorm ServiceLocator implementation in the same way one would access RPC Services such as HTTPService, WebService etc. from the ServiceLocator


Example
The following example demonstrates a typical implementation of AIRServiceLocator
  
  <?xml version="1.0" encoding="utf-8"?>                      
  <services:AIRServiceLocator xmlns:mx = "http://www.adobe.com/2006/mxml" 
                                 xmlns:services = "com.ericfeminella.air.cairngorm.business." >
   <mx:Script>
    <![CDATA[
     import mx.events.FlexEvent;
        
     public static const RDBMS:String = "rdbms";
     
           protected override function preinitialize(event:FlexEvent) : void
           {
               rdbms.open();
           }
    ]]>
   </mx:Script>
   
   <services:SQLService id = "rdbms" 
                localDatabaseFilePath = "{ File.desktopDirectory.nativePath }"  
                localDatabaseFileName = "air.cairngorm.example.db"
                />
  
  </services:AIRServiceLocator>
  
  

See also

com.adobe.cairngorm.business.ServiceLocator


Protected Properties
 PropertyDefined by
  instance : AIRServiceLocator
[static] Defines the Singleton instance of AIRServiceLocator
AIRServiceLocator
  services : SQLServices
Defines the SQLServices instance which contains a reference to all SQLService defined on a AIRServiceLocator instance
AIRServiceLocator
Public Methods
 MethodDefined by
  
AIRServiceLocator constructor Instantiates the Singleton instance of AIRServiceLocator and adds an listener for the FlexEvent.PREINITIALIZE event
AIRServiceLocator
  
[static] Retrieves the Singleton instance of the AIRServiceLocator
AIRServiceLocator
  
getSQLService(name:String):SQLService
Retrieves a specific SQLService which has been defined by the AIRServiceLocator instance
AIRServiceLocator
  
hasSQLService(name:String):Boolean
Determines if the specified SQLService has been defined on a AIRServiceLocator instance
AIRServiceLocator
Protected Methods
 MethodDefined by
  
preinitialize(event:FlexEvent):void
Abstract method which is invoked when Application.preinitialize event is dispatched.
AIRServiceLocator
Property detail
instanceproperty
protected static var instance:AIRServiceLocator

Defines the Singleton instance of AIRServiceLocator

servicesproperty 
protected var services:SQLServices

Defines the SQLServices instance which contains a reference to all SQLService defined on a AIRServiceLocator instance

Constructor detail
AIRServiceLocator()constructor
public function AIRServiceLocator()

AIRServiceLocator constructor Instantiates the Singleton instance of AIRServiceLocator and adds an listener for the FlexEvent.PREINITIALIZE event


Throws
Method detail
getInstance()method
public static function getInstance():AIRServiceLocator

Retrieves the Singleton instance of the AIRServiceLocator

Returns
AIRServiceLocator — singleton instance of AIRServiceLocator
getSQLService()method 
public function getSQLService(name:String):SQLService

Retrieves a specific SQLService which has been defined by the AIRServiceLocator instance

Parameters
name:String — unique identifier of the SQLService instance

Returns
SQLServiceSQLService instance with the specified name

Example
The following example demonstrates how a SQLService instance can be referenced via AIRServiceLocator.getSQLService
         
         var service:SQLService;
         service = AIRServiceLocator.getInstance().getSQLService( Services.SERVICE );
         
         

hasSQLService()method 
public function hasSQLService(name:String):Boolean

Determines if the specified SQLService has been defined on a AIRServiceLocator instance

Parameters
name:String — unique identifier of the SQLService instance

Returns
Boolean — true if the service exists, otherwise false
preinitialize()method 
protected function preinitialize(event:FlexEvent):void

Abstract method which is invoked when Application.preinitialize event is dispatched.

This method is provided in order to allow clients to override in order to initialize services at startup of the application.

Parameters
event:FlexEvent