avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/manager MX4JSystemManager.java
Date Sat, 07 Dec 2002 04:51:35 GMT
colus       2002/12/06 20:51:35

  Modified:    src/java/org/apache/avalon/phoenix/components/manager
                        MX4JSystemManager.java
  Log:
  stop MX4J components when disposing MX4JSystemManager.
  
  Revision  Changes    Path
  1.21      +52 -5     jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/manager/MX4JSystemManager.java
  
  Index: MX4JSystemManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/components/manager/MX4JSystemManager.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- MX4JSystemManager.java	21 Sep 2002 00:52:11 -0000	1.20
  +++ MX4JSystemManager.java	7 Dec 2002 04:51:35 -0000	1.21
  @@ -17,15 +17,17 @@
   import javax.management.MBeanServerFactory;
   import javax.management.ObjectName;
   import javax.management.ReflectionException;
  -import mx4j.adaptor.rmi.jrmp.JRMPAdaptorMBean;
  -import mx4j.log.Log;
  -import mx4j.util.StandardMBeanProxy;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
  +import org.apache.avalon.excalibur.i18n.Resources;
  +import mx4j.adaptor.rmi.jrmp.JRMPAdaptorMBean;
  +import mx4j.log.Log;
  +import mx4j.util.StandardMBeanProxy;
   
   /**
    * This component is responsible for managing phoenix instance.
  @@ -38,6 +40,9 @@
       extends AbstractJMXManager
       implements Contextualizable, Configurable
   {
  +    private static final Resources REZ =
  +        ResourceManager.getPackageResources( MX4JSystemManager.class );
  +
       private static final String DEFAULT_NAMING_FACTORY =
           "com.sun.jndi.rmi.registry.RegistryContextFactory";
       private static final String DEFAULT_HTTPADAPTER_HOST = "localhost";
  @@ -103,7 +108,7 @@
   
           final MBeanServer mBeanServer = getMBeanServer();
   
  -        configureHttpAdaptor( mBeanServer );
  +        startHttpAdaptor( mBeanServer );
   
           if( m_rmi )
           {
  @@ -111,7 +116,21 @@
           }
       }
   
  -    private void configureHttpAdaptor( final MBeanServer mBeanServer )
  +    public void dispose()
  +    {
  +        final MBeanServer mBeanServer = getMBeanServer();
  +
  +        stopHttpAdaptor( mBeanServer );
  +
  +        if( m_rmi )
  +        {
  +            stopRMIAdaptor( mBeanServer );
  +        }
  +
  +        super.dispose();
  +    }
  +
  +    private void startHttpAdaptor( final MBeanServer mBeanServer )
           throws Exception
       {
           final ObjectName adaptorName = new ObjectName( "Http:name=HttpAdaptor" );
  @@ -162,6 +181,11 @@
                                     new Attribute( "AuthenticationMethod", "basic" ) );
       }
   
  +    private void stopHttpAdaptor( final MBeanServer server )
  +    {
  +        stopJMXMBean( server, "Http:name=HttpAdaptor" );
  +    }
  +
       private void startRMIAdaptor( final MBeanServer server )
           throws Exception
       {
  @@ -185,11 +209,34 @@
           mbean.start();
       }
   
  +    private void stopRMIAdaptor( final MBeanServer server )
  +    {
  +        // stop the JRMP adaptor
  +        stopJMXMBean( server, "Adaptor:protocol=JRMP" );
  +        // stop the naming service
  +        stopJMXMBean( server, "Naming:type=rmiregistry" );
  +    }
  +
       protected MBeanServer createMBeanServer()
           throws Exception
       {
           MX4JLoggerAdapter.setLogger( getLogger() );
           Log.redirectTo( new MX4JLoggerAdapter() );
           return MBeanServerFactory.createMBeanServer( "Phoenix" );
  +    }
  +
  +    private void stopJMXMBean( final MBeanServer mBeanServer, final String name )
  +    {
  +        try
  +        {
  +            final ObjectName objectName = new ObjectName( name );
  +            mBeanServer.invoke( objectName, "stop", null, null );
  +        }
  +        catch ( final Exception e )
  +        {
  +            final String message =
  +                REZ.getString( "jmxmanager.error.jmxmbean.dispose", name );
  +            getLogger().error( message, e );
  +        }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message