avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject svn commit: rev 22484 - in avalon/trunk/planet/facilities/jmx: mx4j mx4j/src/java/org/apache/avalon/jmx/mx4j spi/src/java/org/apache/avalon/jmx/spi test test/etc
Date Fri, 02 Jul 2004 15:46:52 GMT
Author: mcconnell
Date: Fri Jul  2 08:46:51 2004
New Revision: 22484

Removed:
   avalon/trunk/planet/facilities/jmx/mx4j/src/java/org/apache/avalon/jmx/mx4j/MX4JComponentRegistrationManager.xconfig
   avalon/trunk/planet/facilities/jmx/test/etc/
Modified:
   avalon/trunk/planet/facilities/jmx/mx4j/build.xml
   avalon/trunk/planet/facilities/jmx/mx4j/src/java/org/apache/avalon/jmx/mx4j/MX4JComponentRegistrationManager.java
   avalon/trunk/planet/facilities/jmx/spi/src/java/org/apache/avalon/jmx/spi/AbstractComponentRegistrationManager.java
   avalon/trunk/planet/facilities/jmx/spi/src/java/org/apache/avalon/jmx/spi/AbstractJMXComponentRegistrationManager.java
   avalon/trunk/planet/facilities/jmx/test/build.xml
Log:
Simplify the build and implementation of the jmx facility.

Modified: avalon/trunk/planet/facilities/jmx/mx4j/build.xml
==============================================================================
--- avalon/trunk/planet/facilities/jmx/mx4j/build.xml	(original)
+++ avalon/trunk/planet/facilities/jmx/mx4j/build.xml	Fri Jul  2 08:46:51 2004
@@ -9,7 +9,19 @@
   <target name="build" depends="standard.build">
     <x:block name="jmx" embed="MAIN">
       <x:component name="registry" 
-         class="org.apache.avalon.jmx.mx4j.MX4JComponentRegistrationManager"/>
+         class="org.apache.avalon.jmx.mx4j.MX4JComponentRegistrationManager">
+        <x:parameters>
+          <x:parameter name="manager-adaptor-host" value="localhost"/>
+          <x:parameter name="manager-adaptor-port" value="8082"/>
+          <x:parameter name="enable-rmi-adaptor" value="false"/>
+          <!--
+          <x:parameter name="rmi-naming-factory" value="com.sun.jndi.rmi.registry.RegistryContextFactory"/>
+          <x:parameter name="stylesheets-dir" value="conf/xsl"/>
+          <x:parameter name="user" value=""/>
+          <x:parameter name="password" value=""/>
+          -->
+        </x:parameters>
+      </x:component>
     </x:block>
   </target>
 

Modified: avalon/trunk/planet/facilities/jmx/mx4j/src/java/org/apache/avalon/jmx/mx4j/MX4JComponentRegistrationManager.java
==============================================================================
--- avalon/trunk/planet/facilities/jmx/mx4j/src/java/org/apache/avalon/jmx/mx4j/MX4JComponentRegistrationManager.java
(original)
+++ avalon/trunk/planet/facilities/jmx/mx4j/src/java/org/apache/avalon/jmx/mx4j/MX4JComponentRegistrationManager.java
Fri Jul  2 08:46:51 2004
@@ -28,9 +28,9 @@
 import javax.management.ObjectName;
 import javax.management.ReflectionException;
 
-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.logger.Logger;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.context.Contextualizable;
@@ -51,10 +51,10 @@
  * @version $Revision: 1.2 $
  *
  * @avalon.component name="jmx-mx4j-manager" lifestyle="singleton"
- * @avalon.service type="org.apache.avalon.jmx.ComponentRegistrationManager"
+ * @avalon.service type="org.apache.avalon.jmx.ComponentRegistrationManager"
+ * @avalon.attribute key="urn:composition:deployment.timeout" value="6000"
  */
 public class MX4JComponentRegistrationManager extends AbstractJMXComponentRegistrationManager

-    implements Contextualizable, Configurable
 {
     private static final Resources REZ = 
       ResourceManager.getPackageResources( MX4JComponentRegistrationManager.class );
@@ -72,84 +72,48 @@
     private String m_namingFactory;
     private String m_password;
     private String m_username;
-
-   /*
-    public MX4JComponentRegistrationManager(
-      final Context context, final Configuration configuration, ServiceManager manager )
-    {
-    }
+
+   /**
+    * @avalon.entry key="urn:avalon:home" type="java.io.File"
     */
-
-    /**
-     * @avalon.entry key="urn:avalon:home" type="java.io.File"
-     */
-    public void contextualize( Context context ) throws ContextException
-    {
-        m_homeDir = ( File ) context.get( "urn:avalon:home" );
-    }
-
-    public void configure( final Configuration configuration ) throws ConfigurationException
-    {
-        m_host = configuration.getChild( "manager-adaptor-host" ).getValue(
-            DEFAULT_HTTPADAPTER_HOST );
-
-        m_port = configuration.getChild( "manager-adaptor-port" ).getValueAsInteger(
-            DEFAULT_HTTPADAPTER_PORT );
-
-        //This is for backwards compatability with old-style
-        //RI JMX implementation
-        m_port = configuration.getChild( "port" ).getValueAsInteger( m_port );
-
-        getLogger().debug( "MX4J HTTP listener port: " + m_port );
-
-        m_rmi = configuration.getChild( "enable-rmi-adaptor" ).getValueAsBoolean( false );
-
-        m_namingFactory = configuration.getChild( "rmi-naming-factory" ).getValue(
-            DEFAULT_NAMING_FACTORY );
-
-        final String stylesheets = 
-          configuration.getChild( "stylesheets-dir" ).getValue( null );
-        if ( null != stylesheets )
-        {
-            m_stylesheetDir = new File( m_homeDir, stylesheets ).getAbsolutePath();
-        }
-
-        /*
-         * <user>
-         *  <name>user</name>
-         *  <password>passwd</password>
-         * </user>
-         */
-        final Configuration userConfig = configuration.getChild( "user" );
-        m_username = userConfig.getChild( "name" ).getValue( null );
-        m_password = userConfig.getChild( "password" ).getValue( null );
-    }
-
-    public void initialize() throws Exception
-    {
-        super.initialize();
-
-        final MBeanServer mBeanServer = getMBeanServer();
-
-        startHttpAdaptor( mBeanServer );
-
-        if ( m_rmi )
-        {
-            startRMIAdaptor( mBeanServer );
-        }
+    public MX4JComponentRegistrationManager(
+      final Logger logger, final Context context, final Parameters parameters )
+      throws Exception
+    {
+        super( logger );
+
+        m_homeDir = ( File ) context.get( "urn:avalon:home" );
+        m_host = parameters.getParameter( "manager-adaptor-host", DEFAULT_HTTPADAPTER_HOST
);
+        m_port = parameters.getParameterAsInteger( "manager-adaptor-port", DEFAULT_HTTPADAPTER_PORT
);
+        getLogger().debug( "MX4J HTTP listener port: " + m_port );
+        m_rmi = parameters.getParameterAsBoolean( "enable-rmi-adaptor", false );
+        m_namingFactory = parameters.getParameter( "rmi-naming-factory", DEFAULT_NAMING_FACTORY
);
+
+        final String stylesheets = parameters.getParameter( "stylesheets-dir", null );
+        if ( null != stylesheets )
+        {
+            m_stylesheetDir = new File( m_homeDir, stylesheets ).getAbsolutePath();
+        }
+
+        m_username = parameters.getParameter( "name", null );
+        m_password = parameters.getParameter( "password", null );
+
+        final MBeanServer mBeanServer = getMBeanServer();
+        startHttpAdaptor( mBeanServer );
+        if( m_rmi )
+        {
+            startRMIAdaptor( mBeanServer );
+        }
     }
 
     public void dispose()
     {
         final MBeanServer mBeanServer = getMBeanServer();
-
         stopHttpAdaptor( mBeanServer );
-
         if ( m_rmi )
         {
             stopRMIAdaptor( mBeanServer );
         }
-
         super.dispose();
     }
 

Modified: avalon/trunk/planet/facilities/jmx/spi/src/java/org/apache/avalon/jmx/spi/AbstractComponentRegistrationManager.java
==============================================================================
--- avalon/trunk/planet/facilities/jmx/spi/src/java/org/apache/avalon/jmx/spi/AbstractComponentRegistrationManager.java
(original)
+++ avalon/trunk/planet/facilities/jmx/spi/src/java/org/apache/avalon/jmx/spi/AbstractComponentRegistrationManager.java
Fri Jul  2 08:46:51 2004
@@ -22,7 +22,7 @@
 
 import org.apache.avalon.composition.model.ComponentModel;
 
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
 
 import org.apache.avalon.jmx.ComponentRegistrationManager;
 import org.apache.avalon.jmx.ComponentRegistrationException;
@@ -37,15 +37,23 @@
  * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  * @version $Revision: 1.3 $
  */
-public abstract class AbstractComponentRegistrationManager extends AbstractLogEnabled 
+public abstract class AbstractComponentRegistrationManager 
     implements ComponentRegistrationManager
 {
 
     private static final Resources REZ = ResourceManager.getPackageResources(
         AbstractComponentRegistrationManager.class );
 
-    private Map m_entries = Collections.synchronizedMap( new HashMap() );
-
+    private Map m_entries = Collections.synchronizedMap( new HashMap() );
+
+    private final Logger m_logger;
+
+    public AbstractComponentRegistrationManager( final Logger logger )
+      throws Exception
+    {
+        m_logger = logger;
+    }
+
     public void register( ComponentModel componentModel ) 
         throws ComponentRegistrationException
     {
@@ -217,6 +225,11 @@
 
             verifyInterface( clazz );
         }
+    }
+
+    protected Logger getLogger()
+    {
+        return m_logger;
     }
 
 }

Modified: avalon/trunk/planet/facilities/jmx/spi/src/java/org/apache/avalon/jmx/spi/AbstractJMXComponentRegistrationManager.java
==============================================================================
--- avalon/trunk/planet/facilities/jmx/spi/src/java/org/apache/avalon/jmx/spi/AbstractJMXComponentRegistrationManager.java
(original)
+++ avalon/trunk/planet/facilities/jmx/spi/src/java/org/apache/avalon/jmx/spi/AbstractJMXComponentRegistrationManager.java
Fri Jul  2 08:46:51 2004
@@ -28,8 +28,9 @@
 
 import org.apache.avalon.composition.model.ComponentModel;
 
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.activity.Disposable;
 
 import org.apache.avalon.jmx.ComponentRegistrationException;
 import org.apache.avalon.jmx.util.MBeanInfoBuilder;
@@ -44,24 +45,31 @@
  * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  * @version $Revision: 1.1 $
  */
-public abstract class AbstractJMXComponentRegistrationManager extends AbstractComponentRegistrationManager

-    implements Initializable, Disposable
+public abstract class AbstractJMXComponentRegistrationManager 
+    extends AbstractComponentRegistrationManager 
+    implements Disposable
 {
     private static final Resources REZ = ResourceManager.getPackageResources(
         AbstractJMXComponentRegistrationManager.class );
         
     private MBeanInfoBuilder topicBuilder;
     private MBeanServer m_mBeanServer;
-    private String m_domain = "Merlin";
-
-    public void initialize() throws Exception
-    {
-        final MBeanServer mBeanServer = createMBeanServer();
-        setMBeanServer( mBeanServer );
-
-        topicBuilder = new MBeanInfoBuilder();
-        setupLogger( topicBuilder );
-    }
+    private String m_domain = "Merlin";
+
+    public AbstractJMXComponentRegistrationManager( final Logger logger )
+      throws Exception
+    {
+        super( logger );
+
+        final MBeanServer mBeanServer = createMBeanServer();
+        setMBeanServer( mBeanServer );
+        topicBuilder = new MBeanInfoBuilder();
+
+        if( topicBuilder instanceof LogEnabled )
+        {
+            ( (LogEnabled)topicBuilder).enableLogging( logger );
+        }
+    }
 
     public void dispose()
     {
@@ -114,15 +122,15 @@
 
             while ( i.hasNext() )
             {
-                final ObjectName objectName = createObjectName( name,
-                                                                target.getTopic( ( String
) i.next() ) );
-
+                final ObjectName objectName = 
+                  createObjectName( name, target.getTopic( ( String ) i.next() ) );
                 getMBeanServer().unregisterMBean( objectName );
             }
         }
         catch ( final Exception e )
         {
-            final String message = REZ.getString( "jmxmanager.error.unexport.fail", name
);
+            final String message = 
+              REZ.getString( "jmxmanager.error.unexport.fail", name );
             getLogger().error( message, e );
             throw new ComponentRegistrationException( message, e );
         }
@@ -173,8 +181,10 @@
             {
                 if ( getLogger().isDebugEnabled() )
                 {
-                    final String message = REZ.getString( "jmxmanager.debug.interface",
-                                                          allInterfaces[i].getName() );
+                    final String message = 
+                      REZ.getString( 
+                        "jmxmanager.debug.interface",
+                        allInterfaces[i].getName() );
                     getLogger().debug( message );
                 }
 
@@ -326,7 +336,8 @@
         }
         catch ( Exception e )
         {
-            final String message = REZ.getString( "jmxmanager.error.mbean.load.class", className
);
+            final String message = 
+              REZ.getString( "jmxmanager.error.mbean.load.class", className );
             getLogger().error( message, e );
             throw new ComponentRegistrationException( message, e );
         }
@@ -340,7 +351,8 @@
         }
         catch ( final Exception e )
         {
-            final String message = REZ.getString( "jmxmanager.error.mbean.instantiate", className
);
+            final String message = 
+              REZ.getString( "jmxmanager.error.mbean.instantiate", className );
             getLogger().error( message, e );
             throw new ComponentRegistrationException( message, e );
         }
@@ -355,7 +367,8 @@
         }
         catch ( Exception e )
         {
-            final String message = REZ.getString( "jmxmanager.error.mbean.set.resource",
className );
+            final String message = 
+              REZ.getString( "jmxmanager.error.mbean.set.resource", className );
             getLogger().error( message, e );
             throw new ComponentRegistrationException( message, e );
         }

Modified: avalon/trunk/planet/facilities/jmx/test/build.xml
==============================================================================
--- avalon/trunk/planet/facilities/jmx/test/build.xml	(original)
+++ avalon/trunk/planet/facilities/jmx/test/build.xml	Fri Jul  2 08:46:51 2004
@@ -6,5 +6,19 @@
   <property file="build.properties"/>
   <import file="${project.system}/build/standard.xml"/>
 
+  <target name="build" depends="standard.build">
+    <x:block name="jmx" embed="MAIN">
+      <x:component name="mx4j" 
+         class="org.apache.avalon.jmx.mx4j.MX4JComponentRegistrationManager">
+        <x:parameters>
+          <x:parameter name="enable-rmi-adaptor" value="true"/>
+          <x:parameter name="rmi-naming-factory" value="com.sun.jndi.rmi.registry.RegistryContextFactory"/>
+        </x:parameters>
+      </x:component>
+      <x:component name="test" class="org.apache.avalon.playground.jmxtest.JMXTestComponent"/>
+      <x:component name="handler" class="org.apache.avalon.jmx.handler.JmxManagementHandler"/>
+    </x:block>
+  </target>
+
 </project>
 

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


Mime
View raw message