[jboss-svn-commits] JBoss Common SVN: r2714 - in jbossxb/trunk: src/main and 15 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Mar 3 10:37:06 EST 2008
Author: adrian at jboss.org
Date: 2008-03-03 10:37:06 -0500 (Mon, 03 Mar 2008)
New Revision: 2714
Added:
jbossxb/trunk/src/main/java/org/jboss/javabean/
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/Constructor.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBean.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBean10.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBean20.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanBuilder10.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanBuilder20.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanFactory10.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanFactory20.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/Parameter.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/Property.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/Common.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/ConfigurationUtil.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/ConstructorHandler.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/ConstructorInterceptor.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/JavaBeanHandler.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/JavaBeanSchemaInitializer.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/JavaBeanSchemaInitializer20.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/PropertyHandler.java
jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/PropertyInterceptor.java
jbossxb/trunk/src/main/resources/
jbossxb/trunk/src/main/resources/schema/
jbossxb/trunk/src/main/resources/schema/javabean_1_0.xsd
jbossxb/trunk/src/main/resources/schema/javabean_2_0.xsd
jbossxb/trunk/src/main/resources/schema/jbxb_1_0.xsd
jbossxb/trunk/src/test/java/org/jboss/test/javabean/
jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/
jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/AmbiguityBean.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/SimpleBean.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/SimpleBeanFactory.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestParameterInstantiate.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestProperty.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestPropertyWildcard.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestSimpleInstantiate.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestStaticClassMethodInstantiate.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestStaticClassMethodInstantiator.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestStaticMethodInstantiate.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestWildcard.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/
jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/AbstractJavaBeanTest.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/AmbiguityTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/InstantiateTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/JavaBeanTestSuite.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/ParameterInstantiateUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/PropertyTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/PropertyUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/PropertyWildcardUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/SimpleInstantiateUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/StaticClassMethodInstantiateUnitTestCase.java
jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/StaticMethodInstantiateUnitTestCase.java
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/ParameterInstantiate.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/Property.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/PropertyWildcard.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/SimpleInstantiate.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/StaticClassMethodInstantiate.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/StaticMethodInstantiate.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestAmbiguityInt.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestAmbiguityString.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtor.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClass.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClassAndParams.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorFactory.xml
jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestInstantiate.xml
Modified:
jbossxb/trunk/pom.xml
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/AbstractBuilderTest.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/JBossXBTestDelegate.java
Log:
[JBXB-121] - Let the JBossXB project handle the javabean schema
Modified: jbossxb/trunk/pom.xml
===================================================================
--- jbossxb/trunk/pom.xml 2008-02-29 13:32:16 UTC (rev 2713)
+++ jbossxb/trunk/pom.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -84,7 +84,7 @@
<dependency>
<groupId>org.jboss.microcontainer</groupId>
<artifactId>jboss-container</artifactId>
- <version>2.0.0.Beta9</version>
+ <version>2.0.0.Beta10</version>
<scope>compile</scope>
<!-- FIXME http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4077827#4077827 -->
<exclusions>
@@ -131,4 +131,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-</project>
\ No newline at end of file
+</project>
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/Constructor.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/Constructor.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/Constructor.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,76 @@
+/*
+* 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.javabean.plugins.jaxb;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * Constructor.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at XmlType(name="constructorType")
+public class Constructor
+{
+ private String factoryClass;
+
+ private String factoryMethod;
+
+ private Parameter[] parameters;
+
+ public String getFactoryClass()
+ {
+ return factoryClass;
+ }
+
+ @XmlAttribute(name="factoryClass")
+ public void setFactoryClass(String factoryClass)
+ {
+ this.factoryClass = factoryClass;
+ }
+
+ public String getFactoryMethod()
+ {
+ return factoryMethod;
+ }
+
+ @XmlAttribute(name="factoryMethod")
+ public void setFactoryMethod(String factoryMethod)
+ {
+ this.factoryMethod = factoryMethod;
+ }
+
+ public Parameter[] getParameters()
+ {
+ return parameters;
+ }
+
+ @XmlElement(name="parameter")
+ public void setParameters(Parameter[] parameters)
+ {
+ this.parameters = parameters;
+ }
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBean.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBean.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBean.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,245 @@
+/*
+* 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.javabean.plugins.jaxb;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.config.plugins.property.PropertyConfiguration;
+import org.jboss.config.spi.Configuration;
+import org.jboss.joinpoint.plugins.Config;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.propertyeditor.PropertyEditors;
+import org.jboss.xb.spi.BeanAdapter;
+import org.jboss.xb.spi.BeanAdapterFactory;
+
+/**
+ * JavaBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavaBean extends BeanAdapter
+{
+ private static Configuration configuration;
+
+ static
+ {
+ init();
+ }
+
+ static synchronized void init()
+ {
+ if(configuration == null)
+ {
+ configuration = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
+ {
+ public Configuration run()
+ {
+ return new PropertyConfiguration(System.getProperties());
+ }
+ });
+ PropertyEditors.init();
+ }
+ }
+
+ private String className;
+
+ private Constructor constructor;
+
+ private Property[] properties;
+
+ public JavaBean(BeanAdapterFactory beanAdapterFactory)
+ {
+ super(beanAdapterFactory);
+ }
+
+ public String getClassName()
+ {
+ return className;
+ }
+
+ @XmlAttribute(name="class")
+ public void setClassName(String className)
+ {
+ this.className = className;
+ }
+
+ public Constructor getConstructor()
+ {
+ return constructor;
+ }
+
+ public void setConstructor(Constructor constructor)
+ {
+ this.constructor = constructor;
+ }
+
+ public Property[] getProperties()
+ {
+ return properties;
+ }
+
+ @XmlElement(name="property")
+ public void setProperties(Property[] properties)
+ {
+ this.properties = properties;
+ }
+
+ @XmlTransient
+ public Object getValue()
+ {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Object result;
+
+ BeanInfo beanInfo = null;
+ if (className != null)
+ beanInfo = configuration.getBeanInfo(className, cl);
+
+ if (constructor != null)
+ {
+ String factoryMethod = constructor.getFactoryMethod();
+ if (factoryMethod != null)
+ {
+ String factoryClass = constructor.getFactoryClass();
+ BeanInfo factoryBeanInfo = beanInfo;
+ if (factoryClass != null)
+ factoryBeanInfo = configuration.getBeanInfo(factoryClass, cl);
+
+ if (factoryBeanInfo == null)
+ throw new IllegalArgumentException("Missing className or factoryClass: " + this);
+
+ String[] signature = getSignature(constructor.getParameters());
+ MethodInfo factory = Config.findMethodInfo(factoryBeanInfo.getClassInfo(), factoryMethod, signature, true, true);
+ Object[] params = getParams(constructor.getParameters(), factory.getParameterTypes());
+ result = factory.invoke(null, params);
+ }
+ else
+ {
+ if (beanInfo == null)
+ throw new IllegalArgumentException("Missing className: " + this);
+
+ String[] signature = getSignature(constructor.getParameters());
+ ConstructorInfo constructorInfo = Config.findConstructorInfo(beanInfo.getClassInfo(), signature);
+ Object[] params = getParams(constructor.getParameters(), constructorInfo.getParameterTypes());
+ result = constructorInfo.newInstance(params);
+ }
+ }
+ else
+ {
+ if (beanInfo == null)
+ throw new IllegalArgumentException("Missing className: " + this);
+
+ result = beanInfo.newInstance();
+ }
+ if (beanInfo == null)
+ beanInfo = configuration.getBeanInfo(result.getClass());
+
+ if (properties != null)
+ {
+ for (Property property : properties)
+ {
+ Object value = property.getValue();
+ if (value != null)
+ {
+ PropertyInfo propertyInfo = beanInfo.getProperty(property.getName());
+ TypeInfo typeInfo = propertyInfo.getType();
+ String type = property.getType();
+ if (type != null)
+ typeInfo = configuration.getTypeInfo(type, cl);
+ value = typeInfo.convertValue(value, false);
+ propertyInfo.set(result, value);
+ }
+ }
+ }
+
+ return result;
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error constructing javabean", t);
+ }
+ }
+
+ public Object get(PropertyInfo propertyInfo) throws Throwable
+ {
+ return propertyInfo.get(this);
+ }
+
+ public void set(PropertyInfo propertyInfo, Object child) throws Throwable
+ {
+ propertyInfo.set(this, child);
+ }
+
+ /**
+ * Get parameter types.
+ *
+ * @param parameters the parameters
+ * @return parameter types
+ */
+ protected String[] getSignature(Parameter[] parameters)
+ {
+ if (parameters == null)
+ return new String[0];
+ String[] signature = new String[parameters.length];
+ for (int i = 0; i < signature.length; ++i)
+ signature[i] = parameters[i].getType();
+ return signature;
+ }
+
+ /**
+ * Get parameter values.
+ *
+ * @param parameters the parameters
+ * @param paramTypes the types
+ * @return parameter values
+ */
+ protected Object[] getParams(Parameter[] parameters, TypeInfo[] paramTypes)
+ {
+ if (parameters == null)
+ return new String[0];
+ Object[] params = new Object[parameters.length];
+ for (int i = 0; i < params.length; ++i)
+ {
+ Object value = parameters[i].getValue();
+ try
+ {
+ params[i] = paramTypes[i].convertValue(value, false);
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error converting parameter #" + i + " value=" + value + " to type " + paramTypes[i]);
+ }
+ }
+ return params;
+ }
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBean10.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBean10.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBean10.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.javabean.plugins.jaxb;
+
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.xb.annotations.JBossXmlSchema;
+import org.jboss.xb.annotations.JBossXmlType;
+import org.jboss.xb.spi.BeanAdapterFactory;
+
+/**
+ * JavaBean version 1.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at JBossXmlSchema(namespace="urn:jboss:javabean:1.0", elementFormDefault=XmlNsForm.QUALIFIED)
+ at XmlRootElement(name="javabean")
+ at XmlType(name="javabeanType")
+ at JBossXmlType(beanAdapterBuilder=JavaBeanBuilder10.class)
+public class JavaBean10 extends JavaBean
+{
+ /**
+ * Create a new JavaBean10.
+ *
+ * @param beanAdapterFactory the bean adapter factory
+ */
+ public JavaBean10(BeanAdapterFactory beanAdapterFactory)
+ {
+ super(beanAdapterFactory);
+ }
+
+ @XmlTransient // Version 1 didn't have a constructor
+ public void setConstructor(Constructor constructor)
+ {
+ super.setConstructor(constructor);
+ }
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBean20.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBean20.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBean20.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,53 @@
+/*
+* 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.javabean.plugins.jaxb;
+
+import javax.xml.bind.annotation.XmlNsForm;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+import org.jboss.xb.annotations.JBossXmlSchema;
+import org.jboss.xb.annotations.JBossXmlType;
+import org.jboss.xb.spi.BeanAdapterFactory;
+
+/**
+ * JavaBean version 2.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at JBossXmlSchema(namespace="urn:jboss:javabean:2.0", elementFormDefault=XmlNsForm.QUALIFIED)
+ at XmlRootElement(name="javabean")
+ at XmlType(name="javabeanType")
+ at JBossXmlType(beanAdapterBuilder=JavaBeanBuilder20.class)
+public class JavaBean20 extends JavaBean
+{
+ /**
+ * Create a new JavaBean20.
+ *
+ * @param beanAdapterFactory the bean adapter factory
+ */
+ public JavaBean20(BeanAdapterFactory beanAdapterFactory)
+ {
+ super(beanAdapterFactory);
+ }
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanBuilder10.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanBuilder10.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanBuilder10.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,42 @@
+/*
+* 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.javabean.plugins.jaxb;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.xb.spi.BeanAdapterBuilder;
+import org.jboss.xb.spi.BeanAdapterFactory;
+
+/**
+ * JavaBeanBuilder version 1.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavaBeanBuilder10 implements BeanAdapterBuilder
+{
+ public BeanAdapterFactory newFactory(BeanInfo beanInfo, MethodInfo factory)
+ {
+ return new JavaBeanFactory10();
+ }
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanBuilder20.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanBuilder20.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanBuilder20.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,42 @@
+/*
+* 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.javabean.plugins.jaxb;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.xb.spi.BeanAdapterBuilder;
+import org.jboss.xb.spi.BeanAdapterFactory;
+
+/**
+ * JavaBeanBuilder version 2.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavaBeanBuilder20 implements BeanAdapterBuilder
+{
+ public BeanAdapterFactory newFactory(BeanInfo beanInfo, MethodInfo factory)
+ {
+ return new JavaBeanFactory20();
+ }
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanFactory10.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanFactory10.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanFactory10.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.javabean.plugins.jaxb;
+
+import org.jboss.xb.spi.BeanAdapter;
+import org.jboss.xb.spi.BeanAdapterFactory;
+
+/**
+ * JavaBeanFactory version 1.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavaBeanFactory10 extends BeanAdapterFactory
+{
+ public BeanAdapter newInstance()
+ {
+ return new JavaBean10(this);
+ }
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanFactory20.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanFactory20.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/JavaBeanFactory20.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.javabean.plugins.jaxb;
+
+import org.jboss.xb.spi.BeanAdapter;
+import org.jboss.xb.spi.BeanAdapterFactory;
+
+/**
+ * JavaBeanFactory version 2.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavaBeanFactory20 extends BeanAdapterFactory
+{
+ public BeanAdapter newInstance()
+ {
+ return new JavaBean20(this);
+ }
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/Parameter.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/Parameter.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/Parameter.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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.javabean.plugins.jaxb;
+
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlValue;
+
+/**
+ * Parameter.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class Parameter
+{
+ private String type;
+
+ private Object value;
+
+ public String getType()
+ {
+ return type;
+ }
+
+ @XmlAttribute(name="class")
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+ @XmlValue
+ @XmlAnyElement
+ public void setValue(Object value)
+ {
+ this.value = value;
+ }
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/Property.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/Property.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/jaxb/Property.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,49 @@
+/*
+* 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.javabean.plugins.jaxb;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * Property.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+ at XmlType(name="propertyType")
+public class Property extends Parameter
+{
+ private String name;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ @XmlAttribute
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/Common.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/Common.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/Common.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,179 @@
+/*
+ * 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.javabean.plugins.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.beans.info.spi.BeanInfo;
+
+/**
+ * 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
+ {
+ private String className;
+ private boolean ctorWasDeclared;
+ private Constructor constructor = new Constructor();
+ private List<String> paramTypes = new ArrayList<String>();
+ private List<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(String type, Object value)
+ {
+ paramTypes.add(type);
+ 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 Constructor getConstructor()
+ {
+ return constructor;
+ }
+
+ public Object newInstance()
+ throws Throwable
+ {
+ String factoryMethod = constructor.getFactoryMethod();
+ if (factoryMethod != null)
+ {
+ BeanInfo beanInfo = ConfigurationUtil.getBeanInfo(constructor.getFactoryClass());
+ return beanInfo.invokeStatic(factoryMethod, getParamTypes(), getArgs());
+ }
+ return ConfigurationUtil.newInstance(getClassName(), getParamTypes(), getArgs());
+ }
+ }
+
+ public static class Constructor
+ {
+ private String factoryClass;
+ private String factoryMethod;
+
+ public String getFactoryClass()
+ {
+ return factoryClass;
+ }
+
+ public void setFactoryClass(String value)
+ {
+ factoryClass = value;
+ }
+
+ public String getFactoryMethod()
+ {
+ return factoryMethod;
+ }
+
+ public void setFactoryMethod(String value)
+ {
+ factoryMethod = value;
+ }
+ }
+
+ 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: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/ConfigurationUtil.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/ConfigurationUtil.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/ConfigurationUtil.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,121 @@
+/*
+* 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.javabean.plugins.xml;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.config.plugins.property.PropertyConfiguration;
+import org.jboss.config.spi.Configuration;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.propertyeditor.PropertyEditors;
+
+/**
+ * Initialize the Configuration
+ *
+ * @author ales.justin at jboss.com
+ */
+public class ConfigurationUtil
+{
+ /** The kernel config */
+ private static Configuration config;
+
+ static synchronized void init()
+ {
+ if(config == null)
+ {
+ config = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
+ {
+ public Configuration run()
+ {
+ return new PropertyConfiguration(System.getProperties());
+ }
+ });
+ PropertyEditors.init();
+ }
+ }
+
+ // ----- utils
+
+ static BeanInfo getBeanInfo(Object object) throws Throwable
+ {
+ return getBeanInfo(object.getClass());
+ }
+
+ static BeanInfo getBeanInfo(Class<?> clazz) throws Throwable
+ {
+ return config.getBeanInfo(clazz);
+ }
+
+ static BeanInfo getBeanInfo(String className) throws Throwable
+ {
+ return config.getBeanInfo(className, Thread.currentThread().getContextClassLoader());
+ }
+
+ static PropertyInfo getPropertyInfo(Object parent, String name) throws Throwable
+ {
+ BeanInfo beanInfo = getBeanInfo(parent);
+ return beanInfo.getProperty(name);
+ }
+
+ static Object newInstance(String className, String[] params, Object[] args)
+ throws Throwable
+ {
+ BeanInfo info = getBeanInfo(className);
+ return info.newInstance(params, args);
+ }
+
+ /**
+ * Convert a value
+ *
+ * @param parent parent object
+ * @param name the property name
+ * @param override the override class
+ * @param value the value
+ * @return the converted value
+ * @throws Throwable for any error
+ */
+ static Object convertValue(Object parent, String name, String override, Object value) throws Throwable
+ {
+ if (parent == null)
+ throw new IllegalArgumentException("Null parent!");
+
+ PropertyInfo property = getPropertyInfo(parent, name);
+ return convertValue(property, override, value);
+ }
+
+ static Object convertValue(PropertyInfo property, String override, Object value)
+ throws Throwable
+ {
+ if (property == null)
+ throw new IllegalArgumentException("Null property!");
+
+ TypeInfo type = property.getType();
+ if (override != null)
+ type = config.getTypeInfoFactory().getTypeInfo(override, null);
+
+ return type != null ? type.convertValue(value) : value;
+ }
+
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/ConstructorHandler.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/ConstructorHandler.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/ConstructorHandler.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,92 @@
+/*
+ * 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.javabean.plugins.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.javabean.plugins.xml.Common.Ctor;
+import org.jboss.javabean.plugins.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();
+ Common.Constructor constructor = ctor.getConstructor();
+ 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
+ {
+ return ctor.newInstance();
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error instantiating class " + ctor.getClassName(), t);
+ }
+
+ }
+}
+
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/ConstructorInterceptor.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/ConstructorInterceptor.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/ConstructorInterceptor.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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.javabean.plugins.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.javabean.plugins.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);
+ }
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/JavaBeanHandler.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/JavaBeanHandler.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/JavaBeanHandler.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,115 @@
+/*
+ * 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.javabean.plugins.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.javabean.plugins.xml.Common.Ctor;
+import org.jboss.javabean.plugins.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;
+ Object result = holder.getValue();
+
+ // We still have a constructor because there was no constructor element
+ if (result != null && result instanceof Ctor)
+ {
+ Ctor ctor = (Ctor) result;
+ result = ctor.getValue();
+
+ // The constructor was never run
+ if (result == null)
+ {
+ try
+ {
+ return ctor.newInstance();
+ }
+ catch (Throwable t)
+ {
+ new RuntimeException("Unable to construct object javabean", t);
+ }
+ }
+ }
+
+ // Sanity check
+ if (result == null)
+ throw new IllegalStateException("Null object creating javabean");
+
+ return result;
+ }
+}
+
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/JavaBeanSchemaInitializer.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/JavaBeanSchemaInitializer.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/JavaBeanSchemaInitializer.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,178 @@
+/*
+* 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.javabean.plugins.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.javabean.plugins.xml.Common.Holder;
+import org.jboss.javabean.plugins.xml.Common.Property;
+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;
+
+/**
+ * JavaBeanSchemaInitializer.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 60322 $
+ */
+public class JavaBeanSchemaInitializer implements SchemaBindingInitializer
+{
+ /** The namespace */
+ private static final String JAVABEAN_NS = "urn:jboss:javabean:1.0";
+
+ /** The javabean binding */
+ private static final QName javabeanTypeQName = new QName(JAVABEAN_NS, "javabeanType");
+
+ /** The property binding */
+ private static final QName propertyTypeQName = new QName(JAVABEAN_NS, "propertyType");
+
+ /** The property element name */
+ private static final QName propertyQName = new QName(JAVABEAN_NS, "property");
+
+ static
+ {
+ ConfigurationUtil.init();
+ }
+
+ public SchemaBinding init(SchemaBinding schema)
+ {
+ // ignore XB property replacement
+ schema.setReplacePropertyRefs(false);
+
+ // javabean binding
+ TypeBinding beanType = schema.getType(javabeanTypeQName);
+ beanType.setHandler(new DefaultElementHandler()
+ {
+
+ 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
+ {
+ BeanInfo beanInfo = ConfigurationUtil.getBeanInfo(className);
+ Object object = beanInfo.newInstance();
+ holder.setValue(object);
+ }
+ 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();
+ }
+ });
+
+ // bean has properties
+ beanType.pushInterceptor(propertyQName, new DefaultElementInterceptor()
+ {
+ public void add(Object parent, Object child, QName name)
+ {
+ Holder holder = (Holder) parent;
+ Object parentValue = holder.getValue();
+
+ Property prop = (Property) child;
+ String property = prop.getProperty();
+ Object value = prop.getValue();
+ try
+ {
+ BeanInfo info = ConfigurationUtil.getBeanInfo(parentValue.getClass());
+ value = ConfigurationUtil.convertValue(parentValue, property, prop.getType(), value);
+ info.setProperty(parentValue, property, 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 binding
+ TypeBinding propertyType = schema.getType(propertyTypeQName);
+ propertyType.setHandler(new DefaultElementHandler()
+ {
+
+ 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));
+ }
+ }
+ });
+
+ return schema;
+ }
+
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/JavaBeanSchemaInitializer20.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/JavaBeanSchemaInitializer20.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/JavaBeanSchemaInitializer20.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,89 @@
+/*
+* 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.javabean.plugins.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
+ {
+ ConfigurationUtil.init();
+ }
+
+ public SchemaBinding init(SchemaBinding schema)
+ {
+ // ignore XB property replacement
+ schema.setReplacePropertyRefs(false);
+
+ // 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;
+ }
+}
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/PropertyHandler.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/PropertyHandler.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/PropertyHandler.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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.javabean.plugins.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.javabean.plugins.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));
+ }
+ }
+}
+
Added: jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/PropertyInterceptor.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/PropertyInterceptor.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/javabean/plugins/xml/PropertyInterceptor.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,107 @@
+/*
+ * 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.javabean.plugins.xml;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.javabean.plugins.xml.Common.Ctor;
+import org.jboss.javabean.plugins.xml.Common.Holder;
+import org.jboss.javabean.plugins.xml.Common.Property;
+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() )
+ {
+ BeanInfo beanInfo = ConfigurationUtil.getBeanInfo(ctor.getClassName());
+ PropertyInfo propertyInfo = beanInfo.getProperty(property);
+ value = ConfigurationUtil.convertValue(propertyInfo, prop.getType(), value);
+ ctor.addParam(propertyInfo.getType().getName(), 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
+ {
+ BeanInfo beanInfo = ConfigurationUtil.getBeanInfo(parentValue);
+ value = ConfigurationUtil.convertValue(parentValue, property, prop.getType(), value);
+ beanInfo.setProperty(parentValue, property, 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);
+ }
+ }
+
+}
Added: jbossxb/trunk/src/main/resources/schema/javabean_1_0.xsd
===================================================================
--- jbossxb/trunk/src/main/resources/schema/javabean_1_0.xsd (rev 0)
+++ jbossxb/trunk/src/main/resources/schema/javabean_1_0.xsd 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- A prototype xsd schema for javabeans
+$Id: javabean_1_0.xsd 60371 2007-02-07 11:48:07Z alesj $
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="urn:jboss:javabean:1.0"
+ xmlns="urn:jboss:javabean:1.0"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0"
+>
+ <xsd:annotation>
+ <xsd:documentation>
+ <![CDATA[
+ A schema for constructing javabeans.
+
+ <javabean xmlns="urn:jboss:javabean:1.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">
+ <property .../>
+ <property .../>
+ </javabean>
+ ]]>
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <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="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>
Added: jbossxb/trunk/src/main/resources/schema/javabean_2_0.xsd
===================================================================
--- jbossxb/trunk/src/main/resources/schema/javabean_2_0.xsd (rev 0)
+++ jbossxb/trunk/src/main/resources/schema/javabean_2_0.xsd 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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>
Added: jbossxb/trunk/src/main/resources/schema/jbxb_1_0.xsd
===================================================================
--- jbossxb/trunk/src/main/resources/schema/jbxb_1_0.xsd (rev 0)
+++ jbossxb/trunk/src/main/resources/schema/jbxb_1_0.xsd 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,425 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema version="1.0beta"
+ attributeFormDefault="unqualified"
+ elementFormDefault="qualified"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:annotation>
+ <xs:documentation>The JBossXB schema customization
+ elements</xs:documentation>
+ </xs:annotation>
+ <xs:element name="schemaBindings">
+ <xs:annotation>
+ <xs:documentation>This element defines default bindings for the
+ schema</xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <!-- The child elements can be selected in any order. -->
+ <xs:choice maxOccurs="unbounded" minOccurs="1">
+ <xs:element maxOccurs="1" minOccurs="0" ref="jbxb:package"/>
+
+ <xs:element name="ignoreUnresolvedFieldOrClass" type="xs:boolean" default="true"
+ maxOccurs="1" minOccurs="0">
+ <xs:annotation>
+ <xs:documentation>The ignoreUnresolvedFieldOrClass specifies the behavior the parser chooses
+ when a field is not found in the parent class for a child value, or when an element does not have
+ any class assignement. If false, an exception will be thrown when either situation is encountered.
+ If true, the missing mapping is ignored and the parse continues.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+
+ <xs:element name="replacePropertyRefs" type="xs:boolean" default="true"
+ maxOccurs="1" minOccurs="0">
+ <xs:annotation>
+ <xs:documentation>The replacePropertyRefs flag indicates whether the
+ text content of values has ${x} system property references replaced
+ during parsing. The default is true.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:choice>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="package" type="xs:NCName">
+ <xs:annotation>
+ <xs:documentation> Defines the default package for the schema which
+ is used for searching classes when unmarshalling elements of
+ complex types. If jbxb:package is not present, schema's
+ namespace URI will be used as the base to generate the default
+ package name for the schema (the mapping is defined in JAXB2.0
+ spec D.5.1 Mapping from a Namespace URI). Example: <![CDATA[
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:schema>
+ <jbxb:package name="org.jboss.test.xml.pojoserver.metadata"/>
+ </jbxb:schema>
+ </xsd:appinfo>
+ </xsd:annotation>
+ ]]></xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="characters">
+ <xs:annotation>
+ <xs:documentation> Binds text content of complex types. This element
+ is just a container for jbxb:value, jbxb:property,
+ jbxb:mapEntryKey, jbxb:mapEntryValue elements, all of them are
+ optional. This element can only appear inside complex type
+ definitions. Example: <![CDATA[
+ <xsd:complexType name="namedValueType" mixed="true">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractPropertyMetaData"/>
+ <jbxb:characters>
+ <jbxb:property name="value"/>
+ <jbxb:value unmarshalMethod="org.jboss.test.xml.pojoserver.metadata.DataTypeConverter.unmarshalStringValue"/>
+ </jbxb:characters>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexContent>
+ ...
+ </xsd:complexContent>
+ </xsd:complexType>
+ ]]></xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:choice>
+ <xs:element ref="jbxb:property"/>
+ <xs:element ref="jbxb:value"/>
+ <xs:element ref="jbxb:mapEntryKey"/>
+ <xs:element ref="jbxb:mapEntryValue"/>
+ </xs:choice>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="class" type="xs:NCName">
+ <xs:annotation>
+ <xs:documentation> Binds XML element or complex type to a Java class
+ which is specified as a value of attribute 'impl'. If jbxb:class
+ is used inside complex type definition, all elements of this
+ complex type will be unmarshalled into the specified Java type
+ unless there is overriding jbxb:class in an element declaration.
+ Example: <![CDATA[
+ <xsd:complexType name="deploymentType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.deployment.AbstractKernelDeployment"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ ...
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:element name="list" type="listType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractListMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ ]]></xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attribute name="impl" type="xs:NCName" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="property">
+ <xs:annotation>
+ <xs:documentation> Binds an element to property/field in a class.
+ This element can appear inside an element definition or inside
+ jbxb:characters. If jbxb:property is not specified for an
+ element, the property name is resolved based on the element's
+ name using "D.2 The Name to Identifier Mapping Algorithm"
+ defined in JAXB2.0 spec. Example: <![CDATA[
+ <xsd:element name="list" type="listType">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="value"/>
+ <jbxb:class impl="org.jboss.test.xml.pojoserver.metadata.AbstractListMetaData"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ ]]></xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attribute name="name" type="xs:NCName" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="value">
+ <xs:annotation>
+ <xs:documentation> Binds text value (attribute value or text
+ content) to a Java value. There are two attributes:
+ unmarshalMethod which specfies a public static method that is
+ used to unmarshal text values and marshalMethod which also a
+ public static method that is used to marshal Java values. Both
+ methods are defined as concatenation of fully-qualified class
+ name, '.' and the method name. unmarshalMethod must have two
+ parameters: the first one of type java.lang.String and the
+ second one is of type javax.xml.namespace.NamespaceContext.
+ marshalMethod must also have two parameters: the first one is of
+ type java.lang.Object and the second one is of type
+ javax.xml.namespace.NamespaceContext. jbxb:value can appear
+ inside simple type definitions, attribute declarations and
+ jbxb:characters. If jbxb:value is not used, text values are
+ unmarshalled using default simple types to Java bindings
+ defained in JAXB2.0 spec. If simple type is a user-defined, by
+ default it is not unmarshalled and passed as a string. Example: <![CDATA[
+ <xsd:simpleType name="kernelControllerState">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:value unmarshalMethod="org.jboss.test.xml.pojoserver.metadata.KernelControllerStateDatatypeConverter.unmarshal"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="Not Installed" />
+ <xsd:enumeration value="Described" />
+ <xsd:enumeration value="Instantiated" />
+ <xsd:enumeration value="Configured" />
+ <xsd:enumeration value="Lifecycle" />
+ <xsd:enumeration value="Started" />
+ <xsd:enumeration value="Installed" />
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ public class KernelControllerStateDatatypeConverter
+ {
+ public static KernelControllerState unmarshal(String text, NamespaceContext nsCtx)
+ {
+ KernelControllerState state;
+ if(KernelControllerState.NOT_INSTALLED.getStateString().equals(text))
+ {
+ state = KernelControllerState.NOT_INSTALLED;
+ }
+ else
+ ...
+ ]]></xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="addMethod">
+ <xs:annotation>
+ <xs:documentation> Specified on an element that should be added to
+ its parent not with a setter (is not a property) and not with a
+ field but with a custom method. The attributes are: * name - the
+ name of the method. There is not default value for this
+ attribute. It must be set. * valueType - the type of the
+ argument. If not present, the default is java.lang.Object. And
+ there is a special value 'child' which means the type of the
+ child should be used as the argument's type. Example: <![CDATA[
+ <xs:element name="user">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.mbeanserver.Users$User"/>
+ <jbxb:addMethod name="addUser" valueType="child"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" maxOccurs="unbounded" ref="ur:role"/>
+ </xs:sequence>
+ <xs:attribute name="name" use="required" type="xs:NCName"/>
+ <xs:attribute name="password" use="required" type="xs:NCName"/>
+ </xs:complexType>
+ </xs:element>
+ ]]></xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attribute name="name" type="xs:NCName" use="required">
+ <xs:annotation>
+ <xs:documentation>This required attribute specifies the name
+ of the add method</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute default="java.lang.Object" name="valueType"
+ type="xs:NCName" use="optional">
+ <xs:annotation>
+ <xs:documentation> the type of the add method argument. If
+ not present, the default is java.lang.Object. And there
+ is a special value 'child' which means the type of the
+ child should be used as the argument's type.
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="putMethod">
+ <xs:annotation>
+ <xs:documentation/>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attribute default="put" name="name" type="xs:NCName"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation> the method name in the parent object's
+ class that adds child to to its parent object. If not
+ present, the default is 'put'. </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute default="java.lang.Object" name="keyType"
+ type="xs:NCName" use="optional">
+ <xs:annotation>
+ <xs:documentation> fully qualified type name of the
+ key-parameter to the put-method. If not present, the
+ default is java.lang.Object. </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute default="java.lang.Object" name="valueType"
+ type="xs:NCName" use="optional">
+ <xs:annotation>
+ <xs:documentation>fully qualified type name of the
+ value-parameter to the put-method. If not present, the
+ default is java.lang.Object. </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="mapEntry">
+ <xs:annotation>
+ <xs:documentation> Specified on an element or a complex type
+ definition that is bound to a map entry. jbxb:class and
+ jbxb:mapEntry are mutually exclusive, meanning an element or a
+ complex type cannot be annotated with both jbxb:class and
+ jbxb:mapEntry at the same time. Otherwise, it will result in an
+ exception during binding. </xs:documentation>
+ </xs:annotation>
+ <xs:complexType>
+ <xs:attribute name="impl" type="xs:NCName" use="optional">
+ <xs:annotation>
+ <xs:documentation>an optional element that specifies a fully
+ qualified name of the class that will represent map
+ entry. If absent, a special class will be used by the
+ framework internally.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute default="getKey" name="getKeyMethod" type="xs:NCName"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>an optional attribute that specifies the
+ name of the method that is used to get the key out of
+ the object that represents a map
+ entry.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute default="setKey" name="setKeyMethod" type="xs:NCName"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>an optional attribute that specifies the
+ name of the method that is used to set the key value on
+ the object that represents a map
+ entry.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute default="getValue" name="getValueMethod"
+ type="xs:NCName" use="optional">
+ <xs:annotation>
+ <xs:documentation>an optional element that specifies the
+ name of the method that is used to get the value out of
+ the object that represents a map entry. If absent and
+ impl attribute is absent too, the default value is
+ "getValue". If absent and impl attribute is present, the
+ value will be the object that reprents the map entry
+ itself.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute default="setValue" name="setValueMethod"
+ type="xs:NCName" use="optional">
+ <xs:annotation>
+ <xs:documentation>an optional element that specifies the
+ name of the method that is used to set the value on the
+ object that represents a map entry.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="valueType" type="xs:NCName" use="optional">
+ <xs:annotation>
+ <xs:documentation>an optional attribute that specifies the
+ type of the map entry value. Used when map entry value
+ should be a parent for element/type's
+ content.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute default="false" name="nonNullValue" type="xs:boolean"
+ use="optional">
+ <xs:annotation>
+ <xs:documentation>If true, when a map entry is created, a
+ non-null map entry value will also be created and set on
+ the map entry. Otherwise, a map entry object is created
+ with null value and the value will be created and set
+ later when it is actually parsed. This attribute is used
+ in combination with valueType.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="mapEntryKey">
+ <xs:annotation>
+ <xs:documentation>This element is a marker element that has no
+ attributes. It is specified on an element, attribute or inside
+ jbxb:characters to specify that the element, attribute or
+ characters should be used as the key in map
+ entry.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="mapEntryValue">
+ <xs:annotation>
+ <xs:documentation>This element is a marker element that has no
+ attributes. It is specified on an element, attribute or inside
+ jbxb:characters to specify that the element, attribute or
+ characters should be used as the value in map entry. Example:<![CDATA[
+ <xsd:element name="entry1">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <putMethod/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntry/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:sequence>
+ <xsd:element name="key1" type="xsd:string">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryKey/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="value1" type="xsd:string">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:mapEntryValue/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ ]]></xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="skip">
+ <xs:annotation>
+ <xs:documentation>This element can be used on an element declaration
+ or a complex type definition. Unmarshaller will not try to
+ create new objects for elements (or elements of complex types)
+ that are annotated with jbxb:skip. Instead, the object that was
+ created for the parent of such elements will be propagated and
+ values of attributes, character contents and child elements of
+ such elements will be set on their parent's
+ object. Example:<![CDATA[
+ <xs:element name="authentication">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:skip/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element ref="jaas:login-module"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ ]]>In the example above, login-modules will be added to the parent of authentication element.</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+</xs:schema>
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/AmbiguityBean.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/AmbiguityBean.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/AmbiguityBean.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,60 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.javabean.support;
+
+/**
+ * SimpleBean.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AmbiguityBean
+{
+ private Integer someint;
+ private String somestring;
+
+ public void setSomething(Integer integer)
+ {
+ someint = integer;
+ }
+
+ public void setSomething(String string)
+ {
+ somestring = string;
+ }
+
+ public Object something()
+ {
+ if (someint != null && somestring != null)
+ throw new IllegalArgumentException("Only one 'something' can be set!");
+ if (someint != null)
+ return someint;
+ if (somestring != null)
+ return somestring;
+ throw new IllegalArgumentException("Must set 'something'!");
+ }
+
+ public String toString()
+ {
+ return someint + "," + somestring;
+ }
+
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/SimpleBean.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/SimpleBean.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/SimpleBean.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,447 @@
+/*
+* 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.javabean.support;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+/**
+ * SimpleBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 60371 $
+ */
+public class SimpleBean
+{
+ /** Constructor used */
+ private String constructorUsed;
+ private String factoryUsed;
+
+ /** Object */
+ private Object anObject;
+
+ /** A string */
+ private String aString;
+
+ /** Byte */
+ private Byte aByte;
+
+ /** Boolean */
+ private Boolean aBoolean;
+
+ /** Character */
+ private Character aCharacter;
+
+ /** Short */
+ private Short aShort;
+
+ /** Int */
+ private Integer anInt;
+
+ /** Long */
+ private Long aLong;
+
+ /** Float */
+ private Float aFloat;
+
+ /** Double */
+ private Double aDouble;
+
+ /** Date */
+ private Date aDate;
+
+ /** BigDecimal */
+ private BigDecimal aBigDecimal;
+
+ /** BigDecimal */
+ private BigInteger aBigInteger;
+
+ /** byte */
+ private byte abyte;
+
+ /** boolean */
+ private boolean aboolean;
+
+ /** char */
+ private char achar;
+
+ /** short */
+ private short ashort;
+
+ /** int */
+ private int anint;
+
+ /** long */
+ private long along;
+
+ /** float */
+ private float afloat;
+
+ /** double */
+ private double adouble;
+
+ /** number */
+ private Number aNumber;
+
+ /** Overloaded property */
+ private String overloadedProperty;
+ private String xyz;
+ private String abc;
+
+ public SimpleBean()
+ {
+ 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;
+ }
+
+ public void setAnObject(Object object)
+ {
+ anObject = object;
+ }
+
+ public BigDecimal getABigDecimal()
+ {
+ return aBigDecimal;
+ }
+
+ public void setABigDecimal(BigDecimal bigDecimal)
+ {
+ aBigDecimal = bigDecimal;
+ }
+
+ public BigInteger getABigInteger()
+ {
+ return aBigInteger;
+ }
+
+ public void setABigInteger(BigInteger bigInteger)
+ {
+ aBigInteger = bigInteger;
+ }
+
+ public boolean isAboolean()
+ {
+ return aboolean;
+ }
+
+ public void setAboolean(boolean aboolean)
+ {
+ this.aboolean = aboolean;
+ }
+
+ public Boolean getABoolean()
+ {
+ return aBoolean;
+ }
+
+ public void setABoolean(Boolean boolean1)
+ {
+ aBoolean = boolean1;
+ }
+
+ public Number getANumber()
+ {
+ return aNumber;
+ }
+
+ public void setANumber(Number number)
+ {
+ aNumber = number;
+ }
+
+ public byte getAbyte()
+ {
+ return abyte;
+ }
+
+ public void setAbyte(byte abyte)
+ {
+ this.abyte = abyte;
+ }
+
+ public Byte getAByte()
+ {
+ return aByte;
+ }
+
+ public void setAByte(Byte byte1)
+ {
+ aByte = byte1;
+ }
+
+ public char getAchar()
+ {
+ return achar;
+ }
+
+ public void setAchar(char achar)
+ {
+ this.achar = achar;
+ }
+
+ public Character getACharacter()
+ {
+ return aCharacter;
+ }
+
+ public void setACharacter(Character character)
+ {
+ aCharacter = character;
+ }
+
+ public Date getADate()
+ {
+ return aDate;
+ }
+
+ public void setADate(Date date)
+ {
+ aDate = date;
+ }
+
+ public double getAdouble()
+ {
+ return adouble;
+ }
+
+ public void setAdouble(double adouble)
+ {
+ this.adouble = adouble;
+ }
+
+ public Double getADouble()
+ {
+ return aDouble;
+ }
+
+ public void setADouble(Double double1)
+ {
+ aDouble = double1;
+ }
+
+ public float getAfloat()
+ {
+ return afloat;
+ }
+
+ public void setAfloat(float afloat)
+ {
+ this.afloat = afloat;
+ }
+
+ public Float getAFloat()
+ {
+ return aFloat;
+ }
+
+ public void setAFloat(Float float1)
+ {
+ aFloat = float1;
+ }
+
+ public long getAlong()
+ {
+ return along;
+ }
+
+ public void setAlong(long along)
+ {
+ this.along = along;
+ }
+
+ public Long getALong()
+ {
+ return aLong;
+ }
+
+ public void setALong(Long long1)
+ {
+ aLong = long1;
+ }
+
+ public int getAnint()
+ {
+ return anint;
+ }
+
+ public void setAnint(int anint)
+ {
+ this.anint = anint;
+ }
+
+ public Integer getAnInt()
+ {
+ return anInt;
+ }
+
+ public void setAnInt(Integer anInt)
+ {
+ this.anInt = anInt;
+ }
+
+ public short getAshort()
+ {
+ return ashort;
+ }
+
+ public void setAshort(short ashort)
+ {
+ this.ashort = ashort;
+ }
+
+ public Short getAShort()
+ {
+ return aShort;
+ }
+
+ public void setAShort(Short short1)
+ {
+ aShort = short1;
+ }
+
+ public String getAString()
+ {
+ return aString;
+ }
+
+ public void setAString(String string)
+ {
+ aString = string;
+ }
+
+ public String getOverloadedProperty()
+ {
+ return overloadedProperty;
+ }
+
+ public void setOverloadedProperty(Long broken)
+ {
+ throw new RuntimeException("Invoked the wrong setter");
+ }
+
+ public void setOverloadedProperty(String overloadedProperty)
+ {
+ this.overloadedProperty = overloadedProperty;
+ }
+
+ public void setOverloadedProperty(Integer broken)
+ {
+ throw new RuntimeException("Invoked the wrong setter");
+ }
+
+ public String getXYZ()
+ {
+ return xyz;
+ }
+ public void setXYZ(String xyz)
+ {
+ this.xyz = xyz;
+ }
+
+ public String getAbc()
+ {
+ return abc;
+ }
+ public void setAbc(String abc)
+ {
+ this.abc = abc;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/SimpleBeanFactory.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/SimpleBeanFactory.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/SimpleBeanFactory.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestParameterInstantiate.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestParameterInstantiate.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestParameterInstantiate.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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.test.javabean.support;
+
+/**
+ * TestSimpleInstantiate.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestParameterInstantiate
+{
+ public String constructorUsed;
+
+ public TestParameterInstantiate(String string, int integer)
+ {
+ constructorUsed = string + integer;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestProperty.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestProperty.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestProperty.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,364 @@
+/*
+* 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.javabean.support;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Date;
+
+/**
+ * TestStaticMethodInstantiate.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestProperty
+{
+ /** Object */
+ private Object anObject;
+
+ /** A string */
+ private String aString;
+
+ /** Byte */
+ private Byte aByte;
+
+ /** Boolean */
+ private Boolean aBoolean;
+
+ /** Character */
+ private Character aCharacter;
+
+ /** Short */
+ private Short aShort;
+
+ /** Int */
+ private Integer anInt;
+
+ /** Long */
+ private Long aLong;
+
+ /** Float */
+ private Float aFloat;
+
+ /** Double */
+ private Double aDouble;
+
+ /** Date */
+ private Date aDate;
+
+ /** BigDecimal */
+ private BigDecimal aBigDecimal;
+
+ /** BigDecimal */
+ private BigInteger aBigInteger;
+
+ /** byte */
+ private byte abyte;
+
+ /** boolean */
+ private boolean aboolean;
+
+ /** char */
+ private char achar;
+
+ /** short */
+ private short ashort;
+
+ /** int */
+ private int anint;
+
+ /** long */
+ private long along;
+
+ /** float */
+ private float afloat;
+
+ /** double */
+ private double adouble;
+
+ /** number */
+ private Number aNumber;
+
+ /** Overloaded property */
+ private String overloadedProperty;
+ private String xyz;
+ private String abc;
+
+ public Object getAnObject()
+ {
+ return anObject;
+ }
+
+ public void setAnObject(Object object)
+ {
+ anObject = object;
+ }
+
+ public BigDecimal getABigDecimal()
+ {
+ return aBigDecimal;
+ }
+
+ public void setABigDecimal(BigDecimal bigDecimal)
+ {
+ aBigDecimal = bigDecimal;
+ }
+
+ public BigInteger getABigInteger()
+ {
+ return aBigInteger;
+ }
+
+ public void setABigInteger(BigInteger bigInteger)
+ {
+ aBigInteger = bigInteger;
+ }
+
+ public boolean isAboolean()
+ {
+ return aboolean;
+ }
+
+ public void setAboolean(boolean aboolean)
+ {
+ this.aboolean = aboolean;
+ }
+
+ public Boolean getABoolean()
+ {
+ return aBoolean;
+ }
+
+ public void setABoolean(Boolean boolean1)
+ {
+ aBoolean = boolean1;
+ }
+
+ public Number getANumber()
+ {
+ return aNumber;
+ }
+
+ public void setANumber(Number number)
+ {
+ aNumber = number;
+ }
+
+ public byte getAbyte()
+ {
+ return abyte;
+ }
+
+ public void setAbyte(byte abyte)
+ {
+ this.abyte = abyte;
+ }
+
+ public Byte getAByte()
+ {
+ return aByte;
+ }
+
+ public void setAByte(Byte byte1)
+ {
+ aByte = byte1;
+ }
+
+ public char getAchar()
+ {
+ return achar;
+ }
+
+ public void setAchar(char achar)
+ {
+ this.achar = achar;
+ }
+
+ public Character getACharacter()
+ {
+ return aCharacter;
+ }
+
+ public void setACharacter(Character character)
+ {
+ aCharacter = character;
+ }
+
+ public Date getADate()
+ {
+ return aDate;
+ }
+
+ public void setADate(Date date)
+ {
+ aDate = date;
+ }
+
+ public double getAdouble()
+ {
+ return adouble;
+ }
+
+ public void setAdouble(double adouble)
+ {
+ this.adouble = adouble;
+ }
+
+ public Double getADouble()
+ {
+ return aDouble;
+ }
+
+ public void setADouble(Double double1)
+ {
+ aDouble = double1;
+ }
+
+ public float getAfloat()
+ {
+ return afloat;
+ }
+
+ public void setAfloat(float afloat)
+ {
+ this.afloat = afloat;
+ }
+
+ public Float getAFloat()
+ {
+ return aFloat;
+ }
+
+ public void setAFloat(Float float1)
+ {
+ aFloat = float1;
+ }
+
+ public long getAlong()
+ {
+ return along;
+ }
+
+ public void setAlong(long along)
+ {
+ this.along = along;
+ }
+
+ public Long getALong()
+ {
+ return aLong;
+ }
+
+ public void setALong(Long long1)
+ {
+ aLong = long1;
+ }
+
+ public int getAnint()
+ {
+ return anint;
+ }
+
+ public void setAnint(int anint)
+ {
+ this.anint = anint;
+ }
+
+ public Integer getAnInt()
+ {
+ return anInt;
+ }
+
+ public void setAnInt(Integer anInt)
+ {
+ this.anInt = anInt;
+ }
+
+ public short getAshort()
+ {
+ return ashort;
+ }
+
+ public void setAshort(short ashort)
+ {
+ this.ashort = ashort;
+ }
+
+ public Short getAShort()
+ {
+ return aShort;
+ }
+
+ public void setAShort(Short short1)
+ {
+ aShort = short1;
+ }
+
+ public String getAString()
+ {
+ return aString;
+ }
+
+ public void setAString(String string)
+ {
+ aString = string;
+ }
+
+ public String getOverloadedProperty()
+ {
+ return overloadedProperty;
+ }
+
+ public void setOverloadedProperty(Long broken)
+ {
+ throw new RuntimeException("Invoked the wrong setter");
+ }
+
+ public void setOverloadedProperty(String overloadedProperty)
+ {
+ this.overloadedProperty = overloadedProperty;
+ }
+
+ public void setOverloadedProperty(Integer broken)
+ {
+ throw new RuntimeException("Invoked the wrong setter");
+ }
+
+ public String getXYZ()
+ {
+ return xyz;
+ }
+ public void setXYZ(String xyz)
+ {
+ this.xyz = xyz;
+ }
+
+ public String getAbc()
+ {
+ return abc;
+ }
+ public void setAbc(String abc)
+ {
+ this.abc = abc;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestPropertyWildcard.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestPropertyWildcard.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestPropertyWildcard.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,44 @@
+/*
+* 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.javabean.support;
+
+/**
+ *
+ * TestPropertyWildcard.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestPropertyWildcard
+{
+ private TestWildcard bean;
+
+ public TestWildcard getBean()
+ {
+ return bean;
+ }
+
+ public void setBean(TestWildcard bean)
+ {
+ this.bean = bean;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestSimpleInstantiate.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestSimpleInstantiate.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestSimpleInstantiate.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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.javabean.support;
+
+/**
+ * TestSimpleInstantiate.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestSimpleInstantiate
+{
+
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestStaticClassMethodInstantiate.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestStaticClassMethodInstantiate.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestStaticClassMethodInstantiate.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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.test.javabean.support;
+
+/**
+ * TestStaticClassMethodInstantiate.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestStaticClassMethodInstantiate
+{
+ TestStaticClassMethodInstantiate()
+ {
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestStaticClassMethodInstantiator.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestStaticClassMethodInstantiator.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestStaticClassMethodInstantiator.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,36 @@
+/*
+* 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.javabean.support;
+
+/**
+ * TestStaticClassMethodInstantiator.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestStaticClassMethodInstantiator
+{
+ public static TestStaticClassMethodInstantiate instantiate()
+ {
+ return new TestStaticClassMethodInstantiate();
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestStaticMethodInstantiate.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestStaticMethodInstantiate.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestStaticMethodInstantiate.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,40 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.javabean.support;
+
+/**
+ * TestStaticMethodInstantiate.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestStaticMethodInstantiate
+{
+ public static TestStaticMethodInstantiate instantiate()
+ {
+ return new TestStaticMethodInstantiate();
+ }
+
+ private TestStaticMethodInstantiate()
+ {
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestWildcard.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestWildcard.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/support/TestWildcard.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,34 @@
+/*
+* 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.javabean.support;
+
+/**
+ *
+ * TestPropertyWildcard.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class TestWildcard
+{
+
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/AbstractJavaBeanTest.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/AbstractJavaBeanTest.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/AbstractJavaBeanTest.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,56 @@
+/*
+* 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.javabean.test;
+
+import org.jboss.javabean.plugins.jaxb.JavaBean10;
+import org.jboss.javabean.plugins.jaxb.JavaBean20;
+import org.jboss.test.xb.builder.AbstractBuilderTest;
+
+/**
+ * AbstractJavaBeanTest.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision$
+ */
+public class AbstractJavaBeanTest extends AbstractBuilderTest
+{
+ public AbstractJavaBeanTest(String name)
+ {
+ super(name);
+ }
+
+ protected <T> T unmarshalJavaBean(Class<T> expected, Class<?>... others) throws Exception
+ {
+ return unmarshalJavaBean10(expected, others);
+ }
+
+ protected <T> T unmarshalJavaBean10(Class<T> expected, Class<?>... others) throws Exception
+ {
+ return unmarshalObject(expected, JavaBean10.class, others);
+ }
+
+ protected <T> T unmarshalJavaBean20(Class<T> expected, Class<?>... others) throws Exception
+ {
+ return unmarshalObject(expected, JavaBean20.class, others);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/AmbiguityTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/AmbiguityTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/AmbiguityTestCase.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,69 @@
+/*
+* 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.javabean.test;
+
+import junit.framework.Test;
+import org.jboss.test.javabean.support.AmbiguityBean;
+
+/**
+ * PropertyTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 58996 $
+ */
+public class AmbiguityTestCase extends AbstractJavaBeanTest
+{
+ /**
+ * Create a new AmbiguityTestCase.
+ *
+ * @param name the test name
+ */
+ public AmbiguityTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Setup the test
+ *
+ * @return the test
+ */
+ public static Test suite()
+ {
+ return suite(AmbiguityTestCase.class);
+ }
+
+ public void testConfigureInt() throws Exception
+ {
+ AmbiguityBean ab = unmarshal("TestAmbiguityInt.xml", AmbiguityBean.class);
+ Object something = ab.something();
+ assertEquals(something.getClass(), Integer.class);
+ }
+
+ public void testConfigureString() throws Exception
+ {
+ AmbiguityBean ab = unmarshal("TestAmbiguityString.xml", AmbiguityBean.class);
+ Object something = ab.something();
+ assertEquals(something.getClass(), String.class);
+ }
+
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/InstantiateTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/InstantiateTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/InstantiateTestCase.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,61 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.javabean.test;
+
+import junit.framework.Test;
+import org.jboss.test.javabean.support.SimpleBean;
+
+/**
+ * InstantiateTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 68544 $
+ */
+public class InstantiateTestCase extends AbstractJavaBeanTest
+{
+ public void testInstantiate() throws Exception
+ {
+ SimpleBean bean = unmarshal("TestInstantiate.xml", SimpleBean.class);
+ assertEquals("()", bean.getConstructorUsed());
+ }
+
+ /**
+ * Setup the test
+ *
+ * @return the test
+ */
+ public static Test suite()
+ {
+ return suite(InstantiateTestCase.class);
+ }
+
+ /**
+ * Create a new InstantiateTestCase.
+ *
+ * @param name the test name
+ */
+ public InstantiateTestCase(String name)
+ {
+ super(name);
+ }
+
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/JavaBeanTestSuite.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/JavaBeanTestSuite.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/JavaBeanTestSuite.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.javabean.test;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * JavaBean Test Suite.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 68544 $
+ */
+public class JavaBeanTestSuite extends TestSuite
+{
+ public static void main(String[] args)
+ {
+ TestRunner.run(suite());
+ }
+
+ public static Test suite()
+ {
+ TestSuite suite = new TestSuite("JavaBean Tests");
+
+ suite.addTest(InstantiateTestCase.suite());
+ suite.addTest(PropertyTestCase.suite());
+ suite.addTest(AmbiguityTestCase.suite());
+ // jaxb tests
+ suite.addTest(SimpleInstantiateUnitTestCase.suite());
+ suite.addTest(StaticMethodInstantiateUnitTestCase.suite());
+ suite.addTest(StaticClassMethodInstantiateUnitTestCase.suite());
+ suite.addTest(ParameterInstantiateUnitTestCase.suite());
+ suite.addTest(PropertyUnitTestCase.suite());
+ suite.addTest(PropertyWildcardUnitTestCase.suite());
+
+ return suite;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/ParameterInstantiateUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/ParameterInstantiateUnitTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/ParameterInstantiateUnitTestCase.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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.test.javabean.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.javabean.support.TestParameterInstantiate;
+
+/**
+ * ParameterInstantiateUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ParameterInstantiateUnitTestCase extends AbstractJavaBeanTest
+{
+ public static Test suite()
+ {
+ return suite(ParameterInstantiateUnitTestCase.class);
+ }
+
+ public ParameterInstantiateUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testParameterInstantiate() throws Exception
+ {
+ TestParameterInstantiate result = unmarshalJavaBean20(TestParameterInstantiate.class);
+ assertEquals("Hello5", result.constructorUsed);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/PropertyTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/PropertyTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/PropertyTestCase.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,204 @@
+/*
+* 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.javabean.test;
+
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+
+import junit.framework.Test;
+import org.jboss.test.javabean.support.SimpleBean;
+import org.jboss.util.NestedRuntimeException;
+
+/**
+ * PropertyTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 68544 $
+ */
+public class PropertyTestCase extends AbstractJavaBeanTest
+{
+// private static DateFormat dateFormat = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy");
+ // EEE names - Locale configured
+ private static DateFormat dateFormat = new SimpleDateFormat("MMM d HH:mm:ss z yyyy");
+
+ String stringValue = "StringValue";
+ Byte byteValue = new Byte("12");
+ Boolean booleanValue = Boolean.TRUE;
+ // TODO character
+ // Character characterValue = new Character('a');
+ Short shortValue = new Short("123");
+ Integer integerValue = new Integer("1234");
+ Long longValue = new Long("12345");
+ Float floatValue = new Float("3.14");
+ Double doubleValue = new Double("3.14e12");
+// Date dateValue = createDate("Mon Jan 01 00:00:00 CET 2001");
+ Date dateValue = createDate("Jan 01 00:00:00 CET 2001");
+ BigDecimal bigDecimalValue = new BigDecimal("12e4");
+ BigInteger bigIntegerValue = new BigInteger("123456");
+
+ 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
+ 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());
+ assertEquals(booleanValue, bean.getABoolean());
+ // TODO character
+ // assertEquals(characterValue, bean.getACharacter());
+ assertEquals(shortValue, bean.getAShort());
+ assertEquals(integerValue, bean.getAnInt());
+ assertEquals(longValue, bean.getALong());
+ assertEquals(floatValue, bean.getAFloat());
+ assertEquals(doubleValue, bean.getADouble());
+ assertEquals(dateValue, bean.getADate());
+ assertEquals(bigDecimalValue, bean.getABigDecimal());
+ assertEquals(bigIntegerValue, bean.getABigInteger());
+ assertEquals(byteValue.byteValue(), bean.getAbyte());
+ assertEquals(booleanValue.booleanValue(), bean.isAboolean());
+ // TODO character
+ // assertEquals(characterValue.charValue(), bean.getAchar());
+ assertEquals(shortValue.shortValue(), bean.getAshort());
+ assertEquals(integerValue.intValue(), bean.getAnint());
+ assertEquals(longValue.longValue(), bean.getAlong());
+ assertEquals(floatValue.floatValue(), bean.getAfloat());
+ assertEquals(doubleValue.doubleValue(), bean.getAdouble());
+ Number number = bean.getANumber();
+ assertEquals(Long.class, number.getClass());
+ assertEquals(longValue, number);
+ assertEquals(stringValue, bean.getOverloadedProperty());
+ // An all uppercase property
+ assertEquals("XYZ", bean.getXYZ());
+ assertEquals("abc", bean.getAbc());
+ }
+
+ protected Date createDate(String date)
+ {
+ try
+ {
+ return dateFormat.parse(date);
+ }
+ catch (Exception e)
+ {
+ throw new NestedRuntimeException(e);
+ }
+ }
+
+ /**
+ * Setup the test
+ *
+ * @return the test
+ */
+ public static Test suite()
+ {
+ return suite(PropertyTestCase.class);
+ }
+
+ /**
+ * Create a new InstantiateTestCase.
+ *
+ * @param name the test name
+ */
+ public PropertyTestCase(String name)
+ {
+ super(name);
+ }
+
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/PropertyUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/PropertyUnitTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/PropertyUnitTestCase.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,115 @@
+/*
+* 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.javabean.test;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import junit.framework.Test;
+
+import org.jboss.test.javabean.support.TestProperty;
+
+/**
+ * PropertyInstantiateUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class PropertyUnitTestCase extends AbstractJavaBeanTest
+{
+ private static DateFormat dateFormat = new SimpleDateFormat("MMM d HH:mm:ss z yyyy");
+
+ String stringValue = "StringValue";
+ Byte byteValue = new Byte("12");
+ Boolean booleanValue = Boolean.TRUE;
+ // TODO character
+ // Character characterValue = new Character('a');
+ Short shortValue = new Short("123");
+ Integer integerValue = new Integer("1234");
+ Long longValue = new Long("12345");
+ Float floatValue = new Float("3.14");
+ Double doubleValue = new Double("3.14e12");
+// Date dateValue = createDate("Mon Jan 01 00:00:00 CET 2001");
+// Date dateValue = createDate("Jan 01 00:00:00 CET 2001");
+ BigDecimal bigDecimalValue = new BigDecimal("12e4");
+ BigInteger bigIntegerValue = new BigInteger("123456");
+
+ public static Test suite()
+ {
+ return suite(PropertyUnitTestCase.class);
+ }
+
+ public PropertyUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testProperty() throws Exception
+ {
+ TestProperty bean = unmarshalJavaBean(TestProperty.class);
+
+ assertEquals(stringValue, bean.getAString());
+ assertEquals(byteValue, bean.getAByte());
+ assertEquals(booleanValue, bean.getABoolean());
+ // TODO character
+ // assertEquals(characterValue, bean.getACharacter());
+ assertEquals(shortValue, bean.getAShort());
+ assertEquals(integerValue, bean.getAnInt());
+ assertEquals(longValue, bean.getALong());
+ assertEquals(floatValue, bean.getAFloat());
+ assertEquals(doubleValue, bean.getADouble());
+ // TODO assertEquals(dateValue, bean.getADate());
+ assertEquals(bigDecimalValue, bean.getABigDecimal());
+ assertEquals(bigIntegerValue, bean.getABigInteger());
+ assertEquals(byteValue.byteValue(), bean.getAbyte());
+ assertEquals(booleanValue.booleanValue(), bean.isAboolean());
+ // TODO character
+ // assertEquals(characterValue.charValue(), bean.getAchar());
+ assertEquals(shortValue.shortValue(), bean.getAshort());
+ assertEquals(integerValue.intValue(), bean.getAnint());
+ assertEquals(longValue.longValue(), bean.getAlong());
+ assertEquals(floatValue.floatValue(), bean.getAfloat());
+ assertEquals(doubleValue.doubleValue(), bean.getAdouble());
+ Number number = bean.getANumber();
+ assertEquals(Long.class, number.getClass());
+ assertEquals(longValue, number);
+ assertEquals(stringValue, bean.getOverloadedProperty());
+ // An all uppercase property
+ assertEquals("XYZ", bean.getXYZ());
+ assertEquals("abc", bean.getAbc());
+ }
+
+ protected Date createDate(String date)
+ {
+ try
+ {
+ return dateFormat.parse(date);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/PropertyWildcardUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/PropertyWildcardUnitTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/PropertyWildcardUnitTestCase.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,53 @@
+/*
+* 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.javabean.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.javabean.support.TestPropertyWildcard;
+import org.jboss.test.javabean.support.TestWildcard;
+
+/**
+ * PropertyWildcardUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class PropertyWildcardUnitTestCase extends AbstractJavaBeanTest
+{
+ public static Test suite()
+ {
+ return suite(PropertyWildcardUnitTestCase.class);
+ }
+
+ public PropertyWildcardUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testProperty() throws Exception
+ {
+ TestPropertyWildcard bean = unmarshalJavaBean(TestPropertyWildcard.class);
+ TestWildcard wildcard = bean.getBean();
+ assertNotNull(wildcard);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/SimpleInstantiateUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/SimpleInstantiateUnitTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/SimpleInstantiateUnitTestCase.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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.test.javabean.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.javabean.support.TestSimpleInstantiate;
+
+/**
+ * SimpleInstantiateUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleInstantiateUnitTestCase extends AbstractJavaBeanTest
+{
+ public static Test suite()
+ {
+ return suite(SimpleInstantiateUnitTestCase.class);
+ }
+
+ public SimpleInstantiateUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testSimpleInstantiate() throws Exception
+ {
+ unmarshalJavaBean20(TestSimpleInstantiate.class);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/StaticClassMethodInstantiateUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/StaticClassMethodInstantiateUnitTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/StaticClassMethodInstantiateUnitTestCase.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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.test.javabean.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.javabean.support.TestStaticClassMethodInstantiate;
+
+/**
+ * StaticClassMethodInstantiateUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class StaticClassMethodInstantiateUnitTestCase extends AbstractJavaBeanTest
+{
+ public static Test suite()
+ {
+ return suite(StaticClassMethodInstantiateUnitTestCase.class);
+ }
+
+ public StaticClassMethodInstantiateUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testStaticClassMethodInstantiate() throws Exception
+ {
+ unmarshalJavaBean20(TestStaticClassMethodInstantiate.class);
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/StaticMethodInstantiateUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/StaticMethodInstantiateUnitTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/javabean/test/StaticMethodInstantiateUnitTestCase.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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.test.javabean.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.javabean.support.TestStaticMethodInstantiate;
+
+/**
+ * StaticMethodInstantiateUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class StaticMethodInstantiateUnitTestCase extends AbstractJavaBeanTest
+{
+ public static Test suite()
+ {
+ return suite(StaticMethodInstantiateUnitTestCase.class);
+ }
+
+ public StaticMethodInstantiateUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testStaticMethodInstantiate() throws Exception
+ {
+ unmarshalJavaBean20(TestStaticMethodInstantiate.class);
+ }
+}
Modified: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/AbstractBuilderTest.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/AbstractBuilderTest.java 2008-02-29 13:32:16 UTC (rev 2713)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/AbstractBuilderTest.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -211,7 +211,38 @@
result = rootName + ".xml";
return result;
}
-
+
+ /**
+ * Unmarshal some xml
+ *
+ * @param <T> the expected type
+ * @param name the name
+ * @param expected the expected type
+ * @return the unmarshalled object
+ * @throws Exception for any error
+ */
+ protected <T> T unmarshal(String name, Class<T> expected) throws Exception
+ {
+ Object object = unmarshal(name);
+ if (object == null)
+ fail("No object from " + name);
+ assertTrue("Object '" + object + "' cannot be assigned to " + expected.getName(), expected.isAssignableFrom(object.getClass()));
+ return expected.cast(object);
+ }
+
+ /**
+ * Unmarshal some xml
+ *
+ * @param name the name
+ * @return the unmarshalled object
+ * @throws Exception for any error
+ */
+ protected Object unmarshal(String name) throws Exception
+ {
+ String url = findXML(name);
+ return getJBossXBDelegate().unmarshal(url);
+ }
+
/**
* Get the package root name
*
Modified: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/JBossXBTestDelegate.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/JBossXBTestDelegate.java 2008-02-29 13:32:16 UTC (rev 2713)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/JBossXBTestDelegate.java 2008-03-03 15:37:06 UTC (rev 2714)
@@ -31,6 +31,7 @@
import org.jboss.xb.binding.sunday.unmarshalling.DefaultSchemaResolver;
import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory;
import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
/**
@@ -128,6 +129,31 @@
throw e;
}
}
+
+ /**
+ * Unmarshal an object
+ *
+ * @param url the url
+ * @return the object
+ * @throws Exception for any error
+ */
+ public Object unmarshal(String url) throws Exception
+ {
+ long start = System.currentTimeMillis();
+ Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+ log.debug("Initialized parsing in " + (System.currentTimeMillis() - start) + "ms");
+ try
+ {
+ Object result = unmarshaller.unmarshal(url, SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver());
+ log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms");
+ return result;
+ }
+ catch (Exception e)
+ {
+ log.debug("Error during parsing: " + url, e);
+ throw e;
+ }
+ }
/**
* Unmarshal an object
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/ParameterInstantiate.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/ParameterInstantiate.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/ParameterInstantiate.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:2.0"
+ class="org.jboss.test.javabean.support.TestParameterInstantiate">
+ <constructor>
+ <parameter>Hello</parameter>
+ <parameter>5</parameter>
+ </constructor>
+</javabean>
\ No newline at end of file
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/Property.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/Property.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/Property.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:1.0"
+ class="org.jboss.test.javabean.support.TestProperty">
+ <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">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>
\ No newline at end of file
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/PropertyWildcard.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/PropertyWildcard.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/PropertyWildcard.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:1.0"
+ class="org.jboss.test.javabean.support.TestPropertyWildcard">
+ <property name="bean">
+ <javabean class="org.jboss.test.javabean.support.TestWildcard"/>
+ </property>
+</javabean>
\ No newline at end of file
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/SimpleInstantiate.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/SimpleInstantiate.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/SimpleInstantiate.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:2.0"
+ class="org.jboss.test.javabean.support.TestSimpleInstantiate">
+</javabean>
\ No newline at end of file
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/StaticClassMethodInstantiate.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/StaticClassMethodInstantiate.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/StaticClassMethodInstantiate.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:2.0">
+ <constructor factoryClass="org.jboss.test.javabean.support.TestStaticClassMethodInstantiator" factoryMethod="instantiate"/>
+</javabean>
\ No newline at end of file
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/StaticMethodInstantiate.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/StaticMethodInstantiate.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/StaticMethodInstantiate.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:2.0"
+ class="org.jboss.test.javabean.support.TestStaticMethodInstantiate">
+ <constructor factoryMethod="instantiate"/>
+</javabean>
\ No newline at end of file
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestAmbiguityInt.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestAmbiguityInt.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestAmbiguityInt.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:1.0" class="org.jboss.test.javabean.support.AmbiguityBean">
+ <property name="something" class="java.lang.Integer">123</property>
+</javabean>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestAmbiguityString.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestAmbiguityString.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestAmbiguityString.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:1.0" class="org.jboss.test.javabean.support.AmbiguityBean">
+ <property name="something" class="java.lang.String">SomeString</property>
+</javabean>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:1.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>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtor.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtor.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtor.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClass.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClass.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClass.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClassAndParams.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClassAndParams.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorExplicitFactoryClassAndParams.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorFactory.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorFactory.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestConfigure20WithCtorFactory.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -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>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestInstantiate.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestInstantiate.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/javabean/test/TestInstantiate.xml 2008-03-03 15:37:06 UTC (rev 2714)
@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<javabean xmlns="urn:jboss:javabean:1.0" class="org.jboss.test.javabean.support.SimpleBean"/>
More information about the jboss-svn-commits
mailing list