0 Replies Latest reply on Jan 19, 2009 1:12 PM by

    Writing a Cairngorm ServiceLocator for 'fallback' services

      Hi,
      I'm a Flash developer migrating to Flex and Cairngorm. I want to
      have my Cairngorm ServiceLocator use AMF Remoting as the first option
      but then fall back to a SOAP webservice if that fails. Both services
      have the same methods/operations as they are implemented in ASP.Net
      with WebOrb.

      I can define both the Remoting service and the webservice in the
      Services.mxml file in the usual way and can access both from my
      delegates and it all works fine.

      Here's my problem: The Cairngorm examples I have seen all show that
      the generic getService() method is depreciated and I should use
      getRemoteObject() or getWebService() from IServiceLocator. Using
      that approach I could put the logic to decide which service to use
      into each and every delegate but it would make more sense to have it
      centralised in the Services.mxml file and have this serve up the
      currently used service to my delegate. Since they both inherit the
      same methods, I should be able to call a generic services object
      using polymorphism and do some good OOP in the process.

      So here's my question: How would you experienced Cairngorm users out
      there approach this?
      - Should I write a new method in my Services.mxml component, which
      switches between services by binding it to a variable indicating
      which service type to use in the ModelLocator? I'm not sure it would be good
      OOP to have the Servicelocator write to the ModelLocator though.
      - Should I scrap the mxml version and extend ServiceLocator in
      Actionscript?
      - Should I abandon this bit of the Cairngorm framework swc interfaces
      and write this from scratch?
      - Any other suggestions/warnings? Has anyone done something like
      this before?

      Thanks in anticipation of your help!