EAServer components in any component model follow the state diagram illustrated in this figure:
Figure 2-1: States in the EAServer component life cycle
The state transitions are as follows:
New instance The EAServer runtime allocates a new instance of the component. The instance remains idle in the instance pool waiting for the first method invocation.
Activation Activation prepares a component instance for use by a client. Once an instance is activated, it is bound to one client and can service no other client until it has been deactivated. If a component is transactional, activation also indicates the beginning of the instance’s participation in a transaction.
In method In response to a method invocation request from the client, the EAServer runtime calls the corresponding method in the component. The next state depends on which of the transaction state primitives the method calls before returning. (For Java components, the state transition also depends on whether the method returns with an uncaught exception.) See “Using transaction state primitives” for more information.
Deactivation Deactivation indicates that the component is no longer bound to the client. Methods can call either the completeWork or rollbackWork transaction state primitives to cause explicit deactivation of the instance. As discussed in “Using transaction state primitives”, these primitives also affect the transaction’s outcome. Deactivation can also occur automatically, under any of the following circumstances:
If the instance is participating in a transaction, the instance is deactivated when the transaction commits, rolls back, or times out.
If you have configured the component’s Instance Timeout property to a finite setting, an instance is deactivated if the time between consecutive method calls exceeds the timeout value. “CORBA component property descriptions” describes how to configure this property.
If an exception occurs in a user transaction, you must call rollbackWork after catching the exception; otherwise, a transaction deadlock may occur in the database, which can cause client applications to fail.
Destruction Destruction occurs if the component instance cannot be recycled. “Supporting instance pooling in your component” describes how to ensure instance reuse. If the component cannot be reused, deactivation is followed by destruction of the instance.
The EAServer component life cycle allows component instances to be recycled; idle component instances can be cached when idle and bound to the service of individual clients only as needed. If your component has been coded to support early deactivation, a client holding a reference to the component’s stub or proxy object may be serviced by several different instances of the component. After each deactivation, the next method invocation causes an instance to be activated and bound to the client. Overall server scalability is increased because a new instance does not have to be instantiated each time a client invokes a method.