Java Reference
In-Depth Information
state of the workflow, and the setState() method tells the workflow bean to jump
ahead to a certain state. Notice that the state value is represented by a String . The
MBean that the EJB creates will expose these methods as its management interface.
The WorkflowBean class
Listing 14.9 contains the code for the WorkflowBean class. It implements meth-
ods that correspond to both the home and remote interfaces (although it doesn't
implement these interfaces). After discussing the code for the EJB , we will begin
examining the code for the MBean of this EJB .
Listing 14.9
WorkflowBean.java
package jmxbook.ch14;
import java.io.*;
import java.sql.*;
import java.util.*;
import javax.ejb.*;
import javax.naming.*;
import javax.sql.*;
import javax.management.*;
public class WorkflowBean implements EntityBean
{
private DataSource ds = null;
private EntityContext ctx = null;
private String clientID = null;
private int state = -1;
public void advanceState()
{
state++;
}
public String getState()
{
return state + "";
}
B
Implement
business
methods
public void setState( String state )
{
this.state = Integer.parseInt( state );
}
C
Load EJB
public void ejbLoad()
{
Connection conn = null;
PreparedStatement ps = null;
clientID = ( String ) ctx.getPrimaryKey();
try
Search WWH ::




Custom Search