[jboss-cvs] JBossAS SVN: r59971 - in projects/microcontainer/trunk: deployers and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 24 10:56:38 EST 2007


Author: adrian at jboss.org
Date: 2007-01-24 10:56:38 -0500 (Wed, 24 Jan 2007)
New Revision: 59971

Added:
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/JAXBDeployer.java
Modified:
   projects/microcontainer/trunk/build/build-thirdparty.xml
   projects/microcontainer/trunk/deployers/.classpath
   projects/microcontainer/trunk/deployers/build.xml
Log:
Add initial support for a JAXB parsing deployer.

Modified: projects/microcontainer/trunk/build/build-thirdparty.xml
===================================================================
--- projects/microcontainer/trunk/build/build-thirdparty.xml	2007-01-24 15:53:31 UTC (rev 59970)
+++ projects/microcontainer/trunk/build/build-thirdparty.xml	2007-01-24 15:56:38 UTC (rev 59971)
@@ -62,6 +62,9 @@
       <componentref name="jboss/test14" version="snapshot"/>
       <componentref name="osgi" version="4.0"/>
       <componentref name="oswego-concurrent" version="1.3.4"/>
+      <componentref name="stax-api" version="1.0"/>
+      <componentref name="sun-jaf" version="1.1"/>
+      <componentref name="sun-jaxb" version="2.1"/>
       <componentref name="sun-javacc" version="4.0"/>
       <componentref name="trove" version="1.0.2"/>
    </build>

Modified: projects/microcontainer/trunk/deployers/.classpath
===================================================================
--- projects/microcontainer/trunk/deployers/.classpath	2007-01-24 15:53:31 UTC (rev 59970)
+++ projects/microcontainer/trunk/deployers/.classpath	2007-01-24 15:56:38 UTC (rev 59971)
@@ -1,20 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src/main"/>
-	<classpathentry kind="src" path="src/tests"/>
-	<classpathentry kind="lib" path="src/resources/tests"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar" sourcepath="/thirdparty/jboss/common-core/lib/jboss-common-core-sources.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-log4j/lib/jboss-logging-log4j.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/apache-log4j/lib/log4j.jar"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/container"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jbossxb/lib/jboss-xml-binding.jar"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/kernel"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/dependency"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs.jar" sourcepath="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs-sources.jar"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/managed"/>
-	<classpathentry kind="output" path="output/eclipse-classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry kind="src" path="src/tests"/>
+	<classpathentry kind="lib" path="src/resources/tests"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar" sourcepath="/thirdparty/jboss/common-core/lib/jboss-common-core-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-log4j/lib/jboss-logging-log4j.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/apache-log4j/lib/log4j.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/container"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jbossxb/lib/jboss-xml-binding.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/kernel"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/dependency"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs.jar" sourcepath="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs-sources.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/managed"/>
+	<classpathentry kind="lib" path="/thirdparty/sun-jaf/lib/activation.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/sun-jaxb/lib/jaxb-api.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/stax-api/lib/stax-api.jar"/>
+	<classpathentry kind="output" path="output/eclipse-classes"/>
+</classpath>

Modified: projects/microcontainer/trunk/deployers/build.xml
===================================================================
--- projects/microcontainer/trunk/deployers/build.xml	2007-01-24 15:53:31 UTC (rev 59970)
+++ projects/microcontainer/trunk/deployers/build.xml	2007-01-24 15:56:38 UTC (rev 59971)
@@ -72,6 +72,9 @@
       <path refid="jboss/common.logging.log4j.classpath"/>
       <path refid="jboss.jbossxb.classpath"/>
       <path refid="jboss/jboss.vfs.classpath"/>
+      <path refid="stax.api.classpath"/>
+      <path refid="sun.jaf.classpath"/>
+      <path refid="sun.jaxb.classpath"/>
     </path>
 
     &modules;

Added: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/JAXBDeployer.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/JAXBDeployer.java	                        (rev 0)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployers/helpers/JAXBDeployer.java	2007-01-24 15:56:38 UTC (rev 59971)
@@ -0,0 +1,132 @@
+/*
+* 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.plugins.deployers.helpers;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.virtual.VirtualFile;
+import org.xml.sax.InputSource;
+
+/**
+ * JAXBDeployer.
+ * 
+ * @param <T> the expected type 
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class JAXBDeployer<T> extends AbstractParsingDeployer<T>
+{
+   /** The JAXBContext */ 
+   private JAXBContext context;
+
+   /** The properties */
+   private Map<String, Object> properties;
+   
+   /**
+    * Create a new JAXBDeployer.
+    * 
+    * @param deploymentType the deployment type
+    * @throws IllegalArgumentException for a null deployment type
+    */
+   public JAXBDeployer(Class<T> deploymentType)
+   {
+      super(deploymentType);
+   }
+
+   /**
+    * Get the properties.
+    * 
+    * @return the properties.
+    */
+   public Map<String, Object> getProperties()
+   {
+      return properties;
+   }
+
+   /**
+    * Set the properties.
+    * 
+    * @param properties the properties.
+    */
+   public void setProperties(Map<String, Object> properties)
+   {
+      this.properties = properties;
+   }
+
+   /**
+    * Create lifecycle
+    * 
+    * @throws Exception for any problem
+    */
+   public void create() throws Exception
+   {
+      if (properties != null)
+         context = JAXBContext.newInstance(new Class[] { getDeploymentType() }, properties);
+      else
+         context = JAXBContext.newInstance(getDeploymentType());
+   }
+
+   /**
+    * Destroy lifecycle
+    */
+   public void destroy()
+   {
+      context = null;
+   }
+   
+   /**
+    * Parse a deployment
+    * 
+    * @param unit the deployment unit
+    * @param file the metadata file
+    * @param root - possibly null pre-existing root
+    * @return the metadata
+    * @throws Exception for any error
+    */
+   protected T parse(DeploymentUnit unit, VirtualFile file, T root) throws Exception
+   {
+      Unmarshaller unmarshaller = context.createUnmarshaller();
+      InputStream is = file.openStream();
+      try
+      {
+         InputSource source = new InputSource(is);
+         source.setSystemId(file.toURI().toString());
+         Object o = unmarshaller.unmarshal(source);
+         return getDeploymentType().cast(o);
+      }
+      finally
+      {
+         try
+         {
+            is.close();
+         }
+         catch (Exception ignored)
+         {
+         }
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list