User: andreas 
  Date: 00/12/07 10:16:16

  Modified:    src/main/test/jboss/jmx TestClient.java
  Added:       src/main/test/jboss/jmx TestServer.java
  Log:
  Changes to ServiceMBean therefore that if the Default-
  Log class is not available then it does not logging.
  Thus I could extract the JMX Connector (server-side)
  from jBoss therefore that it can be used elsewhere.
  Both (server- and client-side) connector archives are then
  put in the new directory external which should keep all
  archives developed under jBoss but available to other
  groups.
  
  Revision  Changes    Path
  1.6       +21 -7     jboss/src/main/test/jboss/jmx/TestClient.java
  
  Index: TestClient.java
  ===================================================================
  RCS file: /products/cvs/ejboss/jboss/src/main/test/jboss/jmx/TestClient.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestClient.java   2000/12/07 15:45:28     1.5
  +++ TestClient.java   2000/12/07 18:16:15     1.6
  @@ -9,6 +9,7 @@
   import java.util.Iterator;
   
   import javax.management.MBeanAttributeInfo;
  +import javax.management.MBeanException;
   import javax.management.MBeanInfo;
   import javax.management.MBeanOperationInfo;
   import javax.management.MBeanServer;
  @@ -62,15 +63,23 @@
                        );
                        // First create a MBeanServer and let it start
                        final MBeanServer lLocalServer = 
MBeanServerFactory.createMBeanServer();
  -                     // Then register the logger
  -                     lLocalServer.createMBean(
  -                             "org.jboss.logging.Logger",
  -                             new ObjectName( "DefaultDomain :name=Logger" )
  -                     );
                        // Then register the connector factory
                        final ObjectInstance lFactoryInstance = 
lLocalServer.createMBean(
                                "org.jboss.jmx.client.ConnectorFactoryService",
  -                             new ObjectName( "DefaultDomain:name=ConnectorFactory" )
  +                             new ObjectName( lLocalServer.getDefaultDomain(), 
"name", "ConnectorFactory" )
  +                     );
  +                     System.out.println( "Found Factory: " + 
lFactoryInstance.getObjectName() );
  +                     lLocalServer.invoke(
  +                             lFactoryInstance.getObjectName(),
  +                             "init",
  +                             new Object[] {},
  +                             new String[] {}
  +                     );
  +                     lLocalServer.invoke(
  +                             lFactoryInstance.getObjectName(),
  +                             "start",
  +                             new Object[] {},
  +                             new String[] {}
                        );
                        getUserInput(
                                "\n" +
  @@ -81,7 +90,7 @@
                        Collection lServers = (Collection) lLocalServer.invoke(
                                lFactoryInstance.getObjectName(),
                                "getServers",
  -                             new String[] {
  +                             new Object[] {
                                        null
                                },
                                new String[] {
  @@ -223,6 +232,11 @@
                        System.err.println( "TestClient.main(), caught: " + rme +
                                ", target: " + rme.getTargetException() );
                        rme.printStackTrace();
  +             }
  +             catch( MBeanException me ) {
  +                     System.err.println( "TestClient.main(), caught: " + me +
  +                             ", target: " + me.getTargetException() );
  +                     me.printStackTrace();
                }
                catch( RuntimeErrorException rte ) {
                        System.err.println( "TestClient.main(), caught: " + rte +
  
  
  
  1.1                  jboss/src/main/test/jboss/jmx/TestServer.java
  
  Index: TestServer.java
  ===================================================================
  /*
  * jBoss, the OpenSource EJB server
  * Distributable under GPL license.
  * See terms of license at gnu.org.
  */
  package test.jboss.jmx;
  
  import java.security.AccessController;
  import java.security.PrivilegedAction;
  
  import javax.management.MBeanException;
  import javax.management.MBeanServer;
  import javax.management.MBeanServerFactory;
  import javax.management.ObjectName;
  import javax.management.ReflectionException;
  import javax.management.RuntimeErrorException;
  import javax.management.RuntimeMBeanException;
  import javax.management.RuntimeOperationsException;
  import javax.naming.InitialContext; 
  
  /**
  * Test Program for the JMX Connector over RMI for the server-side.
  *
  * It creates a local MBeanServer, loads the RMI Connector and registered
  * it as a MBean. At the end it will bind it to the local JNDI server
  * (us your own or download the ??.jar and ??.properties from jBoss).
  * Afterwards you can download connector.jar from jBoss and test the
  * connection.
  *
  *   @see <related>
  *   @author Andreas "Mad" Schaefer ([EMAIL PROTECTED])
  **/
  public class TestServer {
        // Constants -----------------------------------------------------> 
        // Attributes ----------------------------------------------------> 
        // Static --------------------------------------------------------
        public static void main(String[] args)
                throws Exception
        {
                // Start server - Main does not have the proper permissions
                AccessController.doPrivileged(
                        new PrivilegedAction() {
                                public Object run() {
                                        new TestServer();
                                        return null;
                                }
                        }
                );
        }
        
        public TestServer() {
                try {
                        System.out.println( "Start local MBeanServer" );
                        MBeanServer lServer = MBeanServerFactory.createMBeanServer();
                        System.out.println( "Load and register the Naming Service" );
                        ObjectName lNamingName = new ObjectName( 
lServer.getDefaultDomain(), "service", "naming" );
                        lServer.createMBean(
                                "org.jboss.naming.NamingService",
                                lNamingName
                        );
                        System.out.println( "Start the Naming Server" );
                        lServer.invoke( lNamingName, "init", new Object[] {}, new 
String[] {} );
                        lServer.invoke( lNamingName, "start", new Object[] {}, new 
String[] {} );
                        System.out.println( "Load and register the JMX RMI-Connector" 
);
                        ObjectName lConnectorName = new ObjectName( 
lServer.getDefaultDomain(), "service", "RMIConnector" );
                        lServer.createMBean(
                                "org.jboss.jmx.server.RMIConnectorService",
                                lConnectorName
                        );
                        System.out.println( "Start the Connector" );
                        lServer.invoke( lConnectorName, "init", new Object[] {}, new 
String[] {} );
                        lServer.invoke( lConnectorName, "start", new Object[] {}, new 
String[] {} );
                        System.out.println( "Now open a new Terminal or Command Prompt 
and start the connector.jar test client" );
                }
                catch( RuntimeMBeanException rme ) {
                        System.err.println( "TestServer.main(), caught: " + rme +
                                ", target: " + rme.getTargetException() );
                        rme.printStackTrace();
                }
                catch( MBeanException me ) {
                        System.err.println( "TestServer.main(), caught: " + me +
                                ", target: " + me.getTargetException() );
                        me.printStackTrace();
                }
                catch( RuntimeErrorException rte ) {
                        System.err.println( "TestServer.main(), caught: " + rte +
                                ", target: " + rte.getTargetError() );
                        rte.printStackTrace();
                }
                catch( ReflectionException re ) {
                        System.err.println( "TestServer.main(), caught: " + re +
                                ", target: " + re.getTargetException() );
                        re.printStackTrace();
                }
                catch( Exception e ) {
                        System.err.println( "TestServer.main(), caught: " + e );
                        e.printStackTrace();
                }
        }
        
        // Constructors --------------------------------------------------> 
        // Public --------------------------------------------------------
  }
  
  
  
  

Reply via email to