Java Reference
In-Depth Information
}
catch(Exception e){
System.out.println(e.toString());
}
}
public static void main( String[] args ){
System.out.println("\n\tCONNECT to the MBeanServer.");
RmiConnectorClient client = RMIClientFactory.getClient();
System.out.println("\n\tGot RMI Client.");
try{
//register the JMX_MBean
Object[] params = new Object[0];
String[] sig = new String[0];
System.out.println("\n>>> REGISTERING JMX MBean");
//register the JMX Controller MBean
System.out.println("\n>>> REGISTERING JMX Controller MBean");
ObjectName JMXBeanName = new ObjectName(
"JMXBookAgent:name=EJB_UserInfo_Bean" );
client.createMBean( "jmxbook.ch14.UserInfoMgr",
JMXBeanName );
client.disconnect();
C
Register MBean with
JMXBookAgent
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Error Registering MBeans");
}
}
}
B
In order for the methods exposed in the MBean's management interface to
accomplish their tasks, the MBean must be able to look up the
EJB
that represents
the user name and was passed in as a parameter. The
getUserInfo()
method
accepts a user name as an argument and returns a
UserInfo
EJB
reference.
Remember from the entity bean implementation that the
UserInfo
object is the
remote interface instance that contains the business methods of the entity bean.
The
getUserInfo()
method obtains a reference to the remote object using the
naming service from the application server containing the
EJB
. It then obtains
the entity bean for the particular user using the user name as the primary key.
Once you have the entity bean for a user, you can either get the number of suc-
cessful logins or modify the login permissions for that user.