1 22 package org.jboss.tutorial.service_deployment_descriptor.client; 23 24 import org.jboss.tutorial.service_deployment_descriptor.bean.ServiceOneRemote; 25 import org.jboss.tutorial.service_deployment_descriptor.bean.ServiceOne; 26 import org.jboss.jmx.adaptor.rmi.RMIAdaptor; 27 28 import javax.naming.InitialContext ; 29 import javax.management.ObjectName ; 30 31 32 public class Client 33 { 34 public static void main(String [] args) throws Exception 35 { 36 try { 37 InitialContext ctx = new InitialContext (); 38 RMIAdaptor server = (RMIAdaptor)ctx.lookup("jmx/invoker/RMIAdaptor"); 40 41 ServiceOneRemote serviceOne = (ServiceOneRemote) ctx.lookup("serviceOne/remote"); 43 serviceOne.setAttribute(100); 44 45 ObjectName service1 = new ObjectName ("jboss.j2ee:jar=tutorial.jar,service=EJB3,name=ServiceOne,type=ManagementInterface"); 47 int attr1 = (Integer )server.getAttribute(service1, "Attribute"); 49 System.out.println("attribute value for singleton obtained via JMX is what we set via remote i/f: " + attr1); 50 51 ObjectName service3 = new ObjectName ("jboss.j2ee:jar=tutorial.jar,service=EJB3,name=ServiceThree,type=ManagementInterface"); 53 Object [] noArgs = new Object [0]; String [] noSig = new String [0]; 57 String service1Hello = (String )server.invoke(service3, "serviceOneHello", noArgs, noSig); 58 System.out.println(service1Hello); 59 String service2Hello = (String )server.invoke(service3, "serviceTwoHello", noArgs, noSig); 60 System.out.println(service2Hello); 61 } catch (Exception e) 62 { 63 e.printStackTrace(); 64 } 65 } 66 } 67 | Popular Tags |