avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/proposal/4.0/src/java/org/apache/phoenix/engine/facilities ManagerImpl.java
Date Mon, 16 Apr 2001 14:09:39 GMT
leosimons    01/04/16 07:09:39

  Modified:    proposal/4.0/src/java/org/apache/phoenix/engine/facilities
                        ManagerImpl.java
  Log:
  adding rudimentary jmx support
  
  Revision  Changes    Path
  1.2       +78 -29    jakarta-avalon-phoenix/proposal/4.0/src/java/org/apache/phoenix/engine/facilities/ManagerImpl.java
  
  Index: ManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/proposal/4.0/src/java/org/apache/phoenix/engine/facilities/ManagerImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ManagerImpl.java	2001/04/06 15:41:30	1.1
  +++ ManagerImpl.java	2001/04/16 14:09:38	1.2
  @@ -8,58 +8,107 @@
   package org.apache.phoenix.engine.facilities;
   
   import javax.management.MBeanServer;
  +import javax.management.ObjectName;
   
  +import org.apache.phoenix.facilities.Manager;
  +import org.apache.phoenix.core.Kernel;
  +import org.apache.phoenix.core.Embeddor;
   import org.apache.framework.context.Context;
  +import org.apache.framework.context.ContextException;
   import org.apache.framework.configuration.Configuration;
  +import org.apache.framework.lifecycle.StartException;
  +import org.apache.framework.lifecycle.StopException;
   
  -import org.apache.phoenix.facilities.Manager;
  +import org.apache.avalon.camelot.Deployer;
   
   import org.apache.log.Logger;
   
  +import org.apache.jmx.introspector.DynamicMBeanFactory;
  +
   /**
    *
    * @author <a href="mailto:mail@leosimons.com">Leo Simons</a>
    */
   public class ManagerImpl implements Manager
   {
  +    private MBeanServer mBeanServer;
  +    private Logger logger;
  +    private Embeddor embeddor;
  +    private Deployer deployer;
  +    private Kernel kernel;
  +
       public ManagerImpl()
       {
       }
  -    public ManagerImpl( MBeanServer mBeanServer )
  -    {
  -    }
   
       /////////////////////////
       /// LIFECYCLE METHODS ///
       /////////////////////////
       public void setLogger( Logger logger )
  -    {
  -    }
  -    public void contextualize( Context context )
  -    {
  -    }
  -    public void configure( Configuration configuration )
  -    {
  -    }
  -    public void init()
  -    {
  -    }
  -    public void start()
  -    {
  -    }
  -    public void run()
  -    {
  -    }
  -    public void suspend()
  -    {
  -    }
  -    public void resume()
  -    {
  -    }
  -    public void stop()
       {
  +        this.logger = logger;
       }
  -    public void dispose()
  +    public void contextualize( Context context ) throws ContextException
       {
  +        try { this.mBeanServer = (MBeanServer)context.get( "javax.management.MBeanServer"
); }
  +        catch( Exception e ) {
  +            logger.error( "Invalid context - no MBeanServer supplied", e );
  +            throw new ContextException( "Invalid context - no MBeanServer supplied", e
); }
  +        try { this.embeddor = (Embeddor)context.get( "org.apache.framework.atlantis.core.Embeddor"
); }
  +        catch( Exception e ) {
  +            logger.error( "Invalid context - no Embeddor supplied", e );
  +            throw new ContextException( "Invalid context - no Embeddor supplied", e );
}
  +        try { this.kernel = (Kernel)context.get( "org.apache.framework.atlantis.core.Kernel"
); }
  +        catch( Exception e ) {
  +            logger.error( "Invalid context - no Kernel supplied", e );
  +            throw new ContextException( "Invalid context - no Kernel supplied", e ); }
  +        try { this.deployer = (Deployer)context.get( "org.apache.avalon.camelot.Deployer"
); }
  +        catch( Exception e ) {
  +            logger.error( "Invalid context - no Deployer supplied", e );
  +            throw new ContextException( "Invalid context - no Deployer supplied", e );
}
  +    }
  +    public void start() throws StartException
  +    {
  +        try
  +        {
  +            mBeanServer.registerMBean(
  +                DynamicMBeanFactory.create( embeddor ),
  +                new ObjectName( "Embeddor" ) );
  +        }
  +        catch( Exception e ) { logger.error( "Unable to register MBean for Embeddor", e
); }
  +        try
  +        {
  +            mBeanServer.registerMBean(
  +                DynamicMBeanFactory.create( deployer ),
  +                new ObjectName( "Deployer" ) );
  +        }
  +        catch( Exception e ) { logger.error( "Unable to register MBean for Deployer", e
); }
  +        try
  +        {
  +            mBeanServer.registerMBean(
  +                DynamicMBeanFactory.create( kernel ),
  +                new ObjectName( "Kernel" ) );
  +        }
  +        catch( Exception e ) { logger.error( "Unable to register MBean for Kernel", e );
}
  +        try
  +        {
  +            mBeanServer.registerMBean(
  +                DynamicMBeanFactory.create( logger ),
  +                new ObjectName( "Logger" ) );
  +        }
  +        catch( Exception e ) { logger.error( "Unable to register MBean for Logger", e );
}
  +    }
  +    public void stop() throws StopException
  +    {
  +        try {
  +            mBeanServer.unregisterMBean( new ObjectName( "Embeddor" ) );
  +            mBeanServer.unregisterMBean( new ObjectName( "Kernel" ) );
  +            mBeanServer.unregisterMBean( new ObjectName( "Deployer" ) );
  +            mBeanServer.unregisterMBean( new ObjectName( "Logger" ) );
  +        }
  +        catch( Exception e )
  +        {
  +            logger.error( "error unregistering MBeans", 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