3.5. Summary

In this chapter you looked at the classes and interfaces associated with the Cairngorm ServiceLocator. These included:

  • AbstractServices

  • HTTPServices

  • IServiceLocator

  • IServices

  • RemoteObjects

  • Responder

  • ServiceLocator

  • WebServices

The ServiceLocator acts a centralized repository where your remote classes such as HTTPService, WebService, and RemoteObject are created and accessed.

Services are looked up by instance name using to corresponding function for the type of service that you are looking for. These functions are getHTTPService, getRemoteObject, and getWebService.

The ServiceLocator is not intended to be used outside the control layer.

The ServiceLocator is implemented as an MXML file, normally in the business package. You register services by adding the appropriate tags to the ServiceLocator MXML file.

You need to have an instance of the ServiceLocator MXML file in your main application; however, this instance is not directly accessed. Instead you use the singleton getInstance method to refer to the instance and then call the desired methods on the returned instance.

Once you have retrieved a service from the ServiceLocator, working with it becomes the same as working with that service in any Flex project.

Get Professional Cairngorm™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.