avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/tools SystemInfo.java
Date Mon, 18 Aug 2003 12:46:05 GMT
mcconnell    2003/08/18 05:46:05

  Modified:    merlin-test/merlin-jmx-demo README.TXT maven.xml project.xml
               merlin-test/merlin-jmx-demo/conf block.xml
               merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx
                        JMXServerProxy.java JRMPAdaptorWrapper.java
                        MBeanableHandler.java
               merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/samples
                        HelloSample.java HelloSample2.java
                        HelloSample3.java HelloSample4.java
               merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/tools
                        SystemInfo.java
  Log:
  Updating.
  
  Revision  Changes    Path
  1.5       +2 -2      avalon-sandbox/merlin-test/merlin-jmx-demo/README.TXT
  
  Index: README.TXT
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin-test/merlin-jmx-demo/README.TXT,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- README.TXT	15 Jul 2003 19:03:28 -0000	1.4
  +++ README.TXT	18 Aug 2003 12:46:04 -0000	1.5
  @@ -6,9 +6,9 @@
     - a JRMP connector
     - a series of manageble components
   
  -To execute the demo you muyst have the avalon-meta-plugin-1.1-RC1.jar installed in [MAVEN-HOME]/plugins/
directory.
  +To execute the demo:
   
  -  $ maven jar
  +  $ maven jar:install
     $ merlin target\merlin-jmx-demo-1.0.jar
   
   Launch a JMX client (using either HTTP or RMI to see the components).
  
  
  
  1.3       +6 -0      avalon-sandbox/merlin-test/merlin-jmx-demo/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin-test/merlin-jmx-demo/maven.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- maven.xml	15 Jul 2003 19:03:28 -0000	1.2
  +++ maven.xml	18 Aug 2003 12:46:04 -0000	1.3
  @@ -4,4 +4,10 @@
       <attainGoal name="avalon:meta"/>
     </preGoal>
   
  +  <!--
  +  <postGoal name="jar:jar">
  +    <attainGoal name="merlin:deploy"/>
  +  </preGoal>
  +  -->
  +
   </project>
  
  
  
  1.2       +2 -2      avalon-sandbox/merlin-test/merlin-jmx-demo/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin-test/merlin-jmx-demo/project.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- project.xml	29 Jun 2003 09:16:20 -0000	1.1
  +++ project.xml	18 Aug 2003 12:46:04 -0000	1.2
  @@ -60,14 +60,14 @@
           </includes>
         </resource>
         <resource>
  -        <directory>${maven.conf.dir}</directory>
  +        <directory>${basedir}/conf</directory>
           <targetPath>BLOCK-INF</targetPath>
           <includes>
             <include>block.xml</include>
           </includes>
         </resource>
         <resource>
  -        <directory>${maven.conf.dir}</directory>
  +        <directory>${basedir}/conf</directory>
           <includes>
             <include>jndi.properties</include>
             <include>mbeans.mlet</include>
  
  
  
  1.2       +19 -20    avalon-sandbox/merlin-test/merlin-jmx-demo/conf/block.xml
  
  Index: block.xml
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin-test/merlin-jmx-demo/conf/block.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- block.xml	29 Jun 2003 09:16:20 -0000	1.1
  +++ block.xml	18 Aug 2003 12:46:04 -0000	1.2
  @@ -1,25 +1,23 @@
  -<?xml version="1.0" encoding="iso-8859-1"?>
   
  -<block name="jmx">
  +<container name="jmx">
   
  -  <implementation>
  -
  -    <categories priority="INFO"/>
  -
  -    <engine>
  +    <classloader>
         <classpath>
           <repository>
             <resource id="mx4j:mx4j-jmx" version="1.1.1"/>
             <resource id="mx4j:mx4j-tools" version="1.1.1"/>
  +          <resource id="avalon-framework:avalon-framework-api" version="SNAPSHOT"/>
  +          <resource id="avalon-framework:avalon-framework-impl" version="SNAPSHOT"/>
  +          <resource id="excalibur-lifecycle:excalibur-lifecycle" version="1.0"/>
           </repository>
         </classpath>
  -    </engine>
  +    </classloader>
   
       <!-- the declaration of jmx-server is optional -->
  -    <component name="jmx-server" class="my.avalon.jmx.JMXServerProxy" activation="true"/>
  +    <component name="jmx-server" class="my.avalon.jmx.JMXServerProxy"/>
   
       <!-- an "jmx-http" could be used to access jmx-server throught HTTP -->
  -    <component name="jmx-http" class="my.avalon.jmx.HTTPAdaptorWrapper" activation="true">
  +    <component name="jmx-http" class="my.avalon.jmx.HTTPAdaptorWrapper">
         <configuration>
           <xslt-processor enable="true"/>
           <port>8082</port>
  @@ -27,22 +25,23 @@
         </configuration>
       </component>
   
  -    <component name="jmx-jrmp" class="my.avalon.jmx.JRMPAdaptorWrapper" activation="true">
  +    <component name="jmx-jrmp" class="my.avalon.jmx.JRMPAdaptorWrapper">
         <configuration>
           <port>1099</port>
         </configuration>
       </component>
   
       <!-- samples component (see api for difference) -->
  -    <component name="system-info" class="my.avalon.jmx.tools.SystemInfo" activation="true"/>
  +    <component name="system-info" class="my.avalon.jmx.tools.SystemInfo"/>
   
       <!-- samples component (see api for difference) -->
  -    <component name="jmx-hello" class="my.avalon.jmx.samples.HelloSample" activation="true"/>
  -    <component name="jmx-hello2" class="my.avalon.jmx.samples.HelloSample2" activation="true"/>
  -    <component name="jmx-hello3" class="my.avalon.jmx.samples.HelloSample3" activation="true"/>
  -    <component name="jmx-hello3Bis" class="my.avalon.jmx.samples.HelloSample3" activation="true"/>
  -    <container name="jmx-hello4Compo" class="my.avalon.jmx.samples.HelloSample4" activation="true">
  -      <component name="jmx-hello3Sub" class="my.avalon.jmx.samples.HelloSample3" activation="true"/>
  +    <component name="jmx-hello" class="my.avalon.jmx.samples.HelloSample"/>
  +    <component name="jmx-hello2" class="my.avalon.jmx.samples.HelloSample2"/>
  +    <component name="jmx-hello3" class="my.avalon.jmx.samples.HelloSample3"/>
  +    <component name="jmx-hello3Bis" class="my.avalon.jmx.samples.HelloSample3"/>
  +
  +    <container name="container">
  +      <component name="jmx-hello4Sub" class="my.avalon.jmx.samples.HelloSample4"/>
       </container>
  -  </implementation>
  -</block>
  +
  +</container>
  
  
  
  1.4       +3 -1      avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/JMXServerProxy.java
  
  Index: JMXServerProxy.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/JMXServerProxy.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JMXServerProxy.java	22 Jul 2003 08:58:20 -0000	1.3
  +++ JMXServerProxy.java	18 Aug 2003 12:46:04 -0000	1.4
  @@ -16,7 +16,9 @@
    * @avalon.component version="1.0" name="jmx-server" lifestyle="singleton"
    * @avalon.service type="javax.management.MBeanServer"
    */
  -public class JMXServerProxy extends AbstractLogEnabled implements Initializable, MBeanServer
{
  +public class JMXServerProxy extends AbstractLogEnabled 
  +implements Initializable, MBeanServer 
  +{
       private MBeanServer server_;
   
       /**
  
  
  
  1.4       +56 -23    avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/JRMPAdaptorWrapper.java
  
  Index: JRMPAdaptorWrapper.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/JRMPAdaptorWrapper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JRMPAdaptorWrapper.java	22 Jul 2003 08:58:20 -0000	1.3
  +++ JRMPAdaptorWrapper.java	18 Aug 2003 12:46:04 -0000	1.4
  @@ -26,11 +26,11 @@
    */
   public class JRMPAdaptorWrapper extends AbstractLogEnabled implements Serviceable, Configurable,
Startable 
   {
  -    private MBeanServer   jmxServer_;
  -    private JRMPAdaptor   wrapped_;
  -    private ObjectName    jmxName_;
  -    private NamingService naming_;
  -    private ObjectName    jmxNameNaming_;
  +    private MBeanServer   m_server;
  +    private JRMPAdaptor   m_adapter;
  +    private ObjectName    m_name;
  +    private NamingService m_naming;
  +    private ObjectName    m_namingName;
       private int           port_;
   
       /**
  @@ -42,7 +42,7 @@
        * @avalon.dependency key="jmx-server" type="javax.management.MBeanServer"
        */
       public void service(ServiceManager manager) throws ServiceException {
  -        jmxServer_ = (MBeanServer) manager.lookup("jmx-server");
  +        m_server = (MBeanServer) manager.lookup("jmx-server");
       }
   
       /**
  @@ -59,30 +59,63 @@
   
       public void start() throws Exception {
           // Create and start the naming service
  -        jmxNameNaming_     = new ObjectName("JMXServer:name=naming,type=rmiregistry");
  -        naming_            = new NamingService(port_);
  -        jmxServer_.registerMBean(naming_, jmxNameNaming_);
  -        naming_.start();
  +        m_namingName     = new ObjectName("JMXServer:name=naming,type=rmiregistry");
  +        m_naming            = new NamingService(port_);
  +        m_server.registerMBean(m_naming, m_namingName);
  +        m_naming.start();
   
           // Create the JRMP adaptor
  -        ObjectName jmxName_ = new ObjectName("JMXServer:name=adaptor,protocol=JRMP");
  -        wrapped_ = new JRMPAdaptor();
  -        wrapped_.setJNDIName("jrmp");
  -        wrapped_.setPort(port_);
  +        m_name = new ObjectName("JMXServer:name=adaptor,protocol=JRMP");
  +        m_adapter = new JRMPAdaptor();
  +        m_adapter.setJNDIName("jrmp");
  +        m_adapter.setPort(port_);
   
           // Optionally, you can specify the JNDI properties,
           // instead of having in the classpath a jndi.properties file
  -        wrapped_.putJNDIProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
  -        wrapped_.putJNDIProperty(Context.PROVIDER_URL, "rmi://localhost:" + port_);
  +        m_adapter.putJNDIProperty(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
  +        m_adapter.putJNDIProperty(Context.PROVIDER_URL, "rmi://localhost:" + port_);
   
  -        jmxServer_.registerMBean(wrapped_, jmxName_);
  -        wrapped_.start();
  +        m_server.registerMBean(m_adapter, m_name);
  +        m_adapter.start();
       }
   
  -    public void stop() throws Exception {
  -        wrapped_.stop();
  -        jmxServer_.unregisterMBean(jmxName_);
  -        naming_.stop();
  -        jmxServer_.unregisterMBean(jmxNameNaming_);
  +    public void stop() throws Exception 
  +    {
  +        try
  +        {
  +            m_adapter.stop();
  +        }
  +        catch( Throwable e )
  +        {
  +            getLogger().warn( "ignoring error while attempting to stop adapter", e );
  +        }
  +
  +        try
  +        {
  +            m_server.unregisterMBean( m_name );
  +        }
  +        catch( Throwable e )
  +        {
  +            getLogger().warn( "ignoring error while unregister jrmp management point: "
+ m_name, e );
  +        }
  +
  +        try
  +        {
  +            m_naming.stop();
  +        }
  +        catch( Throwable e )
  +        {
  +            getLogger().warn( "ignoring error while attempting to stop naming service",
e );
  +        }
  +
  +        try
  +        {
  +            m_server.unregisterMBean( m_namingName );
  +        }
  +        catch( Throwable e )
  +        {
  +            getLogger().warn( "ignoring error while unregister rmi name seerver management
point" , e );
  +        }
  +
       }
   }
  
  
  
  1.4       +24 -12    avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/MBeanableHandler.java
  
  Index: MBeanableHandler.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/MBeanableHandler.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MBeanableHandler.java	22 Jul 2003 08:58:20 -0000	1.3
  +++ MBeanableHandler.java	18 Aug 2003 12:46:04 -0000	1.4
  @@ -59,7 +59,7 @@
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
  -import org.apache.avalon.lifecycle.Accessor;
  +import org.apache.avalon.lifecycle.Creator;
   
   import javax.management.MBeanServer;
   import javax.management.ObjectName;
  @@ -73,13 +73,18 @@
    *   <li>the value of "urn:avalon:name" store in context.</li>
    * </ul>
    *
  - * To be auto-registered a MBean component need to include the stage "my.avalon.jmx.MBeanable".
  - * The implementation of the interface my.avalon.jmx.MBeanable is optional (only if you
want to choose your name).
  + * To be auto-registered a MBean component need to include the stage 
  + * "my.avalon.jmx.MBeanable". The implementation of the interface 
  + * my.avalon.jmx.MBeanable is optional (only if you want to choose 
  + * your name).
    *
    * @avalon.component version="1.0" name="jmx-handler"
    * @avalon.extension type="my.avalon.jmx.MBeanable"
    */
  -public class MBeanableHandler extends AbstractLogEnabled implements Accessor, Serviceable
{
  +public class MBeanableHandler extends AbstractLogEnabled 
  +    implements Creator, Serviceable 
  +{
  +
       private MBeanServer jmxServer_;
   
       /**
  @@ -99,7 +104,7 @@
       /**
        * Register object to "jmx-server" service.
        */
  -    public void access(Object object, Context context)
  +    public void create(Object object, Context context)
                   throws Exception {
           try {
               if (jmxServer_ != null) {
  @@ -115,15 +120,21 @@
       /**
        * Unregister object form "jmx-server" service.
        */
  -    public void release(Object object, Context context) {
  -        try {
  -            if (jmxServer_ != null) {
  -                ObjectName name = getObjectName(object, context);
  +    public void destroy(Object object, Context context) 
  +    {
  +        ObjectName name = null;
  +        try 
  +        {
  +            if (jmxServer_ != null) 
  +            {
  +                name = getObjectName(object, context);
                   jmxServer_.unregisterMBean(name);
                   getLogger().debug("unregister component : " + name);
               }
  -        } catch (Exception exc) {
  -            getLogger().warn("unregister", exc);
  +        } 
  +        catch (Exception exc) 
  +        {
  +            getLogger().warn( "unregister: " + name, exc );
           }
       }
   
  @@ -142,7 +153,8 @@
           }
   
           if (back == null) {
  -            back = (String) context.get("urn:avalon:partition");
  +            back = (String) context.get("urn:avalon:partition")
  +              + "/" + (String) context.get("urn:avalon:name");
           }
   
           return new ObjectName("Application:name=" + back);
  
  
  
  1.4       +1 -1      avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/samples/HelloSample.java
  
  Index: HelloSample.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/samples/HelloSample.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HelloSample.java	22 Jul 2003 08:58:20 -0000	1.3
  +++ HelloSample.java	18 Aug 2003 12:46:05 -0000	1.4
  @@ -80,7 +80,7 @@
    * </ul>
    *
    * @jmx.mbean
  - * @avalon.component version="1.0" name="jmx-hello"
  + * @avalon.component version="1.0" name="jmx-hello" lifestyle="singleton"
    */
   public class HelloSample extends AbstractLogEnabled implements HelloSampleMBean, Serviceable,
Configurable, Initializable, Executable, Disposable {
       private MBeanServer jmxServer_;
  
  
  
  1.4       +1 -1      avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/samples/HelloSample2.java
  
  Index: HelloSample2.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/samples/HelloSample2.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HelloSample2.java	22 Jul 2003 08:58:20 -0000	1.3
  +++ HelloSample2.java	18 Aug 2003 12:46:05 -0000	1.4
  @@ -65,7 +65,7 @@
    * This component include stage "my.avalon.jmx.MBeanable" and implements MBeanable interface.
    *
    * @jmx.mbean
  - * @avalon.component version="1.0" name="jmx-hello2" 
  + * @avalon.component version="1.0" name="jmx-hello2" lifestyle="singleton"
    * @avalon.stage type="my.avalon.jmx.MBeanable"
    */
   public class HelloSample2 extends AbstractLogEnabled implements HelloSample2MBean, MBeanable,
Executable {
  
  
  
  1.4       +1 -1      avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/samples/HelloSample3.java
  
  Index: HelloSample3.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/samples/HelloSample3.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HelloSample3.java	22 Jul 2003 08:58:20 -0000	1.3
  +++ HelloSample3.java	18 Aug 2003 12:46:05 -0000	1.4
  @@ -66,7 +66,7 @@
    * "a meta.verifier.VerifyException" is throw, but Component is accessible.
    *
    * @jmx.mbean
  - * @avalon.component version="1.0" name="jmx-hello3"
  + * @avalon.component version="1.0" name="jmx-hello3" lifestyle="singleton"
    * @avalon.stage type="my.avalon.jmx.MBeanable"
    */
   public class HelloSample3 extends AbstractLogEnabled implements HelloSample3MBean, Executable
{
  
  
  
  1.4       +1 -1      avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/samples/HelloSample4.java
  
  Index: HelloSample4.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/samples/HelloSample4.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HelloSample4.java	22 Jul 2003 08:58:20 -0000	1.3
  +++ HelloSample4.java	18 Aug 2003 12:46:05 -0000	1.4
  @@ -66,7 +66,7 @@
    * but return null as getName(), so MBeanableHandler used "urn:avalon:name".
    *
    * @jmx.mbean
  - * @avalon.component version="1.0" name="jmx-hello2"
  + * @avalon.component version="1.0" name="jmx-hello2" lifestyle="singleton"
    * @avalon.stage type="my.avalon.jmx.MBeanable"
    */
   public class HelloSample4 extends AbstractLogEnabled 
  
  
  
  1.4       +1 -1      avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/tools/SystemInfo.java
  
  Index: SystemInfo.java
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/merlin-test/merlin-jmx-demo/src/main/my/avalon/jmx/tools/SystemInfo.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SystemInfo.java	22 Jul 2003 08:58:21 -0000	1.3
  +++ SystemInfo.java	18 Aug 2003 12:46:05 -0000	1.4
  @@ -67,7 +67,7 @@
    * Useness for monitoring.
    *
    * @jmx.mbean
  - * @avalon.component version="1.0" name="system-info"
  + * @avalon.component version="1.0" name="system-info" lifestyle="singleton"
    * @avalon.stage type="my.avalon.jmx.MBeanable"
    */
   public class SystemInfo extends AbstractLogEnabled implements Initializable, SystemInfoMBean,
MBeanable {
  
  
  

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


Mime
View raw message