I'm new to Flex and have been spending a lot of time trying to figure
out how is part of cairngorm framework works. Please help.

Cairngorm uses singleton pattern to ensure that there is only one
instance of a class running for each app.

For example, the ServiceLocator class use a static method to return
the instance reference to you.

     public static function getInstance() : ServiceLocator
     {
                  if ( serviceLocator == null )
                        serviceLocator = new ServiceLocator();
     
                  return serviceLocator;
     }

The documentation said that the recommended way to use this class is
to subclass ServiceLocator and define your services, using the code
similar to the following:
    
<cairngorm:ServiceLocator xmlns:mx="http://www.macromedia.com/2003/
mxml" xmlns:cairngorm="org.nevis.cairngorm.business.*" >

    <mx:RemoteObject id="customerDelegate" source="org.nevis.
cairngorm.samples.login.LoginDelegate"
                     result="event.call.resultHandler( event )"
                     fault="event.call.faultHandler( event )">
    </mx:RemoteObject>

</cairngorm:ServiceLocator>

so far so good. however the documentation said Services can later be
located, usually in a business delegate class as shown here:
    var service = ServiceLocator.getInstance().getService( "
customerDelegate" );

This is where I am confused. I just used mxml to subclass the
servicelocator class and add a new property (remoteobject) to the
instance of the subclass (not parent class). But when I use
ServiceLocator.getInstance("cusomerDelegate")

what I get is a reference to the parent class which is "ServiceLocator
" class defined by cairngorm. How can i use a reference to the parent
class to locate a property of the child class.

I'm very confused. This may have something to do with the way that
mxml script is compiled into actionscript object. Someone please give
me some ideas.

By the way, I tried to subclass the ServiceLocator class in
actionscript 2 and assign an service object to the subclass.

When I use

ServiceLocator.getInstance.getService('myService');

The program returned saying that the service can not be found. I
guess it kind of makes sense in that the object belongs to the
subclass not the parent class.

sorry for making this a bit long.

Thanks,

Larry

















--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to