Chapter 31 Creating Service Components
Service components perform background processing or provide common services for EAServer clients and other EAServer components. For example, you might create service components to perform the following tasks:
Service components are like any other EAServer component, except that:
The Thread Manager and service components
You can use the Thread Manager as an alternative to creating
a service component to handle repetitive processing. You may find
the Thread Manager interface allows more design flexibility. For
example, you can suspend processing in services run by the Thread
Manager, and you can start threads at any time rather than only
at server start-up.PowerBuilder developers can use the Thread Manager to develop
more robust services. Since PowerBuilder components cannot support
sharing and concurrency, you cannot develop a service that can be
stopped or refreshed without using the Thread Manager.See Chapter 30, "Using the Thread Manager" for
more information.
Your component implementation must implement all the methods in the CtsServices::GenericService interface. Your implementation does not need to explicitly implement the interface (that is, list it in the implements clause of the class declaration), and you do not need to list the interface in the component's Interfaces folder in Jaguar Manager.
EAServer calls the CtsServices::GenericService methods to indicate transitions in the service's state:
Service components that make intercomponent calls
If your start method makes intercomponent
calls, check the
com.sybase.jaguar.server.bindrefresh
property
for the servers where your component is installed. Use the All Properties
tab in the Server Properties dialog box to view and change this
property. This property must be set to "start" to
allow name service lookups in the start method
of service components. The default setting is "run".
WARNING! | Your run() method must either return immediately or call the Thread.sleep() Java method, the EAServer JagSleep C routine, or some other thread-aware implementation of sleep. Do not call the sleep system routine or any other routine that suspends process (and not thread) execution. If coding service components in PowerBuilder, code your component to call the JagSleep C routine; do not use the PowerBuilder timer event, which may suspend the EAServer process. |
Your component can implement additional interfaces. EAServer clients, servlets, and other components can execute a service component's methods like those of any other component, with one exception: Clients cannot invoke methods on the service component until the start() method has returned. This restriction allows you to perform required initialization in start() without worrying about thread synchronization issues.
After start() returns, EAServer calls the run() method in its own thread. Client method invocations may arrive at this time as well. There is no guarantee that run() will have been called when a client method invocation occurs; the first client invocations may arrive before EAServer calls the run() method.
Copyright © 2002 Sybase, Inc. All rights reserved. |
![]() |