[jboss-cvs] JBossAS SVN: r59748 - in projects/microcontainer/trunk/kernel/src: resources/org/jboss/test/javabean/test and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jan 18 02:31:50 EST 2007


Author: scott.stark at jboss.org
Date: 2007-01-18 02:31:49 -0500 (Thu, 18 Jan 2007)
New Revision: 59748

Added:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/Common.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/ConstructorHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/ConstructorInterceptor.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanSchemaInitializer20.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/KernelConfigInit.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/PropertyHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/PropertyInterceptor.java
   projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20.xml
   projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtor.xml
   projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClass.xml
   projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClassAndParams.xml
   projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorFactory.xml
   projects/microcontainer/trunk/kernel/src/resources/schema/javabean_2_0.xsd
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/support/SimpleBeanFactory.java
Modified:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanSchemaInitializer.java
   projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/deployment/xml/test/SetWithWildcard.xml
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/support/SimpleBean.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/test/PropertyTestCase.java
Log:
Add a javabean 2.0 schema that supports constructor element with factory support.

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/Common.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/Common.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/Common.java	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,228 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.config.xml;
+
+import java.util.ArrayList;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.joinpoint.spi.Joinpoint;
+import org.jboss.kernel.plugins.config.Configurator;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.test.kernel.config.support.SimpleBean;
+
+/**
+ * Common classes and static methods
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class Common
+{
+   public static class Holder
+   {
+      private Object object;      
+      
+      public Holder()
+      {
+      }
+
+      public Object getValue()
+      {
+         return object;
+      }
+      
+      public void setValue(Object object)
+      {
+         this.object = object;
+      }
+   }
+
+   public static class Ctor extends Holder
+   {
+      String className;
+      boolean ctorWasDeclared;
+      AbstractConstructorMetaData metaData = new AbstractConstructorMetaData();
+      ArrayList<String> paramTypes = new ArrayList<String>();
+      ArrayList<Object> argValues = new ArrayList<Object>();
+
+      public Ctor(String className)
+      {
+         this.className = className;
+      }
+
+      public boolean isCtorWasDeclared()
+      {
+         return ctorWasDeclared;
+      }
+      public void setCtorWasDeclared(boolean ctorWasDeclared)
+      {
+         this.ctorWasDeclared = ctorWasDeclared;
+      }
+      public String getClassName()
+      {
+         return className;
+      }
+      
+      public void addParam(PropertyInfo param, Object value)
+      {
+         paramTypes.add(param.getType().getName());
+         argValues.add(value);
+      }
+      public String[] getParamTypes()
+      {
+         String[] types = new String[paramTypes.size()];
+         paramTypes.toArray(types);
+         return types;
+      }
+      public Object[] getArgs()
+      {
+         Object[] args = new Object[argValues.size()];
+         argValues.toArray(args);
+         return args;
+      }
+      public AbstractConstructorMetaData getMetaData()
+      {
+         return metaData;
+      }
+      public Object newInstance()
+         throws Throwable
+      {
+         /*
+         ConstructorInfo ctorInfo = getConstructor(this);
+         Object[] args = getArgs();
+         return ctorInfo.newInstance(args);
+         */
+         return Common.newInstance(this);
+      }
+   }
+   public static class Property extends Holder
+   {
+      private String property;
+      
+      private String type;
+      
+      public Property()
+      {
+      }
+      
+      public String getProperty()
+      {
+         return property;
+      }
+      
+      public void setProperty(String property)
+      {
+         this.property = property;
+      }
+      
+      public String getType()
+      {
+         return type;
+      }
+      
+      public void setType(String type)
+      {
+         this.type = type;
+      }
+   }
+
+   static BeanInfo getBeanInfo(String name)
+      throws Throwable
+   {
+      BeanInfo beanInfo = KernelConfigInit.config.getBeanInfo(name,
+            Thread.currentThread().getContextClassLoader());
+      return beanInfo;
+   }
+   static ConstructorInfo getConstructor(Ctor ctor)
+      throws Throwable
+   {
+      BeanInfo beanInfo = getBeanInfo(ctor.getClassName());
+      String[] paramTypes = ctor.getParamTypes();
+      ClassInfo classInfo = beanInfo.getClassInfo();
+      ConstructorInfo ctorInfo = Configurator.findConstructorInfo(classInfo, paramTypes);
+      return ctorInfo;
+   }
+   static Object newInstance(Ctor ctor)
+      throws Throwable
+   {
+      AbstractBeanMetaData bmd = new AbstractBeanMetaData(SimpleBean.class.getName());
+      AbstractConstructorMetaData cmd = ctor.getMetaData();
+      bmd.setConstructor(cmd);
+      Object[] args = ctor.getArgs();
+      if( args.length > 0 )
+      {
+         String[] paramTypes = ctor.getParamTypes();
+         ArrayList<ParameterMetaData> constructorParams = new ArrayList<ParameterMetaData>();
+         for(int n = 0; n < args.length; n ++)
+         {
+            Object arg = args[n];
+            AbstractParameterMetaData pmd = new AbstractParameterMetaData(arg);
+            pmd.setType(paramTypes[n]);
+            constructorParams.add(pmd);
+         }
+         cmd.setParameters(constructorParams);
+      }
+      BeanInfo info = getBeanInfo(ctor.getClassName());
+      Joinpoint joinPoint = Configurator.getConstructorJoinPoint(KernelConfigInit.config,
+            info, cmd, bmd);
+      return joinPoint.dispatch();
+   }
+
+   static PropertyInfo getProperty(Object parent, String property, String type) throws Throwable
+   {
+      BeanInfo beanInfo = KernelConfigInit.config.getBeanInfo(parent.getClass());
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      return Configurator.resolveProperty(false, beanInfo, cl, property, type);
+   }
+   static PropertyInfo getProperty(String className, String property, String type)
+      throws Throwable
+   {
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      BeanInfo beanInfo = KernelConfigInit.config.getBeanInfo(className, cl);            
+      return Configurator.resolveProperty(false, beanInfo, cl, property, type);
+   }
+
+   /**
+    * Convert a value
+    * 
+    * @param info the property info
+    * @param override the override class
+    * @param value the value
+    * @return the converted value
+    * @throws Throwable for any error
+    */
+   static Object convertValue(PropertyInfo info, String override, Object value) throws Throwable
+   {
+      TypeInfo type = info.getType();
+      if (override != null)
+         type = KernelConfigInit.typeInfoFactory.getTypeInfo(override, null);
+      return type.convertValue(value);
+   }
+
+}


Property changes on: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/Common.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/ConstructorHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/ConstructorHandler.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/ConstructorHandler.java	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.config.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.kernel.plugins.config.xml.Common.Ctor;
+import org.jboss.kernel.plugins.config.xml.Common.Holder;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * Handler for the constructor element.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 43020 $
+ */
+public class ConstructorHandler extends DefaultElementHandler
+{
+   /** The handler */
+   public static final ConstructorHandler HANDLER = new ConstructorHandler();
+
+   public Object startElement(Object parent, QName name, ElementBinding element)
+   {
+      Holder holder = (Holder) parent;
+      Ctor ctor = (Ctor) holder.getValue();
+      ctor.setCtorWasDeclared(true);
+      return holder;
+   }
+
+   public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+   {
+      Holder holder = (Holder) o;
+      Ctor ctor = (Ctor) holder.getValue();
+      AbstractConstructorMetaData constructor = ctor.getMetaData();
+      for (int i = 0; i < attrs.getLength(); ++i)
+      {
+         String localName = attrs.getLocalName(i);
+         if ("factoryClass".equals(localName))
+            constructor.setFactoryClass(attrs.getValue(i));
+         else if ("factoryMethod".equals(localName))
+            constructor.setFactoryMethod(attrs.getValue(i));
+      }
+      if( constructor.getFactoryMethod() != null && constructor.getFactoryClass() == null )
+         constructor.setFactoryClass(ctor.getClassName());
+   }
+
+   public Object endElement(Object o, QName qName, ElementBinding element)
+   {
+      Holder holder = (Holder) o;
+      Ctor ctor = (Ctor) holder.getValue();
+      try
+      {
+         Object bean = ctor.newInstance();
+         return bean;
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      catch (Error e)
+      {
+         throw e;
+      }
+      catch (Throwable t)
+      {
+         throw new RuntimeException("Error instantiating class " + ctor.getClassName(), t);
+      }
+
+   }
+}
+


Property changes on: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/ConstructorHandler.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/ConstructorInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/ConstructorInterceptor.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/ConstructorInterceptor.java	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.config.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.kernel.plugins.config.xml.Common.Holder;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * Set the parent Holder value to the Ctor of the constructor element. 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ConstructorInterceptor extends DefaultElementInterceptor
+{
+   /** The interceptor */
+   public static final ConstructorInterceptor INTERCEPTOR = new ConstructorInterceptor();
+   
+   public void add(Object parent, Object child, QName name)
+   {
+      Holder holder = (Holder) parent;
+      holder.setValue(child);
+   }
+}


Property changes on: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/ConstructorInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanHandler.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanHandler.java	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.config.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.kernel.plugins.config.xml.Common.Ctor;
+import org.jboss.kernel.plugins.config.xml.Common.Holder;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * Handler for the javabean element.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 43020 $
+ */
+public class JavaBeanHandler extends DefaultElementHandler
+{
+   /** The handler */
+   public static final JavaBeanHandler HANDLER = new JavaBeanHandler();
+
+   public Object startElement(Object parent, QName name, ElementBinding element)
+   {
+      return new Holder();
+   }
+
+   public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+   {
+      Holder holder = (Holder) o;
+      String className = null;
+      for (int i = 0; i < attrs.getLength(); ++i)
+      {
+         String localName = attrs.getLocalName(i);
+         if ("class".equals(localName))
+            className = attrs.getValue(i);
+      }
+      
+      if (className == null)
+         throw new IllegalArgumentException("No class attribute for " + elementName);
+      
+      try
+      {
+         Ctor ctor = new Ctor(className);
+         holder.setValue(ctor);
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      catch (Error e)
+      {
+         throw e;
+      }
+      catch (Throwable t)
+      {
+         throw new RuntimeException("Error instantiating class " + className, t);
+      }
+   }
+
+   public Object endElement(Object o, QName qName, ElementBinding element)
+   {
+      Holder holder = (Holder) o;
+      return holder.getValue();
+   }
+}
+


Property changes on: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanHandler.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanSchemaInitializer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanSchemaInitializer.java	2007-01-18 07:30:31 UTC (rev 59747)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanSchemaInitializer.java	2007-01-18 07:31:49 UTC (rev 59748)
@@ -23,20 +23,19 @@
 
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
-import java.security.AccessController;
-import java.security.PrivilegedExceptionAction;
 
 import org.jboss.beans.info.spi.BeanInfo;
 import org.jboss.beans.info.spi.PropertyInfo;
 import org.jboss.kernel.plugins.config.Configurator;
-import org.jboss.kernel.plugins.config.property.PropertyKernelConfig;
-import org.jboss.kernel.spi.config.KernelConfig;
-import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory;
+import org.jboss.kernel.plugins.config.xml.Common.Holder;
+import org.jboss.kernel.plugins.config.xml.Common.Property;
 import org.jboss.reflect.spi.MethodInfo;
-import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.reflect.spi.TypeInfoFactory;
-import org.jboss.util.propertyeditor.PropertyEditors;
-import org.jboss.xb.binding.sunday.unmarshalling.*;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingInitializer;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
 import org.xml.sax.Attributes;
 
 /**
@@ -47,11 +46,6 @@
  */
 public class JavaBeanSchemaInitializer implements SchemaBindingInitializer
 {
-   /** The kernel config */
-   private static final KernelConfig config;
-   /** The type info factory */
-   protected static final TypeInfoFactory typeInfoFactory = new IntrospectionTypeInfoFactory();
-
    /** The namespace */
    private static final String JAVABEAN_NS = "urn:jboss:javabean:1.0";
 
@@ -66,26 +60,7 @@
 
    static
    {
-      try
-      {
-         config = AccessController.doPrivileged(new PrivilegedExceptionAction<KernelConfig>()
-         {
-            public KernelConfig run() throws Exception
-            {
-               return new PropertyKernelConfig(System.getProperties());
-            }
-         });
-      }
-      catch (RuntimeException e)
-      {
-         throw e;
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException("Error getting configuration", e);
-      }
-      
-      PropertyEditors.init();
+      KernelConfigInit.init();
    }
 
    public SchemaBinding init(SchemaBinding schema)
@@ -116,8 +91,8 @@
             
             try
             {
-               BeanInfo beanInfo = config.getBeanInfo(className, Thread.currentThread().getContextClassLoader());
-               Object object = Configurator.instantiate(config, beanInfo, null);
+               BeanInfo beanInfo = KernelConfigInit.config.getBeanInfo(className, Thread.currentThread().getContextClassLoader());
+               Object object = Configurator.instantiate(KernelConfigInit.config, beanInfo, null);
                holder.setValue(object);
             }
             catch (RuntimeException e)
@@ -156,8 +131,8 @@
             Object value = prop.getValue();
             try
             {
-               PropertyInfo info = getProperty(parentValue, property, prop.getType());
-               value = convertValue(info, prop.getType(), value);
+               PropertyInfo info = Common.getProperty(parentValue, property, prop.getType());
+               value = Common.convertValue(info, prop.getType(), value);
                method = info.getSetter();
                method.invoke(parentValue, new Object[] { value });
             }
@@ -203,77 +178,4 @@
       return schema;
    }
    
-   private PropertyInfo getProperty(Object parent, String property, String type) throws Throwable
-   {
-      BeanInfo beanInfo = config.getBeanInfo(parent.getClass());
-      ClassLoader cl = Thread.currentThread().getContextClassLoader();
-      return Configurator.resolveProperty(false, beanInfo, cl, property, type);
-   }
-
-   /**
-    * Convert a value
-    * 
-    * @param info the property info
-    * @param override the override class
-    * @param value the value
-    * @return the converted value
-    * @throws Throwable for any error
-    */
-   private Object convertValue(PropertyInfo info, String override, Object value) throws Throwable
-   {
-      TypeInfo type = info.getType();
-      if (override != null)
-         type = typeInfoFactory.getTypeInfo(override, null);
-      return type.convertValue(value);
-   }
-   
-   public static class Holder
-   {
-      private Object object;
-      
-      public Holder()
-      {
-      }
-      
-      public Object getValue()
-      {
-         return object;
-      }
-      
-      public void setValue(Object object)
-      {
-         this.object = object;
-      }
-   }
-   
-   public static class Property extends Holder
-   {
-      private String property;
-      
-      private String type;
-      
-      public Property()
-      {
-      }
-      
-      public String getProperty()
-      {
-         return property;
-      }
-      
-      public void setProperty(String property)
-      {
-         this.property = property;
-      }
-      
-      public String getType()
-      {
-         return type;
-      }
-      
-      public void setType(String type)
-      {
-         this.type = type;
-      }
-   }
 }

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanSchemaInitializer20.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanSchemaInitializer20.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanSchemaInitializer20.java	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,86 @@
+/*
+* 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.config.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingInitializer;
+import org.jboss.xb.binding.sunday.unmarshalling.TypeBinding;
+
+/**
+ * JavaBeanSchemaInitializer version 2.0. This extends the
+ * urn:jboss:javabean:1.0 schema by adding a constructor element to
+ * specify the javabean constructor to use. 
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 59176 $
+ */
+public class JavaBeanSchemaInitializer20 implements SchemaBindingInitializer
+{
+   /** The namespace */
+   private static final String JAVABEAN_NS = "urn:jboss:javabean:2.0";
+
+   /** The javabean binding */
+   private static final QName javabeanTypeQName = new QName(JAVABEAN_NS, "javabeanType");
+
+   /** The constructor binding */
+   private static final QName constructorTypeQName = new QName(JAVABEAN_NS, "constructorType");
+
+   /** The property binding */
+   private static final QName propertyTypeQName = new QName(JAVABEAN_NS, "propertyType");
+
+   /** The constructor element name */
+   private static final QName constructorQName = new QName(JAVABEAN_NS, "constructor");
+
+   /** The property element name */
+   private static final QName propertyQName = new QName(JAVABEAN_NS, "property");
+
+   static
+   {
+      KernelConfigInit.init();
+   }
+
+   public SchemaBinding init(SchemaBinding schema)
+   {
+      // javabean binding
+      TypeBinding beanType = schema.getType(javabeanTypeQName);
+      beanType.setHandler(JavaBeanHandler.HANDLER);
+      // bean has constructor
+      beanType.pushInterceptor(constructorQName, ConstructorInterceptor.INTERCEPTOR);
+      // bean has properties
+      beanType.pushInterceptor(propertyQName, PropertyInterceptor.INTERCEPTOR);
+
+      // constructor binding
+      TypeBinding constructorType = schema.getType(constructorTypeQName);
+      constructorType.setHandler(ConstructorHandler.HANDLER);
+      // constructor has properties
+      constructorType.pushInterceptor(propertyQName, PropertyInterceptor.INTERCEPTOR);
+
+      // property binding
+      TypeBinding propertyType = schema.getType(propertyTypeQName);
+      propertyType.setHandler(PropertyHandler.HANDLER);
+
+      return schema;
+   }
+}


Property changes on: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/JavaBeanSchemaInitializer20.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/KernelConfigInit.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/KernelConfigInit.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/KernelConfigInit.java	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.config.xml;
+
+import java.security.AccessController;
+import java.security.PrivilegedExceptionAction;
+
+import org.jboss.kernel.plugins.config.property.PropertyKernelConfig;
+import org.jboss.kernel.spi.config.KernelConfig;
+import org.jboss.reflect.plugins.introspection.IntrospectionTypeInfoFactory;
+import org.jboss.reflect.spi.TypeInfoFactory;
+import org.jboss.util.propertyeditor.PropertyEditors;
+
+/**
+ * Initialize the KernelConfig and TypeInfoFactory.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class KernelConfigInit
+{
+   /** The kernel config */
+   static KernelConfig config;
+   /** The type info factory */
+   static final TypeInfoFactory typeInfoFactory = new IntrospectionTypeInfoFactory();
+
+   static synchronized void init()
+   {
+      if( config == null )
+      {
+         try
+         {
+            config = AccessController.doPrivileged(new PrivilegedExceptionAction<KernelConfig>()
+            {
+               public KernelConfig run() throws Exception
+               {
+                  return new PropertyKernelConfig(System.getProperties());
+               }
+            });
+         }
+         catch (RuntimeException e)
+         {
+            throw e;
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Error getting configuration", e);
+         }
+         
+         PropertyEditors.init();
+      }
+   }
+}


Property changes on: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/KernelConfigInit.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/PropertyHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/PropertyHandler.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/PropertyHandler.java	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.config.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.kernel.plugins.config.xml.Common.Property;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * Handler for the property element.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 43020 $
+ */
+public class PropertyHandler extends DefaultElementHandler
+{
+   /** The handler */
+   public static final PropertyHandler HANDLER = new PropertyHandler();
+
+   public Object startElement(Object parent, QName name, ElementBinding element)
+   {
+      return new Property();
+   }
+
+   public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+   {
+      Property property = (Property) o;
+      for (int i = 0; i < attrs.getLength(); ++i)
+      {
+         String localName = attrs.getLocalName(i);
+         if ("name".equals(localName))
+            property.setProperty(attrs.getValue(i));
+         else if ("class".equals(localName))
+            property.setType(attrs.getValue(i));
+      }
+   }
+}
+


Property changes on: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/PropertyHandler.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/PropertyInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/PropertyInterceptor.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/PropertyInterceptor.java	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.config.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.kernel.plugins.config.xml.Common.Ctor;
+import org.jboss.kernel.plugins.config.xml.Common.Holder;
+import org.jboss.kernel.plugins.config.xml.Common.Property;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * Interceptor for the property element that adds the Property to the
+ * Holder parent.
+ * 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class PropertyInterceptor extends DefaultElementInterceptor
+{
+   /** The interceptor */
+   public static final PropertyInterceptor INTERCEPTOR = new PropertyInterceptor();
+
+
+   /**
+    * Add a property to the bean. If the parent value is a Ctor the bean
+    * had no explicit contstructor element and the instance must be created by
+    * the default ctor. Otherwise, the property is added to teh Ctor as
+    * params.
+    * 
+    * If the parent value is not a Ctor the Property is a value to set on
+    * the bean.
+    * 
+    * @param parent Holder containing either a Ctor or javabean instance.
+    * @param child - the Property instance to add
+    */
+   public void add(Object parent, Object child, QName name)
+   {
+      Holder holder = (Holder) parent;
+      Object parentValue = holder.getValue();
+      Property prop = (Property) child;
+      Object value = prop.getValue();
+      String property = prop.getProperty();
+
+      try
+      {
+         if( parentValue instanceof Ctor )
+         {
+            Ctor ctor = (Ctor) parentValue;
+            if( ctor.isCtorWasDeclared() )
+            {
+               PropertyInfo info = Common.getProperty(ctor.getClassName(), property, prop.getType());
+               value = Common.convertValue(info, prop.getType(), value);
+               ctor.addParam(info, value);
+            }
+            else
+            {
+               // There was no explicit ctor to create the bean and reset the parent value
+               parentValue = ctor.newInstance();
+               holder.setValue(parentValue);
+               add(parent, child, name);
+            }
+         }
+         else
+         {   
+            MethodInfo method;
+            PropertyInfo info = Common.getProperty(parentValue, property, prop.getType());
+            value = Common.convertValue(info, prop.getType(), value);
+            method = info.getSetter();
+            method.invoke(parentValue, new Object[] { value });
+         }
+      }
+      catch (RuntimeException e)
+      {
+         throw e;
+      }
+      catch (Error e)
+      {
+         throw e;
+      }
+      catch (Throwable t)
+      {
+         throw new RuntimeException("Error setting property " + property + " on object" + parentValue + " with value " + value, t);
+      }
+   }
+
+}


Property changes on: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/config/xml/PropertyInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20.xml	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:2.0" class="org.jboss.test.javabean.support.SimpleBean">
+   <property name="AString">StringValue</property>
+   <property name="AByte">12</property>
+   <property name="ABoolean">true</property>
+   <property name="AShort">123</property>
+   <property name="anInt">1234</property>
+   <property name="ALong">12345</property>
+   <property name="AFloat">3.14</property>
+   <property name="ADouble">3.14e12</property>
+   <!--<property name="ADate">Mon Jan 01 00:00:00 CET 2001</property>-->
+   <property name="ADate">Jan 01 00:00:00 CET 2001</property>
+   <property name="ABigDecimal">12e4</property>
+   <property name="ABigInteger">123456</property>
+   <property name="abyte">12</property>
+   <property name="aboolean">true</property>
+   <property name="ashort">123</property>
+   <property name="anint">1234</property>
+   <property name="along">12345</property>
+   <property name="afloat">3.14</property>
+   <property name="adouble">3.14e12</property>
+   <property name="ANumber" class="java.lang.Long">12345</property>
+   <property name="overloadedProperty">StringValue</property>
+   <property name="XYZ">XYZ</property>
+   <property name="abc">abc</property>
+</javabean>


Property changes on: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20.xml
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtor.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtor.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtor.xml	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:2.0"
+   class="org.jboss.test.javabean.support.SimpleBean">
+   <!--
+      public SimpleBean(Object anObject, String string, Byte byte1,
+      Boolean boolean1, Character character, Short short1,
+      Integer anInt, Long long1, Float float1, Double double1,
+      Date date, BigDecimal bigDecimal, BigInteger bigInteger,
+      byte abyte, boolean aboolean, char achar, short ashort,
+      int anint2, long along, float afloat, double adouble,
+      Number number, String overloadedProperty, String xyz, String abc)      
+   -->
+   <constructor>
+      <!-- The name is not used for parameter matching, its just for info -->
+      <property name="anObject">anObjectValue</property>
+      <property name="AString">StringValue</property>
+      <property name="AByte">12</property>
+      <property name="ABoolean">true</property>
+      <property name="ACharacter">x</property>      
+      <property name="AShort">123</property>
+      <property name="anInt">1234</property>
+      <property name="ALong">12345</property>
+      <property name="AFloat">3.14</property>
+      <property name="ADouble">3.14e12</property>
+      <property name="ADate">Jan 01 00:00:00 CET 2001</property>
+      <property name="ABigDecimal">12e4</property>
+      <property name="ABigInteger">123456</property>
+      <property name="abyte">12</property>
+      <property name="aboolean">true</property>
+      <property name="achar">y</property>
+      <property name="ashort">123</property>
+      <property name="anint">1234</property>
+      <property name="along">12345</property>
+      <property name="afloat">3.14</property>
+      <property name="adouble">3.14e12</property>
+      <property name="ANumber" class="java.lang.Long">12345</property>
+      <property name="overloadedProperty">StringValue</property>
+      <property name="XYZ">XYZ</property>
+      <property name="abc">abc</property>
+   </constructor>
+</javabean>


Property changes on: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtor.xml
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClass.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClass.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClass.xml	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:2.0"
+    class="org.jboss.test.javabean.support.SimpleBean">
+    <!--
+        public SimpleBean(Object anObject, String string, Byte byte1,
+        Boolean boolean1, Character character, Short short1,
+        Integer anInt, Long long1, Float float1, Double double1,
+        Date date, BigDecimal bigDecimal, BigInteger bigInteger,
+        byte abyte, boolean aboolean, char achar, short ashort,
+        int anint2, long along, float afloat, double adouble,
+        Number number, String overloadedProperty, String xyz, String abc)      
+    -->
+    <constructor factoryClass="org.jboss.test.javabean.support.SimpleBeanFactory"
+        factoryMethod="newInstance" />
+
+    <property name="anObject">anObjectValue</property>
+    <property name="AString">StringValue</property>
+    <property name="AByte">12</property>
+    <property name="ABoolean">true</property>
+    <property name="ACharacter">x</property>      
+    <property name="AShort">123</property>
+    <property name="anInt">1234</property>
+    <property name="ALong">12345</property>
+    <property name="AFloat">3.14</property>
+    <property name="ADouble">3.14e12</property>
+    <property name="ADate">Jan 01 00:00:00 CET 2001</property>
+    <property name="ABigDecimal">12e4</property>
+    <property name="ABigInteger">123456</property>
+    <property name="abyte">12</property>
+    <property name="aboolean">true</property>
+    <property name="achar">y</property>
+    <property name="ashort">123</property>
+    <property name="anint">1234</property>
+    <property name="along">12345</property>
+    <property name="afloat">3.14</property>
+    <property name="adouble">3.14e12</property>
+    <property name="ANumber" class="java.lang.Long">12345</property>
+    <property name="overloadedProperty">StringValue</property>
+    <property name="XYZ">XYZ</property>
+    <property name="abc">abc</property>
+</javabean>


Property changes on: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClass.xml
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClassAndParams.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClassAndParams.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClassAndParams.xml	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:2.0"
+    class="org.jboss.test.javabean.support.SimpleBean">
+    <!--
+        public SimpleBean(Object anObject, String string, Byte byte1,
+        Boolean boolean1, Character character, Short short1,
+        Integer anInt, Long long1, Float float1, Double double1,
+        Date date, BigDecimal bigDecimal, BigInteger bigInteger,
+        byte abyte, boolean aboolean, char achar, short ashort,
+        int anint2, long along, float afloat, double adouble,
+        Number number, String overloadedProperty, String xyz, String abc)      
+    -->
+    <constructor factoryClass="org.jboss.test.javabean.support.SimpleBeanFactory"
+        factoryMethod="newInstance">
+        <!-- The name is not used for parameter matching, its just for info -->
+        <property name="anObject" class="java.lang.Object">anObjectValue</property>
+        <property name="AString">StringValue</property>
+        <property name="AByte">12</property>
+        <property name="ABoolean">true</property>
+        <property name="ACharacter">x</property>      
+        <property name="AShort">123</property>
+        <property name="anInt">1234</property>
+        <property name="ALong">12345</property>
+        <property name="AFloat">3.14</property>
+        <property name="ADouble">3.14e12</property>
+        <property name="ADate">Jan 01 00:00:00 CET 2001</property>
+        <property name="ABigDecimal">12e4</property>
+        <property name="ABigInteger">123456</property>
+        <property name="abyte">12</property>
+        <property name="aboolean">true</property>
+        <property name="achar">y</property>
+        <property name="ashort">123</property>
+        <property name="anint">1234</property>
+        <property name="along">12345</property>
+        <property name="afloat">3.14</property>
+        <property name="adouble">3.14e12</property>
+        <property name="ANumber" class="java.lang.Long">12345</property>
+        <property name="overloadedProperty">StringValue</property>
+        <property name="XYZ">XYZ</property>
+        <property name="abc">abc</property>
+    </constructor>
+</javabean>


Property changes on: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClassAndParams.xml
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Added: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorFactory.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorFactory.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorFactory.xml	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:2.0"
+   class="org.jboss.test.javabean.support.SimpleBean">
+   <!--
+      public SimpleBean(Object anObject, String string, Byte byte1,
+      Boolean boolean1, Character character, Short short1,
+      Integer anInt, Long long1, Float float1, Double double1,
+      Date date, BigDecimal bigDecimal, BigInteger bigInteger,
+      byte abyte, boolean aboolean, char achar, short ashort,
+      int anint2, long along, float afloat, double adouble,
+      Number number, String overloadedProperty, String xyz, String abc)      
+   -->
+   <constructor factoryMethod="getInstance">
+      <!-- The name is not used for parameter matching, its just for info -->
+      <property name="anObject" class="java.lang.Object">anObjectValue</property>
+      <property name="AString">StringValue</property>
+      <property name="AByte">12</property>
+      <property name="ABoolean">true</property>
+      <property name="ACharacter">x</property>      
+      <property name="AShort">123</property>
+      <property name="anInt">1234</property>
+      <property name="ALong">12345</property>
+      <property name="AFloat">3.14</property>
+      <property name="ADouble">3.14e12</property>
+      <property name="ADate">Jan 01 00:00:00 CET 2001</property>
+      <property name="ABigDecimal">12e4</property>
+      <property name="ABigInteger">123456</property>
+      <property name="abyte">12</property>
+      <property name="aboolean">true</property>
+      <property name="achar">y</property>
+      <property name="ashort">123</property>
+      <property name="anint">1234</property>
+      <property name="along">12345</property>
+      <property name="afloat">3.14</property>
+      <property name="adouble">3.14e12</property>
+      <property name="ANumber" class="java.lang.Long">12345</property>
+      <property name="overloadedProperty">StringValue</property>
+      <property name="XYZ">XYZ</property>
+      <property name="abc">abc</property>
+   </constructor>
+</javabean>


Property changes on: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorFactory.xml
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Modified: projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/deployment/xml/test/SetWithWildcard.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/deployment/xml/test/SetWithWildcard.xml	2007-01-18 07:30:31 UTC (rev 59747)
+++ projects/microcontainer/trunk/kernel/src/resources/org/jboss/test/kernel/deployment/xml/test/SetWithWildcard.xml	2007-01-18 07:31:49 UTC (rev 59748)
@@ -4,6 +4,7 @@
    <property name="PropertyName">
       <set>
          <javabean xmlns="urn:jboss:javabean:1.0" class="java.lang.Object"/>
+         <javabean xmlns="urn:jboss:javabean:1.0" class="org.jboss.test.javabean.support.SimpleBean" />
       </set>
    </property>
 </bean>

Added: projects/microcontainer/trunk/kernel/src/resources/schema/javabean_2_0.xsd
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/schema/javabean_2_0.xsd	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/schema/javabean_2_0.xsd	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- An xsd schema for javabeans
+$Id: javabean_1_0.xsd 59176 2006-12-20 11:56:02Z alesj $
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+   targetNamespace="urn:jboss:javabean:2.0"
+   xmlns="urn:jboss:javabean:2.0"
+   elementFormDefault="qualified"
+   attributeFormDefault="unqualified"
+   version="1.0"
+>
+   <xsd:annotation>
+      <xsd:documentation>
+         <![CDATA[
+         A schema for constructing javabeans. This extends the 1.0
+         syntax to support constructor specifications.
+
+         <javabean xmlns="urn:jboss:javabean:2.0"
+                   class="com.acme.MyJavaBean">
+            <property name="someProperty">SomeValue</property>
+         ...
+         ]]>
+      </xsd:documentation>
+   </xsd:annotation>
+
+   <xsd:element name="javabean" type="javabeanType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           The root of the javabean document
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+   </xsd:element>
+
+   <xsd:complexType name="javabeanType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           The javabean contains a set of properties.
+           
+           e.g.
+           <javabean class="com.acme.SomeJavaBean">
+              <constructor .../>
+              <property .../>
+              <property .../>    
+           </javabean>
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:sequence>
+         <xsd:element name="constructor" type="constructorType" minOccurs="0" maxOccurs="1"/>
+         <xsd:element name="property" type="propertyType" minOccurs="0" maxOccurs="unbounded"/>
+      </xsd:sequence>
+      <xsd:attribute name="class" type="xsd:token" use="required"/>
+   </xsd:complexType>
+
+   <xsd:complexType name="constructorType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+           The constructor for a javabean instance.
+           
+           e.g. simple constructor - new POJO(new String("String value"));
+           <javabean class="com.acme.POJO">
+              <constructor>
+                 <property>String value</property>
+              </constructor>
+           </javabean>
+
+           e.g. static factory - com.acme.Factory.newInstance(new String("String value"));
+           <bean name="MyBean" class="com.acme.POJO">
+              <constructor factoryClass="com.acme.Factory" factoryMethod="newInstance">
+                 <property>String value</property>
+              </constructor>
+           </bean>
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:sequence>
+         <xsd:element name="property" type="propertyType" minOccurs="1" maxOccurs="unbounded"/>
+      </xsd:sequence>
+      <xsd:attribute name="factoryClass" type="classNameType" use="optional"/>
+      <xsd:attribute name="factoryMethod" type="xsd:token" use="optional"/>
+   </xsd:complexType>
+   
+   <xsd:complexType name="propertyType" mixed="true">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           A property defines values passed to the setters.
+           
+           e.g. Using the type from the setter argument
+           <javabean ...>
+              <property name="someProperty">Some value</property>
+           </javabean>
+           
+           e.g. Overridding the injected type
+           <javabean ...>
+              <property name="someProperty" class="java.lang.String">Some value</property>
+           </javabean>
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:complexContent>
+         <xsd:extension base="valueType"/>
+      </xsd:complexContent>
+   </xsd:complexType>
+
+   <xsd:simpleType name="classNameType">
+      <xsd:annotation>
+         <xsd:documentation> The elements that use this type designate the name
+            of a Java class or interface. The name is in the form of a "binary
+            name", as defined in the JLS and as used in Class.forName().
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:restriction base="xsd:string">
+         <xsd:whiteSpace value="collapse"/>
+      </xsd:restriction>
+   </xsd:simpleType>
+
+   <xsd:complexType name="valueType" mixed="true">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           A simple value with an optional class name
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:attribute name="class" type="classNameType" use="optional"/>
+   </xsd:complexType>
+
+</xsd:schema>

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/support/SimpleBean.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/support/SimpleBean.java	2007-01-18 07:30:31 UTC (rev 59747)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/support/SimpleBean.java	2007-01-18 07:31:49 UTC (rev 59748)
@@ -35,6 +35,7 @@
 {
    /** Constructor used */
    private String constructorUsed;
+   private String factoryUsed;
 
    /** Object */
    private Object anObject;
@@ -111,12 +112,81 @@
    {
       constructorUsed = "()";
    }
+   public SimpleBean(String aString)
+   {
+      constructorUsed = "(String)";
+      this.aString = aString;
+   }
 
+   public static SimpleBean getInstance(Object anObject, String string, Byte byte1,
+         Boolean boolean1, Character character, Short short1,
+         Integer anInt, Long long1, Float float1, Double double1,
+         Date date, BigDecimal bigDecimal, BigInteger bigInteger,
+         byte abyte, boolean aboolean, char achar, short ashort,
+         int anint2, long along, float afloat, double adouble,
+         Number number, String overloadedProperty, String xyz, String abc)
+   {
+      SimpleBean bean = new SimpleBean(anObject, string, byte1,
+            boolean1, character, short1,
+            anInt, long1, float1, double1,
+            date, bigDecimal, bigInteger,
+            abyte, aboolean, achar, ashort,
+            anint2, along, afloat, adouble,
+            number, overloadedProperty, xyz, abc);
+      bean.factoryUsed = "getInstance(<all-fields>)";
+      return bean;
+   }
+
+   public SimpleBean(Object anObject, String string, Byte byte1,
+         Boolean boolean1, Character character, Short short1,
+         Integer anInt, Long long1, Float float1, Double double1,
+         Date date, BigDecimal bigDecimal, BigInteger bigInteger,
+         byte abyte, boolean aboolean, char achar, short ashort,
+         int anint2, long along, float afloat, double adouble,
+         Number number, String overloadedProperty, String xyz, String abc)
+   {
+      constructorUsed = "(<all-fields>)";
+      this.anObject = anObject;
+      aString = string;
+      aByte = byte1;
+      aBoolean = boolean1;
+      aCharacter = character;
+      aShort = short1;
+      this.anInt = anInt;
+      aLong = long1;
+      aFloat = float1;
+      aDouble = double1;
+      aDate = date;
+      aBigDecimal = bigDecimal;
+      aBigInteger = bigInteger;
+      this.abyte = abyte;
+      this.aboolean = aboolean;
+      this.achar = achar;
+      this.ashort = ashort;
+      anint = anint2;
+      this.along = along;
+      this.afloat = afloat;
+      this.adouble = adouble;
+      aNumber = number;
+      this.overloadedProperty = overloadedProperty;
+      this.xyz = xyz;
+      this.abc = abc;
+   }
+
    public String getConstructorUsed()
    {
       return constructorUsed;
    }
 
+   public String getFactoryUsed()
+   {
+      return factoryUsed;
+   }
+   public void setFactoryUsed(String factoryUsed)
+   {
+      this.factoryUsed = factoryUsed;
+   }
+
    public Object getAnObject()
    {
       return anObject;

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/support/SimpleBeanFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/support/SimpleBeanFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/support/SimpleBeanFactory.java	2007-01-18 07:31:49 UTC (rev 59748)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * 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.javabean.support;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+/**
+ * Factory for javabean tests.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SimpleBeanFactory
+{
+   public static SimpleBean newInstance()
+   {
+      SimpleBean bean = new SimpleBean();
+      bean.setFactoryUsed("SimpleBeanFactory.newInstance()");
+      return bean;      
+   }
+   public static SimpleBean newInstance(Object anObject, String string, Byte byte1,
+         Boolean boolean1, Character character, Short short1,
+         Integer anInt, Long long1, Float float1, Double double1,
+         Date date, BigDecimal bigDecimal, BigInteger bigInteger,
+         byte abyte, boolean aboolean, char achar, short ashort,
+         int anint2, long along, float afloat, double adouble,
+         Number number, String overloadedProperty, String xyz, String abc)
+   {
+      SimpleBean bean = new SimpleBean(anObject, string, byte1,
+            boolean1, character, short1,
+            anInt, long1, float1, double1,
+            date, bigDecimal, bigInteger,
+            abyte, aboolean, achar, ashort,
+            anint2, along, afloat, adouble,
+            number, overloadedProperty, xyz, abc);
+      bean.setFactoryUsed("SimpleBeanFactory.newInstance(<all-fields>)");
+      return bean;
+   }
+}


Property changes on: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/support/SimpleBeanFactory.java
___________________________________________________________________
Name: svn:keywords
   + Id,Revision
Name: svn:eol-style
   + native

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/test/PropertyTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/test/PropertyTestCase.java	2007-01-18 07:30:31 UTC (rev 59747)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/javabean/test/PropertyTestCase.java	2007-01-18 07:31:49 UTC (rev 59748)
@@ -65,11 +65,80 @@
 
    public void testConfigure() throws Exception
    {
+      // check bean
+      SimpleBean bean = unmarshal("TestConfigure.xml", SimpleBean.class);
+      validateFields("()", null, bean);
+   }
+
+   public void testConfigure20() throws Exception
+   {
+      // check bean
+      SimpleBean bean = unmarshal("TestConfigure20.xml", SimpleBean.class);
+      validateFields("()", null, bean);
+   }
+
+   public void testConfigure20WithCtor() throws Exception
+   {
+      // check bean
+      SimpleBean bean = unmarshal("TestConfigure20WithCtor.xml", SimpleBean.class);
+      validateFields("(<all-fields>)", null, bean);
+   }
+
+   public void testConfigure20WithCtorFactory() throws Exception
+   {
+      // check bean
+      SimpleBean bean = unmarshal("TestConfigure20WithCtorFactory.xml", SimpleBean.class);
+      validateFields("(<all-fields>)", "getInstance(<all-fields>)", bean);
+   }
+
+   public void testConfigure20WithCtorExplicitFactoryClass() throws Exception
+   {
+      // check bean
+      SimpleBean bean = unmarshal("TestConfigure20WithCtorExplicitFactoryClass.xml", SimpleBean.class);
+      validateFields("()", "SimpleBeanFactory.newInstance()", bean);
+   }
+   public void testConfigure20WithCtorExplicitFactoryClassAndParams() throws Exception
+   {
+      // check bean
+      SimpleBean bean = unmarshal("TestConfigure20WithCtorExplicitFactoryClassAndParams.xml", SimpleBean.class);
+      validateFields("(<all-fields>)", "SimpleBeanFactory.newInstance(<all-fields>)", bean);
+   }
+
+
+   /**
+    * Validate the JavaBean property name introspection
+    * @throws Exception
+    */
+   public void testJavaBeanMatching() throws Exception
+   {
+      BeanInfo info = Introspector.getBeanInfo(SimpleBean.class);
+      PropertyDescriptor[] props = info.getPropertyDescriptors();
+      HashMap<String, PropertyDescriptor> propMap = new HashMap<String, PropertyDescriptor>();
+      for(PropertyDescriptor pd : props)
+      {
+         propMap.put(pd.getName(), pd);
+      }
+      assertNotNull("Has XYZ", propMap.get("XYZ"));
+      assertNull("Does not have xYZ", propMap.get("xYZ"));
+   }
+
+   @Override
+   protected Object unmarshal(String name) throws Exception
+   {
       // tmp format
       System.setProperty("org.jboss.util.propertyeditor.DateEditor.format", "MMM d HH:mm:ss z yyyy");
+      // TODO Auto-generated method stub
+      return super.unmarshal(name);
+   }
+
+   protected void validateFields(String ctor, String factory, SimpleBean bean)
+   {
       // check bean
-      SimpleBean bean = unmarshal("TestConfigure.xml", SimpleBean.class);
-      assertEquals("()", bean.getConstructorUsed());
+      assertEquals(ctor, bean.getConstructorUsed());
+      if( factory == null )
+         assertTrue("factory == null", bean.getFactoryUsed() == null);
+      else
+         assertEquals(factory, bean.getFactoryUsed());
 
       assertEquals(stringValue, bean.getAString());
       assertEquals(byteValue, bean.getAByte());
@@ -99,26 +168,9 @@
       assertEquals(stringValue, bean.getOverloadedProperty());
       // An all uppercase property
       assertEquals("XYZ", bean.getXYZ());
-      assertEquals("abc", bean.getAbc());
+      assertEquals("abc", bean.getAbc());      
    }
 
-   /**
-    * Validate the JavaBean property name introspection
-    * @throws Exception
-    */
-   public void testJavaBeanMatching() throws Exception
-   {
-      BeanInfo info = Introspector.getBeanInfo(SimpleBean.class);
-      PropertyDescriptor[] props = info.getPropertyDescriptors();
-      HashMap<String, PropertyDescriptor> propMap = new HashMap<String, PropertyDescriptor>();
-      for(PropertyDescriptor pd : props)
-      {
-         propMap.put(pd.getName(), pd);
-      }
-      assertNotNull("Has XYZ", propMap.get("XYZ"));
-      assertNull("Does not have xYZ", propMap.get("xYZ"));
-   }
-
    protected Date createDate(String date)
    {
       try




More information about the jboss-cvs-commits mailing list