Java Reference
In-Depth Information
ObjectName obn = new ObjectName( mbs.getDefaultDomain(),
"clientID", clientID );
mbs.unregisterMBean( obn );
}
catch( Exception e )
{
e.printStackTrace();
}
}
private MBeanServer getMBeanServer()
{
// Stubbed out code for locating MBeanServer
return null;
}
private void cleanup( Connection dbconn , Statement stmt )
{
try
{
stmt.close();
dbconn.close();
}
catch( Exception e )
{
e.printStackTrace();
}
}
}//class
B
The first three methods you see when examining the
EJB
code are declared in the
EJB
's remote interface. The
advanceState()
,
getState()
, and
setState()
meth-
ods are implemented here and will be exposed by the MBean the
EJB
creates
later. The three methods do nothing more than manage the state of the workflow,
represented by the
int
class member
state
.
The
ejbLoad()
method is found in every entity
EJB
. It is invoked when it is time
for the bean instance to be initialized with the data set it represents. Notice that
this
EJB
is managing its own persistence and therefore must interact with a data-
base to acquire its information. The
ejbLoad()
method acquires the
clientID
that
an
EJB
client has associated with it, and selects the state from a database using a
connection acquired from a
DataSource
object. After the
EJB
has initialized itself,
it is time to initialize its MBean. You haven't seen the code for the MBean yet,
but the class is called
WorkflowManager
. The
EJB
invokes the
installEJBMBean()
method, which it implements to create a
WorkflowManager
MBean instance.
C