Chapter 2 ActiveX C++ Interface Reference
Allows components to support Jaguar's instance pooling model. Jaguar calls the IObjectControl methods to indicate transitions in the lifecycle of an ActiveX component.
Implement the IObjectControl interface:
Note
If you want to pool instances every time they are deactivated
and you do not need to reset the component's state, you
only need to check the Pooling option on the component's
Instances tab.
The server can maintain a cache of idle component instances and bind them to individual clients only as needed. This strategy allows the server to service more clients without the performance drain caused by allocating a component instance for each request.
The Activate method indicates that an instance is being removed from the pool to service a client. The Deactivate method indicates that the instance is finished servicing the client. Instance reuse is optional (see "Support for instance pooling"). However, components that support it will achieve greater scalability.
If you are coding the component in C++, you can directly implement IObjectControl. However, some automation controllers such as PowerBuilder 7.0 provide built-in, implicit support. See your IDE's documentation for more information.
The instance-pooling lifecycle is tightly coupled with the Jaguar transaction model. See "Understanding Transactions and Component Lifecycle Models" in the Jaguar CTS Programmer's Guide for a description of how components participate in transactions.
The next section discusses the ActiveX component lifecycle in detail.
The following figure illustrates the states and state transitions in the lifecycle of an ActiveX component.
The state transitions are as follows:
TRUE
the
instance is placed back in the idle pool for reuse. Otherwise, the
instance is destroyed.
To support instance pooling using the IObjectControl interface, you must code your component as follows:
TRUE
if
the instance state can be reset.
The decision whether to reuse a specific instance can be made at runtime.
Note
CanBePooled will not be called if the Pooling
option on the component's Instances Tab is checked.
IObjectControl is defined in jagctx.h, which is provided in the Jaguar include subdirectory.
You must include initguid.h in only one source file that is linked into your component DLL. If you do not include initguid.h in one file or you include it several files, your project will not link.
initguid.h is not included with Jaguar. It is part of the Win32 SDK. Both Microsoft Visual C++ and Powersoft Power++ provide this file. Other ActiveX C++ builder tools may provide it as well.
Chapter 8, "Creating ActiveX Components" in the Jaguar CTS Programmer's Guide
Method called by the Jaguar runtime server to indicate that a component instance has been activated.
#include <jagctx.h>
HRESULT IObjectControl::Activate (void);
Activate and Deactivate allow a
component's instances to be pooled. If a component supports
instance pooling, Activate must reset any class
variables to the initial values, as if the component instance were
being freshly constructed. To prohibit instance pooling, code the CanBePooled method
to return FALSE
.
See "ActiveX component lifecycle" for more information on when Activate and Deactivate are called.
If a component is declared to be transactional and its Activate method returns an error (any value other than S_OK), the Jaguar runtime server rolls back the transaction in which the component is about to participate.
Method called by the Jaguar runtime server to determine whether a component instance is eligible for reuse.
Note
CanBePooled will not be called if the Pooling
option on the component's Instances Tab is checked.
#include <jagctx.h>
BOOL IObjectControl::CanBePooled (void);
Return value |
To indicate |
---|---|
TRUE |
The instance can be reused. |
FALSE |
The instance cannot be reused and should be deallocated. |
If a component implements the IObjectControl interface,
a single instance can be activated and deactivated many times to
serve different clients. After deactivation, the Jaguar server runtime
calls the component's CanBePooled method
to determine whether the current instance can be reused. If CanBePooled returns FALSE
,
Jaguar destroys the instance.
Components that support instance pooling must be coded such that a recycled instance behaves the same as a newly allocated instance. See "Support for instance pooling" for more information.
Method called by the Jaguar runtime server to indicate that a component instance has been deactivated.
#include <jagctx.h>
void IObjectControl::Deactivate (void);
The Jaguar runtime calls Deactivate to indicate that the component instance is being deactivated. See "ActiveX component lifecycle" for more information on when Activate and Deactivate are called.
If your component caches data changes, you can code the Deactivate method to send cached changes to the remote database server.
Deactivate can be used to deallocate or reset the state of objects that are initialized in the Activate method.
Copyright © 2000 Sybase, Inc. All rights reserved. |
![]() |