User: andreas 
  Date: 00/10/10 23:04:03

  Modified:    src/main/org/jboss/jmx/client ConnectorFactoryImpl.java
  Log:
  Searches now for server name through the JMX Connector
  JNDI name pattern.
  This is just a temporary fix and must first be extended to
  also lookup the different protocols supported for a particular
  MBeanServer and second to support the new Clustering
  and JINI lookup suggested by Rickard Oeberg.
  
  Revision  Changes    Path
  1.2       +33 -3     jboss/src/main/org/jboss/jmx/client/ConnectorFactoryImpl.java
  
  Index: ConnectorFactoryImpl.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/jmx/client/ConnectorFactoryImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectorFactoryImpl.java 2000/08/31 17:42:58     1.1
  +++ ConnectorFactoryImpl.java 2000/10/11 06:04:03     1.2
  @@ -11,12 +11,17 @@
   import java.util.Collection;
   import java.util.Iterator;
   import java.util.Set;
  +import java.util.Vector;
   
   import javax.management.DynamicMBean;
   import javax.management.MBeanServer;
   import javax.management.ObjectInstance;
   import javax.management.ObjectName;
   
  +import javax.naming.InitialContext;
  +import javax.naming.NameClassPair;
  +import javax.naming.NamingEnumeration;
  +
   import org.jboss.jmx.interfaces.JMXConnector;
   
   /**
  @@ -56,11 +61,36 @@
        public Collection getServers(
   //AS         ServerQuery pServerQuery
        ) {
  +             Vector lServers = new Vector();
  +             try {
  +                     InitialContext lNamingServer = new InitialContext();
  +                     // Lookup the JNDI server
  +                     NamingEnumeration enum = lNamingServer.list( "" );
  +                     while( enum.hasMore() ) {
  +                             NameClassPair lItem = (NameClassPair) enum.next();
  +                             System.out.println( "Naming Server item: " + lItem );
  +                             String lName = lItem.getName();
  +                             if( lName.indexOf( "jmx:" ) == 0 ) {
  +                                     lServers.add(
  +                                             lName.substring(
  +                                                     4,
  +                                                     lName.indexOf( ":", 5 )
  +                                             )
  +                                     );
  +                             }
  +                     }
  +             }
  +             catch( Exception e ) {
  +                     e.printStackTrace();
  +             }
  +             return lServers;
  +/*
                return Arrays.asList(
                        new String[] {
  -                             "localhost"
  +                             System.getProperty( "java.naming.provider.url" )
                        }
                );
  +*/
        }
        
        /**
  @@ -95,7 +125,7 @@
                String pProtocol
        ) {
                JMXConnector lConnector = null;
  -             if( pServer.equals( "localhost" ) ) {
  +//AS         if( pServer.equals( "localhost" ) ) {
                        if( pProtocol.equals( "rmi" ) ) {
                                try {
                                        lConnector = new RMIClientConnectorImpl(
  @@ -110,7 +140,7 @@
                                        e.printStackTrace();
                                }
                        }
  -             }
  +//AS         }
                System.out.println( "ConnectorFactoryImpl.createConnection(), got 
connector: " + lConnector );
                return lConnector;
        }
  
  
  

Reply via email to