geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r386439 - in /geronimo/xbean/trunk: xbean-jmx/ xbean-jmx/src/main/java/org/apache/xbean/jmx/ xbean-jmx/src/main/java/org/apache/xbean/jmx/assembler/ xbean-jmx/src/main/java/org/apache/xbean/jmx/config/ xbean-jmx/src/main/java/org/apache/xbe...
Date Thu, 16 Mar 2006 19:43:31 GMT
Author: adc
Date: Thu Mar 16 11:43:06 2006
New Revision: 386439

URL: http://svn.apache.org/viewcvs?rev=386439&view=rev
Log:
Added pluggable wrapping strategies.

Added:
    geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanWrap.java
    geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/DefaultWrappingStrategy.java
      - copied, changed from r385097, geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/JavaBeanWrappingStrategy.java
    geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/JavaBeanWrappingStrategy.java
    geronimo/xbean/trunk/xbean-jmx/src/main/resources/META-INF/org.apache.xbean.jmx.StrategyFinder/xbean.default
    geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/strategies/
    geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/strategies/DummyWrappingStrategy.java
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/META-INF/
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/META-INF/org.apache.xbean.jmx.StrategyFinder/
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/META-INF/org.apache.xbean.jmx.StrategyFinder/dummy
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-duplicate.xml
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-wrapper.xml
      - copied, changed from r385097, geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-assembler.xml
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-duplicate-wrapper.xml
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-duplicate.xml
Removed:
    geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/BeanPairing.java
    geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/config/JMXServiceConfig.java
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-assembler.xml
Modified:
    geronimo/xbean/trunk/xbean-jmx/pom.xml
    geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/JMXStrategyFinder.java
    geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/JMXWrappingStrategy.java
    geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanExporter.java
    geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanHolder.java
    geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/assembler/JavaBeanMBeanInfoGenerator.java
    geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/JMXStrategyFinderTest.java
    geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/JMXTest.java
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-listener-multiple.xml
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-listener.xml
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-simple-multiple.xml
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-simple.xml
    geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx.xml
    geronimo/xbean/trunk/xbean-reflect/   (props changed)
    geronimo/xbean/trunk/xbean-tiger/   (props changed)

Modified: geronimo/xbean/trunk/xbean-jmx/pom.xml
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/pom.xml?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/pom.xml (original)
+++ geronimo/xbean/trunk/xbean-jmx/pom.xml Thu Mar 16 11:43:06 2006
@@ -31,13 +31,15 @@
                         </goals>
                         <configuration>
                             <tasks>
-                                <taskdef classname="org.apache.xbean.spring.generator.MappingGeneratorTask"
name="mapping">
+                                <taskdef classname="org.apache.xbean.spring.generator.MappingGeneratorTask"
+                                         name="mapping">
                                     <classpath>
                                         <pathelement path="${basedir}/target/classes"></pathelement>
                                         <path refid="maven.runtime.classpath"></path>
                                     </classpath>
                                 </taskdef>
-                                <mapping namespace="http://xbean.apache.org/schemas/jmx"
srcdir="src/main/java" destFile="target/jmx.xsd" metaInfDir="${basedir}/target/generated/"></mapping>
+                                <mapping namespace="http://xbean.apache.org/schemas/jmx"
srcdir="src/main/java"
+                                         destFile="target/jmx.xsd" metaInfDir="${basedir}/target/generated/"></mapping>
                                 <copy todir="${basedir}/target/classes">
                                     <fileset dir="${basedir}/target/generated"></fileset>
                                 </copy>

Modified: geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/JMXStrategyFinder.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/JMXStrategyFinder.java?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/JMXStrategyFinder.java
(original)
+++ geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/JMXStrategyFinder.java
Thu Mar 16 11:43:06 2006
@@ -29,12 +29,8 @@
 public class JMXStrategyFinder {
 
     private final static String PROPERTY_NAME = "org.apache.xbean.jmx.WrapperStrategyClass";
-    private final String path;
-    private final WeakHashMap classCache = new WeakHashMap();
-
-    public JMXStrategyFinder(String path) {
-        this.path = path;
-    }
+    private final static String PATH = "META-INF/org.apache.xbean.jmx.StrategyFinder/";
+    private final static WeakHashMap classCache = new WeakHashMap();
 
     /**
      * Creates a new instance of the given key
@@ -43,7 +39,10 @@
      *            containing the factory name
      * @return a newly created instance
      */
-    public JMXWrappingStrategy newInstance(String key) throws JMXServiceException {
+    public static JMXWrappingStrategy newInstance(String key) throws JMXServiceException
{
+
+        if (key == null) key = "xbean.default";
+
         JMXWrappingStrategy result = null;
         try {
             synchronized (classCache) {
@@ -70,7 +69,7 @@
         return result;
     }
 
-    private Class loadClass(Properties properties) throws ClassNotFoundException, IOException
{
+    private static Class loadClass(Properties properties) throws ClassNotFoundException,
IOException {
 
         String className = properties.getProperty(PROPERTY_NAME);
         if (className == null) {
@@ -84,8 +83,8 @@
         }
     }
 
-    private Properties doFindServiceWrapperProperies(String key) throws IOException {
-        String uri = path + key;
+    private static Properties doFindServiceWrapperProperies(String key) throws IOException
{
+        String uri = PATH + key;
 
         InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(uri);
         if (in == null) {

Modified: geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/JMXWrappingStrategy.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/JMXWrappingStrategy.java?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/JMXWrappingStrategy.java
(original)
+++ geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/JMXWrappingStrategy.java
Thu Mar 16 11:43:06 2006
@@ -16,7 +16,7 @@
  */
 package org.apache.xbean.jmx;
 
-import org.apache.xbean.jmx.config.JMXServiceConfig;
+import java.util.Properties;
 
 
 /**
@@ -28,11 +28,11 @@
      * @param service
      * @param config
      */
-    public Object wrapService(Object service, JMXServiceConfig config) throws JMXServiceException;
+    public Object wrapObject(Object service, Properties config) throws JMXServiceException;
 
     /**
      * @param service
      * @param config
      */
-    public void unwrapService(Object service, JMXServiceConfig config);
+    public void unwrapObject(Object service, Properties config);
 }

Modified: geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanExporter.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanExporter.java?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanExporter.java (original)
+++ geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanExporter.java Thu
Mar 16 11:43:06 2006
@@ -20,15 +20,13 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import javax.management.InstanceNotFoundException;
 import javax.management.JMException;
-import javax.management.MBeanInfo;
 import javax.management.MBeanRegistrationException;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
-import org.apache.xbean.jmx.assembler.JavaBeanMBeanInfoGenerator;
-
 
 /**
  * Exports services to an MBeanServer for management.
@@ -38,10 +36,11 @@
  */
 public class MBeanExporter {
     private MBeanServer mbeanServer;
-    private List mbeanInfos;
+    private List wrapStrategies;
     private List mbeans;
     private List connectors;
     private Map registeredMBeans = new HashMap();
+    private Map configuredClasses = new HashMap();
 
     /**
      * @org.apache.xbean.Property alias="mbeanserver"
@@ -55,14 +54,14 @@
     }
 
     /**
-     * @org.apache.xbean.Property alias="mbeaninfos"
+     * @org.apache.xbean.Property alias="wrapStrategies"
      */
-    public void setMbeanInfos(List mbeanInfos) {
-        this.mbeanInfos = mbeanInfos;
+    public void setWrapStrategies(List wrapStrategies) {
+        this.wrapStrategies = wrapStrategies;
     }
 
-    public List getMbeanInfos() {
-        return mbeanInfos;
+    public List getWrapStrategies() {
+        return wrapStrategies;
     }
 
     /**
@@ -88,22 +87,43 @@
      * @org.apache.xbean.InitMethod
      */
     public void start() {
+
+        List strategies = getWrapStrategies();
+
+        if (strategies != null) {
+            for (int i = 0; i < strategies.size(); i++) {
+                MBeanWrap wrap = (MBeanWrap) strategies.get(i);
+
+                if (configuredClasses.containsKey(wrap.getBeanClass()))
+                    throw new IllegalStateException(wrap.getBeanClass() + "configured multiple
times in <wrapStrategies/>");
+
+                if (wrap.getConfig() == null) wrap.setConfig(new Properties());
+
+                configuredClasses.put(wrap.getBeanClass(), wrap);
+            }
+        }
+
         try {
             MBeanServer server = findMBeanServer();
             List mbeanElements = getMbeans();
             for (int i = 0; i < mbeanElements.size(); i++) {
                 MBeanHolder mbean = (MBeanHolder) mbeanElements.get(i);
+                MBeanWrap wrap = getWrapConfig(mbean);
 
                 ObjectName objectName = mbean.createObjectName();
-                MBeanInfo metadata = createMBeanInfo(mbean, objectName);
-                Object mbeanAdapter = mbean.createMBeanAdapter(metadata, objectName);
+                JMXWrappingStrategy strategy = JMXStrategyFinder.newInstance(wrap.getStrategy());
+                Object mbeanAdapter = strategy.wrapObject(mbean.getBean(), wrap.getConfig());
+
                 server.registerMBean(mbeanAdapter, objectName);
+
                 mbean.bindListeners(mbeanAdapter);
+
                 registeredMBeans.put(objectName, mbean);
             }
-        }
-        catch (JMException x) {
+        } catch (JMException x) {
             throw new JMXException(x);
+        } catch (JMXServiceException e) {
+            throw new JMXException(e);
         }
     }
 
@@ -134,23 +154,26 @@
         throw new JMXException("Cannot find MBeanServer");
     }
 
-    private MBeanInfo createMBeanInfo(MBeanHolder mbean, ObjectName objectName) {
-        MBeanInfo metadata = null;
-        Class beanClass = mbean.getBean().getClass();
-        List infos = getMbeanInfos();
-        if (infos != null) {
-            while (metadata == null && beanClass != Object.class) {
-                for (int j = 0; j < infos.size(); j++) {
-                    BeanPairing beanPairing = (BeanPairing) infos.get(j);
-                    if (beanPairing.getBeanClass().isAssignableFrom(beanClass)) {
-                        metadata = beanPairing.createMBeanInfo(mbean.getBean(), objectName);
-                        return metadata;
-                    }
-                }
-                beanClass = beanClass.getSuperclass();
-            }
+    protected MBeanWrap getWrapConfig(MBeanHolder mbean) {
+        MBeanWrap result;
+
+        String className = mbean.getBean().getClass().getName();
+        String strategyName = mbean.getWrapStrategy();
+
+        result = (MBeanWrap) configuredClasses.get(className);
+        if (result != null) {
+            if (strategyName != null && !result.getStrategy().equals(strategyName))
+                throw new IllegalStateException(className + "configured with " + strategyName
+ " and " + result.getStrategy());
+        } else {
+            result = new MBeanWrap();
+
+            result.setBeanClass(className);
+            result.setStrategy(strategyName);
+            result.setConfig(new Properties());
+
+            configuredClasses.put(className, result);
         }
-        // No specialized assembler found, use a default one
-        return new JavaBeanMBeanInfoGenerator().createMBeanInfo(mbean.getBean(), objectName);
+
+        return result;
     }
 }

Modified: geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanHolder.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanHolder.java?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanHolder.java (original)
+++ geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanHolder.java Thu
Mar 16 11:43:06 2006
@@ -33,6 +33,7 @@
 public class MBeanHolder {
     private Object bean;
     private String objectName;
+    private String wrapStrategy;
     private Class mbeanClass;
     private List eventAdapters;
 
@@ -53,6 +54,14 @@
 
     private String getObjectName() {
         return objectName;
+    }
+
+    public String getWrapStrategy() {
+        return wrapStrategy;
+    }
+
+    public void setWrapStrategy(String wrapStrategy) {
+        this.wrapStrategy = wrapStrategy;
     }
 
     public void setMbeanClass(Class mbeanClass) {

Added: geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanWrap.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanWrap.java?rev=386439&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanWrap.java (added)
+++ geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/MBeanWrap.java Thu Mar
16 11:43:06 2006
@@ -0,0 +1,54 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xbean.jmx;
+
+import java.util.Properties;
+
+
+/**
+ * @version $Revision: $ $Date: $
+ * @org.apache.xbean.XBean element="wrap"
+ */
+public class MBeanWrap {
+    private String beanClass;
+    private String strategy;
+    private Properties config;
+
+    public String getBeanClass() {
+        return beanClass;
+    }
+
+    public void setBeanClass(String beanClass) {
+        this.beanClass = beanClass;
+    }
+
+    public String getStrategy() {
+        return strategy;
+    }
+
+    public void setStrategy(String strategy) {
+        this.strategy = strategy;
+    }
+
+    public Properties getConfig() {
+        return config;
+    }
+
+    public void setConfig(Properties config) {
+        this.config = config;
+    }
+}

Modified: geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/assembler/JavaBeanMBeanInfoGenerator.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/assembler/JavaBeanMBeanInfoGenerator.java?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/assembler/JavaBeanMBeanInfoGenerator.java
(original)
+++ geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/assembler/JavaBeanMBeanInfoGenerator.java
Thu Mar 16 11:43:06 2006
@@ -6,8 +6,8 @@
 import javax.management.MBeanOperationInfo;
 import javax.management.ObjectName;
 
-import org.livetribe.jmx.MBeanUtils;
 import org.apache.xbean.jmx.MBeanInfoGenerator;
+import org.livetribe.jmx.MBeanUtils;
 
 
 /**

Copied: geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/DefaultWrappingStrategy.java
(from r385097, geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/JavaBeanWrappingStrategy.java)
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/DefaultWrappingStrategy.java?p2=geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/DefaultWrappingStrategy.java&p1=geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/JavaBeanWrappingStrategy.java&r1=385097&r2=386439&rev=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/JavaBeanWrappingStrategy.java
(original)
+++ geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/DefaultWrappingStrategy.java
Thu Mar 16 11:43:06 2006
@@ -16,21 +16,21 @@
  */
 package org.apache.xbean.jmx.strategies;
 
+import java.util.Properties;
+
 import org.apache.xbean.jmx.JMXException;
 import org.apache.xbean.jmx.JMXWrappingStrategy;
-import org.apache.xbean.jmx.config.JMXServiceConfig;
 
 
 /**
  * @version $Revision: $ $Date: $
  */
-public class JavaBeanWrappingStrategy implements JMXWrappingStrategy {
+public class DefaultWrappingStrategy implements JMXWrappingStrategy {
 
-    public Object wrapService(Object service, JMXServiceConfig config) throws JMXException
{
-        return null;  //TODO: change body of implemented methods use File | Settings | File
Templates.
+    public Object wrapObject(Object service, Properties config) throws JMXException {
+        return service;
     }
 
-    public void unwrapService(Object service, JMXServiceConfig config) {
-        //TODO: change body of implemented methods use File | Settings | File Templates.
+    public void unwrapObject(Object service, Properties config) {
     }
 }

Added: geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/JavaBeanWrappingStrategy.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/JavaBeanWrappingStrategy.java?rev=386439&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/JavaBeanWrappingStrategy.java
(added)
+++ geronimo/xbean/trunk/xbean-jmx/src/main/java/org/apache/xbean/jmx/strategies/JavaBeanWrappingStrategy.java
Thu Mar 16 11:43:06 2006
@@ -0,0 +1,59 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.xbean.jmx.strategies;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+
+import org.apache.xbean.jmx.JMXException;
+import org.apache.xbean.jmx.JMXWrappingStrategy;
+import org.livetribe.jmx.DynamicMBeanAdapter;
+import org.livetribe.jmx.MBeanUtils;
+
+
+/**
+ * @version $Revision: $ $Date: $
+ */
+public class JavaBeanWrappingStrategy implements JMXWrappingStrategy {
+
+    public final static String MBEAN_DESCRIPTION = "description";
+    public final static List mbeanInfos = new ArrayList();
+
+    public static List getMbeanInfos() {
+        return mbeanInfos;
+    }
+
+    public Object wrapObject(Object service, Properties config) throws JMXException {
+        return new DynamicMBeanAdapter(service, createMBeanInfo(service, config));
+    }
+
+    public void unwrapObject(Object service, Properties config) {
+    }
+
+    private MBeanInfo createMBeanInfo(Object service, Properties config) {
+        MBeanAttributeInfo[] attributes = MBeanUtils.getMBeanAttributeInfo(service);
+        MBeanConstructorInfo[] constructors = MBeanUtils.getMBeanConstructorInfo(service);
+        MBeanOperationInfo[] operations = MBeanUtils.getMBeanOperationInfo(service);
+
+        return new MBeanInfo(service.getClass().getName(), (String) config.get(MBEAN_DESCRIPTION),
attributes, constructors, operations, null);
+    }
+}

Added: geronimo/xbean/trunk/xbean-jmx/src/main/resources/META-INF/org.apache.xbean.jmx.StrategyFinder/xbean.default
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/main/resources/META-INF/org.apache.xbean.jmx.StrategyFinder/xbean.default?rev=386439&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/main/resources/META-INF/org.apache.xbean.jmx.StrategyFinder/xbean.default
(added)
+++ geronimo/xbean/trunk/xbean-jmx/src/main/resources/META-INF/org.apache.xbean.jmx.StrategyFinder/xbean.default
Thu Mar 16 11:43:06 2006
@@ -0,0 +1 @@
+org.apache.xbean.jmx.WrapperStrategyClass=org.apache.xbean.jmx.strategies.DefaultWrappingStrategy
\ No newline at end of file

Modified: geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/JMXStrategyFinderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/JMXStrategyFinderTest.java?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/JMXStrategyFinderTest.java
(original)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/JMXStrategyFinderTest.java
Thu Mar 16 11:43:06 2006
@@ -25,9 +25,7 @@
 public class JMXStrategyFinderTest extends TestCase {
 
     public void testJavaBean() throws Exception {
-        JMXStrategyFinder finder = new JMXStrategyFinder("META-INF/org.apache.xbean.jmx.StrategyFinder/");
-
-        JMXWrappingStrategy strategy = finder.newInstance("javabean");
+        JMXWrappingStrategy strategy = JMXStrategyFinder.newInstance("javabean");
         assertNotNull(strategy);
     }
 }

Modified: geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/JMXTest.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/JMXTest.java?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/JMXTest.java (original)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/JMXTest.java Thu Mar
16 11:43:06 2006
@@ -16,15 +16,16 @@
  */
 package org.apache.xbean.jmx;
 
+import javax.management.Attribute;
+import javax.management.AttributeNotFoundException;
 import javax.management.MBeanServer;
 import javax.management.Notification;
 import javax.management.NotificationListener;
 import javax.management.ObjectName;
-import javax.management.AttributeNotFoundException;
-import javax.management.Attribute;
 
 import junit.framework.TestCase;
 import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.beans.factory.BeanCreationException;
 
 
 /**
@@ -113,8 +114,35 @@
         }
     }
 
-    public void testCustomAssembler() throws Exception {
-        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("org/apache/xbean/jmx/jmx-custom-assembler.xml");
+    public void testDuplicate() {
+        try {
+            new ClassPathXmlApplicationContext("org/apache/xbean/jmx/jmx-duplicate.xml");
+            fail("Should have thrown an IllegalStateException");
+        } catch (BeanCreationException bce) {
+            assertTrue(bce.getCause().getClass().equals(IllegalStateException.class));
+        }
+    }
+
+    public void testCustomDuplicate() {
+        try {
+            new ClassPathXmlApplicationContext("org/apache/xbean/jmx/jmx-custom-duplicate.xml");
+            fail("Should have thrown an IllegalStateException");
+        } catch (BeanCreationException bce) {
+            assertTrue(bce.getCause().getClass().equals(IllegalStateException.class));
+        }
+    }
+
+    public void testDuplicateWrapper() {
+        try {
+            new ClassPathXmlApplicationContext("org/apache/xbean/jmx/jmx-duplicate-wrapper.xml");
+            fail("Should have thrown an IllegalStateException");
+        } catch (BeanCreationException bce) {
+            assertTrue(bce.getCause().getClass().equals(IllegalStateException.class));
+        }
+    }
+
+    public void testCustomWrapper() throws Exception {
+        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("org/apache/xbean/jmx/jmx-custom-wrapper.xml");
         try {
             Object jmxService = context.getBean("jmxService");
             assertNotNull(jmxService);
@@ -128,7 +156,7 @@
             ObjectName objectName = ObjectName.getInstance(":type=JMXService");
             assertTrue(mbeanServer.isRegistered(objectName));
             javax.management.MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName);
-            assertEquals("dummy", mbeanInfo.getDescription());
+            assertEquals("Dummy Description", mbeanInfo.getDescription());
         }
         finally {
             context.destroy();
@@ -179,7 +207,7 @@
 
             MBeanServer mbeanServer = jmxExporter.getMbeanServer();
             assertNotNull(mbeanServer);
-            
+
             ObjectName objectName = ObjectName.getInstance(":type=JMXService");
             assertTrue(mbeanServer.isRegistered(objectName));
 

Added: geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/strategies/DummyWrappingStrategy.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/strategies/DummyWrappingStrategy.java?rev=386439&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/strategies/DummyWrappingStrategy.java
(added)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/java/org/apache/xbean/jmx/strategies/DummyWrappingStrategy.java
Thu Mar 16 11:43:06 2006
@@ -0,0 +1,23 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.xbean.jmx.strategies;
+
+/**
+ * @version $Revision: $ $Date: $
+ */
+public class DummyWrappingStrategy extends JavaBeanWrappingStrategy {
+}

Added: geronimo/xbean/trunk/xbean-jmx/src/test/resources/META-INF/org.apache.xbean.jmx.StrategyFinder/dummy
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/resources/META-INF/org.apache.xbean.jmx.StrategyFinder/dummy?rev=386439&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/resources/META-INF/org.apache.xbean.jmx.StrategyFinder/dummy
(added)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/resources/META-INF/org.apache.xbean.jmx.StrategyFinder/dummy
Thu Mar 16 11:43:06 2006
@@ -0,0 +1 @@
+org.apache.xbean.jmx.WrapperStrategyClass=org.apache.xbean.jmx.strategies.DummyWrappingStrategy
\ No newline at end of file

Added: geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-duplicate.xml
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-duplicate.xml?rev=386439&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-duplicate.xml
(added)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-duplicate.xml
Thu Mar 16 11:43:06 2006
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:jmx="http://xbean.apache.org/schemas/jmx">
+
+    <bean id="jmxService_one" class="org.apache.xbean.jmx.JMXService"/>
+    <bean id="jmxService_two" class="org.apache.xbean.jmx.JMXService"/>
+
+    <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
+        <property name="defaultDomain" value="org.apache.xbean"/>
+    </bean>
+
+    <jmx:export id="jmxExporter" mbeanserver="#mbeanServer">
+        <jmx:wrapStrategies>
+            <jmx:wrap beanClass="org.apache.xbean.jmx.JMXService" strategy="dummy"/>
+        </jmx:wrapStrategies>
+        <jmx:mbeans>
+            <jmx:mbean bean="#jmxService_one" objectname=":type=JMXService"/>
+            <jmx:mbean bean="#jmxService_two" objectname=":type=JMXService" wrapStrategy="javabean"/>
+        </jmx:mbeans>
+    </jmx:export>
+
+</beans>

Copied: geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-wrapper.xml
(from r385097, geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-assembler.xml)
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-wrapper.xml?p2=geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-wrapper.xml&p1=geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-assembler.xml&r1=385097&r2=386439&rev=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-assembler.xml
(original)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-custom-wrapper.xml
Thu Mar 16 11:43:06 2006
@@ -8,9 +8,16 @@
     </bean>
 
     <jmx:export id="jmxExporter" mbeanserver="#mbeanServer">
-        <jmx:mbeaninfos>
-            <jmx:beanPairing beanClass="org.apache.xbean.jmx.JMXService" generatorClass="org.apache.xbean.jmx.DummyMBeanInfoGenerator"/>
-        </jmx:mbeaninfos>
+        <jmx:wrapStrategies>
+            <jmx:wrap beanClass="org.apache.xbean.jmx.JMXService" strategy="dummy">
+                <property name="config">
+                    <value>
+                        description=Dummy Description
+                    </value >
+                </property>
+             </jmx:wrap>
+        </jmx:wrapStrategies>
+
         <jmx:mbeans>
             <jmx:mbean bean="#jmxService" objectname=":type=JMXService"/>
         </jmx:mbeans>

Added: geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-duplicate-wrapper.xml
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-duplicate-wrapper.xml?rev=386439&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-duplicate-wrapper.xml
(added)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-duplicate-wrapper.xml
Thu Mar 16 11:43:06 2006
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:jmx="http://xbean.apache.org/schemas/jmx">
+
+    <bean id="jmxService" class="org.apache.xbean.jmx.JMXService"/>
+
+    <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
+        <property name="defaultDomain" value="org.apache.xbean"/>
+    </bean>
+
+    <jmx:export id="jmxExporter" mbeanserver="#mbeanServer">
+        <jmx:wrapStrategies>
+            <jmx:wrap beanClass="org.apache.xbean.jmx.JMXService" strategy="dummy"/>
+            <jmx:wrap beanClass="org.apache.xbean.jmx.JMXService" strategy="javabean"/>
+        </jmx:wrapStrategies>
+        <jmx:mbeans>
+            <jmx:mbean bean="#jmxService" objectname=":type=JMXService"/>
+        </jmx:mbeans>
+    </jmx:export>
+
+</beans>

Added: geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-duplicate.xml
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-duplicate.xml?rev=386439&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-duplicate.xml
(added)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-duplicate.xml
Thu Mar 16 11:43:06 2006
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns:jmx="http://xbean.apache.org/schemas/jmx">
+
+    <bean id="jmxService_one" class="org.apache.xbean.jmx.JMXService">
+        <property name="intAttr" value="1"/>
+        <property name="integerAttr" value="1"/>
+    </bean>
+
+    <bean id="jmxService_two" class="org.apache.xbean.jmx.JMXService">
+        <property name="intAttr" value="2"/>
+        <property name="integerAttr" value="2"/>
+    </bean>
+
+    <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
+        <property name="defaultDomain" value="org.apache.xbean"/>
+    </bean>
+
+    <jmx:export id="jmxExporter" mbeanserver="#mbeanServer">
+        <jmx:mbeans>
+            <jmx:mbean bean="#jmxService_one" objectname=":type=JMXService,object=one"
wrapStrategy="javabean"/>
+            <jmx:mbean bean="#jmxService_two" objectname=":type=JMXService,object=two"
wrapStrategy="dummy"/>
+        </jmx:mbeans>
+    </jmx:export>
+
+</beans>

Modified: geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-listener-multiple.xml
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-listener-multiple.xml?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-listener-multiple.xml
(original)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-listener-multiple.xml
Thu Mar 16 11:43:06 2006
@@ -9,7 +9,7 @@
 
     <jmx:export id="jmxExporter" mbeanserver="#mbeanServer">
         <jmx:mbeans>
-            <jmx:mbean bean="#jmxService" objectname=":type=JMXService">
+            <jmx:mbean bean="#jmxService" objectname=":type=JMXService" wrapStrategy="javabean">
                 <jmx:listeners>
                     <jmx:listen bean="#jmxService" listener="java.beans.PropertyChangeListener"/>
                     <jmx:listen bean="#jmxService" listener="java.beans.PropertyChangeListener"/>

Modified: geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-listener.xml
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-listener.xml?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-listener.xml
(original)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-listener.xml
Thu Mar 16 11:43:06 2006
@@ -9,7 +9,7 @@
 
     <jmx:export id="jmxExporter" mbeanserver="#mbeanServer">
         <jmx:mbeans>
-            <jmx:mbean bean="#jmxService" objectname=":type=JMXService">
+            <jmx:mbean bean="#jmxService" objectname=":type=JMXService" wrapStrategy="javabean">
                 <jmx:listeners>
                     <jmx:listen bean="#jmxService" listener="java.beans.PropertyChangeListener"/>
                 </jmx:listeners>

Modified: geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-simple-multiple.xml
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-simple-multiple.xml?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-simple-multiple.xml
(original)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-simple-multiple.xml
Thu Mar 16 11:43:06 2006
@@ -10,9 +10,9 @@
 
     <jmx:export id="jmxExporter" mbeanserver="#mbeanServer">
         <jmx:mbeans>
-            <jmx:mbean bean="#jmxService1" objectname=":type=JMXService1,id=1"/>
-            <jmx:mbean bean="#jmxService1" objectname=":type=JMXService1,id=2"/>
-            <jmx:mbean bean="#jmxService2" objectname=":type=JMXService2,id=1"/>
+            <jmx:mbean bean="#jmxService1" objectname=":type=JMXService1,id=1" wrapStrategy="javabean"/>
+            <jmx:mbean bean="#jmxService1" objectname=":type=JMXService1,id=2" wrapStrategy="javabean"/>
+            <jmx:mbean bean="#jmxService2" objectname=":type=JMXService2,id=1" wrapStrategy="javabean"/>
         </jmx:mbeans>
     </jmx:export>
 

Modified: geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-simple.xml
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-simple.xml?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-simple.xml
(original)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx-simple.xml
Thu Mar 16 11:43:06 2006
@@ -12,7 +12,7 @@
 
     <jmx:export id="jmxExporter" mbeanserver="#mbeanServer">
         <jmx:mbeans>
-            <jmx:mbean bean="#jmxService" objectname=":type=JMXService"/>
+            <jmx:mbean bean="#jmxService" objectname=":type=JMXService" wrapStrategy="javabean"/>
         </jmx:mbeans>
     </jmx:export>
 

Modified: geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx.xml
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx.xml?rev=386439&r1=386438&r2=386439&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx.xml (original)
+++ geronimo/xbean/trunk/xbean-jmx/src/test/resources/org/apache/xbean/jmx/jmx.xml Thu Mar
16 11:43:06 2006
@@ -4,7 +4,7 @@
     <bean id="jmxService" class="org.apache.xbean.jmx.JMXService"/>
 
     <jmx:export><!-- mbeanserver=""> -->
-        <jmx:mbean bean="#jmxService"><!-- objectname="" mbean=""> -->
+        <jmx:mbean bean="#jmxService" wrapStrategy="javabean"><!-- objectname=""
mbean=""> -->
             <jmx:listen source="#jmxService"
                         add-method="addPropertyChangeListener"
                         remove-method="removePropertyChangeListener"

Propchange: geronimo/xbean/trunk/xbean-reflect/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Mar 16 11:43:06 2006
@@ -3,3 +3,4 @@
 .wtpmodules
 .classpath
 .project
+*.iml

Propchange: geronimo/xbean/trunk/xbean-tiger/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Mar 16 11:43:06 2006
@@ -0,0 +1,2 @@
+target
+*.iml



Mime
View raw message