O'Reilly logo

Professional Cairngorm™ by Jeremy Wischusen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.1. What Is It?

The ServiceLocator is one of the core singleton classes of the Cairngorm framework. According to a previously cited article, "Flex 3: Introducing Cairngorm" (Adobe Customer Training/Partner Enablement Group, Burleson, Shuman, and Boles), the ServiceLocator has the following characteristics:

  • The ServiceLocator pattern is used to create a global singleton registry to centralize all instances of Flex RDS components used in an application. These include:

    • HTTPService

    • WebService

    • RemoteObject

  • It supports easy lookup of services by name.

  • It should never be used outside the control layer.

In a standard Flex project, services may be instantiated as needed by individual components. This can cause them to be scattered across the application. In Cairngorm all services are created in and accessed by the ServiceLocator. Because the ServiceLocator provides a centralized location for registering and accessing services, individual components no longer have to instantiate services themselves and services can all be configured in a single location.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required