1 7 package org.jboss.tutorial.service.client; 8 9 import org.jboss.tutorial.service.bean.ServiceOneRemote; 10 import org.jboss.jmx.adaptor.rmi.RMIAdaptor; 11 12 import javax.naming.InitialContext ; 13 import javax.management.ObjectName ; 14 15 16 public class Client 17 { 18 public static void main(String [] args) throws Exception 19 { 20 InitialContext ctx = new InitialContext (); 21 RMIAdaptor server = (RMIAdaptor)ctx.lookup("jmx/invoker/RMIAdaptor"); 23 24 ServiceOneRemote serviceOne = (ServiceOneRemote) ctx.lookup(ServiceOneRemote.class.getName()); 26 serviceOne.setAttribute(100); 27 28 ObjectName service1 = new ObjectName ("jboss.j2ee:service=EJB3,name=org.jboss.tutorial.service.bean.ServiceOne,type=service"); 30 int attr1 = (Integer )server.getAttribute(service1, "Attribute"); 32 System.out.println("attribute value for singleton obtained via JMX is what we set via remote i/f: " + attr1); 33 34 ObjectName service3 = new ObjectName ("jboss.j2ee:service=EJB3,name=org.jboss.tutorial.service.bean.ServiceThree,type=service"); 36 Object [] noArgs = new Object [0]; String [] noSig = new String [0]; 40 String service1Hello = (String )server.invoke(service3, "serviceOneHello", noArgs, noSig); 41 System.out.println(service1Hello); 42 String service2Hello = (String )server.invoke(service3, "serviceTwoHello", noArgs, noSig); 43 System.out.println(service2Hello); 44 } 45 } 46 | Popular Tags |