[jboss-cvs] JBossAS SVN: r66956 - in projects/microcontainer/trunk: kernel/src/main/org/jboss/kernel/plugins/deployment and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 12 08:10:58 EST 2007


Author: alesj
Date: 2007-11-12 08:10:58 -0500 (Mon, 12 Nov 2007)
New Revision: 66956

Added:
   projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/Properties2BeansDeployer.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/DeploymentBuilder.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/DeploymentVertex.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/PropertiesGraphFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/TreeVertex.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/VertexFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/AbstractLevelVertexFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/BaseDeploymentVertex.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/BeanVertexFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/ClassVertexFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/DefaultVertexFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/HolderVertexFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/KeywordLevelVertexFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/LevelVertexFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/PropertyVertexFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/ValueMetaDataAwareVertex.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/ValueVertex.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/props/
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/props/support/
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/props/test/
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/props/test/GraphBuilderTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/props/test/PropsTestSuite.java
Modified:
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java
Log:
Initial work on JBMICROCONT-217.

Added: projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/Properties2BeansDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/Properties2BeansDeployer.java	                        (rev 0)
+++ projects/microcontainer/trunk/deployers-vfs/src/main/org/jboss/deployers/vfs/deployer/kernel/Properties2BeansDeployer.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,84 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.deployers.vfs.deployer.kernel;
+
+import java.util.Properties;
+import java.io.InputStream;
+import java.io.IOException;
+
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSParsingDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.kernel.plugins.deployment.props.DeploymentBuilder;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Properties2BeansDeployer.<p>
+ *
+ * This deployer is responsible for looking for -beans.properties
+ * and creating the metadata object.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class Properties2BeansDeployer extends AbstractVFSParsingDeployer<KernelDeployment>
+{
+   /**
+    * Create a new Properties2BeansDeployer.
+    */
+   public Properties2BeansDeployer()
+   {
+      super(KernelDeployment.class);
+      setSuffix("-beans.properties");
+      // Enable ManagedObject creation based on annotations by default
+      setBuildManagedObject(true);
+   }
+
+   @Override
+   protected void init(VFSDeploymentUnit unit, KernelDeployment metaData, VirtualFile file) throws Exception
+   {
+      String name = file.toURI().toString();
+      metaData.setName(name);
+   }
+
+   protected KernelDeployment parse(VFSDeploymentUnit unit, VirtualFile file, KernelDeployment root) throws Exception
+   {
+      Properties properties = new Properties();
+      InputStream is = file.openStream();
+      try
+      {
+         properties.load(is);
+
+         DeploymentBuilder deploymentBuilder = new DeploymentBuilder(properties);
+         return deploymentBuilder.build();
+      }
+      finally
+      {
+         try
+         {
+            is.close();
+         }
+         catch (IOException ignored)
+         {
+         }
+      }
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/DeploymentBuilder.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/DeploymentBuilder.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/DeploymentBuilder.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,82 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+
+/**
+ * Deployment builder.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DeploymentBuilder
+{
+   private PropertiesGraphFactory graphFactory;
+
+   public DeploymentBuilder(Properties properties)
+   {
+      buildGraph(toMap(properties));
+   }
+
+   public DeploymentBuilder(Map<String, String> properties)
+   {
+      buildGraph(properties);
+   }
+
+   protected static Map<String, String> toMap(Properties properties)
+   {
+      if (properties == null)
+         return null;
+
+      Map<String, String> map = new TreeMap<String, String>();
+      for(Object key : properties.keySet())
+      {
+         String ks = key.toString();
+         map.put(ks, properties.getProperty(ks));
+      }
+      return map;
+   }
+
+   /**
+    * Build graph.
+    *
+    * @param properties the properties
+    */
+   protected void buildGraph(Map<String, String> properties)
+   {
+      graphFactory = new PropertiesGraphFactory(properties);
+   }
+
+   /**
+    * Build KernelDeployment instance.
+    *
+    * @return KernelDeployment instance
+    */
+   public KernelDeployment build()
+   {
+      return graphFactory.build();
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/DeploymentVertex.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/DeploymentVertex.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/DeploymentVertex.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props;
+
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.util.graph.Vertex;
+
+/**
+ * Top level deployment vertex.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class DeploymentVertex extends TreeVertex<Vertex<String>>
+{
+   protected DeploymentVertex(String name)
+   {
+      super(name);
+   }
+
+   public abstract KernelDeployment get();
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/PropertiesGraphFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/PropertiesGraphFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/PropertiesGraphFactory.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,158 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props;
+
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+
+import org.jboss.kernel.plugins.deployment.props.vertex.DefaultVertexFactory;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.util.graph.Graph;
+import org.jboss.util.graph.Vertex;
+
+/**
+ * Properties to Graph factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PropertiesGraphFactory
+{
+   /** The graph */
+   private Graph<String> graph;
+
+   /** The root */
+   private DeploymentVertex root;
+
+   /** The vertext factory */
+   private VertexFactory vertexFactory = new DefaultVertexFactory();
+
+   public PropertiesGraphFactory(Properties properties)
+   {
+      if (properties == null)
+         throw new IllegalArgumentException("Null properties.");
+
+      buildGraph(toMap(properties));
+   }
+
+   public PropertiesGraphFactory(Map<String, String> properties)
+   {
+      if (properties == null)
+         throw new IllegalArgumentException("Null properties.");
+
+      buildGraph(properties);
+   }
+
+   /**
+    * Build the kernel deployment.
+    *
+    * @return KernelDeployment instance
+    */
+   public KernelDeployment build()
+   {
+      graph.depthFirstSearch(root, vertexFactory.visitor());
+      return root.get();
+   }
+
+   /**
+    * Transform properties to map.
+    *
+    * @param properties the properties
+    * @return map
+    */
+   protected static Map<String, String> toMap(Properties properties)
+   {
+      Map<String, String> map = new TreeMap<String, String>();
+      for(Object key : properties.keySet())
+      {
+         String ks = key.toString();
+         map.put(ks, properties.getProperty(ks));
+      }
+      return map;
+   }
+
+   /**
+    * Build graph from properties.
+    *
+    * @param properties the properties
+    */
+   protected void buildGraph(Map<String, String> properties)
+   {
+      graph = new Graph<String>();
+      root = vertexFactory.rootVertex();
+      graph.addVertex(root);
+      for(String key : properties.keySet())
+      {
+         String value = properties.get(key);
+         buildVertices(root, 0, key, value, 0);
+      }
+   }
+
+   /**
+    * Build vertices from property key and value.
+    *
+    * @param previous previous vertex
+    * @param index current dot index
+    * @param key the property key
+    * @param value the value
+    * @param level current level
+    */
+   @SuppressWarnings("unchecked")
+   protected void buildVertices(Vertex<String> previous, int index, String key, String value, int level)
+   {
+      int p = key.indexOf('.', index + 1);
+      int end = p > 0 ? p : key.length();
+      String name = key.substring(0, end);
+
+      Vertex<String> current = graph.findVertexByName(name);
+      if (current == null)
+      {
+         current = vertexFactory.createVertex(level, name);
+         graph.addVertex(current);
+      }
+      graph.addEdge(previous, current, level);
+
+      if (p < 0)
+      {
+         Vertex<String> valueVertex = vertexFactory.valueVertex(value);
+         graph.addVertex(valueVertex);
+         graph.addEdge(current, valueVertex, -1);
+      }
+      else
+         buildVertices(current, p, key, value, level + 1);
+   }
+
+   /**
+    * Set the vertex factory.
+    *
+    * @param vertexFactory the vertex factory
+    */
+   public void setVertexFactory(VertexFactory vertexFactory)
+   {
+      this.vertexFactory = vertexFactory;
+   }
+
+   public String toString()
+   {
+      return graph.toString();
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/TreeVertex.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/TreeVertex.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/TreeVertex.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,158 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+import org.jboss.util.graph.Edge;
+import org.jboss.util.graph.Vertex;
+
+/**
+ * Tree vertex.
+ *
+ * @param <T> exact vertex type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class TreeVertex<T extends Vertex<String>> extends Vertex<String>
+{
+   /** The logger */
+   protected Logger log = Logger.getLogger(getClass());
+   /** The last token */
+   private String lastToken;
+
+   protected TreeVertex(String name)
+   {
+      super(name);
+   }
+
+   @SuppressWarnings("unchecked")
+   public void visit()
+   {
+      Vertex<String> parent = getParent(this);
+      Set<Vertex<String>> children = getChildren(this);
+
+      if (log.isTraceEnabled())
+         log.trace("Structure visit, parent: " + parent + ", children: " + children);
+
+      visit((T)parent, children);
+   }
+
+   /**
+    * Get the last token.
+    *
+    * @return
+    */
+   protected String getLastToken()
+   {
+      if (lastToken == null)
+      {
+         String fullName = getName();
+         int p = fullName.lastIndexOf('.') + 1;
+         lastToken = fullName.substring(p);
+      }
+      return lastToken;
+   }
+
+   /**
+    * Get the parent vertex from vertex param.
+    *
+    * @param vertex the vertex to check
+    * @return parent vertex
+    */
+   @SuppressWarnings("unchecked")
+   protected static Vertex<String> getParent(Vertex<String> vertex)
+   {
+      List<Edge<String>> edges = vertex.getIncomingEdges();
+
+      Vertex<String> parent = null;
+      if (edges.isEmpty() == false)
+      {
+         Set<Vertex<String>> previous = new HashSet<Vertex<String>>();
+         for(Edge<String> edge : edges)
+            previous.add(edge.getFrom());
+
+         if (previous.size() > 1)
+            throw new IllegalArgumentException("Multiple parents: " + vertex);
+
+         return previous.iterator().next();
+      }
+      return parent;
+   }
+
+   /**
+    * Get children from vertext param.
+    *
+    * @param vertex the vertex to check
+    * @return children vertices
+    */
+   protected static Set<Vertex<String>> getChildren(Vertex<String> vertex)
+   {
+      Set<Vertex<String>> children = new HashSet<Vertex<String>>();
+      for(int i = 0; i < vertex.getOutgoingEdgeCount(); i++)
+      {
+         Edge<String> edge = vertex.getOutgoingEdge(i);
+         children.add(edge.getTo());
+      }
+      return children;
+   }
+
+   /**
+    * Get previous from vertex param.
+    *
+    * @param vertex the vertex
+    * @return previous vertex
+    */
+   protected static Vertex<String> getPrevious(Vertex<String> vertex)
+   {
+      return getParent(vertex);
+   }
+
+   /**
+    * Get the next vertex.
+    *
+    * @param vertex the vertex
+    * @return next vertex
+    */
+   protected static Vertex<String> getNext(Vertex<String> vertex)
+   {
+      Set<Vertex<String>> children = getChildren(vertex);
+
+      if (children.isEmpty())
+         return null;
+
+      if (children.size() > 1)
+         throw new IllegalArgumentException("Multiple children: " + vertex);
+
+      return children.iterator().next();
+   }
+
+   /**
+    * Do the visit.
+    *
+    * @param parent the parent vertex
+    * @param children the children vertices
+    */
+   public abstract void visit(T parent, Set<Vertex<String>> children);
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/VertexFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/VertexFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/VertexFactory.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props;
+
+import org.jboss.util.graph.Visitor;
+
+/**
+ * Vertex factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface VertexFactory
+{
+   /**
+    * Create root/deploymenent vertex.
+    *
+    * @return DeploymentVertex instance
+    */
+   DeploymentVertex rootVertex();
+
+   /**
+    * Create simple vertex.
+    *
+    * @param level current level
+    * @param name full name
+    * @return new tree vertex
+    */
+   TreeVertex createVertex(int level, String name);
+
+   /**
+    * Create value vertext.
+    *
+    * @param value the text value
+    * @return new value vertex
+    */
+   TreeVertex valueVertex(String value);
+
+   /**
+    * Get the visitor.
+    *
+    * @return visitor instance
+    */
+   Visitor<String> visitor();
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/AbstractLevelVertexFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/AbstractLevelVertexFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/AbstractLevelVertexFactory.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props.vertex;
+
+/**
+ * Ordered level vertex factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractLevelVertexFactory implements LevelVertexFactory
+{
+   private int order = 0;
+
+   protected AbstractLevelVertexFactory()
+   {
+   }
+
+   protected AbstractLevelVertexFactory(int order)
+   {
+      this.order = order;
+   }
+
+   public int getOrder()
+   {
+      return order;
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/BaseDeploymentVertex.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/BaseDeploymentVertex.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/BaseDeploymentVertex.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props.vertex;
+
+import java.util.Set;
+
+import org.jboss.kernel.plugins.deployment.props.DeploymentVertex;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.util.graph.Vertex;
+
+/**
+ * Deployment vertex.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BaseDeploymentVertex extends DeploymentVertex
+{
+   private AbstractKernelDeployment deployment;
+
+   public BaseDeploymentVertex()
+   {
+      super("(root)");
+   }
+
+   public void visit(Vertex<String> parent, Set<Vertex<String>> children)
+   {
+      deployment = new AbstractKernelDeployment();
+   }
+
+   AbstractKernelDeployment getDeployment()
+   {
+      return deployment;
+   }
+
+   public KernelDeployment get()
+   {
+      return getDeployment();
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/BeanVertexFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/BeanVertexFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/BeanVertexFactory.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,84 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props.vertex;
+
+import java.util.Set;
+import java.util.List;
+import java.util.ArrayList;
+
+import org.jboss.kernel.plugins.deployment.props.TreeVertex;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.util.graph.Vertex;
+
+/**
+ * Bean vertex factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanVertexFactory extends AbstractLevelVertexFactory
+{
+   public BeanVertexFactory()
+   {
+      super(Integer.MAX_VALUE);
+   }
+
+   public TreeVertex createVertex(String name)
+   {
+      return new BeanVertex(name);
+   }
+
+   /**
+    * Bean vertex.
+    *
+    * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+    */
+   class BeanVertex extends TreeVertex<BaseDeploymentVertex>
+   {
+      private AbstractBeanMetaData beanMetaData;
+
+      public BeanVertex(String name)
+      {
+         super(name);
+      }
+
+      public void visit(BaseDeploymentVertex parent, Set<Vertex<String>> children)
+      {
+         beanMetaData = new AbstractBeanMetaData();
+         beanMetaData.setName(getName());
+         AbstractKernelDeployment deployment = parent.getDeployment();
+         List<BeanMetaDataFactory> list = deployment.getBeanFactories();
+         if (list == null)
+         {
+            list = new ArrayList<BeanMetaDataFactory>();
+            deployment.setBeanFactories(list);
+         }
+         list.add(beanMetaData);
+      }
+
+      AbstractBeanMetaData getBeanMetaData()
+      {
+         return beanMetaData;
+      }
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/ClassVertexFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/ClassVertexFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/ClassVertexFactory.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props.vertex;
+
+import java.util.Set;
+
+import org.jboss.kernel.plugins.deployment.props.TreeVertex;
+import org.jboss.util.graph.Vertex;
+
+/**
+ * Class vertex factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ClassVertexFactory extends KeywordLevelVertexFactory
+{
+   public ClassVertexFactory()
+   {
+      super("(class)");
+   }
+
+   protected TreeVertex createVertex(String name, String keyword)
+   {
+      return new ClassVertex(name);
+   }
+
+   class ClassVertex extends TreeVertex<BeanVertexFactory.BeanVertex>
+   {
+      public ClassVertex(String name)
+      {
+         super(name);
+      }
+
+      public void visit(BeanVertexFactory.BeanVertex parent, Set<Vertex<String>> children)
+      {
+         Vertex<String> value = getNext(this);
+         parent.getBeanMetaData().setBean(value.getName());
+      }
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/DefaultVertexFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/DefaultVertexFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/DefaultVertexFactory.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,105 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props.vertex;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.jboss.kernel.plugins.deployment.props.DeploymentVertex;
+import org.jboss.kernel.plugins.deployment.props.TreeVertex;
+import org.jboss.kernel.plugins.deployment.props.VertexFactory;
+import org.jboss.logging.Logger;
+import org.jboss.util.graph.Graph;
+import org.jboss.util.graph.Vertex;
+import org.jboss.util.graph.Visitor;
+
+/**
+ * Default vertex factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DefaultVertexFactory implements VertexFactory
+{
+   /** The logger */
+   protected Logger logger = Logger.getLogger(getClass());
+   /** The level factories */
+   protected Map<Integer, Set<LevelVertexFactory>> levelFactories = new HashMap<Integer, Set<LevelVertexFactory>>();
+
+   public DefaultVertexFactory()
+   {
+      addLevelFactory(0, new BeanVertexFactory());
+      addLevelFactory(1, new ClassVertexFactory());
+      addLevelFactory(1, new PropertyVertexFactory());
+      addLevelFactory(2, new HolderVertexFactory());
+   }
+
+   public void addLevelFactory(int level, LevelVertexFactory factory)
+   {
+      Set<LevelVertexFactory> factories = levelFactories.get(level);
+      if (factories == null)
+      {
+         factories = new TreeSet<LevelVertexFactory>(LevelVertexFactory.COMPARATOR);
+         levelFactories.put(level, factories);
+      }
+      factories.add(factory);
+   }
+
+   public DeploymentVertex rootVertex()
+   {
+      return new BaseDeploymentVertex();
+   }
+
+   public TreeVertex createVertex(int level, String name)
+   {
+      Set<LevelVertexFactory> factories = levelFactories.get(level);
+      if (factories == null)
+         throw new IllegalArgumentException("No matching level factories: " + name + " / " + level);
+
+      for(LevelVertexFactory factory : factories)
+      {
+         TreeVertex vertex = factory.createVertex(name);
+         if (vertex != null)
+            return vertex;
+      }
+      throw new IllegalArgumentException("No matching level factory: " + name + " / " + level);
+   }
+
+   public TreeVertex valueVertex(String value)
+   {
+      return new ValueVertex(value);
+   }
+
+   public Visitor<String> visitor()
+   {
+      return new Visitor<String>()
+      {
+         public void visit(Graph<String> g, Vertex<String> v)
+         {
+            if (logger.isTraceEnabled())
+               logger.trace(v);
+         }
+      };
+   }
+}
+

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/HolderVertexFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/HolderVertexFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/HolderVertexFactory.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props.vertex;
+
+import java.util.Set;
+
+import org.jboss.kernel.plugins.deployment.props.TreeVertex;
+import org.jboss.util.graph.Vertex;
+
+/**
+ * Simple holder vertex factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class HolderVertexFactory extends AbstractLevelVertexFactory
+{
+   public HolderVertexFactory()
+   {
+      super(Integer.MAX_VALUE);
+   }
+
+   public TreeVertex createVertex(String name)
+   {
+      return new HolderVertex(name);
+   }
+
+   /**
+    * Holder vertex.
+    */
+   class HolderVertex extends TreeVertex<Vertex<String>>
+   {
+      public HolderVertex(String name)
+      {
+         super(name);
+      }
+
+      public void visit(Vertex<String> parent, Set<Vertex<String>> children)
+      {
+      }
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/KeywordLevelVertexFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/KeywordLevelVertexFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/KeywordLevelVertexFactory.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props.vertex;
+
+import org.jboss.kernel.plugins.deployment.props.TreeVertex;
+
+/**
+ * Keyword matching level vertex factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class KeywordLevelVertexFactory extends AbstractLevelVertexFactory
+{
+   private String keyword;
+
+   protected KeywordLevelVertexFactory(String keyword)
+   {
+      if (keyword == null)
+         throw new IllegalArgumentException("Null keyword.");
+      this.keyword = keyword;
+   }
+
+   public TreeVertex createVertex(String name)
+   {
+      int p = name.lastIndexOf(".") + 1;
+      String keyword = name.substring(p);
+
+      if (this.keyword.equalsIgnoreCase(keyword) == false)
+         return null;
+
+      return createVertex(name, keyword);
+   }
+
+   /**
+    * Create vertex from name and keyword.
+    *
+    * @param name the name
+    * @param keyword the keyword
+    * @return new vertex instance
+    */
+   protected  abstract TreeVertex createVertex(String name, String keyword);
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/LevelVertexFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/LevelVertexFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/LevelVertexFactory.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props.vertex;
+
+import java.util.Comparator;
+
+import org.jboss.kernel.plugins.deployment.props.TreeVertex;
+
+/**
+ * Level vertex factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface LevelVertexFactory
+{
+   /**
+    * Create new vertex.
+    * If name doesn't match factory's creation return null.
+    *
+    * @param name the name
+    * @return new vertex instance or null if cannot create vertex from name
+    */
+   TreeVertex createVertex(String name);
+
+   /**
+    * Get the order.
+    *
+    * @return the order
+    */
+   int getOrder();
+
+   /**
+    * LevelVertexFactory comparator.
+    */
+   public static Comparator<LevelVertexFactory> COMPARATOR = new LevelVertexFactoryComparator();
+
+   static class LevelVertexFactoryComparator implements Comparator<LevelVertexFactory>
+   {
+      public int compare(LevelVertexFactory o1, LevelVertexFactory o2)
+      {
+         return o1.getOrder() - o2.getOrder();
+      }
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/PropertyVertexFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/PropertyVertexFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/PropertyVertexFactory.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,68 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props.vertex;
+
+import java.util.Set;
+
+import org.jboss.kernel.plugins.deployment.props.TreeVertex;
+import org.jboss.util.graph.Vertex;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+
+/**
+ * Property vertex factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PropertyVertexFactory extends AbstractLevelVertexFactory
+{
+   public PropertyVertexFactory()
+   {
+      super(Integer.MAX_VALUE);
+   }
+
+   public TreeVertex createVertex(String name)
+   {
+      return new PropertyVertex(name);
+   }
+
+   /**
+    * Property vertex.
+    */
+   class PropertyVertex extends ValueMetaDataAwareVertex<AbstractPropertyMetaData, BeanVertexFactory.BeanVertex>
+   {
+      public PropertyVertex(String name)
+      {
+         super(name);
+      }
+
+      protected AbstractPropertyMetaData createValueMetaDataAware()
+      {
+         return new AbstractPropertyMetaData();
+      }
+
+      public void visit(BeanVertexFactory.BeanVertex parent, Set<Vertex<String>> children)
+      {
+         delegate.setName(getLastToken());
+         parent.getBeanMetaData().addProperty(delegate);
+      }
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/ValueMetaDataAwareVertex.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/ValueMetaDataAwareVertex.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/ValueMetaDataAwareVertex.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,62 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props.vertex;
+
+import org.jboss.beans.metadata.plugins.ValueMetaDataAware;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.kernel.plugins.deployment.props.TreeVertex;
+import org.jboss.util.graph.Vertex;
+
+/**
+ * Value aware vertex.
+ *
+ * @param <U> exact ValueMetaDataAware type
+ * @param <T> exact parent type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class ValueMetaDataAwareVertex<U extends ValueMetaDataAware, T extends Vertex<String>> extends TreeVertex<T> implements ValueMetaDataAware
+{
+   protected U delegate;
+
+   protected ValueMetaDataAwareVertex(String n)
+   {
+      super(n);
+      delegate = createValueMetaDataAware();
+   }
+
+   /**
+    * Create value meta data aware instance.
+    *
+    * @return ValueMetaDataAware instance
+    */
+   protected abstract U createValueMetaDataAware();
+
+   public ValueMetaData getValue()
+   {
+      return delegate.getValue();
+   }
+
+   public void setValue(ValueMetaData value)
+   {
+      delegate.setValue(value);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/ValueVertex.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/ValueVertex.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/props/vertex/ValueVertex.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,75 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.deployment.props.vertex;
+
+import java.util.Set;
+
+import org.jboss.beans.metadata.plugins.StringValueMetaData;
+import org.jboss.beans.metadata.plugins.ValueMetaDataAware;
+import org.jboss.kernel.plugins.deployment.props.TreeVertex;
+import org.jboss.util.graph.Vertex;
+
+/**
+ * Value vertex.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ValueVertex extends TreeVertex<Vertex<String>>
+{
+   public ValueVertex(String value)
+   {
+      super(value);
+   }
+
+   public void visit(Vertex<String> parent, Set<Vertex<String>> children)
+   {
+      if (parent instanceof ValueMetaDataAware)
+      {
+         StringValueMetaData value = new StringValueMetaData(getName());
+         Set<Vertex<String>> parentsChildren = getChildren(parent);
+         for (Vertex<String> vertex : parentsChildren)
+         {
+            if (vertex == this)
+               continue;
+
+            String name = vertex.getName();
+            if (name.endsWith("type"))
+            {
+               Vertex<String> next = getNext(vertex);
+               value.setType(next.getName());
+            }
+            else if (name.endsWith("trim"))
+            {
+               Vertex<String> next = getNext(vertex);
+               value.setTrim(Boolean.parseBoolean(next.getName()));
+            }
+            else if (name.endsWith("replace"))
+            {
+               Vertex<String> next = getNext(vertex);
+               value.setReplace(Boolean.parseBoolean(next.getName()));
+            }
+         }
+         ValueMetaDataAware valueMetaDataAware = (ValueMetaDataAware)parent;
+         valueMetaDataAware.setValue(value);
+      }
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java	2007-11-12 12:47:52 UTC (rev 66955)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/KernelTestSuite.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -31,6 +31,7 @@
 import org.jboss.test.kernel.dependency.test.DependencyTestSuite;
 import org.jboss.test.kernel.deployment.test.DeploymentTestSuite;
 import org.jboss.test.kernel.deployment.xml.test.XMLTestSuite;
+import org.jboss.test.kernel.deployment.props.test.PropsTestSuite;
 import org.jboss.test.kernel.event.test.EventTestSuite;
 import org.jboss.test.kernel.registry.test.RegistryTestSuite;
 import org.jboss.test.kernel.inject.test.ContextualInjectionTestSuite;
@@ -67,6 +68,7 @@
       suite.addTest(MetaDataTestSuite.suite());
       suite.addTest(AnnotationsTestSuite.suite());
       suite.addTest(LazyTestSuite.suite());
+      suite.addTest(PropsTestSuite.suite());
 
       return suite;
    }

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/props/test/GraphBuilderTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/props/test/GraphBuilderTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/props/test/GraphBuilderTestCase.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.deployment.props.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.Test;
+import org.jboss.kernel.plugins.deployment.props.PropertiesGraphFactory;
+import org.jboss.test.BaseTestCase;
+
+/**
+ * Test graph from properties.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class GraphBuilderTestCase extends BaseTestCase
+{
+   public GraphBuilderTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(GraphBuilderTestCase.class);
+   }
+
+   public void testGraphFromProperties() throws Exception
+   {
+      Map<String, String> properties = new HashMap<String, String>();
+      properties.put("mybean.(class)", "org.jboss.acme.MyBean");
+      properties.put("mybean.somenumber", "123L");
+      properties.put("mybean.somenumber.type", "java.lang.Long");
+
+      PropertiesGraphFactory propertiesGraph = new PropertiesGraphFactory(properties);
+      System.out.println("propertiesGraph " + propertiesGraph);
+      System.out.println("");
+
+      System.out.println(propertiesGraph.build());
+
+      System.out.println("");
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/props/test/PropsTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/props/test/PropsTestSuite.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/props/test/PropsTestSuite.java	2007-11-12 13:10:58 UTC (rev 66956)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.kernel.deployment.props.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PropsTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Props Tests");
+
+      suite.addTest(GraphBuilderTestCase.suite());
+
+      return suite;
+   }
+}




More information about the jboss-cvs-commits mailing list