FileDocCategorySizeDatePackage
Client.javaAPI DocJBoss 4.2.12963Fri Jul 13 20:55:12 BST 2007org.jboss.tutorial.service_deployment_descriptor.client

Client

public class Client extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

      try {
      InitialContext ctx = new InitialContext();
      //Get hold of the MBean server invoker
      RMIAdaptor server = (RMIAdaptor)ctx.lookup("jmx/invoker/RMIAdaptor");

      //Set attribute on singleton ServiceOne via remote interface
      ServiceOneRemote serviceOne = (ServiceOneRemote) ctx.lookup("serviceOne/remote");
      serviceOne.setAttribute(100);

      //Create object name for ServiceOne
      ObjectName service1 = new ObjectName("jboss.j2ee:jar=tutorial.jar,service=EJB3,name=ServiceOne,type=ManagementInterface");
      //Get attribute of singleton ServiceOne via JMX
      int attr1 = (Integer)server.getAttribute(service1, "Attribute");
      System.out.println("attribute value for singleton obtained via JMX is what we set via remote i/f: " + attr1);

      //Create object name for ServiceThree
      ObjectName service3 = new ObjectName("jboss.j2ee:jar=tutorial.jar,service=EJB3,name=ServiceThree,type=ManagementInterface");
      //Call serviceOneHello() and serviceTwoHello() on ServiceThree
      Object[] noArgs = new Object[0];//No arguments
      String[] noSig = new String[0];//No parameters in signature

      String service1Hello = (String)server.invoke(service3, "serviceOneHello", noArgs, noSig);
      System.out.println(service1Hello);
      String service2Hello = (String)server.invoke(service3, "serviceTwoHello", noArgs, noSig);
      System.out.println(service2Hello);
      } catch (Exception e)
      {
         e.printStackTrace();
      }