I'm building an XMPP application using Flex and trying to use Cairngorm. One of the problems I've run into is using the ServiceLocator. Since XMPP isn't one of the standard services I'm assuming I have to write my own child of AbstractService but I can't seem to find any examples. Anyone have any examples? Am I on the right track?
I had similar problems while trying to use the cairngorm ServiceLocator with MySqlService...
the cairngorm 2.2.2 beta changelog says that they have "added getAbstractService and getAbstractInvoker to ServiceLocator to accommodate the usage of third party service packages such as as3rpc."
however i cant seem to find it... in the code or swc...
so i decided to just extend my own class from the cairngorm ServiceLocator...
basically i did the following... and it works:
public class ServiceLocator extends com.adobe.cairngorm.business.ServiceLocator
private static var _instance:com.bs.dpair.business.ServiceLocator;
public static function getInstance() : com.bs.dpair.business.ServiceLocator
if ( _instance == null )
_instance = new com.bs.dpair.business.ServiceLocator();
public function ServiceLocator()
if ( _instance != null )
throw new CairngormError( CairngormMessageCodes.SINGLETON_EXCEPTION, "ServiceLocator" );
_instance = this;
public function getMySqlService(serviceName:String):MySqlService
if(this[serviceName] == null)
throw new CairngormError( CairngormMessageCodes.SERVICE_NOT_FOUND);
return this[serviceName] as MySqlService;
now you can just use this class in the services.mxml file etc...
it could have been much simpler if i just called it ServiceLocator2 or something but i figured this code wont be touched much anyway...