geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject cvs commit: incubator-geronimo/modules/remoting/src/test/org/apache/geronimo/remoting JMXRemotingTest.java StartupTest.java
Date Sat, 31 Jan 2004 20:20:45 GMT
adc         2004/01/31 12:20:45

  Modified:    modules/remoting/src/java/org/apache/geronimo/remoting/jmx
                        MBeanServerStub.java
               modules/remoting/src/java/org/apache/geronimo/remoting/router
                        JMXRouter.java
               modules/remoting/src/test/org/apache/geronimo/remoting
                        JMXRemotingTest.java StartupTest.java
  Log:
  JMXTargets should be assigned specific JMX routers
  
  Revision  Changes    Path
  1.9       +22 -8     incubator-geronimo/modules/remoting/src/java/org/apache/geronimo/remoting/jmx/MBeanServerStub.java
  
  Index: MBeanServerStub.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/remoting/src/java/org/apache/geronimo/remoting/jmx/MBeanServerStub.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MBeanServerStub.java	28 Jan 2004 05:45:23 -0000	1.8
  +++ MBeanServerStub.java	31 Jan 2004 20:20:44 -0000	1.9
  @@ -55,20 +55,20 @@
    */
   package org.apache.geronimo.remoting.jmx;
   
  -import java.util.Set;
  -import java.util.HashSet;
  -
   import org.apache.geronimo.core.service.Interceptor;
   import org.apache.geronimo.gbean.GBean;
   import org.apache.geronimo.gbean.GBeanContext;
   import org.apache.geronimo.gbean.GBeanInfo;
  +import org.apache.geronimo.gbean.GBeanInfoFactory;
   import org.apache.geronimo.gbean.GOperationInfo;
  +import org.apache.geronimo.gbean.GReferenceInfo;
   import org.apache.geronimo.gbean.jmx.GBeanMBeanContext;
   import org.apache.geronimo.proxy.ProxyContainer;
   import org.apache.geronimo.proxy.ReflexiveInterceptor;
   import org.apache.geronimo.remoting.DeMarshalingInterceptor;
  +import org.apache.geronimo.remoting.router.JMXRouter;
   import org.apache.geronimo.remoting.router.JMXTarget;
  -import org.apache.geronimo.remoting.router.AbstractInterceptorRouter;
  +
   
   /**
    * @version $Revision$ $Date$
  @@ -77,17 +77,28 @@
       private ProxyContainer serverContainer;
       private DeMarshalingInterceptor demarshaller;
       private GBeanMBeanContext context;
  +    private JMXRouter router;
   
   
       public Interceptor getRemotingEndpointInterceptor() {
           return demarshaller;
       }
   
  +    public JMXRouter getRouter() {
  +        return router;
  +    }
  +
  +    public void setRouter(JMXRouter router) {
  +        this.router = router;
  +    }
  +
       public void setGBeanContext(GBeanContext context) {
           this.context = (GBeanMBeanContext) context;
       }
   
       public void doStart() {
  +        router.register(context.getObjectName(), this);
  +
           // Setup the server side contianer..
           Interceptor firstInterceptor = new ReflexiveInterceptor(context.getServer());
           demarshaller = new DeMarshalingInterceptor(firstInterceptor, getClass().getClassLoader());
  @@ -95,6 +106,7 @@
       }
   
       public void doStop() {
  +        router.unRegister(context.getObjectName());
           serverContainer = null;
           demarshaller = null;
       }
  @@ -107,9 +119,11 @@
       public static final GBeanInfo GBEAN_INFO;
   
       static {
  -        Set operations = new HashSet();
  -        operations.add(new GOperationInfo("getRemotingEndpointInterceptor"));
  -        GBEAN_INFO = new GBeanInfo(MBeanServerStub.class.getName(), null, null, operations,
null, null);
  +        GBeanInfoFactory infoFactory = new GBeanInfoFactory(MBeanServerStub.class.getName());
  +        infoFactory.addOperation(new GOperationInfo("getName"));
  +        infoFactory.addOperation(new GOperationInfo("getRemotingEndpointInterceptor"));
  +        infoFactory.addReference(new GReferenceInfo("Router", JMXRouter.class.getName()));
  +        GBEAN_INFO = infoFactory.getBeanInfo();
       }
   
       public static GBeanInfo getGBeanInfo() {
  
  
  
  1.8       +22 -7     incubator-geronimo/modules/remoting/src/java/org/apache/geronimo/remoting/router/JMXRouter.java
  
  Index: JMXRouter.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/remoting/src/java/org/apache/geronimo/remoting/router/JMXRouter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JMXRouter.java	26 Jan 2004 06:50:47 -0000	1.7
  +++ JMXRouter.java	31 Jan 2004 20:20:44 -0000	1.8
  @@ -55,15 +55,16 @@
    */
   package org.apache.geronimo.remoting.router;
   
  -import java.net.URI;
  -import javax.management.MalformedObjectNameException;
   import javax.management.ObjectName;
  +import java.net.URI;
  +import java.util.HashMap;
  +import java.util.Map;
   
   import org.apache.geronimo.core.service.Interceptor;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GBeanInfoFactory;
  +import org.apache.geronimo.gbean.GOperationInfo;
   import org.apache.geronimo.gbean.GReferenceInfo;
  -import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
   
   /**
    * Uses JMX Object names to route the request to a JMX object that implements the
  @@ -78,6 +79,7 @@
    */
   public class JMXRouter extends AbstractInterceptorRouter {
       private SubsystemRouter subsystemRouter;
  +    private Map registered = new HashMap();
   
       public SubsystemRouter getSubsystemRouter() {
           return subsystemRouter;
  @@ -87,10 +89,21 @@
           this.subsystemRouter = subsystemRouter;
       }
   
  +    public void register(ObjectName objectName, JMXTarget target) {
  +        registered.put(objectName, target);
  +    }
  +
  +    public void unRegister(ObjectName objectName) {
  +        registered.remove(objectName);
  +    }
  +
       protected Interceptor lookupInterceptorFrom(URI to) throws Exception {
  -        ObjectName on = new ObjectName(to.getFragment());
  -        JMXTarget bean = (JMXTarget) MBeanProxyFactory.getProxy(JMXTarget.class, context.getServer(),
on);
  -        return bean.getRemotingEndpointInterceptor();
  +        ObjectName objectName = new ObjectName(to.getFragment());
  +        JMXTarget bean = (JMXTarget)registered.get(objectName);
  +
  +        if (bean != null) return bean.getRemotingEndpointInterceptor();
  +
  +        throw new IllegalArgumentException("No names mbeans registered that match object
name pattern: " + objectName);
       }
   
       public void doStart() {
  @@ -108,6 +121,8 @@
       static {
           GBeanInfoFactory infoFactory = new GBeanInfoFactory(JMXRouter.class.getName(),
AbstractInterceptorRouter.GBEAN_INFO);
           infoFactory.addReference(new GReferenceInfo("SubsystemRouter", SubsystemRouter.class.getName()));
  +        infoFactory.addOperation(new GOperationInfo("register", new String[] {ObjectName.class.getName(),
JMXTarget.class.getName()}));
  +        infoFactory.addOperation(new GOperationInfo("unRegister", new String[] {ObjectName.class.getName()}));
           GBEAN_INFO = infoFactory.getBeanInfo();
       }
   
  
  
  
  1.2       +2 -1      incubator-geronimo/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java
  
  Index: JMXRemotingTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JMXRemotingTest.java	28 Jan 2004 05:55:39 -0000	1.1
  +++ JMXRemotingTest.java	31 Jan 2004 20:20:44 -0000	1.2
  @@ -106,6 +106,7 @@
           kernel.loadGBean(jmxRouter, gbean);
   
           gbean = new GBeanMBean("org.apache.geronimo.remoting.jmx.MBeanServerStub");
  +        gbean.setReferencePatterns("Router", Collections.singleton(jmxRouter));
           serverStub = new ObjectName("geronimo.remoting:target=MBeanServerStub");
           kernel.loadGBean(serverStub, gbean);
   
  
  
  
  1.3       +2 -1      incubator-geronimo/modules/remoting/src/test/org/apache/geronimo/remoting/StartupTest.java
  
  Index: StartupTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/remoting/src/test/org/apache/geronimo/remoting/StartupTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StartupTest.java	25 Jan 2004 21:07:04 -0000	1.2
  +++ StartupTest.java	31 Jan 2004 20:20:44 -0000	1.3
  @@ -98,6 +98,7 @@
           kernel.loadGBean(registeryRouter, gbean);
   
           gbean = new GBeanMBean("org.apache.geronimo.remoting.jmx.MBeanServerStub");
  +        gbean.setReferencePatterns("Router", Collections.singleton(jmxRouter));
           ObjectName serverStub = new ObjectName("geronimo.remoting:target=MBeanServerStub");
           kernel.loadGBean(serverStub, gbean);
   
  
  
  

Mime
View raw message