Java Reference
In-Depth Information
}//for
}
catch( Exception e )
{
e.printStackTrace();
}
return rvalue;
}
D
Look up EJB
private WorkflowHome lookUpHome() throws Exception
{
Context ctx = new InitialContext();
return ( WorkflowHome ) ctx.lookup( "workflow" );
}
E
Implement
invoke()
method
public Object invoke( String actionName, Object[] args,
String[] sig )
throws MBeanException, ReflectionException
{
try
{
String methodName = actionName;
Class types[] = new Class[ sig.length ];
for( int i = 0; i < types.length; i++ )
types[ i ] = Class.forName( sig[ i ] );
Method m = ejb.getClass().getMethod( methodName, types );
Object temp = m.invoke( ejb, args );
return temp;
}
catch( Exception e )
{
throw new MBeanException( e );
}
}
}
B
The single constructor for this MBean accepts a String object that is the clientid
of the entity EJB , and a JNDI name used to look up the home interface of the EJB
that created the MBean. After storing the clientid in a class member variable, the
constructor invokes the lookUpHome() method to find the EJB home interface. Once
it has a reference to the home interface, the constructor can invoke the findBy-
PrimaryKey() method it provides. The findByPrimaryKey() method accepts the
clientid and returns a reference to the EJB remote interface. The MBean now
has a handle on the resource it exposes for management.
Search WWH ::




Custom Search