[jboss-cvs] JBossAS SVN: r74989 - in trunk: system-jmx/src/main/org/jboss/system/microcontainer/jmx and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jun 24 10:32:58 EDT 2008


Author: alesj
Date: 2008-06-24 10:32:58 -0400 (Tue, 24 Jun 2008)
New Revision: 74989

Added:
   trunk/system-jmx/src/resources/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationPluginTestCase-mc.xml
   trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/support/ExposeJMXAttribute.java
   trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/AbstractJMXAnnotationTest.java
   trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationPluginTestCase.java
Modified:
   trunk/component-matrix/pom.xml
   trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/JMXAnnotationPlugin.java
   trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationTestCase.java
   trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/ServiceUnitNameTestCase.java
Log:
Update to MC 2.0.0.Beta16, Deployers 2.0.0.Beta18.
Add @JMXAnnotationPlugin + tests.
Fix ServiceUnitNameTC.

Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2008-06-24 14:27:20 UTC (rev 74988)
+++ trunk/component-matrix/pom.xml	2008-06-24 14:32:58 UTC (rev 74989)
@@ -44,12 +44,12 @@
     <version.org.jboss.vfs>2.0.0.Beta19</version.org.jboss.vfs>
     <version.org.jboss.cl>2.0.0.Beta12</version.org.jboss.cl>
     <version.org.jboss.cluster>1.1.0.CR1</version.org.jboss.cluster>
-    <version.org.jboss.deployers>2.0.0.Beta17</version.org.jboss.deployers>
+    <version.org.jboss.deployers>2.0.0.Beta18</version.org.jboss.deployers>
     <version.org.jboss.integration>5.0.0.Beta5</version.org.jboss.integration>
     <version.org.jboss.jbossxb>2.0.0.CR11</version.org.jboss.jbossxb>
     <version.org.jboss.man>2.0.0.Beta15</version.org.jboss.man>
     <version.org.jboss.metadata>1.0.0.Beta25</version.org.jboss.metadata>
-    <version.org.jboss.microcontainer>2.0.0.Beta15</version.org.jboss.microcontainer>
+    <version.org.jboss.microcontainer>2.0.0.Beta16</version.org.jboss.microcontainer>
     <version.org.jboss.security>2.0.2.CR5</version.org.jboss.security>
     <version.oswego-concurrent.concurrent>1.3.4-jboss-update1</version.oswego-concurrent.concurrent>
     <version.suffix.org.jboss.javaee>.CR1</version.suffix.org.jboss.javaee>

Modified: trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/JMXAnnotationPlugin.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/JMXAnnotationPlugin.java	2008-06-24 14:27:20 UTC (rev 74988)
+++ trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/JMXAnnotationPlugin.java	2008-06-24 14:32:58 UTC (rev 74989)
@@ -21,12 +21,10 @@
 */
 package org.jboss.system.microcontainer.jmx;
 
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.Method;
 import java.util.List;
 
 import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
 import org.jboss.dependency.spi.Controller;
@@ -58,34 +56,21 @@
       if (exposedInterface == null || exposedInterface.isInterface() == false)
          throw new IllegalArgumentException("Illegal exposed interface: " + exposedInterface);
 
-      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(createObjectName(context, info, jmx), exposedInterface.getName());
-      // TODO - uncomment with new MC release; builder.addAnnotation(jmx);
-      Object proxy = createProxy(context, info, exposedInterface);
+      String name = createObjectName(context, info, jmx);
+      String property = getName(info);
+      log.debug("Exposing " + context.getName() + "." + property + " (" + exposedInterface.getName() + ") via objectName: " + name);
+
+      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(name, exposedInterface.getName());
+      builder.addAnnotation(jmx);
+      builder.setConstructorValue(new AbstractDependencyValueMetaData(context.getName(), property));
+
       KernelController controller = (KernelController)context.getController();
-      controller.install(builder.getBeanMetaData(), proxy);
+      controller.install(builder.getBeanMetaData());
 
       // no change directly on context
       return null;
    }
 
-   /**
-    * Create proxy for attribute.
-    *
-    * @param context the context
-    * @param info the info
-    * @param exposedInterface the exposed interface
-    * @return attribute's proxy
-    * @throws Throwable for any error
-    */
-   protected Object createProxy(KernelControllerContext context, T info, Class<?> exposedInterface) throws Throwable
-   {
-      return Proxy.newProxyInstance(
-            context.getClassLoader(),
-            new Class<?>[]{exposedInterface},
-            new AttributeInvocationHandler(context, getName(info))
-      );
-   }
-
    protected void internalCleanAnnotation(T info, MetaData metaData, JMX jmx, KernelControllerContext context) throws Throwable
    {
       Controller controller = context.getController();
@@ -133,27 +118,6 @@
       {
          objectName = "jboss.pojo:name='" + name + "'";
       }
-      return objectName + ",property=" + getName(info);
+      return objectName + ",attribute=" + getName(info);
    }
-
-   /**
-    * Attribute invocation handler.
-    */
-   protected class AttributeInvocationHandler implements InvocationHandler
-   {
-      private KernelControllerContext context;
-      private String property;
-
-      protected AttributeInvocationHandler(KernelControllerContext context, String property)
-      {
-         this.context = context;
-         this.property = property;
-      }
-
-      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
-      {
-         Object target = context.get(property);
-         return method.invoke(target, args);
-      }
-   }
 }
\ No newline at end of file

Copied: trunk/system-jmx/src/resources/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationPluginTestCase-mc.xml (from rev 74970, trunk/system-jmx/src/resources/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationTestCase-mc.xml)
===================================================================
--- trunk/system-jmx/src/resources/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationPluginTestCase-mc.xml	                        (rev 0)
+++ trunk/system-jmx/src/resources/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationPluginTestCase-mc.xml	2008-06-24 14:32:58 UTC (rev 74989)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <!-- The legacy JMX kernel -->
+   <bean name="ServiceControllerLocator" class="org.jboss.test.system.controller.integration.support.ServiceControllerLocator" />
+
+   <bean name="ServiceLifecycle" class="org.jboss.test.system.controller.integration.support.TestServiceControllerLifecycleCallback">
+      <property name="mbeanServer">
+         <inject bean="ServiceControllerLocator" property="mbeanServer"/>
+      </property>
+      <property name="serviceController">
+         <inject bean="ServiceControllerLocator" property="serviceController"/>
+      </property>
+   </bean>
+
+   <bean name="AnnotationHandlerFactory">
+      <constructor factoryClass="org.jboss.kernel.plugins.annotations.BeanAnnotationAdapterFactory" factoryMethod="getInstance" />
+   </bean>
+   <bean name="AnnotationHandler">
+      <constructor factoryMethod="getBeanAnnotationAdapter">
+         <factory bean="AnnotationHandlerFactory"/>
+      </constructor>
+      <incallback method="addAnnotationPlugin" />
+      <uncallback method="removeAnnotationPlugin" />
+   </bean>
+   <bean name="JMXPropertyPlugin" class="org.jboss.system.microcontainer.jmx.JMXPropertyAnnotationPlugin" />
+   <bean name="JMXFieldPlugin" class="org.jboss.system.microcontainer.jmx.JMXFieldAnnotationPlugin" />
+
+   <bean name="ExposeJMXAttribute" class="org.jboss.test.system.controller.integration.support.ExposeJMXAttribute" access-mode="ALL"/>
+
+</deployment>

Copied: trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/support/ExposeJMXAttribute.java (from rev 74970, trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/support/MockTransactionManager.java)
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/support/ExposeJMXAttribute.java	                        (rev 0)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/support/ExposeJMXAttribute.java	2008-06-24 14:32:58 UTC (rev 74989)
@@ -0,0 +1,58 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.integration.support;
+
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ExposeJMXAttribute
+{
+   private MockUnifiedInvokerMBean invoker = new MockUnifiedInvoker();
+   private MockTransactionManagerMBean tm = new MockTransactionManager();
+
+   @JMX(exposedInterface = void.class, name="jboss:service=invoker,type=field", registerDirectly = true) private MockUnifiedInvokerMBean invokerField = new MockUnifiedInvoker();
+   @JMX(exposedInterface = void.class, registerDirectly = true) private MockTransactionManagerMBean tmField = new MockTransactionManager();
+
+   @JMX(exposedInterface = void.class, name="jboss:service=invoker,type=getter", registerDirectly = true)
+   public MockUnifiedInvokerMBean getInvoker()
+   {
+      return invoker;
+   }
+
+   public void setInvoker(MockUnifiedInvokerMBean invoker)
+   {
+      this.invoker = invoker;
+   }
+
+   @JMX(exposedInterface = void.class, registerDirectly = true)
+   public MockTransactionManagerMBean getTm()
+   {
+      return tm;
+   }
+
+   public void setTm(MockTransactionManagerMBean tm)
+   {
+      this.tm = tm;
+   }
+}
\ No newline at end of file

Added: trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/AbstractJMXAnnotationTest.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/AbstractJMXAnnotationTest.java	                        (rev 0)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/AbstractJMXAnnotationTest.java	2008-06-24 14:32:58 UTC (rev 74989)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.integration.test;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * Abstract JMX annotation test.
+ * Keeps ref to mbean server.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractJMXAnnotationTest extends AbstractIntegrationTest
+{
+   protected AbstractJMXAnnotationTest(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return new JMXAwareTestDelegate(clazz);
+   }
+
+   private static class JMXAwareTestDelegate extends IntegrationTestDelegate
+   {
+      public JMXAwareTestDelegate(Class clazz)
+      {
+         super(clazz);
+      }
+
+      protected MBeanServer createMBeanServer()
+      {
+         return MBeanServerFactory.createMBeanServer("jboss");
+      }
+   }
+}
\ No newline at end of file

Copied: trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationPluginTestCase.java (from rev 74970, trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationTestCase.java)
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationPluginTestCase.java	                        (rev 0)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationPluginTestCase.java	2008-06-24 14:32:58 UTC (rev 74989)
@@ -0,0 +1,69 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.system.controller.integration.test;
+
+import junit.framework.Test;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.test.system.controller.integration.support.MockTransactionManagerMBean;
+import org.jboss.test.system.controller.integration.support.MockUnifiedInvokerMBean;
+
+/**
+ * JMXAnnotationPluginTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class JMXAnnotationPluginTestCase extends AbstractJMXAnnotationTest
+{
+   public static Test suite()
+   {
+      return suite(JMXAnnotationPluginTestCase.class);
+   }
+
+   public JMXAnnotationPluginTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testJMXAnnotationPlugin() throws Throwable
+   {
+      // getter
+      ControllerContext mbeanContext = getControllerContext("jboss:service=invoker,type=getter");
+      assertNotNull(mbeanContext);
+      assertInstanceOf(MockUnifiedInvokerMBean.class, mbeanContext.getTarget());
+      // field
+      mbeanContext = getControllerContext("jboss:service=invoker,type=field");
+      assertNotNull(mbeanContext);
+      assertInstanceOf(MockUnifiedInvokerMBean.class, mbeanContext.getTarget());
+
+      // getter
+      ControllerContext tmJMXContext = getControllerContext("jboss.pojo:name='ExposeJMXAttribute',attribute=tm");
+      assertNotNull(tmJMXContext);
+      assertInstanceOf(MockTransactionManagerMBean.class, tmJMXContext.getTarget());
+      // field
+      tmJMXContext = getControllerContext("jboss.pojo:name='ExposeJMXAttribute',attribute=tmField");
+      assertNotNull(tmJMXContext);
+      assertInstanceOf(MockTransactionManagerMBean.class, tmJMXContext.getTarget());
+
+      validate();
+      validateMC();
+   }
+}
\ No newline at end of file

Modified: trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationTestCase.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationTestCase.java	2008-06-24 14:27:20 UTC (rev 74988)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/controller/integration/test/JMXAnnotationTestCase.java	2008-06-24 14:32:58 UTC (rev 74989)
@@ -21,12 +21,8 @@
 */
 package org.jboss.test.system.controller.integration.test;
 
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-
 import junit.framework.Test;
 import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.test.AbstractTestDelegate;
 import org.jboss.test.system.controller.integration.support.MockTransactionManagerMBean;
 import org.jboss.test.system.controller.integration.support.MockUnifiedInvokerMBean;
 
@@ -35,7 +31,7 @@
  *
  * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  */
-public class JMXAnnotationTestCase extends AbstractIntegrationTest
+public class JMXAnnotationTestCase extends AbstractJMXAnnotationTest
 {
    public static Test suite()
    {
@@ -66,22 +62,4 @@
       validate();
       validateMC();
    }
-
-   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
-   {
-      return new JMXAwareTestDelegate(clazz);
-   }
-
-   private static class JMXAwareTestDelegate extends IntegrationTestDelegate
-   {
-      public JMXAwareTestDelegate(Class clazz)
-      {
-         super(clazz);
-      }
-
-      protected MBeanServer createMBeanServer()
-      {
-         return MBeanServerFactory.createMBeanServer("jboss");
-      }
-   }
 }

Modified: trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/ServiceUnitNameTestCase.java
===================================================================
--- trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/ServiceUnitNameTestCase.java	2008-06-24 14:27:20 UTC (rev 74988)
+++ trunk/system-jmx/src/tests/org/jboss/test/system/deployers/test/ServiceUnitNameTestCase.java	2008-06-24 14:32:58 UTC (rev 74989)
@@ -32,6 +32,7 @@
 import org.jboss.dependency.plugins.AbstractController;
 import org.jboss.deployers.client.plugins.deployment.AbstractDeployment;
 import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.client.spi.IncompleteDeploymentException;
 import org.jboss.deployers.plugins.deployers.DeployersImpl;
 import org.jboss.deployers.plugins.main.MainDeployerImpl;
 import org.jboss.deployers.spi.DeploymentException;
@@ -118,7 +119,12 @@
                mainDeployer.process();
 
                mainDeployer.checkComplete(deployment);
+               fail("Should not be here");
             }
+            catch (Exception e)
+            {
+               assertInstanceOf(e, IncompleteDeploymentException.class);               
+            }
             finally
             {
                mbeanServer.unregisterMBean(objectName);
@@ -158,15 +164,13 @@
       }
 
       @Override
-      protected ServiceDeployment parse(DeploymentUnit arg0, Set<String> arg1,
-            ServiceDeployment arg2) throws Exception
+      protected ServiceDeployment parse(DeploymentUnit arg0, Set<String> arg1, ServiceDeployment arg2) throws Exception
       {
          return getServiceDeployment();
       }
 
       @Override
-      protected ServiceDeployment parse(DeploymentUnit arg0, Set<String> arg1,
-            String arg2, ServiceDeployment arg3) throws Exception
+      protected ServiceDeployment parse(DeploymentUnit arg0, Set<String> arg1, String arg2, ServiceDeployment arg3) throws Exception
       {
          return getServiceDeployment();
       }




More information about the jboss-cvs-commits mailing list