9.10.1 Setting the runtime properties for Stateful Session Beans
Set the runtime properties of an application for the individual Stateful Session Beans that form the application.
- Organization of this subsection
(1) Attribute file to be edited
Session Bean attribute file
(2) Acquiring the attribute file to be edited and setting the attributes
-
Acquiring the attribute file
Execute the following command to acquire a Session Bean attribute file:
- Execution format
cjgetappprop [server-name] [-nameserver provider-URL] -name J2EE application-name -type ejb -resname EJB-JAR-display-name/Stateful-Session-Bean-display-name -c path-of-the-Session-Bean-attribute-file
- Example of execution
cjgetappprop MyServer -name adder -type ejb -resname adder/MyAdder -c C:\home\MyAdder.xml
-
Setting the attributes
Execute the following command to apply the values of the Session Bean attribute file:
- Execution format
cjsetappprop [server-name] [-nameserver provider-URL] -name J2EE application-name -type ejb -resname EJB-JAR-display-name/Stateful-Session-Bean-display-name -c path-of-the-Session-Bean-attribute-file
- Example of execution
cjsetappprop MyServer -name adder -type ejb -resname adder/MyAdder -c C:\home\MyAdder.xml
(3) Attribute settings to be edited
The runtime properties of the Stateful Session Bean are classified into the following two types:
-
Runtime attributes common to the Session Beans
-
Attributes specific to the Stateful Session Beans
The respective settings are described below:
(a) Runtime attributes common to the Session Beans
The following table describes the property settings of runtime attributes (<runtime>) common to the Session Bean:
Items |
Mandatory |
Corresponding tags |
---|---|---|
Look up name of the Enterprise Beans#1 |
Y |
<lookup-name> |
Optional name of the Enterprise Bean name having a remote interface#1 |
O |
<optional-name> |
Optional name of the Enterprise Bean name having a local interface#1 |
O |
<local-optional-name> |
Maximum number of sessions#2 |
O |
<maximum-sessions> |
Pass by reference settings#3 |
O |
<pass-by-reference> |
- #1
-
For referencing and changing the name registered in the JNDI namespace, see 9.13.2 Referencing and changing the Enterprise Bean name.
- #2
-
The maximum number of sessions specified in the Stateful Session Bean is the maximum number of Stateful Session Beans that can be used from an EJB client application. If '0' is specified, the number of sessions (EJB objects) of the Stateful Session Beans that can be generated concurrently becomes infinite (the real maximum value is 2147483647).
- #3
-
Pass by reference settings can be implemented in the usrconf.properties file also. If the settings are specified in either the properties or in the usrconf.properties file, the pass by reference settings become valid.
For details on the property settings, see 3.4.1 Specifications of the HITACHI Session Bean Property file in the uCosminexus Application Server Application and Resource Definition Reference Guide.
(b) Attributes specific to Stateful Session Beans
The following table describes the property settings of runtime attributes specific to the Stateful Session Bean (<runtime> - <stateful>):
Items |
Mandatory |
Corresponding tags |
---|---|---|
Maximum number of active sessions |
Y |
<maximum-active-sessions> |
Period for which the bean is passivated, before it is reactivated |
Y |
<inactivity-timeout> |
Period for which the bean is passivated, before the session is deleted |
Y |
<removal-timeout> |
For details on the property settings, see 3.4.1 Specifications of the HITACHI Session Bean Property file in the uCosminexus Application Server Application and Resource Definition Reference Guide.
The property settings and operations are explained below:
- Maximum number of active sessions
-
The generated Stateful Session Beans have the following two types of states:
-
method-ready state
-
passive state
The Stateful Session Beans in the method-ready state are already executable when accessed from an EJB client application.
The Stateful Session Bean in the passive state is activated and can be executed when it is in the method-ready state.
In the maximum number of active sessions, specify the maximum number of Stateful Session Beans that can concurrently be in a method-ready state. This value is the maximum number of Stateful Session Beans for which execution can start immediately, when accessed from multiple EJB client applications. If the number of Stateful Session Beans that are generated is more than the number specified here, some of the Stateful Session Beans that are in method-ready state are passivated. Among the Stateful Session Beans in the method-ready state, the Beans that are in a transaction are not passivated. If '0' is specified in the maximum number of sessions or the maximum number of active sessions, the passivation function does not work (The state of the Stateful Session Bean does not change from method-ready state to passive state).
-
- Period for which the bean is passivated before it is reactivated (Default: 0 (minutes))
-
Specify the timeout value in minutes. If the Stateful Session Bean that is in a passive state, does not get activated until the lapse of the specified time period, this Bean is deleted. If '0' is specified in the period for which the Stateful Session Bean remains in a passive state until the bean is reactivated, then a timeout does not occur. In the deletion of Stateful Session Bean instance, at maximum there may be a delay of the time specified in ejbserver.container.passivate.scan.interval, for the specified <inactivity-timeout> value. If you want to change this start up interval, specify the start up interval in the system property ejbserver.container.passivate.scan.interval of the usrconf.properties file in seconds. By default, 0 seconds are specified. An example of the specification of ejbserver.container.passivate.scan.interval is given below:
- When you want to start the delete function of a Stateful Session Bean that is in a passive state, at 10-minute intervals
ejbserver.container.passivate.scan.interval=600
- Period for which the bean is passivated before the session is deleted (Default: 0 (minutes))
-
Specify the timeout value in minutes. If the Stateful Session Bean that is in a method-ready state, is not used even once during the period that is specified here, this Bean is deleted. Among the Stateful Session Beans in the method-ready state, the Beans in a transaction are not deleted.
If '0' is specified in the period for which the Stateful Session Bean remains in a passive state until the session is deleted, then a timeout does not occur. In the deletion of Stateful Session Bean instance, at maximum there may be a delay of the time specified in ejbserver.container.remove.scan.interval, for the specified <removal-timeout> value. If you want to change this start up interval, specify the start up interval in ejbserver.container.passivate.scan.interval of usrconf.properties file in minutes. An interval of 5 minutes is assumed by default. An example of specification of ejbserver.container.remove.scan.interval is given below:
- When you want to start the delete function of a Stateful Session Bean that is in a method-ready state, at 10-minute intervals
ejbserver.container.remove.scan.interval=10
(4) Notes
-
The default user definition is 'a function that invokes ejbActivate and ejbPassivate and saves and restores the state of the Stateful Session Bean' and by default, the activation and passivation of the Stateful Session Bean does not work. As a result, the <maximum-active-sessions> setting that can be specified as the Enterprise Bean runtime property of the Stateful Session Bean, is not valid. In addition, the function for deleting the passivated Stateful Session Bean by timeout does not work. As a result, the <inactivity-timeout> setting that can be specified as the Enterprise Bean runtime property of the Stateful Session Bean is not valid.
-
When using the activation and passivation functions, specify true for the ejbserver.stateful.passivate.switch key in the usrconf.properties file for the J2EE server.
-
When the passivation function is running, the state of the Stateful Session Bean is saved by writing to a file and the instance is destroyed. On the other hand, when the activation function is running, the state of the Stateful Session Bean is read from the file and the instance is restored. When the activation and passivation functions are running, the objects set in the member variables of the Stateful Session Bean (or the classes referenced by the Bean) are also saved and restored. At this time, the following items can be saved and restored:
-
Objects that can be serialized
-
EJB object references
-
EJB home object references
-
javax.naming.Context obtained by "java: comp/env" lookup
-
javax.ejb.SessionContext
Note that javax.jta.UserTransaction cannot be saved and restored, hence, do not save the object in the member variable. If the objects that cannot be saved or restored are stored in the member variable, release (substitute with null in the member variable) such objects using ejbPassivate and acquire the objects again by using ejbActivate.
-
-
Specify the maximum number of sessions of the Stateful Session Bean that can be generated concurrently and the maximum number of Stateful Session Beans that are in the method-ready state, such that the following condition is fulfilled:
Maximum number of Stateful Session Beans in the method ready state ≤ Maximum number of sessions of the Stateful Session Beans that can be generated concurrently
When you specify the maximum number of sessions of the Stateful Session Beans that can be generated concurrently, you also need to specify the maximum number of Stateful Session Beans that are in the method-ready state.