Navigation trail: TurbineProjectPages - JakartaTurbine2 - JakartaTurbine2UsersGuide - Services


Turbine 2.x User's Guide: What Is A Service?

Services are singletons within the Turbine Framework which have pluggable implementation, and are capable of participating in the Turbine startup and shutdown. As Services are Singletons, there is only one instance of each service in the system. Memory or connections are allocated only once and the internal state is common to all requesting clients. A Service that is never used will not allocate resources to itself. A Service can also execute actions upon the system being shutdown, such as closing open connections.

Services are configurable accessing ServletConfig and TurbineResouces.properties at startup. Uses might include setting paths, defaults and similar functionality. They also access RunData on the first Turbine doGet execution to get the environment Turbine is operating within. Services can also initialize themselves before they are requested by the client for the first time.

The Singleton pattern also allows for the Services to be accessed from anywhere within your code, which is were the real power of Services comes in to play. As separate, testable entities, Services should contain all business logic so that screens and actions may become as thin as possible. Further, business and application logic can be separted in an effort to cleanly decouple application components.


CategoryJakartaTurbine2

  • No labels