Chapter 29 Managing Persistent Component State
Stateful components collect client session data over successive client method invocations. Normally, state data is stored in memory using fields in the implementation class. However, instances of a component coded this way can run on one server only, and cannot support load balancing or failover. Implementing the component to use persistent state allows instances to participate in failover and load balancing.
To use persistent state management, a stateful component must be an EJB stateful session Bean or a component of another type that uses the control interface CtsComponents::ObjectControl.
You can manage persistence using these techniques:
To use Java serialization, configure the following fields on the Persistence Tab in the Component Properties window:
To use automatic persistence, configure the following properties fields on the Persistence Tab in the Component Properties window:
getState,setState
.
Your component implementation must contain these methods, but they
should not be listed in the component's client interfaces.
The getState method returns an instance of the
type specified by the State field, and the setState method
accepts a parameter of this type. For example, if the State type
is ShoppingCartState, the getState and setState methods
might be defined as follows in Java:private ShoppingCartState data;
ShoppingCartState getState()
{
return data;
}
void setState(ShoppingCartState state)
{
data = state;
}
Copyright © 2000 Sybase, Inc. All rights reserved. |