avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine PhoenixManager.java
Date Wed, 25 Apr 2001 01:08:05 GMT
donaldp     01/04/24 18:08:05

  Modified:    src/java/org/apache/phoenix/engine PhoenixManager.java
  Log:
  Made manager load mBeanServer and RMIAdaptor.
  
  The Adaptor is exported on vanilla TCP and exported via a name registry.
  
  Revision  Changes    Path
  1.3       +68 -1     jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/PhoenixManager.java
  
  Index: PhoenixManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/phoenix/engine/PhoenixManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PhoenixManager.java	2001/04/24 09:08:50	1.2
  +++ PhoenixManager.java	2001/04/25 01:08:05	1.3
  @@ -9,6 +9,16 @@
   
   import org.apache.avalon.atlantis.SystemManager;
   import org.apache.avalon.logger.AbstractLoggable;
  +import org.apache.avalon.parameters.ParameterException;
  +import org.apache.avalon.parameters.Parameterizable;
  +import org.apache.avalon.parameters.Parameters;
  +import org.apache.jmx.adaptor.RMIAdaptorImpl;
  +import java.rmi.server.RemoteObject;
  +import java.rmi.server.UnicastRemoteObject;
  +import java.rmi.registry.Registry;
  +import java.rmi.Remote;
  +import java.rmi.registry.LocateRegistry;
  +import javax.management.MBeanServer;
   
   /**
    * This component is responsible for managing phoenix instance.
  @@ -19,25 +29,82 @@
    */
   public class PhoenixManager
       extends AbstractLoggable
  -    implements SystemManager
  +    implements SystemManager, Parameterizable
   {
  +    private Parameters      m_parameters;
  +    private MBeanServer     m_mBeanServer;
  +    private RMIAdaptorImpl  m_rmiAdaptor;
  +    private Registry        m_rmiRegistry;
  +
  +    ///Name Adaptor registered with
  +    private String          m_name;
  +
  +    public void parameterize( final Parameters parameters )
  +        throws ParameterException
  +    {
  +        m_parameters = parameters;
  +    }
  +
       public void init()
           throws Exception
       {
  +        m_mBeanServer = createMBeanServer();
  +        m_rmiAdaptor = new RMIAdaptorImpl( m_mBeanServer );
  +
  +        //TODO: Register everything here or in embeddor???
       }
   
       public void start()
           throws Exception
       {
  +        final int port = m_parameters.getParameterAsInteger( "manager-registry-port", 1111
);
  +        m_name = m_parameters.getParameter( "manager-name", "Phoenix.JMXAdaptor" );
  +        
  +        m_rmiRegistry = LocateRegistry.createRegistry( port );
  +        
  +        final Remote exported = UnicastRemoteObject.exportObject( m_rmiAdaptor );
  +        final Remote stub = RemoteObject.toStub( exported );
  +        
  +        //TODO: should this do a lookup and refuse to lauch if existing server registered???
  +        m_rmiRegistry.bind( m_name, stub );
       }
   
       public void stop()
           throws Exception
       {
  +        m_rmiRegistry.unbind( m_name );
  +        UnicastRemoteObject.unexportObject( m_rmiAdaptor, true );
  +
  +        //TODO: How do you shutdown registry???
       }
   
       public void dispose()
           throws Exception
       {
  +        //TODO: Unregister everything here or in embeddor???
  +        m_rmiAdaptor = null;
  +        m_mBeanServer = null;
  +    }
  +
  +    /**
  +     * Creates a new Manager. The mBeanServer it uses is determined from
  +     * the Parameters's manager-mBeanServer-class variable.
  +     */
  +    private MBeanServer createMBeanServer() 
  +        throws Exception
  +    {
  +        final String className = 
  +            m_parameters.getParameter( "manager-mBeanServer-class", 
  +                                       "org.apache.jmx.MBeanServerImpl" );
  +
  +        try
  +        {
  +            Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
  +            return (MBeanServer)Class.forName( className ).newInstance();
  +        }
  +        catch( final Exception e )
  +        {
  +            throw new ParameterException( "Failed to create MBean Server of class " + className,
e );
  +        }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message