[jboss-cvs] JBossAS SVN: r74476 - in projects/jboss-deployers/trunk: deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jun 12 07:14:59 EDT 2008


Author: alesj
Date: 2008-06-12 07:14:58 -0400 (Thu, 12 Jun 2008)
New Revision: 74476

Added:
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/UnmarshallerFactory.java
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/UnmarshallerFactoryDeployer.java
Modified:
   projects/jboss-deployers/trunk/build/pom.xml
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JBossXBDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JBossXBDeployerHelper.java
   projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/MultipleJBossXBDeployer.java
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/MyMetaData-include.xml
   projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/included.xml
   projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/IncludeTestCase.java
Log:
[JBDEPLOY-47]; allow for parsers to define/set features.
Update jbossxb to 2.0.0.CR10.

Modified: projects/jboss-deployers/trunk/build/pom.xml
===================================================================
--- projects/jboss-deployers/trunk/build/pom.xml	2008-06-12 10:53:09 UTC (rev 74475)
+++ projects/jboss-deployers/trunk/build/pom.xml	2008-06-12 11:14:58 UTC (rev 74476)
@@ -28,7 +28,7 @@
     <version.jboss.common.core>2.2.4.GA</version.jboss.common.core>
     <version.jboss.common.logging.spi>2.0.4.GA</version.jboss.common.logging.spi>
     <version.jboss.common.logging.log4j>2.0.4.GA</version.jboss.common.logging.log4j>
-    <version.jbossxb>2.0.0-SNAPSHOT</version.jbossxb>
+    <version.jbossxb>2.0.0.CR10</version.jbossxb>
     <version.jboss.aop>2.0.0.CR11</version.jboss.aop>
     <version.jboss.vfs>2.0.0.Beta14</version.jboss.vfs>
     <version.org.jboss.test>1.0.5.GA</version.org.jboss.test>

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/MyMetaData-include.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/MyMetaData-include.xml	2008-06-12 10:53:09 UTC (rev 74475)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/MyMetaData-include.xml	2008-06-12 11:14:58 UTC (rev 74476)
@@ -2,7 +2,7 @@
 
 <jboss-include xmlns="urn:jboss:include:1.0" name="mymetadata" xmlns:xi="http://www.w3.org/2001/XInclude">
 
-  <jboss-test>test1</jboss-test>
-  <xi:include fixup-base-uris="false" fixup-language="false" href="included.xml"/>
+  <jboss-test name="test1"/>
+  <xi:include href="included.xml"/>
   
 </jboss-include>

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/included.xml
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/included.xml	2008-06-12 10:53:09 UTC (rev 74475)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/resources/tests/org/jboss/test/deployers/vfs/xb/test/included.xml	2008-06-12 11:14:58 UTC (rev 74476)
@@ -1,3 +1,3 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<jboss-test xmlns="urn:jboss:include:1.0">test2</jboss-test>
+<jboss-test xmlns="urn:jboss:include:1.0" name="test2"/>
 

Modified: projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/IncludeTestCase.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/IncludeTestCase.java	2008-06-12 10:53:09 UTC (rev 74475)
+++ projects/jboss-deployers/trunk/deployers-vfs/src/tests/org/jboss/test/deployers/vfs/xb/test/IncludeTestCase.java	2008-06-12 11:14:58 UTC (rev 74476)
@@ -67,6 +67,6 @@
       int size = 2;
       assertEquals(size, others.size());
       for(int i=0; i < size; i++)
-         assertEquals("test" + i, others.get(i).getName());
+         assertEquals("test" + (i+1), others.get(i).getName());
    }
 }

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java	2008-06-12 10:53:09 UTC (rev 74475)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java	2008-06-12 11:14:58 UTC (rev 74476)
@@ -42,9 +42,10 @@
  * @param <T> the expected type 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @author Scott.Stark at jboss.org
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  * @version $Revision: 60707 $
  */
-public abstract class JAXPDeployer<T> extends AbstractVFSParsingDeployer<T>
+public abstract class JAXPDeployer<T> extends UnmarshallerFactoryDeployer<T, Boolean>
 {
    /** Use a namespace aware parser */
    private boolean useNamespaceAwareParser = true;
@@ -138,7 +139,23 @@
    {
       documentBuilderFactory = null;
    }
-   
+
+   protected UnmarshallerFactory<Boolean> createUnmarshallerFactory()
+   {
+      return new UnmarshallerFactory<Boolean>()
+      {
+         public void setFeature(String featureName, Boolean flag) throws Exception
+         {
+            getDocumentBuilderFactory().setFeature(featureName, flag);
+         }
+      };
+   }
+
+   protected Boolean fromString(String value)
+   {
+      return Boolean.valueOf(value);
+   }
+
    @Override
    protected T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception
    {

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JBossXBDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JBossXBDeployer.java	2008-06-12 10:53:09 UTC (rev 74475)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JBossXBDeployer.java	2008-06-12 11:14:58 UTC (rev 74476)
@@ -27,7 +27,7 @@
  * @param <T> the expected type
  * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  */
-public abstract class JBossXBDeployer<T> extends AbstractVFSParsingDeployer<T>
+public abstract class JBossXBDeployer<T> extends UnmarshallerFactoryDeployer<T, Boolean>
 {
    /** The helper */
    private JBossXBDeployerHelper<T> helper;
@@ -54,6 +54,16 @@
       return helper;
    }
 
+   protected UnmarshallerFactory<Boolean> createUnmarshallerFactory()
+   {
+      return getHelper();
+   }
+
+   protected Boolean fromString(String value)
+   {
+      return Boolean.valueOf(value);
+   }
+
    /**
     * Get the useSchemaValidation.
     *

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JBossXBDeployerHelper.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JBossXBDeployerHelper.java	2008-06-12 10:53:09 UTC (rev 74475)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JBossXBDeployerHelper.java	2008-06-12 11:14:58 UTC (rev 74476)
@@ -41,7 +41,7 @@
  * @param <T> the expected type
  * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  */
-public class JBossXBDeployerHelper<T>
+public class JBossXBDeployerHelper<T> implements org.jboss.deployers.vfs.spi.deployer.UnmarshallerFactory<Boolean>
 {
    /** The log */
    private Logger log = Logger.getLogger(JBossXBDeployerHelper.class);
@@ -74,6 +74,11 @@
       this.output = output;
    }
 
+   public void setFeature(String featureName, Boolean flag) throws Exception
+   {
+      factory.setFeature(featureName, flag);
+   }
+
    /**
     * Get the useSchemaValidation.
     *

Modified: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/MultipleJBossXBDeployer.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/MultipleJBossXBDeployer.java	2008-06-12 10:53:09 UTC (rev 74475)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/MultipleJBossXBDeployer.java	2008-06-12 11:14:58 UTC (rev 74476)
@@ -34,6 +34,9 @@
    /** The helper */
    private JBossXBDeployerHelper<T> helper;
 
+   /** The features */
+   private Map<String, Boolean> features;
+
    public MultipleJBossXBDeployer(Class<T> output, Map<String, Class<?>> mappings)
    {
       this(output, mappings, null, null);
@@ -55,6 +58,15 @@
       return helper;
    }
 
+   public void start() throws Exception
+   {
+      if (features != null && features.isEmpty() == false)
+      {
+         for(Map.Entry<String,Boolean> entry : features.entrySet())
+            helper.setFeature(entry.getKey(), entry.getValue());
+      }
+   }
+
    /**
     * Get the useSchemaValidation.
     *
@@ -94,4 +106,24 @@
    {
       helper.setUseValidation(useValidation);
    }
+
+   /**
+    * Get unmarshaller features.
+    *
+    * @return the features
+    */
+   public Map<String, Boolean> getFeatures()
+   {
+      return features;
+   }
+
+   /**
+    * Set the unmarshaller features.
+    *
+    * @param features the features
+    */
+   public void setFeatures(Map<String, Boolean> features)
+   {
+      this.features = features;
+   }
 }
\ No newline at end of file

Added: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/UnmarshallerFactory.java
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/UnmarshallerFactory.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/UnmarshallerFactory.java	2008-06-12 11:14:58 UTC (rev 74476)
@@ -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.deployers.vfs.spi.deployer;
+
+/**
+ * Set feature on parser/unmarshaller.
+ *
+ * @param <T> exact feature flag type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+interface UnmarshallerFactory<T>
+{
+   /**
+    * Apply feature.
+    *
+    * @param featureName the feature name
+    * @param flag the feature flag
+    * @throws Exception for any error
+    */
+   void setFeature(String featureName, T flag) throws Exception;
+}

Copied: projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/UnmarshallerFactoryDeployer.java (from rev 74415, projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/JAXPDeployer.java)
===================================================================
--- projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/UnmarshallerFactoryDeployer.java	                        (rev 0)
+++ projects/jboss-deployers/trunk/deployers-vfs-spi/src/main/org/jboss/deployers/vfs/spi/deployer/UnmarshallerFactoryDeployer.java	2008-06-12 11:14:58 UTC (rev 74476)
@@ -0,0 +1,112 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.deployers.vfs.spi.deployer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Unmarshaller factory deployer.
+ * Able to apply features to unmarshaller factory.
+ *
+ * @param <U> exact unmarshaller factory's flag type
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class UnmarshallerFactoryDeployer<T, U> extends AbstractVFSParsingDeployer<T>
+{
+   /** The fixup base uris */
+   static String FIXUP_BASE_URIS = "http://apache.org/xml/features/xinclude/fixup-base-uris";
+
+   /** The fixup base lang */
+   static String FIXUP_LANGUAGE = "http://apache.org/xml/features/xinclude/fixup-language";
+
+   /** Use default features */
+   private boolean useDefaultFeatures = true;
+
+   /** Features map */
+   private Map<String, U> features;
+
+   protected UnmarshallerFactoryDeployer(Class<T> output)
+   {
+      super(output);
+   }
+
+   /**
+    * Create unmarshaller factory wrapper.
+    * @return the unmarshaller factory
+    */
+   protected abstract UnmarshallerFactory<U> createUnmarshallerFactory();
+
+   public void start() throws Exception
+   {
+      UnmarshallerFactory<U> unmarshallerFactory = createUnmarshallerFactory();
+      if (unmarshallerFactory == null)
+         throw new IllegalArgumentException("Unmarshaller factory cannot be null.");
+
+      Map<String,U> features = getFeatures();
+      if (isUseDefaultFeatures())
+      {
+         if (features == null)
+            features = new HashMap<String,U>();
+
+         if (features.containsKey(FIXUP_BASE_URIS) == false)
+            features.put(FIXUP_BASE_URIS, fromString("false"));
+
+         if (features.containsKey(FIXUP_LANGUAGE) == false)
+            features.put(FIXUP_LANGUAGE, fromString("false"));
+      }
+
+      if (features != null && features.isEmpty() == false)
+      {
+         for(Map.Entry<String,U> entry : features.entrySet())
+            unmarshallerFactory.setFeature(entry.getKey(), entry.getValue());
+      }
+   }
+
+   /**
+    * Transform string to flag value.
+    *
+    * @param value the value
+    * @return value as T type
+    */
+   protected abstract U fromString(String value);
+
+   public boolean isUseDefaultFeatures()
+   {
+      return useDefaultFeatures;
+   }
+
+   public void setUseDefaultFeatures(boolean useDefaultFeatures)
+   {
+      this.useDefaultFeatures = useDefaultFeatures;
+   }
+
+   public Map<String, U> getFeatures()
+   {
+      return features;
+   }
+
+   public void setFeatures(Map<String, U> features)
+   {
+      this.features = features;
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list