[jboss-cvs] JBossAS SVN: r90350 - in projects/mc-tools/trunk/src: main/java/org/jboss/mc/tools/jmx/convert and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 17 15:23:48 EDT 2009


Author: flavia.rainone at jboss.com
Date: 2009-06-17 15:23:48 -0400 (Wed, 17 Jun 2009)
New Revision: 90350

Added:
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/MetaDataConverter2.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AliasMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AnnotationMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AttributeMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AttributeValueMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ConstructorMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/DependencyMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/DependencyValueMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ElementValueMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/InjectionValueMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/JBXBValueMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/JavaBeanValueMetaDateConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/MetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ServiceMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/TextValueMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ValueFactoryMetaDataConverter.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ValueMetaDataConverter.java
Removed:
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/MetaDataConverter.java
Modified:
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/JMXAnnotationStrategy.java
   projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/XMLMigrator.java
   projects/mc-tools/trunk/src/test/java/org/jboss/mc/tools/jmx/MetaDataConverterTestCase.java
   projects/mc-tools/trunk/src/test/java/org/jboss/mc/tools/jmx/XMLMarshallerTestCase.java
Log:
[JBMICROCONT-444] Created a new metadata converter class hierarchy structure, more OO than the plain old MetaDataConverter, which has been renamed to MetaDataConverter2.
Once this new structure is complete and tested, the old MetaDataConverter will be removed. This structure is also intended to replace XMLMarshaller

Modified: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/JMXAnnotationStrategy.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/JMXAnnotationStrategy.java	2009-06-17 18:39:22 UTC (rev 90349)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/JMXAnnotationStrategy.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -34,7 +34,7 @@
  * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
  * @version $Revision$
  */
-interface JMXAnnotationStrategy
+public interface JMXAnnotationStrategy
 {
    AnnotationMetaData createAnnotation(ServiceMetaData service);
 }

Deleted: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/MetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/MetaDataConverter.java	2009-06-17 18:39:22 UTC (rev 90349)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/MetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -1,327 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, 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.mc.tools.jmx;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.jboss.beans.metadata.plugins.AbstractAliasMetaData;
-import org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData;
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
-import org.jboss.beans.metadata.plugins.AbstractDependencyMetaData;
-import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
-import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
-import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
-import org.jboss.beans.metadata.plugins.AbstractValueFactoryMetaData;
-import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
-import org.jboss.beans.metadata.plugins.StringValueMetaData;
-import org.jboss.beans.metadata.spi.AliasMetaData;
-import org.jboss.beans.metadata.spi.AnnotationMetaData;
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.DependencyMetaData;
-import org.jboss.beans.metadata.spi.ParameterMetaData;
-import org.jboss.beans.metadata.spi.PropertyMetaData;
-import org.jboss.beans.metadata.spi.ValueMetaData;
-import org.jboss.mc.tools.jmx.naming.BeanNameService;
-import org.jboss.system.ConfigurationException;
-import org.jboss.system.metadata.ServiceAnnotationMetaData;
-import org.jboss.system.metadata.ServiceAttributeMetaData;
-import org.jboss.system.metadata.ServiceConstructorMetaData;
-import org.jboss.system.metadata.ServiceDependencyMetaData;
-import org.jboss.system.metadata.ServiceDependencyValueMetaData;
-import org.jboss.system.metadata.ServiceElementValueMetaData;
-import org.jboss.system.metadata.ServiceInjectionValueMetaData;
-import org.jboss.system.metadata.ServiceJBXBValueMetaData;
-import org.jboss.system.metadata.ServiceJavaBeanValueMetaData;
-import org.jboss.system.metadata.ServiceMetaData;
-import org.jboss.system.metadata.ServiceMetaDataParser;
-import org.jboss.system.metadata.ServiceTextValueMetaData;
-import org.jboss.system.metadata.ServiceValueFactoryParameterMetaData;
-import org.jboss.system.metadata.ServiceValueFactoryValueMetaData;
-import org.jboss.system.metadata.ServiceValueMetaData;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Converts ServiceMetaData objects to BeanMetaData.
- * 
- * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
- */
-class MetaDataConverter
-{
-   private boolean xMBeanDDFound = false;
-   private boolean xMBeanDescriptorFound = false;
-   private boolean xMBeanCodeFound = false;
-   private JMXAnnotationStrategy jmxAnnotationStrategy;
-   private BeanNameService nameTranslator;
-   
-   public MetaDataConverter(JMXAnnotationStrategy jmxAnnotationGenerator, BeanNameService nameTranslator)
-   {
-      this.jmxAnnotationStrategy = jmxAnnotationGenerator;
-      this.nameTranslator = nameTranslator;
-   }
-   
-   public boolean isXMBeanDescriptorFound()
-   {
-      return this.xMBeanDescriptorFound;
-   }
-   
-   public boolean isXMBeanDDFound()
-   {
-      return this.xMBeanDDFound;
-   }
-   
-   public boolean isXMBeanCodeFound()
-   {
-      return this.xMBeanCodeFound;
-   }
-   
-   /**
-    * Converts jmxMetaData (old MicroKernel) into BeanMetaData (Microcontainer)
-    * 
-    * @param jmxMetaData metadata to be transformed
-    * @return a collection of BeanMetaData
-    */
-   public Collection<? extends BeanMetaData> convert(Collection<ServiceMetaData> jmxMetaData)
-   {
-      Collection<AbstractBeanMetaData> beanMetaData = new ArrayList<AbstractBeanMetaData>();
-      for (ServiceMetaData service: jmxMetaData)
-      {
-         beanMetaData.add(convert(service));
-      }
-      return beanMetaData;
-   }
-   
-   private AbstractBeanMetaData convert(ServiceMetaData service) 
-   {
-      // TODO trim e replace!!!!
-      // TODO ControllerMode
-      service.getMode();
-      // update xMBean*Found variables
-      xMBeanDescriptorFound = xMBeanDescriptorFound || service.getXMBeanDescriptor() != null;
-      xMBeanDDFound = xMBeanDDFound || service.getXMBeanDD() != null;
-      xMBeanCodeFound = xMBeanCodeFound || ServiceMetaData.XMBEAN_CODE.equals(service.getXMBeanCode()) == false;
-      
-      // create bean metadata and set its class and name properties
-      AbstractBeanMetaData beanMetaData = new AbstractBeanMetaData(service.getCode());
-      beanMetaData.setName(nameTranslator.translate(service));
-      
-      // convert constructor meta data
-      beanMetaData.setConstructor(convertConstructor(service));
-      
-      // convert attribute meta data
-      for(ServiceAttributeMetaData attribute: service.getAttributes())
-      {
-         ValueMetaData newValue = convert(attribute.getValue());
-         String name = attribute.getName().substring(0, 1).toLowerCase() + attribute.getName().substring(1);
-         PropertyMetaData propertyMetaData = new AbstractPropertyMetaData(name, newValue); 
-         beanMetaData.addProperty(propertyMetaData);
-      }
-      
-      // convert dependency meta data
-      if (!service.getDependencies().isEmpty())
-      {
-         Set<DependencyMetaData> newDependencies = new HashSet<DependencyMetaData>();
-         for (ServiceDependencyMetaData dependency: service.getDependencies())
-         {
-            String dependencyName = nameTranslator.translate(dependency.getIDependOn());
-            newDependencies.add(new AbstractDependencyMetaData(dependencyName)); 
-         }
-         beanMetaData.setDepends(newDependencies);
-      }
-      
-      // convert alias meta data
-      if (service.getAliases()!= null && !service.getAliases().isEmpty())
-      {
-         Set<AliasMetaData> aliases = new HashSet<AliasMetaData>();
-         for (String alias: service.getAliases())
-         {
-            AbstractAliasMetaData newAlias = new AbstractAliasMetaData();
-            newAlias.setAliasValue(alias);
-            aliases.add(newAlias);
-         }
-         beanMetaData.setAliasMetaData(aliases);
-      }
-      
-      // convert annotation meta data
-      Set<AnnotationMetaData> annotations = null;
-      if (!service.getAnnotations().isEmpty())
-      {
-         annotations = new HashSet<AnnotationMetaData>();
-         for (ServiceAnnotationMetaData annotation: service.getAnnotations())
-         {
-            annotations.add(new AbstractAnnotationMetaData(annotation.getAnnotation()));
-         }
-      }
-      // create @JMX annotation metadata when appliable
-      AnnotationMetaData jmxAnnotation = jmxAnnotationStrategy.createAnnotation(service);
-      if (jmxAnnotation != null)
-      {
-         if (annotations == null)
-         {
-            annotations = new HashSet<AnnotationMetaData>();
-         }
-         annotations.add(jmxAnnotation);
-      }
-      beanMetaData.setAnnotations(annotations);
-      return beanMetaData;
-   }
-
-   private ValueMetaData convert(ServiceValueMetaData value)
-   {
-      ValueMetaData newValue = null;
-      if (value instanceof ServiceJavaBeanValueMetaData)
-      {
-         newValue = getAnonymousBean(((ServiceJavaBeanValueMetaData) value).getElement());
-      }
-      else if (value instanceof ServiceJBXBValueMetaData)
-      {
-         // TODO: is there an equivalent for MC?
-      }
-      else if (value instanceof ServiceInjectionValueMetaData)
-      {
-         ServiceInjectionValueMetaData valueMetaData = (ServiceInjectionValueMetaData) value;
-         String dependency = (String) valueMetaData.getDependency();
-         String property = valueMetaData.getProperty();
-         newValue = new AbstractInjectionValueMetaData(nameTranslator.translate(dependency), property);
-      }
-      else if (value instanceof ServiceDependencyValueMetaData)
-      {
-         ServiceDependencyValueMetaData valueMetaData = (ServiceDependencyValueMetaData) value;
-         String dependency = valueMetaData.getDependency();
-         newValue = new AbstractInjectionValueMetaData(nameTranslator.translate(dependency));
-      }
-      else if (value instanceof ServiceValueFactoryValueMetaData)
-      {
-         ServiceValueFactoryValueMetaData valueMetaData = (ServiceValueFactoryValueMetaData) value;
-         String dependency = nameTranslator.translate((String) valueMetaData.getDependency());
-         String method = valueMetaData.getMethod();
-         String defaultValue = valueMetaData.getDefaultValue() == null? null: valueMetaData.getDefaultValue().getText();
-         
-         AbstractValueFactoryMetaData metaData = new AbstractValueFactoryMetaData(dependency, method, defaultValue);
-         if (valueMetaData.getParameterMetaData().size() == 1)
-         {
-            ServiceValueFactoryParameterMetaData parameter = valueMetaData.getParameterMetaData().get(0);
-            if (parameter.getParameterTypeName() == null && parameter.getValueTypeName() == null)
-            {
-               metaData.setParameter(parameter.getTextValue());
-            }
-         }
-         if (metaData.getParameter() == null)
-         {
-            List<ParameterMetaData> newParameters = new ArrayList<ParameterMetaData>();
-            for (ServiceValueFactoryParameterMetaData parameter: valueMetaData.getParameterMetaData())
-            {
-               String textValue = parameter.getTextValue();
-               String type = parameter.getParameterTypeName();
-               String type2 = parameter.getValueTypeName();
-               type = type2 == null? type: type2;
-               ValueMetaData parameterValue = new AbstractValueMetaData(textValue);
-               newParameters.add(new AbstractParameterMetaData(type2 == null? type: type2, parameterValue));
-            }
-            metaData.setParameters(newParameters);
-         }
-         newValue = metaData;
-      }
-      else if (value instanceof ServiceElementValueMetaData)
-      {
-         // TODO what to do in this case?
-         //throw new RuntimeException("XML Element Value Unsupported");
-      }
-      else if (value instanceof ServiceTextValueMetaData)
-      {
-         newValue = new StringValueMetaData(((ServiceTextValueMetaData)value).getText());
-      }
-      else if (value instanceof ServiceDependencyMetaData)
-      {
-         ServiceDependencyValueMetaData valueMetaData = (ServiceDependencyValueMetaData) value;
-         if (valueMetaData.getProxyType() != null)
-         {
-            // TODO
-            throw new RuntimeException("Unsupported");
-         }
-         String beanName = nameTranslator.translate(valueMetaData.getDependency());
-         newValue = new AbstractInjectionValueMetaData(beanName);
-      }
-      else
-      {
-         throw new RuntimeException("Unexpected value type: " + (value == null? value: value.getClass().getName()));
-      }
-      return newValue;
-   }
-
-   private AbstractConstructorMetaData convertConstructor(ServiceMetaData service)
-   {
-      AbstractConstructorMetaData beanConstructor = null;
-      ServiceConstructorMetaData constructor = service.getConstructor();
-      String[] parameters = constructor.getParams();
-      String[] signature;
-      try
-      {
-         signature = constructor.getSignature();
-      }
-      catch (ConfigurationException e)
-      {
-         throw new RuntimeException("Unexpected exception", e);
-      }
-      if (parameters != null)
-      {
-         beanConstructor = new AbstractConstructorMetaData();
-         List<ParameterMetaData> newParameters = new ArrayList<ParameterMetaData>();
-         for (int i = 0; i < parameters.length; i++)
-         {
-            AbstractParameterMetaData parameter = new AbstractParameterMetaData();
-            parameter.setValue(new AbstractValueMetaData(parameters[i]));
-            parameter.setType(signature[i]);
-            newParameters.add(parameter);
-         }
-         beanConstructor.setParameters(newParameters);
-      }
-      return beanConstructor;
-   }
-   
-   private BeanMetaData getAnonymousBean(Element element)
-   {
-      AbstractBeanMetaData beanMetaData = new AbstractBeanMetaData(element.getAttribute("attributeClass"));
-      NodeList properties = element.getElementsByTagName("property");
-      for(int n = 0; n < properties.getLength(); n ++)
-      {
-         // Skip over non-element nodes
-         Node node = properties.item(n);
-         if (node.getNodeType() != Node.ELEMENT_NODE)
-         {
-            continue;
-         }
-         Element property = (Element) node;
-         String name = property.getAttribute("name");
-         String value = ServiceMetaDataParser.getRawElementTextContent(property);
-         beanMetaData.addProperty(new AbstractPropertyMetaData(name, value));
-      }
-      return beanMetaData;
-   }
-}
\ No newline at end of file

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/MetaDataConverter2.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/MetaDataConverter2.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/MetaDataConverter2.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,327 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.AbstractAliasMetaData;
+import org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDependencyMetaData;
+import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.plugins.AbstractValueFactoryMetaData;
+import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+import org.jboss.beans.metadata.plugins.StringValueMetaData;
+import org.jboss.beans.metadata.spi.AliasMetaData;
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.DependencyMetaData;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.mc.tools.jmx.naming.BeanNameService;
+import org.jboss.system.ConfigurationException;
+import org.jboss.system.metadata.ServiceAnnotationMetaData;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+import org.jboss.system.metadata.ServiceDependencyMetaData;
+import org.jboss.system.metadata.ServiceDependencyValueMetaData;
+import org.jboss.system.metadata.ServiceElementValueMetaData;
+import org.jboss.system.metadata.ServiceInjectionValueMetaData;
+import org.jboss.system.metadata.ServiceJBXBValueMetaData;
+import org.jboss.system.metadata.ServiceJavaBeanValueMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+import org.jboss.system.metadata.ServiceMetaDataParser;
+import org.jboss.system.metadata.ServiceTextValueMetaData;
+import org.jboss.system.metadata.ServiceValueFactoryParameterMetaData;
+import org.jboss.system.metadata.ServiceValueFactoryValueMetaData;
+import org.jboss.system.metadata.ServiceValueMetaData;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Converts ServiceMetaData objects to BeanMetaData.
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class MetaDataConverter2
+{
+   private boolean xMBeanDDFound = false;
+   private boolean xMBeanDescriptorFound = false;
+   private boolean xMBeanCodeFound = false;
+   private JMXAnnotationStrategy jmxAnnotationStrategy;
+   private BeanNameService nameTranslator;
+   
+   public MetaDataConverter2(JMXAnnotationStrategy jmxAnnotationGenerator, BeanNameService nameTranslator)
+   {
+      this.jmxAnnotationStrategy = jmxAnnotationGenerator;
+      this.nameTranslator = nameTranslator;
+   }
+   
+   public boolean isXMBeanDescriptorFound()
+   {
+      return this.xMBeanDescriptorFound;
+   }
+   
+   public boolean isXMBeanDDFound()
+   {
+      return this.xMBeanDDFound;
+   }
+   
+   public boolean isXMBeanCodeFound()
+   {
+      return this.xMBeanCodeFound;
+   }
+   
+   /**
+    * Converts jmxMetaData (old MicroKernel) into BeanMetaData (Microcontainer)
+    * 
+    * @param jmxMetaData metadata to be transformed
+    * @return a collection of BeanMetaData
+    */
+   public Collection<? extends BeanMetaData> convert(Collection<ServiceMetaData> jmxMetaData)
+   {
+      Collection<AbstractBeanMetaData> beanMetaData = new ArrayList<AbstractBeanMetaData>();
+      for (ServiceMetaData service: jmxMetaData)
+      {
+         beanMetaData.add(convert(service));
+      }
+      return beanMetaData;
+   }
+   
+   private AbstractBeanMetaData convert(ServiceMetaData service) 
+   {
+      // TODO trim e replace!!!!
+      // TODO ControllerMode
+      service.getMode();
+      // update xMBean*Found variables
+      xMBeanDescriptorFound = xMBeanDescriptorFound || service.getXMBeanDescriptor() != null;
+      xMBeanDDFound = xMBeanDDFound || service.getXMBeanDD() != null;
+      xMBeanCodeFound = xMBeanCodeFound || ServiceMetaData.XMBEAN_CODE.equals(service.getXMBeanCode()) == false;
+      
+      // create bean metadata and set its class and name properties
+      AbstractBeanMetaData beanMetaData = new AbstractBeanMetaData(service.getCode());
+      beanMetaData.setName(nameTranslator.translate(service));
+      
+      // convert constructor meta data
+      beanMetaData.setConstructor(convertConstructor(service));
+      
+      // convert attribute meta data
+      for(ServiceAttributeMetaData attribute: service.getAttributes())
+      {
+         ValueMetaData newValue = convert(attribute.getValue());
+         String name = attribute.getName().substring(0, 1).toLowerCase() + attribute.getName().substring(1);
+         PropertyMetaData propertyMetaData = new AbstractPropertyMetaData(name, newValue); 
+         beanMetaData.addProperty(propertyMetaData);
+      }
+      
+      // convert dependency meta data
+      if (!service.getDependencies().isEmpty())
+      {
+         Set<DependencyMetaData> newDependencies = new HashSet<DependencyMetaData>();
+         for (ServiceDependencyMetaData dependency: service.getDependencies())
+         {
+            String dependencyName = nameTranslator.translate(dependency.getIDependOn());
+            newDependencies.add(new AbstractDependencyMetaData(dependencyName)); 
+         }
+         beanMetaData.setDepends(newDependencies);
+      }
+      
+      // convert alias meta data
+      if (service.getAliases()!= null && !service.getAliases().isEmpty())
+      {
+         Set<AliasMetaData> aliases = new HashSet<AliasMetaData>();
+         for (String alias: service.getAliases())
+         {
+            AbstractAliasMetaData newAlias = new AbstractAliasMetaData();
+            newAlias.setAliasValue(alias);
+            aliases.add(newAlias);
+         }
+         beanMetaData.setAliasMetaData(aliases);
+      }
+      
+      // convert annotation meta data
+      Set<AnnotationMetaData> annotations = null;
+      if (!service.getAnnotations().isEmpty())
+      {
+         annotations = new HashSet<AnnotationMetaData>();
+         for (ServiceAnnotationMetaData annotation: service.getAnnotations())
+         {
+            annotations.add(new AbstractAnnotationMetaData(annotation.getAnnotation()));
+         }
+      }
+      // create @JMX annotation metadata when appliable
+      AnnotationMetaData jmxAnnotation = jmxAnnotationStrategy.createAnnotation(service);
+      if (jmxAnnotation != null)
+      {
+         if (annotations == null)
+         {
+            annotations = new HashSet<AnnotationMetaData>();
+         }
+         annotations.add(jmxAnnotation);
+      }
+      beanMetaData.setAnnotations(annotations);
+      return beanMetaData;
+   }
+
+   private ValueMetaData convert(ServiceValueMetaData value)
+   {
+      ValueMetaData newValue = null;
+      if (value instanceof ServiceJavaBeanValueMetaData)
+      {
+         newValue = getAnonymousBean(((ServiceJavaBeanValueMetaData) value).getElement());
+      }
+      else if (value instanceof ServiceJBXBValueMetaData)
+      {
+         // TODO: is there an equivalent for MC?
+      }
+      else if (value instanceof ServiceInjectionValueMetaData)
+      {
+         ServiceInjectionValueMetaData valueMetaData = (ServiceInjectionValueMetaData) value;
+         String dependency = (String) valueMetaData.getDependency();
+         String property = valueMetaData.getProperty();
+         newValue = new AbstractInjectionValueMetaData(nameTranslator.translate(dependency), property);
+      }
+      else if (value instanceof ServiceDependencyValueMetaData)
+      {
+         ServiceDependencyValueMetaData valueMetaData = (ServiceDependencyValueMetaData) value;
+         String dependency = valueMetaData.getDependency();
+         newValue = new AbstractInjectionValueMetaData(nameTranslator.translate(dependency));
+      }
+      else if (value instanceof ServiceValueFactoryValueMetaData)
+      {
+         ServiceValueFactoryValueMetaData valueMetaData = (ServiceValueFactoryValueMetaData) value;
+         String dependency = nameTranslator.translate((String) valueMetaData.getDependency());
+         String method = valueMetaData.getMethod();
+         String defaultValue = valueMetaData.getDefaultValue() == null? null: valueMetaData.getDefaultValue().getText();
+         
+         AbstractValueFactoryMetaData metaData = new AbstractValueFactoryMetaData(dependency, method, defaultValue);
+         if (valueMetaData.getParameterMetaData().size() == 1)
+         {
+            ServiceValueFactoryParameterMetaData parameter = valueMetaData.getParameterMetaData().get(0);
+            if (parameter.getParameterTypeName() == null && parameter.getValueTypeName() == null)
+            {
+               metaData.setParameter(parameter.getTextValue());
+            }
+         }
+         if (metaData.getParameter() == null)
+         {
+            List<ParameterMetaData> newParameters = new ArrayList<ParameterMetaData>();
+            for (ServiceValueFactoryParameterMetaData parameter: valueMetaData.getParameterMetaData())
+            {
+               String textValue = parameter.getTextValue();
+               String type = parameter.getParameterTypeName();
+               String type2 = parameter.getValueTypeName();
+               type = type2 == null? type: type2;
+               ValueMetaData parameterValue = new AbstractValueMetaData(textValue);
+               newParameters.add(new AbstractParameterMetaData(type2 == null? type: type2, parameterValue));
+            }
+            metaData.setParameters(newParameters);
+         }
+         newValue = metaData;
+      }
+      else if (value instanceof ServiceElementValueMetaData)
+      {
+         // TODO what to do in this case?
+         //throw new RuntimeException("XML Element Value Unsupported");
+      }
+      else if (value instanceof ServiceTextValueMetaData)
+      {
+         newValue = new StringValueMetaData(((ServiceTextValueMetaData)value).getText());
+      }
+      else if (value instanceof ServiceDependencyMetaData)
+      {
+         ServiceDependencyValueMetaData valueMetaData = (ServiceDependencyValueMetaData) value;
+         if (valueMetaData.getProxyType() != null)
+         {
+            // TODO
+            throw new RuntimeException("Unsupported");
+         }
+         String beanName = nameTranslator.translate(valueMetaData.getDependency());
+         newValue = new AbstractInjectionValueMetaData(beanName);
+      }
+      else
+      {
+         throw new RuntimeException("Unexpected value type: " + (value == null? value: value.getClass().getName()));
+      }
+      return newValue;
+   }
+
+   private AbstractConstructorMetaData convertConstructor(ServiceMetaData service)
+   {
+      AbstractConstructorMetaData beanConstructor = null;
+      ServiceConstructorMetaData constructor = service.getConstructor();
+      String[] parameters = constructor.getParams();
+      String[] signature;
+      try
+      {
+         signature = constructor.getSignature();
+      }
+      catch (ConfigurationException e)
+      {
+         throw new RuntimeException("Unexpected exception", e);
+      }
+      if (parameters != null)
+      {
+         beanConstructor = new AbstractConstructorMetaData();
+         List<ParameterMetaData> newParameters = new ArrayList<ParameterMetaData>();
+         for (int i = 0; i < parameters.length; i++)
+         {
+            AbstractParameterMetaData parameter = new AbstractParameterMetaData();
+            parameter.setValue(new AbstractValueMetaData(parameters[i]));
+            parameter.setType(signature[i]);
+            newParameters.add(parameter);
+         }
+         beanConstructor.setParameters(newParameters);
+      }
+      return beanConstructor;
+   }
+   
+   private BeanMetaData getAnonymousBean(Element element)
+   {
+      AbstractBeanMetaData beanMetaData = new AbstractBeanMetaData(element.getAttribute("attributeClass"));
+      NodeList properties = element.getElementsByTagName("property");
+      for(int n = 0; n < properties.getLength(); n ++)
+      {
+         // Skip over non-element nodes
+         Node node = properties.item(n);
+         if (node.getNodeType() != Node.ELEMENT_NODE)
+         {
+            continue;
+         }
+         Element property = (Element) node;
+         String name = property.getAttribute("name");
+         String value = ServiceMetaDataParser.getRawElementTextContent(property);
+         beanMetaData.addProperty(new AbstractPropertyMetaData(name, value));
+      }
+      return beanMetaData;
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/MetaDataConverter2.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Modified: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/XMLMigrator.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/XMLMigrator.java	2009-06-17 18:39:22 UTC (rev 90349)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/XMLMigrator.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -89,7 +89,7 @@
       BeanNameService nameTranslator = createNameTranslator(nameTranslatorClass);
       
       // create meta data converter
-      MetaDataConverter metaDataConverter = new MetaDataConverter(jmxAnnotationStrategy, nameTranslator);
+      MetaDataConverter2 metaDataConverter = new MetaDataConverter2(jmxAnnotationStrategy, nameTranslator);
       for (String arg: args)
       {
          // ignore optional args

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AliasMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AliasMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AliasMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+
+import org.jboss.beans.metadata.plugins.AbstractAliasMetaData;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class AliasMetaDataConverter implements MetaDataConverter<String, AbstractAliasMetaData>
+{
+   public AbstractAliasMetaData toMCMetaData(String alias, Collection<String> unhandledAtributes)
+   {
+      AbstractAliasMetaData newAlias = new AbstractAliasMetaData();
+      newAlias.setAliasValue(alias);
+      return newAlias;
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AliasMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AnnotationMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AnnotationMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AnnotationMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+
+import org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData;
+import org.jboss.system.metadata.ServiceAnnotationMetaData;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ *
+ */
+class AnnotationMetaDataConverter implements MetaDataConverter <ServiceAnnotationMetaData, AbstractAnnotationMetaData>
+{
+   public AbstractAnnotationMetaData toMCMetaData(ServiceAnnotationMetaData annotation, Collection<String> unhandled)
+   {
+      return new AbstractAnnotationMetaData(((ServiceAnnotationMetaData) annotation).getAnnotation());
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AnnotationMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AttributeMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AttributeMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AttributeMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceValueMetaData;
+
+/**
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class AttributeMetaDataConverter implements MetaDataConverter<ServiceAttributeMetaData, AbstractPropertyMetaData>
+{
+   Map<Class<?>, AttributeValueMetaDataConverter<?, ?>> valueConverters;
+   private ValueMetaDataConverter defaultValueConverter = new ValueMetaDataConverter(); 
+   
+   public AttributeMetaDataConverter()
+   {
+      valueConverters = new HashMap<Class<?>, AttributeValueMetaDataConverter<?, ?>>();
+      AttributeValueMetaDataConverter<?,?> valueConverter = new JavaBeanValueMetaDataConverter(); 
+      valueConverters.put(valueConverter.getClass(), valueConverter);
+      valueConverter = new JBXBValueMetaDataConverter();
+      valueConverters.put(valueConverter.getClass(), valueConverter);
+      valueConverter = new InjectionValueMetaDataConverter();
+      valueConverters.put(valueConverter.getClass(), valueConverter);
+      valueConverter = new DependencyValueMetaDataConverter();
+      valueConverters.put(valueConverter.getClass(), valueConverter);
+      valueConverter = new ValueFactoryMetaDataConverter();
+      valueConverters.put(valueConverter.getClass(), valueConverter);
+      valueConverter = new ElementValueMetaDataConverter();
+      valueConverters.put(valueConverter.getClass(), valueConverter);
+      valueConverter = new TextValueMetaDataConverter();
+      valueConverters.put(valueConverter.getClass(), valueConverter);
+    }
+   
+   public AbstractPropertyMetaData toMCMetaData(ServiceAttributeMetaData attributeMetaData, Collection<String> unhandledAttributes)
+   {
+      ServiceAttributeMetaData attribute = (ServiceAttributeMetaData) attributeMetaData;
+      ServiceValueMetaData serviceValue = attribute.getValue();
+      AttributeValueMetaDataConverter<?, ?> valueConverter = valueConverters.get(serviceValue.getChildren());
+      if (valueConverter == null)
+      {
+         valueConverter = defaultValueConverter;
+      }
+      ValueMetaData newValue = valueConverter.toMCMetaData(serviceValue, unhandledAttributes);
+      String name = attribute.getName().substring(0, 1).toLowerCase() + attribute.getName().substring(1);
+      return new AbstractPropertyMetaData(name, newValue);
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AttributeMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AttributeValueMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AttributeValueMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AttributeValueMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.system.metadata.ServiceValueMetaData;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ *
+ */
+abstract class AttributeValueMetaDataConverter<V extends ServiceValueMetaData, B extends ValueMetaData> implements MetaDataConverter<V, B>
+{
+   public abstract Class<V> getCompatibleClass();
+
+   /**
+    * @param serviceValue
+    * @param unhandledAttributes
+    * @return
+    */
+   @SuppressWarnings("all")
+   public B toMCMetaData(ServiceValueMetaData serviceValue,
+         Collection<String> unhandledAttributes)
+   {
+      return this.toMCMetaData((V) serviceValue, unhandledAttributes);
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/AttributeValueMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ConstructorMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ConstructorMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ConstructorMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
+import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.system.ConfigurationException;
+import org.jboss.system.metadata.ServiceConstructorMetaData;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class ConstructorMetaDataConverter implements MetaDataConverter<ServiceConstructorMetaData, AbstractConstructorMetaData>
+{
+   public AbstractConstructorMetaData toMCMetaData(ServiceConstructorMetaData constructor, Collection<String> unhandled)
+   {
+      String[] parameters = constructor.getParams();
+      String[] signature;
+      try
+      {
+         signature = constructor.getSignature();
+      }
+      catch (ConfigurationException e)
+      {
+         throw new RuntimeException("Unexpected exception", e);
+      }
+      AbstractConstructorMetaData beanConstructor = null;
+      if (parameters != null)
+      {
+         beanConstructor = new AbstractConstructorMetaData();
+         List<ParameterMetaData> newParameters = new ArrayList<ParameterMetaData>();
+         for (int i = 0; i < parameters.length; i++)
+         {
+            AbstractParameterMetaData parameter = new AbstractParameterMetaData();
+            parameter.setValue(new AbstractValueMetaData(parameters[i]));
+            parameter.setType(signature[i]);
+            newParameters.add(parameter);
+         }
+         beanConstructor.setParameters(newParameters);
+      }
+      return beanConstructor;
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ConstructorMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/DependencyMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/DependencyMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/DependencyMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+
+import org.jboss.beans.metadata.plugins.AbstractDependencyMetaData;
+import org.jboss.system.metadata.ServiceDependencyMetaData;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ *
+ */
+class DependencyMetaDataConverter implements MetaDataConverter<ServiceDependencyMetaData, AbstractDependencyMetaData>
+{
+   public AbstractDependencyMetaData toMCMetaData(ServiceDependencyMetaData valueMetaData, Collection<String> unhandledAttributes)
+   {
+      String dependencyName = NAME_TRANSLATOR.translate(valueMetaData.getIDependOn());
+      return new AbstractDependencyMetaData(dependencyName); 
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/DependencyMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/DependencyValueMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/DependencyValueMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/DependencyValueMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+
+import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
+import org.jboss.system.metadata.ServiceDependencyValueMetaData;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class DependencyValueMetaDataConverter extends AttributeValueMetaDataConverter<ServiceDependencyValueMetaData, AbstractInjectionValueMetaData>
+{
+   public Class<ServiceDependencyValueMetaData> getCompatibleClass()
+   {
+      return ServiceDependencyValueMetaData.class;
+   }
+   
+   public AbstractInjectionValueMetaData toMCMetaData(ServiceDependencyValueMetaData valueMetaData, Collection<String> unhandledAttributes)
+   {
+      ServiceDependencyValueMetaData value = (ServiceDependencyValueMetaData) valueMetaData;
+      if (value.getProxyType() != null)
+      {
+         // TODO
+         throw new RuntimeException("Unsupported");
+      }
+      String beanName = NAME_TRANSLATOR.translate(value.getDependency());
+      return new AbstractInjectionValueMetaData(beanName);
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/DependencyValueMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ElementValueMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ElementValueMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ElementValueMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.system.metadata.ServiceElementValueMetaData;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class ElementValueMetaDataConverter<B extends ValueMetaData> extends AttributeValueMetaDataConverter<ServiceElementValueMetaData, B>
+{
+   public Class<ServiceElementValueMetaData> getCompatibleClass()
+   {
+      return ServiceElementValueMetaData.class;
+   }
+   
+   public B toMCMetaData(ServiceElementValueMetaData valueMetaData, Collection<String> unhandledAttributes)
+   {
+      //ServiceElementValueMetaData
+      // TODO what to do in this case?
+      throw new RuntimeException("XML Element Value Unsupported");
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ElementValueMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/InjectionValueMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/InjectionValueMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/InjectionValueMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+
+import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
+import org.jboss.system.metadata.ServiceInjectionValueMetaData;
+
+/**
+ * 
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class InjectionValueMetaDataConverter extends AttributeValueMetaDataConverter<ServiceInjectionValueMetaData, AbstractInjectionValueMetaData>
+{
+   public Class<ServiceInjectionValueMetaData> getCompatibleClass()
+   {
+      return ServiceInjectionValueMetaData.class;
+   }
+   
+   public AbstractInjectionValueMetaData toMCMetaData(ServiceInjectionValueMetaData valueMetaData, Collection<String> unhandledAttributes)
+   {
+      ServiceInjectionValueMetaData value = (ServiceInjectionValueMetaData) valueMetaData;
+      String dependency = (String) value.getDependency();
+      String property = value.getProperty();
+      return new AbstractInjectionValueMetaData(NAME_TRANSLATOR.translate(dependency), property);
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/InjectionValueMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/JBXBValueMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/JBXBValueMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/JBXBValueMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.system.metadata.ServiceJBXBValueMetaData;
+
+/**
+ * 
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$ *
+ */
+class JBXBValueMetaDataConverter<B extends ValueMetaData> extends AttributeValueMetaDataConverter<ServiceJBXBValueMetaData, B>
+{
+   public Class<ServiceJBXBValueMetaData> getCompatibleClass()
+   {
+      return ServiceJBXBValueMetaData.class;
+   }
+   
+   public B toMCMetaData(ServiceJBXBValueMetaData valueMetaData, Collection<String> unhandledAttributes)
+   {
+      //ServiceJBXBValueMetaData
+      // TODO: is there an equivalent for MC?
+      return null;
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/JBXBValueMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/JavaBeanValueMetaDateConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/JavaBeanValueMetaDateConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/JavaBeanValueMetaDateConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.system.metadata.ServiceJavaBeanValueMetaData;
+import org.jboss.system.metadata.ServiceMetaDataParser;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ *
+ */
+class JavaBeanValueMetaDataConverter extends AttributeValueMetaDataConverter<ServiceJavaBeanValueMetaData, AbstractBeanMetaData>
+{
+   public Class<ServiceJavaBeanValueMetaData> getCompatibleClass()
+   {
+      return ServiceJavaBeanValueMetaData.class;
+   }
+   
+   public AbstractBeanMetaData toMCMetaData(ServiceJavaBeanValueMetaData beanMetaData, Collection<String> unhandledAttributes)
+   {
+      Element element = ((ServiceJavaBeanValueMetaData) beanMetaData).getElement(); 
+      AbstractBeanMetaData result = new AbstractBeanMetaData(element.getAttribute("attributeClass"));
+      NodeList properties = element.getElementsByTagName("property");
+      for(int n = 0; n < properties.getLength(); n ++)
+      {
+         // Skip over non-element nodes
+         Node node = properties.item(n);
+         if (node.getNodeType() != Node.ELEMENT_NODE)
+         {
+            continue;
+         }
+         Element property = (Element) node;
+         String name = property.getAttribute("name");
+         String value = ServiceMetaDataParser.getRawElementTextContent(property);
+         result.addProperty(new AbstractPropertyMetaData(name, value));
+      }
+      return result;
+   }
+}


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/JavaBeanValueMetaDateConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Copied: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/MetaDataConverter.java (from rev 90155, projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/MetaDataConverter.java)
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/MetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/MetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+
+import org.jboss.mc.tools.jmx.naming.BeanNameService;
+import org.jboss.mc.tools.jmx.naming.InputNameService;
+
+/**
+ * Converts ServiceMetaData objects to BeanMetaData.
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+interface MetaDataConverter<S,B>
+{
+   BeanNameService NAME_TRANSLATOR = new InputNameService();
+   
+   public abstract B toMCMetaData(S serviceMetaData, Collection<String> unhandledAtributes);
+}
\ No newline at end of file

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ServiceMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ServiceMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ServiceMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,201 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.spi.AliasMetaData;
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.DependencyMetaData;
+import org.jboss.mc.tools.jmx.JMXAnnotationStrategy;
+import org.jboss.system.metadata.ServiceAnnotationMetaData;
+import org.jboss.system.metadata.ServiceAttributeMetaData;
+import org.jboss.system.metadata.ServiceDependencyMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ *
+ */
+public class ServiceMetaDataConverter implements MetaDataConverter<ServiceMetaData, BeanMetaData>
+{
+   private JMXAnnotationStrategy jmxAnnotationStrategy;
+   private ConstructorMetaDataConverter constructorConverter;
+   private AttributeMetaDataConverter attributeConverter;
+   private DependencyMetaDataConverter dependencyConverter;
+   private AliasMetaDataConverter aliasConverter;
+   private AnnotationMetaDataConverter annotationConverter;
+   
+   public ServiceMetaDataConverter(JMXAnnotationStrategy jmxAnnotationStrategy)
+   {
+      this.jmxAnnotationStrategy = jmxAnnotationStrategy;
+      this.constructorConverter = new ConstructorMetaDataConverter();
+      this.attributeConverter = new AttributeMetaDataConverter();
+      this.aliasConverter = new AliasMetaDataConverter();
+      this.annotationConverter = new AnnotationMetaDataConverter();
+   }
+   
+   /**
+    * Converts jmxMetaData (old MicroKernel) into BeanMetaData (Microcontainer)
+    * 
+    * @param jmxMetaData metadata to be transformed
+    * @return a collection of BeanMetaData
+    */
+   // TODO replace unhandledAttributes with a map: element/attribute
+   //              this collection will be treated generically by the caller and attribute null will
+   //              indicate that the whole element couldn't be treated
+   public Collection<? extends BeanMetaData> convert(Collection<ServiceMetaData> jmxMetaData, Collection<String> unhandledAttributes)
+   {
+      Collection<BeanMetaData> beanMetaData = new ArrayList<BeanMetaData>();
+      for (ServiceMetaData service: jmxMetaData)
+      {
+         beanMetaData.add(toMCMetaData(service, unhandledAttributes));
+      }
+      return beanMetaData;
+   }
+   
+   public BeanMetaData toMCMetaData(ServiceMetaData service, Collection<String> unhandledAttributes)
+   {
+      // TODO trim e replace!!!!
+      // TODO ControllerMode
+      service.getMode();
+      // update xMBean*Found variables
+      if(service.getXMBeanDescriptor() != null)
+      {
+         unhandledAttributes.add("XMBeanDescriptor");
+      }
+      if (service.getXMBeanDD() != null)
+      {
+         unhandledAttributes.add("xmBeanDD");
+      }
+      if (!ServiceMetaData.XMBEAN_CODE.equals(service.getXMBeanCode()))
+      {
+         unhandledAttributes.add("xmBeanCode");
+      }
+   
+      // create bean metadata and set its class and name properties
+      AbstractBeanMetaData beanMetaData = new AbstractBeanMetaData(service.getCode());
+      beanMetaData.setName(NAME_TRANSLATOR.translate(service));
+   
+      // convert constructor meta data
+      beanMetaData.setConstructor(constructorConverter.toMCMetaData(service.getConstructor(), unhandledAttributes));
+   
+      fillProperties(service, unhandledAttributes, beanMetaData);
+      fillDependencies(service, unhandledAttributes, beanMetaData);
+      fillAliases(service, unhandledAttributes, beanMetaData);
+      fillAnnotations(service, unhandledAttributes, beanMetaData);
+      
+      return beanMetaData;
+   }
+
+   /**
+    * @param service
+    * @param unhandled
+    * @param beanMetaData
+    */
+   private void fillProperties(ServiceMetaData service,
+         Collection<String> unhandled, AbstractBeanMetaData beanMetaData)
+   {
+      // convert attribute meta data
+      for(ServiceAttributeMetaData attribute: service.getAttributes())
+      {
+         beanMetaData.addProperty(attributeConverter.toMCMetaData(attribute, unhandled));
+      }
+   }
+
+   /**
+    * @param service
+    * @param unhandled
+    * @param beanMetaData
+    */
+   private void fillDependencies(ServiceMetaData service,
+         Collection<String> unhandled, AbstractBeanMetaData beanMetaData)
+   {
+      // convert dependency meta data
+      if (!service.getDependencies().isEmpty())
+      {
+         Set<DependencyMetaData> newDependencies = new HashSet<DependencyMetaData>();
+         for (ServiceDependencyMetaData dependency: service.getDependencies())
+         {
+            newDependencies.add(dependencyConverter.toMCMetaData(dependency, unhandled)); 
+         }
+         beanMetaData.setDepends(newDependencies);
+      }
+   }
+
+   /**
+    * @param service
+    * @param unhandled
+    * @param beanMetaData
+    */
+   private void fillAliases(ServiceMetaData service, Collection<String> unhandled,
+         AbstractBeanMetaData beanMetaData)
+   {
+      // convert alias meta data
+      if (service.getAliases()!= null && !service.getAliases().isEmpty())
+      {
+         Set<AliasMetaData> aliases = new HashSet<AliasMetaData>();
+         for (String alias: service.getAliases())
+         {
+            aliases.add(aliasConverter.toMCMetaData(alias, unhandled));
+         }
+         beanMetaData.setAliasMetaData(aliases);
+      }
+   }
+
+   /**
+    * @param service
+    * @param unhandled
+    * @param beanMetaData
+    */
+   private void fillAnnotations(ServiceMetaData service,
+         Collection<String> unhandled, AbstractBeanMetaData beanMetaData)
+   {
+      // convert annotation meta data
+      Set<AnnotationMetaData> annotations = null;
+      if (!service.getAnnotations().isEmpty())
+      {
+         annotations = new HashSet<AnnotationMetaData>();
+         for (ServiceAnnotationMetaData annotation: service.getAnnotations())
+         {
+            annotations.add(annotationConverter.toMCMetaData(annotation, unhandled));
+         }
+      }
+      // create @JMX annotation metadata when appliable
+      AnnotationMetaData jmxAnnotation = jmxAnnotationStrategy.createAnnotation(service);
+      if (jmxAnnotation != null)
+      {
+         if (annotations == null)
+         {
+            annotations = new HashSet<AnnotationMetaData>();
+         }
+         annotations.add(jmxAnnotation);
+      }
+      beanMetaData.setAnnotations(annotations);
+   }  
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ServiceMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/TextValueMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/TextValueMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/TextValueMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+
+import org.jboss.beans.metadata.plugins.StringValueMetaData;
+import org.jboss.system.metadata.ServiceTextValueMetaData;
+
+/**
+ * 
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+class TextValueMetaDataConverter extends AttributeValueMetaDataConverter<ServiceTextValueMetaData, StringValueMetaData>
+{
+   public Class<ServiceTextValueMetaData> getCompatibleClass()
+   {
+      return ServiceTextValueMetaData.class;
+   }
+   
+   public StringValueMetaData toMCMetaData(ServiceTextValueMetaData valueMetaData, Collection<String> unhandledAttributes)
+   {
+      return new StringValueMetaData(valueMetaData.getText());
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/TextValueMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ValueFactoryMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ValueFactoryMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ValueFactoryMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
+import org.jboss.beans.metadata.plugins.AbstractValueFactoryMetaData;
+import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.system.metadata.ServiceValueFactoryParameterMetaData;
+import org.jboss.system.metadata.ServiceValueFactoryValueMetaData;
+
+/**
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ *
+ */
+class ValueFactoryMetaDataConverter extends AttributeValueMetaDataConverter<ServiceValueFactoryValueMetaData, AbstractValueFactoryMetaData>
+{
+   public Class<ServiceValueFactoryValueMetaData> getCompatibleClass()
+   {
+      return ServiceValueFactoryValueMetaData.class;
+   }
+   
+   public AbstractValueFactoryMetaData toMCMetaData(ServiceValueFactoryValueMetaData value, Collection<String> unhandledAttributes)
+   {
+      String dependency = NAME_TRANSLATOR.translate((String) value.getDependency());
+      String method = value.getMethod();
+      String defaultValue = value.getDefaultValue() == null? null: value.getDefaultValue().getText();
+
+      AbstractValueFactoryMetaData metaData = new AbstractValueFactoryMetaData(dependency, method, defaultValue);
+      if (value.getParameterMetaData().size() == 1)
+      {
+         ServiceValueFactoryParameterMetaData parameter = value.getParameterMetaData().get(0);
+         if (parameter.getParameterTypeName() == null && parameter.getValueTypeName() == null)
+         {
+            metaData.setParameter(parameter.getTextValue());
+         }
+      }
+      if (metaData.getParameter() == null)
+      {
+         List<ParameterMetaData> newParameters = new ArrayList<ParameterMetaData>();
+         // TODO
+         for (ServiceValueFactoryParameterMetaData parameter: value.getParameterMetaData())
+         {
+            String textValue = parameter.getTextValue();
+            String type = parameter.getParameterTypeName();
+            String type2 = parameter.getValueTypeName();
+            type = type2 == null? type: type2;
+            ValueMetaData parameterValue = new AbstractValueMetaData(textValue);
+            newParameters.add(new AbstractParameterMetaData(type2 == null? type: type2, parameterValue));
+         }
+         metaData.setParameters(newParameters);
+      }
+      return metaData;
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ValueFactoryMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Added: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ValueMetaDataConverter.java
===================================================================
--- projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ValueMetaDataConverter.java	                        (rev 0)
+++ projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ValueMetaDataConverter.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.mc.tools.jmx.convert;
+
+import java.util.Collection;
+
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.system.metadata.ServiceValueMetaData;
+
+/**
+ * 
+ * 
+ * @author  <a href="flavia.rainone at jboss.com">Flavia Rainone</a>
+ * @version $Revision$
+ */
+public class ValueMetaDataConverter extends AttributeValueMetaDataConverter<ServiceValueMetaData, ValueMetaData>
+{
+   public Class<ServiceValueMetaData> getCompatibleClass()
+   {
+      return ServiceValueMetaData.class;
+   }
+   
+   public ValueMetaData toMCMetaData(ServiceValueMetaData valueMetaData, Collection<String> unhandledAttributes)
+   {
+      throw new RuntimeException("Unexpected value type: " + (valueMetaData == null? valueMetaData: valueMetaData.getClass().getName()));
+   }
+}
\ No newline at end of file


Property changes on: projects/mc-tools/trunk/src/main/java/org/jboss/mc/tools/jmx/convert/ValueMetaDataConverter.java
___________________________________________________________________
Name: svn:keywords
   + Date Revision Author HeadURL Id

Modified: projects/mc-tools/trunk/src/test/java/org/jboss/mc/tools/jmx/MetaDataConverterTestCase.java
===================================================================
--- projects/mc-tools/trunk/src/test/java/org/jboss/mc/tools/jmx/MetaDataConverterTestCase.java	2009-06-17 18:39:22 UTC (rev 90349)
+++ projects/mc-tools/trunk/src/test/java/org/jboss/mc/tools/jmx/MetaDataConverterTestCase.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -61,13 +61,13 @@
       super(name);
    }
 
-   private MetaDataConverter converter = null;
+   private MetaDataConverter2 converter = null;
    
    @Override
    public void setUp() throws Exception
    {
       super.setUp();
-      converter = new MetaDataConverter(new AnnotateAllStrategy(), new UsePropertyService());
+      converter = new MetaDataConverter2(new AnnotateAllStrategy(), new UsePropertyService());
    }
    
    public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception

Modified: projects/mc-tools/trunk/src/test/java/org/jboss/mc/tools/jmx/XMLMarshallerTestCase.java
===================================================================
--- projects/mc-tools/trunk/src/test/java/org/jboss/mc/tools/jmx/XMLMarshallerTestCase.java	2009-06-17 18:39:22 UTC (rev 90349)
+++ projects/mc-tools/trunk/src/test/java/org/jboss/mc/tools/jmx/XMLMarshallerTestCase.java	2009-06-17 19:23:48 UTC (rev 90350)
@@ -54,13 +54,13 @@
       super(name);
    }
 
-   private MetaDataConverter converter = null;
+   private MetaDataConverter2 converter = null;
    
    @Override
    public void setUp() throws Exception
    {
       super.setUp();
-      converter = new MetaDataConverter(new AnnotateAllStrategy(), new UsePropertyService());
+      converter = new MetaDataConverter2(new AnnotateAllStrategy(), new UsePropertyService());
    }
    
    public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception




More information about the jboss-cvs-commits mailing list