[jboss-svn-commits] JBoss Common SVN: r3008 - in jbossxb/trunk/src: test/java/org/jboss/test/xb/builder and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Mar 5 04:19:45 EST 2009
Author: alex.loubyansky at jboss.com
Date: 2009-03-05 04:19:44 -0500 (Thu, 05 Mar 2009)
New Revision: 3008
Added:
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/useunorderedsequence/
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/useunorderedsequence/test/
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/useunorderedsequence/test/InitializationUnitTestCase.java
Modified:
jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBBuilder.java
Log:
JBXB-189
Modified: jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBBuilder.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBBuilder.java 2009-03-04 15:59:18 UTC (rev 3007)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBBuilder.java 2009-03-05 09:19:44 UTC (rev 3008)
@@ -43,11 +43,23 @@
/**
* JBossXBBuilder.
*
+ * Builds instances SchemaBinding for passed in classes by parsing binding annotations.
+ * By default, built instances of SchemaBinding are cached in the instances of ClassInfo.
+ * There are methods though that allow to re-build the cached bindings.
+ *
+ * Whether SequenceBinding or UnorderedSequenceBinding is used as the default for sequences is controlled
+ * by static property useUnorderedSequence. The value can be set by calling static method setUseUnorderedSequence(boolean value)
+ * or by setting system property xb.builder.useUnorderedSequence to true or false. The initialization fro the system property
+ * happens once in the static initializer.
+ *
* @author <a href="adrian at jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
public class JBossXBBuilder
{
+ /** system property name to use for initialization */
+ public static final String USE_UNORDERED_SEQUENCE_PROPERTY = "xb.builder.useUnorderedSequence";
+
/** The configuration */
static Configuration configuration;
@@ -68,9 +80,13 @@
return new PropertyConfiguration();
}
});
-
+
STRING = configuration.getClassInfo(String.class);
OBJECT = configuration.getClassInfo(Object.class);
+
+ String useUnorderedSequenceStr = System.getProperty(JBossXBBuilder.USE_UNORDERED_SEQUENCE_PROPERTY);
+ if(useUnorderedSequenceStr != null)
+ useUnorderedSequence = Boolean.parseBoolean(useUnorderedSequenceStr);
}
public static boolean isUseUnorderedSequence()
Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/useunorderedsequence/test/InitializationUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/useunorderedsequence/test/InitializationUnitTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/useunorderedsequence/test/InitializationUnitTestCase.java 2009-03-05 09:19:44 UTC (rev 3008)
@@ -0,0 +1,78 @@
+/*
+ * 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.xb.builder.useunorderedsequence.test;
+
+import java.lang.reflect.Method;
+import java.net.URLClassLoader;
+
+import org.jboss.xb.builder.JBossXBBuilder;
+
+import junit.framework.TestCase;
+
+/**
+ * A InitializationUnitTestCase.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class InitializationUnitTestCase extends TestCase
+{
+ private String unorderedSequenceDefaultSystemValue;
+ private ClassLoader cl;
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ unorderedSequenceDefaultSystemValue = System.getProperty(JBossXBBuilder.USE_UNORDERED_SEQUENCE_PROPERTY);
+
+ ClassLoader builderCl = JBossXBBuilder.class.getClassLoader();
+ if(builderCl == null)
+ builderCl = ClassLoader.getSystemClassLoader();
+ assertTrue(builderCl instanceof URLClassLoader);
+ cl = new URLClassLoader(((URLClassLoader)builderCl).getURLs(), null);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ if(unorderedSequenceDefaultSystemValue != null)
+ System.setProperty(JBossXBBuilder.USE_UNORDERED_SEQUENCE_PROPERTY, unorderedSequenceDefaultSystemValue);
+ }
+
+ public void testFalse() throws Exception
+ {
+ initAndAssert(false);
+ }
+
+ public void testTrue() throws Exception
+ {
+ initAndAssert(true);
+ }
+
+ private void initAndAssert(Boolean value) throws Exception
+ {
+ System.setProperty(JBossXBBuilder.USE_UNORDERED_SEQUENCE_PROPERTY, Boolean.toString(value));
+ Class<?> clazz = cl.loadClass(JBossXBBuilder.class.getName());
+ Method m = clazz.getMethod("isUseUnorderedSequence");
+ assertEquals(value, m.invoke(null));
+ }
+}
More information about the jboss-svn-commits
mailing list