Working with shared components
To allow clients to share state information, Jaguar provides
support for shared components. Shared components
allow multiple clients to share the same component instance.
When you deploy a PowerBuilder nonvisual object to Jaguar,
you have the option to configure this object as a Jaguar shared
Benefits of using Jaguar shared components
Shared components allow you to:
- Provide convenient
access to common data that would otherwise need to be retrieved
separately by each client connection
- Reduce the number of database accesses, allowing
the database server to be available for other processing
Jaguar shared components versus PowerBuilder
Jaguar shared components offer many of the same benefits as
PowerBuilder shared objects. However, they are not the same thing.
PowerBuilder components that you deploy to Jaguar can act as clients
to Jaguar shared components, as well as to PowerBuilder shared objects.
Jaguar shared components can be accessed by components and clients
that are not implemented in PowerBuilder.
However, Jaguar does not treat PowerBuilder shared objects
as if they were Jaguar shared components. Therefore, the functions
used to manipulate PowerBuilder shared objects (SharedObjectRegister,
SharedObjectGet, and so forth) do not work with Jaguar shared components.
If you try to call one of these functions inside a PowerBuilder
component running in Jaguar, the request will fail.
Creating a shared component
You can mark a component as shared in the PowerBuilder wizards.
This is equivalent to marking it as shared in the Instances tab
of the Component Properties dialog box in Jaguar Manager.
Clients (and other server components) access a shared component
just as if it were any other kind of component.
Creating a service component
You can mark a shared component as a service component in
the PowerBuilder wizards. A service component performs background
processing for Jaguar clients and other Jaguar components. Jaguar
loads service components at server startup time.
When you mark a component as a service in one of the PowerBuilder
wizards, PowerBuilder installs the component as a service in Jaguar
at deployment time. This is equivalent to adding the component to
the list of services for the server by modifying its com.sybase.jaguar.server.services
The PowerBuilder wizards include three additional functions
for a service component. These functions allow you to control the
behavior of background processes associated with the service:
- Start The Jaguar server calls the Start function after the service component
has been loaded. You can add logic to this function to perform startup
initialization for the service.
- Run The Jaguar server calls the Run function after the first invocation
of the Start function returns. The Run function allows you to perform repetitive
tasks as a background process. The Run function must periodically
suspend its own execution by calling the JagSleep C function.
The JagSleep function frees the CPU to perform other tasks. To use
the JagSleep function, you need to declare an external function
for JagSleep in PowerBuilder. Here’s the syntax you need
to use for the function declaration:PowerBuilder1subroutine JagSleep (Long seconds) LIBRARY
- Stop This function allows you to stop the execution of the background process
coded in the Run function. You can implement a service-manager client
for your service that calls Stop, Start, and Run so that the service
can be restarted without restarting the Jaguar server. The script
for the Stop function can also clean up any resources that were
allocated in the Start function.