[jboss-cvs] JBossAS SVN: r66536 - in projects/microcontainer/trunk: deployers-impl/src/main/org/jboss/deployers/plugins/main and 17 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Oct 29 11:36:38 EDT 2007


Author: alesj
Date: 2007-10-29 11:36:38 -0400 (Mon, 29 Oct 2007)
New Revision: 66536

Added:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/api/annotations/Supply.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/ClassMatcher.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/Matcher.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/MatcherFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/MatcherTransformer.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NonNullMatcher.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NonNullMatcherTransformer.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NumberMatcher.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/StringMatcher.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DefaultMatcher.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DefaultMatcherFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/IntervalMatcher.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/IntervalMatcherTransformer.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/MatcherFactoryBuilder.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/RegexpMatcher.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/RegexpMatcherTransformer.java
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase0.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase1.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase2.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase3.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase4.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase5.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DemandWithTransformer.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/SupplyWithClass.xml
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/CustomDemander.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/CustomMatcherTransfomer.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/CustomSupplier.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/IntervalDemander.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/IntervalSupplier.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/RegexpDemander.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/RegexpSupplier.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyAnnotationTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase.java
Modified:
   projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoGenericInterface.java
   projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/api/annotations/Demand.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/api/annotations/Supplys.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractSupplyMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DemandHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/SupplyHandler.java
   projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SetsAnnotationTester.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/SupplyPlainDependecySimpleBeanImpl.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/DependencyTestSuite.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/DemandTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/SupplyTestCase.java
Log:
Extending the Demand/Supply notion with Matcher interface.
See AbstractKernelController or MatcherDemandSupplyTestCase for the usage.

Modified: projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoGenericInterface.java
===================================================================
--- projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoGenericInterface.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/container/src/tests/org/jboss/test/beaninfo/support/BeanInfoGenericInterface.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -24,11 +24,12 @@
 
 /**
  * A BeanInfoGenericInterface.
- * 
+ *
+ * @param <T> exact property type
  * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
  * @version $Revision: 1.1 $
  */
-public interface BeanInfoGenericInterface<T extends Object>
+public interface BeanInfoGenericInterface<T>
 {
    T getProperty();
    void setProperty(T value);

Modified: projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java
===================================================================
--- projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/deployers-impl/src/main/org/jboss/deployers/plugins/main/MainDeployerImpl.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -66,6 +66,7 @@
    
    /** The structural deployers */
    private StructuralDeployers structuralDeployers;
+
    /** The ManagedDeploymentCreator plugin */
    private ManagedDeploymentCreator mgtDeploymentCreator = null;
    

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/api/annotations/Demand.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/api/annotations/Demand.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/api/annotations/Demand.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -48,4 +48,11 @@
     * @return the when required state
     */
    String whenRequired() default "Instantiated";
+
+   /**
+    * Get the transfomer.
+    *
+    * @return the transformer
+    */
+   String transformer() default "";
 }

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/api/annotations/Supply.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/api/annotations/Supply.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/api/annotations/Supply.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,51 @@
+/*
+* 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.beans.metadata.api.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/**
+ * The supplys.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.TYPE})
+public @interface Supply
+{
+   /**
+    * Get suppl values.
+    *
+    * @return the supply value
+    */
+   String value();
+
+   /**
+    * Get class type.
+    *
+    * @return the class type
+    */
+   String type() default "";
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/api/annotations/Supplys.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/api/annotations/Supplys.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/api/annotations/Supplys.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -40,5 +40,5 @@
     *
     * @return the supplys
     */
-   String[] value();
+   Supply[] value();
 }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDemandMetaData.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -33,6 +33,8 @@
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.dependency.spi.DependencyItem;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.api.dependency.MatcherFactory;
+import org.jboss.kernel.api.dependency.Matcher;
 import org.jboss.util.JBossObject;
 import org.jboss.util.JBossStringBuilder;
 import org.jboss.util.HashCode;
@@ -53,7 +55,10 @@
    
    /** When the dependency is required */
    protected ControllerState whenRequired = ControllerState.DESCRIBED;
-   
+
+   /** The transformer */
+   protected String transformer;
+
    /**
     * Create a new demand
     */
@@ -103,6 +108,26 @@
       return whenRequired;
    }
 
+   /**
+    * Get the transformer class name.
+    *
+    * @return the transformer class name
+    */
+   public String getTransformer()
+   {
+      return transformer;
+   }
+
+   /**
+    * Set the transformer class name.
+    *
+    * @param transformer the transformer class name
+    */
+   public void setTransformer(String transformer)
+   {
+      this.transformer = transformer;
+   }
+
    public void initialVisit(MetaDataVisitor visitor)
    {
       KernelControllerContext context = visitor.getControllerContext();
@@ -150,6 +175,9 @@
     */
    public class DemandDependencyItem extends AbstractDependencyItem 
    {
+      /** The matcher */
+      private Matcher matcher;
+
       /**
        * Create a new demand dependecy
        * 
@@ -158,11 +186,14 @@
       public DemandDependencyItem(Object name)
       {
          super(name, null, whenRequired, null);
+         if (getTransformer() != null)
+            matcher = MatcherFactory.getInstance().createMatcher(getTransformer(), getDemand());
       }
       
       public boolean resolve(Controller controller)
       {
-         ControllerContext context = controller.getInstalledContext(demand);
+         Object name = (matcher != null) ? matcher : getDemand();
+         ControllerContext context = controller.getInstalledContext(name);
          if (context != null)
          {
             setIDependOn(context.getName());

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractSupplyMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractSupplyMetaData.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractSupplyMetaData.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -21,15 +21,18 @@
 */
 package org.jboss.beans.metadata.plugins;
 
+import java.beans.PropertyEditor;
 import java.io.Serializable;
 import java.util.Iterator;
 
 import org.jboss.beans.metadata.spi.MetaDataVisitor;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.logging.Logger;
+import org.jboss.util.HashCode;
 import org.jboss.util.JBossObject;
 import org.jboss.util.JBossStringBuilder;
-import org.jboss.util.HashCode;
+import org.jboss.util.propertyeditor.PropertyEditors;
 
 /**
  * A supply.
@@ -42,9 +45,26 @@
 {
    private static final long serialVersionUID = 1L;
 
+   private static Logger log = Logger.getLogger(AbstractSupplyMetaData.class);
+
+   static
+   {
+      try
+      {
+         PropertyEditors.init();
+      }
+      catch (Throwable t)
+      {
+         log.debug("Unable to initialise property editors", t);
+      }
+   }
+
    /** The supply */
    protected Object supply;
 
+   /** The type */
+   protected String type;
+
    /**
     * Create a new supply
     */
@@ -73,11 +93,49 @@
       flushJBossObjectCache();
    }
 
+   /**
+    * Get the class type.
+    *
+    * @return the class type
+    */
+   public String getType()
+   {
+      return type;
+   }
+
+   /**
+    * Set the class type
+    *
+    * @param type the type
+    */
+   public void setType(String type)
+   {
+      this.type = type;
+   }
+
    public Object getSupply()
    {
+      if (supply instanceof String && type != null)
+      {
+         PropertyEditor editor = getPropertyEditor();
+         editor.setAsText((String)supply);
+         return editor.getValue();
+      }
       return supply;
    }
 
+   protected PropertyEditor getPropertyEditor()
+   {
+      try
+      {
+         return PropertyEditors.getEditor(type);
+      }
+      catch (ClassNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
    public void initialVisit(MetaDataVisitor visitor)
    {
       visitor.initialVisit(this);
@@ -96,6 +154,8 @@
    public void toString(JBossStringBuilder buffer)
    {
       buffer.append("supply=").append(supply);
+      if (type != null)
+         buffer.append(" class=").append(type);
    }
    
    public void toShortString(JBossStringBuilder buffer)
@@ -107,12 +167,11 @@
    {
       if (obj instanceof AbstractSupplyMetaData == false)
          return false;
-      return equals(supply, ((AbstractSupplyMetaData)obj).supply);
+      return equals(supply, ((AbstractSupplyMetaData)obj).supply) && equals(type, ((AbstractSupplyMetaData)obj).type);
    }
 
    protected int getHashCode()
    {
       return HashCode.generate(supply);
    }
-
 }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/builder/BeanMetaDataBuilderImpl.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -41,6 +41,7 @@
 import org.jboss.beans.metadata.spi.ValueMetaData;
 import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
 import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.ControllerState;
 
 /**
  * Helper class.
@@ -258,25 +259,43 @@
 
    public BeanMetaDataBuilder addSupply(Object supply)
    {
+      return addSupply(supply, null);
+   }
+
+   public BeanMetaDataBuilder addSupply(Object supply, String type)
+   {
       Set<SupplyMetaData> supplies = beanMetaData.getSupplies();
       if (supplies == null)
       {
          supplies = new HashSet<SupplyMetaData>();
          beanMetaData.setSupplies(supplies);
       }
-      supplies.add(new AbstractSupplyMetaData(supply));
+      AbstractSupplyMetaData asmd = new AbstractSupplyMetaData(supply);
+      if (type != null)
+         asmd.setType(type);
+      supplies.add(asmd);
       return this;
    }
 
    public BeanMetaDataBuilder addDemand(Object demand)
    {
+      return addDemand(demand, null, null);
+   }
+
+   public BeanMetaDataBuilder addDemand(Object demand, String whenRequired, String transformer)
+   {
       Set<DemandMetaData> demands = beanMetaData.getDemands();
       if (demands == null)
       {
          demands = new HashSet<DemandMetaData>();
          beanMetaData.setDemands(demands);
       }
-      demands.add(new AbstractDemandMetaData(demand));
+      AbstractDemandMetaData admd = new AbstractDemandMetaData(demand);
+      if (whenRequired != null)
+         admd.setWhenRequired(new ControllerState(whenRequired));
+      if (transformer != null)
+         admd.setTransformer(transformer);
+      demands.add(admd);
       return this;
    }
 

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/builder/BeanMetaDataBuilder.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -85,8 +85,12 @@
 
    BeanMetaDataBuilder addSupply(Object supply);
 
+   BeanMetaDataBuilder addSupply(Object supply, String type);
+
    BeanMetaDataBuilder addDemand(Object demand);
 
+   BeanMetaDataBuilder addDemand(Object demand, String whenRequired, String transformer);
+
    BeanMetaDataBuilder addDependency(Object dependency);
 
    BeanMetaDataBuilder addInstall(String methodName);

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/ClassMatcher.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/ClassMatcher.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/ClassMatcher.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,52 @@
+/*
+* 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.api.dependency;
+
+/**
+ * Match the class type.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class ClassMatcher<T> extends NonNullMatcher
+{
+   private Class<T> clazz;
+
+   protected ClassMatcher(Class<T> clazz)
+   {
+      if (clazz == null)
+         throw new IllegalArgumentException("Null class");
+      this.clazz = clazz;
+   }
+
+   protected boolean internalMatch(Object other)
+   {
+      return clazz.isAssignableFrom(other.getClass()) != false && matchByType(clazz.cast(other));
+   }
+
+   /**
+    * Match by type.
+    *
+    * @param other the T para to match
+    * @return true if matched, false otherwise
+    */
+   protected abstract boolean matchByType(T other);
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/Matcher.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/Matcher.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/Matcher.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,39 @@
+/*
+* 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.api.dependency;
+
+/**
+ * Matcher.
+ * Match this instance against any object.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface Matcher
+{
+   /**
+    * Do we match this object other param.
+    *
+    * @param other the object to match
+    * @return true if we match the other param, false otherwise
+    */
+   boolean match(Object other);
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/MatcherFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/MatcherFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/MatcherFactory.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -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.api.dependency;
+
+import org.jboss.kernel.plugins.dependency.MatcherFactoryBuilder;
+
+/**
+ * Matcher factory.
+ * Holding the obvious Matcher implementations.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class MatcherFactory
+{
+   /** The singleton builder */
+   private static final MatcherFactoryBuilder builder = new MatcherFactoryBuilder();
+
+   /**
+    * Get the matcher factory
+    *
+    * @return the instance
+    */
+   public static final MatcherFactory getInstance()
+   {
+      return builder.create();
+   }
+
+   /**
+    * Add matcher transfomer.
+    *
+    * @param key the key
+    * @param transformer the transfomer
+    */
+   public abstract void addMatcherTransfomer(String key, MatcherTransformer transformer);
+
+   /**
+    * Create the Matcher.
+    *
+    * @param transformer the transformer
+    * @param value the value to wrap
+    * @return new Matcher instance
+    */
+   public abstract Matcher createMatcher(String transformer, Object value);
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/MatcherTransformer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/MatcherTransformer.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/MatcherTransformer.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,38 @@
+/*
+* 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.api.dependency;
+
+/**
+ * Matcher transformer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface MatcherTransformer
+{
+   /**
+    * Transform value param to Matcher instance.
+    *
+    * @param value the value
+    * @return Matcher instance
+    */
+   Matcher transform(Object value);
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NonNullMatcher.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NonNullMatcher.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NonNullMatcher.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,41 @@
+/*
+* 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.api.dependency;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class NonNullMatcher implements Matcher
+{
+   public boolean match(Object other)
+   {
+      return other != null && internalMatch(other);
+   }
+
+   /**
+    * Do internal match.
+    *
+    * @param other the other param to match
+    * @return true if matched, false otherwise
+    */
+   protected abstract boolean internalMatch(Object other);
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NonNullMatcherTransformer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NonNullMatcherTransformer.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NonNullMatcherTransformer.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,47 @@
+/*
+* 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.api.dependency;
+
+/**
+ * Non null matcher transfomer.
+ * Throws exception if value to transform is null.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class NonNullMatcherTransformer implements MatcherTransformer
+{
+   public Matcher transform(Object value)
+   {
+      if (value == null)
+         throw new IllegalArgumentException("Null value");
+
+      return internalTransform(value);
+   }
+
+   /**
+    * Transform non null value.
+    *
+    * @param value the value
+    * @return matcher instance
+    */
+   protected abstract Matcher internalTransform(Object value);
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NumberMatcher.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NumberMatcher.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/NumberMatcher.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,35 @@
+/*
+* 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.api.dependency;
+
+/**
+ * Number matcher.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class NumberMatcher extends ClassMatcher<Number>
+{
+   protected NumberMatcher()
+   {
+      super(Number.class);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/StringMatcher.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/StringMatcher.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/api/dependency/StringMatcher.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,35 @@
+/*
+* 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.api.dependency;
+
+/**
+ * String matcher.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class StringMatcher extends ClassMatcher<String>
+{
+   protected StringMatcher()
+   {
+      super(String.class);
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -63,6 +63,9 @@
       {
          AbstractDemandMetaData admd = new AbstractDemandMetaData(demand.value());
          admd.setWhenRequired(new ControllerState(demand.whenRequired()));
+         if (isAttributePresent(demand.transformer()))
+            admd.setTransformer(demand.transformer());
+         
          if (demands.add(admd))
             nodes.add(admd);
       }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -29,6 +29,7 @@
 import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
 import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
 import org.jboss.beans.metadata.api.annotations.Supplys;
+import org.jboss.beans.metadata.api.annotations.Supply;
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.SupplyMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
@@ -55,9 +56,12 @@
          ((AbstractBeanMetaData)beanMetaData).setSupplies(supplies);
       }
       List<MetaDataVisitorNode> nodes = new ArrayList<MetaDataVisitorNode>();
-      for(String supply : annotation.value())
+      for(Supply supply : annotation.value())
       {
-         AbstractSupplyMetaData asmd = new AbstractSupplyMetaData(supply);
+         AbstractSupplyMetaData asmd = new AbstractSupplyMetaData(supply.value());
+         if (isAttributePresent(supply.type()))
+            asmd.setType(supply.type());
+         
          if (supplies.add(asmd))
             nodes.add(asmd);
       }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -35,6 +35,7 @@
 import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.kernel.Kernel;
+import org.jboss.kernel.api.dependency.Matcher;
 import org.jboss.kernel.plugins.event.AbstractEventEmitter;
 import org.jboss.kernel.spi.dependency.KernelController;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
@@ -98,7 +99,11 @@
 
    public KernelRegistryEntry getEntry(Object name)
    {
-      List<KernelControllerContext> list = suppliers.get(name);
+      List<KernelControllerContext> list;
+      if (name instanceof Matcher)
+         list = matchSupplies((Matcher)name);
+      else
+         list = suppliers.get(name);
       if (list != null && list.isEmpty() == false)
          return list.get(0);
       else if (name instanceof Class)
@@ -107,6 +112,22 @@
          return null;
    }
 
+   /**
+    * Try matching supplies.
+    *
+    * @param matcher the matcher
+    * @return list of context's who have a matching supply
+    */
+   protected List<KernelControllerContext> matchSupplies(Matcher matcher)
+   {
+      for(Map.Entry<Object, List<KernelControllerContext>> entry : suppliers.entrySet())
+      {
+         if (matcher.match(entry.getKey()))
+            return entry.getValue();
+      }
+      return null;
+   }
+
    public ControllerContext getContext(Object name, ControllerState state)
    {
       ControllerContext context = super.getContext(name, state);

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DefaultMatcher.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DefaultMatcher.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DefaultMatcher.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,51 @@
+/*
+* 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.dependency;
+
+import java.io.Serializable;
+
+import org.jboss.kernel.api.dependency.Matcher;
+import org.jboss.util.JBossObject;
+
+/**
+ * Default Matcher.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+class DefaultMatcher implements Matcher, Serializable
+{
+   private static final long serialVersionUID = -6608028542574356737L;
+
+   // Should be serializable if we want to serialize this Matcher instance
+   private Object value;
+
+   public DefaultMatcher(Object value)
+   {
+      this.value = value;
+   }
+
+   public boolean match(Object other)
+   {
+      return JBossObject.equals(value, other);
+   }
+}
+

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DefaultMatcherFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DefaultMatcherFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DefaultMatcherFactory.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,104 @@
+/*
+* 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.dependency;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.kernel.api.dependency.Matcher;
+import org.jboss.kernel.api.dependency.MatcherFactory;
+import org.jboss.kernel.api.dependency.MatcherTransformer;
+import org.jboss.logging.Logger;
+import org.jboss.reflect.plugins.introspection.ReflectionUtils;
+
+/**
+ * Default Matcher factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class DefaultMatcherFactory extends MatcherFactory implements MatcherTransformer
+{
+   /** The log */
+   protected Logger log = Logger.getLogger(getClass());
+
+   /** The matcher transformers map */
+   private Map<String, MatcherTransformer> transfomers = new HashMap<String, MatcherTransformer>();
+
+   public DefaultMatcherFactory()
+   {
+      addMatcherTransfomer("default", this);
+      addMatcherTransfomer("regexp", new RegexpMatcherTransformer());
+      addMatcherTransfomer("interval", new IntervalMatcherTransformer());
+   }
+
+   public void addMatcherTransfomer(String key, MatcherTransformer transformer)
+   {
+      if (key == null && transformer != null)
+         transfomers.put(transformer.getClass().getName(), transformer);
+      
+      if (key != null)
+      {
+         if (transformer == null)
+            transfomers.remove(key);
+         else
+            transfomers.put(key, transformer);
+      }
+   }
+
+   /**
+    * Create the Matcher.
+    *
+    * @param transformer the transformer
+    * @param value the value to wrap
+    * @return new Matcher instance
+    */
+   public Matcher createMatcher(String transformer, Object value)
+   {
+      if (value instanceof Matcher)
+         return (Matcher)value;
+
+      if (transformer == null)
+         transformer = "default";
+
+      MatcherTransformer mt = transfomers.get(transformer);
+      if (mt != null)
+         return mt.transform(value);
+
+      if (log.isTraceEnabled())
+         log.trace("No matching transfomer key '" + transformer + "', trying to instantiate new.");
+
+      try
+      {
+         mt = (MatcherTransformer)ReflectionUtils.newInstance(transformer);
+         return mt.transform(value);
+      }
+      catch(Throwable t)
+      {
+         throw new IllegalArgumentException("Cannot create Matcher instance: " + t);
+      }
+   }
+
+   public Matcher transform(Object value)
+   {
+      return new DefaultMatcher(value);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/IntervalMatcher.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/IntervalMatcher.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/IntervalMatcher.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,103 @@
+/*
+* 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.dependency;
+
+import java.io.Serializable;
+
+import org.jboss.kernel.api.dependency.NumberMatcher;
+
+/**
+ * Interval matcher.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class IntervalMatcher extends NumberMatcher implements Serializable
+{
+   private static final long serialVersionUID = 1L;
+   /**
+    * The lower bound of the range
+    */
+   private Number floor;
+   /**
+    * The upper bound of the range
+    */
+   private Number ceiling;
+   /**
+    * is the floor a >(true) or >= constraint(false)
+    */
+   private boolean floorIsGreaterThan;
+   /**
+    * is the ceiling a <(true) or <= constraint(false)
+    */
+   private boolean ceilingIsLessThan;
+
+   public IntervalMatcher(Number floor, Number ceiling, boolean floorIsGreaterThan, boolean ceilingIsLessThan)
+   {
+      this.floor = floor;
+      this.ceiling = ceiling;
+      this.floorIsGreaterThan = floorIsGreaterThan;
+      this.ceilingIsLessThan = ceilingIsLessThan;
+   }
+
+   /**
+    * Compare other value with edge value.
+    * Return default value if edge is null.
+    *
+    * @param other the other
+    * @param edge the edge
+    * @param defaultValue default value
+    * @return -1 if edge greater than other, 1 if other greater than edge, 0 if equal
+    */
+   protected int compareTo(Number other, Number edge, int defaultValue)
+   {
+      if (edge == null)
+         return defaultValue;
+
+      double dOther = other.doubleValue();
+      double dEdge = edge.doubleValue();
+      return Double.compare(dOther, dEdge);
+   }
+
+   protected boolean matchByType(Number other)
+   {
+      boolean isInRange = floor == null;
+      if (isInRange == false)
+      {
+         // Test the floor
+         int floorCompare = compareTo(other, floor, 1);
+         if ((floorIsGreaterThan && floorCompare > 0) || (floorIsGreaterThan == false && floorCompare >= 0))
+         {
+            isInRange = ceiling == null;
+            if (isInRange == false)
+            {
+               // Test the ceiling
+               int ceilingCompare = compareTo(other, ceiling, -1);
+               if ((ceilingIsLessThan && ceilingCompare < 0) || (ceilingIsLessThan == false && ceilingCompare <= 0))
+               {
+                  isInRange = true;
+               }
+            }
+         }
+      }
+      return isInRange;
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/IntervalMatcherTransformer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/IntervalMatcherTransformer.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/IntervalMatcherTransformer.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,81 @@
+/*
+* 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.dependency;
+
+import java.util.StringTokenizer;
+
+import org.jboss.kernel.api.dependency.NonNullMatcherTransformer;
+import org.jboss.kernel.api.dependency.Matcher;
+
+/**
+ * Interval expression matcher transformer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class IntervalMatcherTransformer extends NonNullMatcherTransformer
+{
+   protected Matcher internalTransform(Object value)
+   {
+      String interval = value.toString();
+
+      Number floor = null;
+      Number ceiling = null;
+      StringTokenizer st = new StringTokenizer(interval, ",[]()", true);
+      Boolean floorIsGreaterThan = null;
+      Boolean ceilingIsLessThan = null;
+      boolean mid = false;
+      while (st.hasMoreTokens())
+      {
+         String token = st.nextToken();
+         if (token.equals("["))
+            floorIsGreaterThan = false;
+         else if (token.equals("("))
+            floorIsGreaterThan = true;
+         else if (token.equals("]"))
+            ceilingIsLessThan = false;
+         else if (token.equals(")"))
+            ceilingIsLessThan = true;
+         else if (token.equals(","))
+            mid = true;
+         else if (token.equals("\"") == false)
+         {
+            if (floor == null)
+               floor = Double.parseDouble(token);
+            else
+               ceiling = Double.parseDouble(token);
+         }
+
+      }
+      // check for parenthesis
+      if (floorIsGreaterThan == null || ceilingIsLessThan == null)
+      {
+         // non-empty interval usage
+         if (mid)
+            throw new IllegalArgumentException("Missing parenthesis: " + interval);
+         // single value
+         floorIsGreaterThan = false;
+         ceilingIsLessThan = false;
+      }
+
+      return new IntervalMatcher(floor, ceiling, floorIsGreaterThan, ceilingIsLessThan);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/MatcherFactoryBuilder.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/MatcherFactoryBuilder.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/MatcherFactoryBuilder.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -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.dependency;
+
+import org.jboss.kernel.api.dependency.MatcherFactory;
+
+/**
+ * Matcher factory builder.
+ *
+ * TODO this class only creates a singleton fixed implementation for now
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MatcherFactoryBuilder
+{
+   /** The singleton */
+   private static final MatcherFactory singleton = new DefaultMatcherFactory();
+
+   /**
+    * Create the factory
+    *
+    * @return the factory
+    */
+   public MatcherFactory create()
+   {
+      return singleton;
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/RegexpMatcher.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/RegexpMatcher.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/RegexpMatcher.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,50 @@
+/*
+* 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.dependency;
+
+import java.util.regex.Pattern;
+import java.io.Serializable;
+
+import org.jboss.kernel.api.dependency.StringMatcher;
+
+/**
+ * Regular expression matcher.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class RegexpMatcher extends StringMatcher implements Serializable
+{
+   private static final long serialVersionUID = 1L;
+
+   private Pattern pattern;
+
+   public RegexpMatcher(String regexp)
+   {
+      pattern = Pattern.compile(regexp);
+   }
+
+   protected boolean matchByType(String other)
+   {
+      boolean b = pattern.matcher(other).matches();
+      return b;
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/RegexpMatcherTransformer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/RegexpMatcherTransformer.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/RegexpMatcherTransformer.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,38 @@
+/*
+* 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.dependency;
+
+import org.jboss.kernel.api.dependency.Matcher;
+import org.jboss.kernel.api.dependency.NonNullMatcherTransformer;
+
+/**
+ * Regular expression matcher transformer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class RegexpMatcherTransformer extends NonNullMatcherTransformer
+{
+   protected Matcher internalTransform(Object value)
+   {
+      return new RegexpMatcher(value.toString());
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DemandHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DemandHandler.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/DemandHandler.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -54,6 +54,8 @@
          String localName = attrs.getLocalName(i);
          if ("state".equals(localName))
             demand.setWhenRequired(new ControllerState(attrs.getValue(i)));
+         else if ("transformer".equals(localName))
+            demand.setTransformer(attrs.getValue(i));
       }
    }
    

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/SupplyHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/SupplyHandler.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/SupplyHandler.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -22,10 +22,12 @@
 package org.jboss.kernel.plugins.deployment.xml;
 
 import javax.xml.namespace.QName;
+import javax.xml.namespace.NamespaceContext;
 
 import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
 import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
 import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
 
 /**
  * SupplyHandler.
@@ -43,11 +45,21 @@
       return new AbstractSupplyMetaData();
    }
    
+   public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+   {
+      AbstractSupplyMetaData supply = (AbstractSupplyMetaData) o;
+      for (int i = 0; i < attrs.getLength(); ++i)
+      {
+         if ("class".equals(attrs.getLocalName(i)))
+            supply.setType(attrs.getValue(i));
+      }
+   }
+
    public Object endElement(Object o, QName qName, ElementBinding element)
    {
       AbstractSupplyMetaData x = (AbstractSupplyMetaData) o;
-      String name = (String) x.getSupply();
-      if (name == null || name.trim().length() == 0)
+      Object supply = x.getSupply();
+      if (supply == null || supply.toString().length() == 0)
          throw new IllegalArgumentException("Null or empty supply.");
       return o;
    }

Modified: projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd	2007-10-29 15:36:38 UTC (rev 66536)
@@ -970,6 +970,7 @@
       <xsd:simpleContent>
          <xsd:extension base="xsd:string">
             <xsd:attribute name="state" type="controllerStateType" use="optional"/>
+            <xsd:attribute name="transformer" type="xsd:token" use="optional"/>
          </xsd:extension>
       </xsd:simpleContent>
    </xsd:complexType>
@@ -991,7 +992,9 @@
          </xsd:documentation>
       </xsd:annotation>
       <xsd:simpleContent>
-         <xsd:extension base="xsd:string"/>
+         <xsd:extension base="xsd:string">
+            <xsd:attribute name="class" type="classNameType" use="optional"/>
+         </xsd:extension>
       </xsd:simpleContent>
    </xsd:complexType>
 

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase0.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase0.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase0.xml	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="regexpDemander" class="org.jboss.test.kernel.dependency.support.SimpleBeanImpl">
+      <demand transformer="regexp">^[a-zA-Z0-9._%+-]+ at acme\.((org)|(com))$</demand>
+   </bean>
+</deployment>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase1.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase1.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase1.xml	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="regexpSupplier" class="org.jboss.test.kernel.dependency.support.SimpleBeanImpl">
+      <supply>aj at acme.org</supply>
+   </bean>
+</deployment>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase2.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase2.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase2.xml	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="intervalDemander" class="org.jboss.test.kernel.dependency.support.SimpleBeanImpl">
+      <demand transformer="interval">(1,10]</demand>
+   </bean>
+</deployment>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase3.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase3.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase3.xml	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="intervalSupplier" class="org.jboss.test.kernel.dependency.support.SimpleBeanImpl">
+      <supply class="java.lang.Integer">5</supply>
+   </bean>
+</deployment>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase4.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase4.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase4.xml	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="customDemander" class="org.jboss.test.kernel.dependency.support.SimpleBeanImpl">
+      <demand transformer="org.jboss.test.kernel.dependency.support.CustomMatcherTransfomer">fragment</demand>
+   </bean>
+</deployment>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase5.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase5.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase5.xml	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+   <bean name="customSupplier" class="org.jboss.test.kernel.dependency.support.SimpleBeanImpl">
+      <supply>i supply fragment word</supply>
+   </bean>
+</deployment>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DemandWithTransformer.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DemandWithTransformer.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/DemandWithTransformer.xml	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <demand transformer="default">Demand</demand>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/SupplyWithClass.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/SupplyWithClass.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/SupplyWithClass.xml	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <supply class="java.lang.Integer">123</supply>
+</bean>

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SetsAnnotationTester.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SetsAnnotationTester.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SetsAnnotationTester.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -25,13 +25,14 @@
 import org.jboss.beans.metadata.api.annotations.Demand;
 import org.jboss.beans.metadata.api.annotations.Depends;
 import org.jboss.beans.metadata.api.annotations.Supplys;
+import org.jboss.beans.metadata.api.annotations.Supply;
 
 /**
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
 @Demands({@Demand("deployer")})
 @Depends({"deployer"})
- at Supplys({"somesupply"})
+ at Supplys({@Supply("somesupply")})
 public class SetsAnnotationTester implements AnnotationTester
 {
    public Object getValue()

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/CustomDemander.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/CustomDemander.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/CustomDemander.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,33 @@
+/*
+* 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.dependency.support;
+
+import org.jboss.beans.metadata.api.annotations.Demands;
+import org.jboss.beans.metadata.api.annotations.Demand;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Demands({@Demand(value = "fragment", transformer = "org.jboss.test.kernel.dependency.support.CustomMatcherTransfomer")})
+public class CustomDemander
+{
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/CustomMatcherTransfomer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/CustomMatcherTransfomer.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/CustomMatcherTransfomer.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,52 @@
+/*
+* 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.dependency.support;
+
+import org.jboss.kernel.api.dependency.Matcher;
+import org.jboss.kernel.api.dependency.NonNullMatcherTransformer;
+import org.jboss.kernel.api.dependency.StringMatcher;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CustomMatcherTransfomer extends NonNullMatcherTransformer
+{
+   protected Matcher internalTransform(Object value)
+   {
+      return new FragmentMatcher(value.toString());
+   }
+
+   private class FragmentMatcher extends StringMatcher
+   {
+      private String fragment;
+
+      public FragmentMatcher(String string)
+      {
+         this.fragment = string;
+      }
+
+      protected boolean matchByType(String other)
+      {
+         return other.contains(fragment);
+      }
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/CustomSupplier.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/CustomSupplier.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/CustomSupplier.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,33 @@
+/*
+* 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.dependency.support;
+
+import org.jboss.beans.metadata.api.annotations.Supplys;
+import org.jboss.beans.metadata.api.annotations.Supply;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Supplys({@Supply(value = "i supply fragment word")})
+public class CustomSupplier
+{
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/IntervalDemander.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/IntervalDemander.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/IntervalDemander.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,33 @@
+/*
+* 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.dependency.support;
+
+import org.jboss.beans.metadata.api.annotations.Demands;
+import org.jboss.beans.metadata.api.annotations.Demand;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Demands({@Demand(value = "(1,10]", transformer = "interval")})
+public class IntervalDemander
+{
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/IntervalSupplier.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/IntervalSupplier.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/IntervalSupplier.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,33 @@
+/*
+* 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.dependency.support;
+
+import org.jboss.beans.metadata.api.annotations.Supplys;
+import org.jboss.beans.metadata.api.annotations.Supply;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Supplys({@Supply(value = "5", type = "java.lang.Integer")})
+public class IntervalSupplier
+{
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/RegexpDemander.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/RegexpDemander.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/RegexpDemander.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,33 @@
+/*
+* 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.dependency.support;
+
+import org.jboss.beans.metadata.api.annotations.Demands;
+import org.jboss.beans.metadata.api.annotations.Demand;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Demands({@Demand(value = "^[a-zA-Z0-9._%+-]+ at acme\\.((org)|(com))$", transformer = "regexp")})
+public class RegexpDemander
+{
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/RegexpSupplier.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/RegexpSupplier.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/RegexpSupplier.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,33 @@
+/*
+* 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.dependency.support;
+
+import org.jboss.beans.metadata.api.annotations.Supplys;
+import org.jboss.beans.metadata.api.annotations.Supply;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Supplys({@Supply(value = "aj at acme.org")})
+public class RegexpSupplier
+{
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/SupplyPlainDependecySimpleBeanImpl.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/SupplyPlainDependecySimpleBeanImpl.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/support/SupplyPlainDependecySimpleBeanImpl.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -22,13 +22,14 @@
 package org.jboss.test.kernel.dependency.support;
 
 import org.jboss.beans.metadata.api.annotations.Supplys;
+import org.jboss.beans.metadata.api.annotations.Supply;
 
 /**
  * A simple bean
  *
  * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  */
- at Supplys({"WhatIWant"})
+ at Supplys({@Supply("WhatIWant")})
 public class SupplyPlainDependecySimpleBeanImpl extends PlainDependecySimpleBeanImpl
 {
    private static final long serialVersionUID = 3258132440433243443L;

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/DependencyTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/DependencyTestSuite.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/DependencyTestSuite.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -97,6 +97,9 @@
       suite.addTest(CallbackCollectionTestCase.suite());
       suite.addTest(CallbackCollectionXMLTestCase.suite());
       suite.addTest(CallbackCollectionAnnotationTestCase.suite());
+      suite.addTest(MatcherDemandSupplyTestCase.suite());
+      suite.addTest(MatcherDemandSupplyXMLTestCase.suite());
+      suite.addTest(MatcherDemandSupplyAnnotationTestCase.suite());
       return suite;
    }
 }

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyAnnotationTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyAnnotationTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyAnnotationTestCase.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,79 @@
+/*
+* 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.dependency.test;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.test.kernel.dependency.support.RegexpDemander;
+import org.jboss.test.kernel.dependency.support.RegexpSupplier;
+import org.jboss.test.kernel.dependency.support.IntervalDemander;
+import org.jboss.test.kernel.dependency.support.IntervalSupplier;
+import org.jboss.test.kernel.dependency.support.CustomDemander;
+import org.jboss.test.kernel.dependency.support.CustomSupplier;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * Test matcher demand/supply.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MatcherDemandSupplyAnnotationTestCase extends MatcherDemandSupplyTestCase
+{
+   public MatcherDemandSupplyAnnotationTestCase(String name)
+         throws Throwable
+   {
+      super(name, false);
+   }
+
+   public static Test suite()
+   {
+      return suite(MatcherDemandSupplyAnnotationTestCase.class);
+   }
+
+   protected ControllerState getState()
+   {
+      return ControllerState.DESCRIBED;
+   }
+
+   protected void setBeanMetaDatas() throws Throwable
+   {
+      BeanMetaDataBuilder b0 = BeanMetaDataBuilderFactory.createBuilder("regexpDemander", RegexpDemander.class.getName());
+      BeanMetaDataBuilder b1 = BeanMetaDataBuilderFactory.createBuilder("regexpSupplier", RegexpSupplier.class.getName());
+      BeanMetaDataBuilder b2 = BeanMetaDataBuilderFactory.createBuilder("intervalDemander", IntervalDemander.class.getName());
+      BeanMetaDataBuilder b3 = BeanMetaDataBuilderFactory.createBuilder("intervalSupplier", IntervalSupplier.class.getName());
+      BeanMetaDataBuilder b4 = BeanMetaDataBuilderFactory.createBuilder("customDemander", CustomDemander.class.getName());
+      BeanMetaDataBuilder b5 = BeanMetaDataBuilderFactory.createBuilder("customSupplier", CustomSupplier.class.getName());
+
+      setBeanMetaDatas(new BeanMetaData[]
+            {
+               b0.getBeanMetaData(),
+               b1.getBeanMetaData(),
+               b2.getBeanMetaData(),
+               b3.getBeanMetaData(),
+               b4.getBeanMetaData(),
+               b5.getBeanMetaData(),
+            }
+      );
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyTestCase.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,106 @@
+/*
+* 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.dependency.test;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.test.kernel.dependency.support.CustomMatcherTransfomer;
+
+/**
+ * Test matcher demand/supply.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MatcherDemandSupplyTestCase extends AbstractKernelDependencyTest
+{
+   public MatcherDemandSupplyTestCase(String name)
+         throws Throwable
+   {
+      super(name);
+   }
+
+   public MatcherDemandSupplyTestCase(String name, boolean xmltest)
+         throws Throwable
+   {
+      super(name, xmltest);
+   }
+
+   public static Test suite()
+   {
+      return suite(MatcherDemandSupplyTestCase.class);
+   }
+
+   public void testMatching() throws Throwable
+   {
+      setBeanMetaDatas();
+
+      ControllerContext regexpDemand = assertInstall(0, "regexpDemander", getState());
+      assertInstall(1, "regexpSupplier");
+      assertEquals(ControllerState.INSTALLED, regexpDemand.getState());
+
+      ControllerContext limitDemand = assertInstall(2, "intervalDemander", getState());
+      assertInstall(3, "intervalSupplier");
+      assertEquals(ControllerState.INSTALLED, limitDemand.getState());
+
+      ControllerContext customDemand = assertInstall(4, "customDemander", getState());
+      assertInstall(5, "customSupplier");
+      assertEquals(ControllerState.INSTALLED, customDemand.getState());
+   }
+
+   protected ControllerState getState()
+   {
+      return ControllerState.PRE_INSTALL;
+   }
+
+   protected void setBeanMetaDatas() throws Throwable
+   {
+      BeanMetaDataBuilder b0 = BeanMetaDataBuilderFactory.createBuilder("regexpDemander", Object.class.getName());
+      b0.addDemand("^[a-zA-Z0-9._%+-]+ at acme\\.((org)|(com))$", null, "regexp");
+      BeanMetaDataBuilder b1 = BeanMetaDataBuilderFactory.createBuilder("regexpSupplier", Object.class.getName());
+      b1.addSupply("aj at acme.org");
+
+      BeanMetaDataBuilder b2 = BeanMetaDataBuilderFactory.createBuilder("intervalDemander", Object.class.getName());
+      b2.addDemand("(1,10]", null, "interval");
+      BeanMetaDataBuilder b3 = BeanMetaDataBuilderFactory.createBuilder("intervalSupplier", Object.class.getName());
+      b3.addSupply("5", "java.lang.Integer");
+
+      BeanMetaDataBuilder b4 = BeanMetaDataBuilderFactory.createBuilder("customDemander", Object.class.getName());
+      b4.addDemand("fragment", null, CustomMatcherTransfomer.class.getName());
+      BeanMetaDataBuilder b5 = BeanMetaDataBuilderFactory.createBuilder("customSupplier", Object.class.getName());
+      b5.addSupply("i supply fragment word");
+
+      setBeanMetaDatas(new BeanMetaData[]
+            {
+               b0.getBeanMetaData(),
+               b1.getBeanMetaData(),
+               b2.getBeanMetaData(),
+               b3.getBeanMetaData(),
+               b4.getBeanMetaData(),
+               b5.getBeanMetaData(),
+            }
+      );
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/dependency/test/MatcherDemandSupplyXMLTestCase.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -0,0 +1,43 @@
+/*
+* 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.dependency.test;
+
+import junit.framework.Test;
+
+/**
+ * Test matcher demand/supply.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class MatcherDemandSupplyXMLTestCase extends MatcherDemandSupplyTestCase
+{
+   public MatcherDemandSupplyXMLTestCase(String name)
+         throws Throwable
+   {
+      super(name, true);
+   }
+
+   public static Test suite()
+   {
+      return suite(MatcherDemandSupplyXMLTestCase.class);
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/DemandTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/DemandTestCase.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/DemandTestCase.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -62,6 +62,13 @@
       assertEquals(ControllerState.CONFIGURED, demand.getWhenRequired());
    }
 
+   public void testDemandWithTransformer() throws Exception
+   {
+      AbstractDemandMetaData demand = getDemand("DemandWithTransformer.xml");
+      assertEquals("Demand", demand.getDemand());
+      assertEquals("default", demand.getTransformer());
+   }
+
    public void testDemandBadNoValue() throws Exception
    {
       try

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/SupplyTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/SupplyTestCase.java	2007-10-29 15:29:41 UTC (rev 66535)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/SupplyTestCase.java	2007-10-29 15:36:38 UTC (rev 66536)
@@ -53,6 +53,13 @@
       assertEquals("Supply", supply.getSupply());
    }
 
+   public void testSupplyWithClass() throws Exception
+   {
+      AbstractSupplyMetaData supply = getSupply("SupplyWithClass.xml");
+      assertEquals(123, supply.getSupply());
+      assertEquals("java.lang.Integer", supply.getType());
+   }
+
    public void testSupplyBadNoValue() throws Exception
    {
       try




More information about the jboss-cvs-commits mailing list