[jboss-cvs] JBossAS SVN: r90063 - in projects/jboss-jca/trunk: doc/developerguide/en/modules and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 10 15:45:36 EDT 2009


Author: jesper.pedersen
Date: 2009-06-10 15:45:35 -0400 (Wed, 10 Jun 2009)
New Revision: 90063

Added:
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/ExtractUtil.java
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/RADeployer.java
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/RADeployment.java
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/SecurityActions.java
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/package.html
   projects/jboss-jca/trunk/sjc/src/main/resources/sjc-ra-manifest.mf
Removed:
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/RarDeployer.java
Modified:
   projects/jboss-jca/trunk/doc/developerguide/en/modules/standalone.xml
   projects/jboss-jca/trunk/ivy.xml
   projects/jboss-jca/trunk/sjc/build.xml
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/Main.java
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/Deployer.java
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/Deployment.java
   projects/jboss-jca/trunk/sjc/src/main/resources/boot.xml
   projects/jboss-jca/trunk/sjc/src/main/resources/log4j.xml
Log:
[JBJBA-96] SJC Resource Adapter deployer

Modified: projects/jboss-jca/trunk/doc/developerguide/en/modules/standalone.xml
===================================================================
--- projects/jboss-jca/trunk/doc/developerguide/en/modules/standalone.xml	2009-06-10 18:21:36 UTC (rev 90062)
+++ projects/jboss-jca/trunk/doc/developerguide/en/modules/standalone.xml	2009-06-10 19:45:35 UTC (rev 90063)
@@ -17,6 +17,8 @@
       JBoss JCA container where the configuration is done in a similar
       way to the JBoss Microcontainer.</para>
 
+    <para>SJC is short for "Simple JCA Container".</para>
+
     <section id="jcasjc_layout">
       <title>Layout</title>
 
@@ -138,6 +140,24 @@
       </itemizedlist>
     </section>
 
+    <section id="jcasjc_logging">
+      <title>Logging</title>
+
+      <para>There is support for logging using the JBoss Logging framework. The logging is done using two different
+        methods</para>
+
+      <itemizedlist>
+        <listitem>
+          <para>Inside SJC</para>
+          <para>All logging is handled through reflection calls which are wrapped with methods inside <code>Main</code> itself.</para>
+        </listitem>
+        <listitem>
+          <para>All other services</para>
+          <para>Logging is handled by importing <code>org.jboss.logging.Logger</code> and using the class as you would normally do.</para>
+        </listitem>
+      </itemizedlist>
+    </section>
+
     <section id="jcasjc_classloading">
       <title>Classloading</title>
 
@@ -179,10 +199,11 @@
 /**
  * Deploy
  * @param f The file
+ * @param parent The parent classloader
  * @return The deployment; or null if no deployment was made
  * @exception Exception Thrown if an error occurs
  */
-public Deployment deploy(File f) throws Exception;
+public Deployment deploy(File f, ClassLoader parent) throws Exception;
       </programlisting>
       <para>method which is invoked once with each of the files in the
         $JBOSS_JCA_HOME/deploy/ directory.</para>

Modified: projects/jboss-jca/trunk/ivy.xml
===================================================================
--- projects/jboss-jca/trunk/ivy.xml	2009-06-10 18:21:36 UTC (rev 90062)
+++ projects/jboss-jca/trunk/ivy.xml	2009-06-10 19:45:35 UTC (rev 90063)
@@ -50,10 +50,10 @@
     <dependency org="org.easymock" name="easymock" rev="${version.easymock}" conf="test->default"/>
     <dependency org="org.easymock" name="easymockclassextension" rev="${version.easymock}" conf="test->default"/>
     <dependency org="org.jboss" name="jboss-common-core" rev="${version.jboss.common}" conf="standalone->default;sjc->*"/>
-    <dependency org="org.jboss" name="jboss-mdr" rev="${version.jboss.mdr}" conf="standalone->default"/>
-    <dependency org="org.jboss" name="jboss-reflect" rev="${version.jboss.reflect}" conf="standalone->default"/>
+    <dependency org="org.jboss" name="jboss-mdr" rev="${version.jboss.mdr}" conf="standalone->default;sjc->*"/>
+    <dependency org="org.jboss" name="jboss-reflect" rev="${version.jboss.reflect}" conf="standalone->default;sjc->*"/>
     <dependency org="org.jboss" name="jboss-vfs" rev="${version.jboss.vfs}" conf="standalone->default"/>
-    <dependency org="org.jboss" name="jbossxb" rev="${version.jboss.xb}" conf="standalone->default"/>
+    <dependency org="org.jboss" name="jbossxb" rev="${version.jboss.xb}" conf="standalone->default;sjc->*"/>
     <dependency org="org.jboss.aop" name="jboss-aop" rev="${version.jboss.aop}" conf="standalone->default"/>
     <dependency org="org.jboss.aop" name="jboss-aop-asintegration-core" rev="${version.jboss.aop}" conf="standalone->default"/>
     <dependency org="org.jboss.aop" name="jboss-aop-asintegration-jmx" rev="${version.jboss.aop}" conf="standalone->default"/>
@@ -82,7 +82,7 @@
     <dependency org="org.jboss.logmanager" name="jboss-logmanager" rev="${version.jboss.logmanager}" conf="standalone->default;sjc->*"/>
     <dependency org="org.jboss.man" name="jboss-managed" rev="${version.jboss.managed}" conf="standalone->default"/>
     <dependency org="org.jboss.man" name="jboss-metatype" rev="${version.jboss.managed}" conf="standalone->default"/>
-    <dependency org="org.jboss.metadata" name="jboss-metadata" rev="${version.jboss.metadata}" conf="standalone->default"/>
+    <dependency org="org.jboss.metadata" name="jboss-metadata" rev="${version.jboss.metadata}" conf="standalone->default;sjc->*"/>
     <dependency org="org.jboss.microcontainer" name="jboss-aop-mc-int" rev="${version.jboss.mc.aop-int}" conf="standalone->default"/>
     <dependency org="org.jboss.microcontainer" name="jboss-dependency" rev="${version.jboss.mc.dependency}" conf="standalone->default"/>
     <dependency org="org.jboss.microcontainer" name="jboss-kernel" rev="${version.jboss.mc.kernel}" conf="standalone->default"/>

Modified: projects/jboss-jca/trunk/sjc/build.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/build.xml	2009-06-10 18:21:36 UTC (rev 90062)
+++ projects/jboss-jca/trunk/sjc/build.xml	2009-06-10 19:45:35 UTC (rev 90063)
@@ -82,6 +82,11 @@
     <jar destfile="${target.dir}/jboss-jca-sjc.jar"
          manifest="src/main/resources/sjc-manifest.mf"
          basedir="${build.sjc.dir}/impl"
+         excludes="**/*.java,**/ra/**"/>
+    <jar destfile="${target.dir}/jboss-jca-sjc-ra-deployer.jar"
+         manifest="src/main/resources/sjc-ra-manifest.mf"
+         basedir="${build.sjc.dir}/impl"
+         includes="**/ra/**"
          excludes="**/*.java"/>
   </target>
 
@@ -145,6 +150,7 @@
       <fileset dir="${target.dir}">
         <include name="*.jar"/>
         <exclude name="*sjc.jar"/>
+        <exclude name="jboss-jca-deployers*.jar"/>
       </fileset>
     </copy>
 

Modified: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/Main.java
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/Main.java	2009-06-10 18:21:36 UTC (rev 90062)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/Main.java	2009-06-10 19:45:35 UTC (rev 90063)
@@ -59,6 +59,9 @@
    /** Services */
    private static Map<String, Object> services = new HashMap<String, Object>();
 
+   /** Logging */
+   private static Object logging;
+
    /**
     * Default constructor
     */
@@ -102,6 +105,8 @@
          URLClassLoader classLoader = new URLClassLoader(urls, parent);
          SecurityActions.setThreadContextClassLoader(classLoader);
 
+         initLogging(classLoader);
+
          SecurityActions.setSystemProperty("xb.builder.useUnorderedSequence", "true");
          SecurityActions.setSystemProperty("jboss.deploy.url", deployDirectory.toURI().toURL().toString());
          SecurityActions.setSystemProperty("jboss.lib.url", libDirectory.toURI().toURL().toString());
@@ -125,7 +130,7 @@
                }
                else
                {
-                  System.out.println("Warning: A service with name " + bt.getName() + " already exists");
+                  warn("Warning: A service with name " + bt.getName() + " already exists");
                }
             }
          }
@@ -169,7 +174,7 @@
          }
       }
 
-      System.out.println("Shutdown complete");
+      info("Shutdown complete");
    }
 
    /**
@@ -264,12 +269,13 @@
       {
          try
          {
-            Method deployMethod = clz.getMethod("deploy", new Class[] {File.class});
+            Method deployMethod = clz.getMethod("deploy", new Class[] {File.class, ClassLoader.class});
 
             for (File f : deployDirectory.listFiles())
             {
+               Object[] parameters = new Object[] {f, cl};
                org.jboss.jca.sjc.deployers.Deployment deployment = 
-                  (org.jboss.jca.sjc.deployers.Deployment)deployMethod.invoke(instance, new Object[] {f});
+                  (org.jboss.jca.sjc.deployers.Deployment)deployMethod.invoke(instance, parameters);
                if (deployment != null)
                {
                   if (services.get(deployment.getName()) == null)
@@ -279,14 +285,14 @@
                   }
                   else
                   {
-                     System.out.println("Warning: A deployment with name " + deployment.getName() + " already exists");
+                     warn("Warning: A deployment with name " + deployment.getName() + " already exists");
                   }
                }
             }
          }
          catch (Exception e)
          {
-            e.printStackTrace(System.err);
+            error("Exception during createBean()", e);
          }
       }
 
@@ -439,6 +445,104 @@
    }
 
    /**
+    * Init logging
+    * @param cl The classloader to load from
+    */
+   private static void initLogging(ClassLoader cl)
+   {
+      try
+      {
+         Class clz = Class.forName("org.jboss.logging.Logger", true, cl);
+         
+         Method mGetLogger = clz.getMethod("getLogger", String.class);
+
+         logging = mGetLogger.invoke((Object)null, new Object[] { "Main" });
+      }
+      catch (Exception e)
+      {
+         // Nothing we can do
+      }
+   }
+
+   /**
+    * Logging: ERROR
+    * @param s The string
+    * @param t The throwable
+    */
+   private static void error(String s, Throwable t)
+   {
+      if (logging != null)
+      {
+         try
+         {
+            Class clz = logging.getClass();
+            Method mError = clz.getMethod("error", Object.class, Throwable.class);
+            mError.invoke(logging, new Object[] { s, t });
+         }
+         catch (Exception e)
+         {
+            // Nothing we can do
+         }
+      }
+      else
+      {
+         System.out.println(s);
+         t.printStackTrace(System.out);
+      }
+   }
+
+   /**
+    * Logging: WARN
+    * @param s The string
+    */
+   private static void warn(String s)
+   {
+      if (logging != null)
+      {
+         try
+         {
+            Class clz = logging.getClass();
+            Method mWarn = clz.getMethod("warn", Object.class);
+            mWarn.invoke(logging, new Object[] { s });
+         }
+         catch (Exception e)
+         {
+            // Nothing we can do
+         }
+      }
+      else
+      {
+         System.out.println(s);
+      }
+   }
+
+   /**
+    * Logging: INFO
+    * @param s The string
+    */
+   private static void info(String s)
+   {
+      if (logging != null)
+      {
+         try
+         {
+            Class clz = logging.getClass();
+            Method mInfo = clz.getMethod("info", Object.class);
+            mInfo.invoke(logging, new Object[] { s });
+         }
+         catch (Exception e)
+         {
+            // Nothing we can do
+         }
+      }
+      else
+      {
+         System.out.println(s);
+      }
+   }
+
+
+   /**
     * Main
     * @param args The arguments
     */
@@ -460,8 +564,7 @@
                }
                catch (Exception e)
                {
-                  System.err.println("Failed to boot JBoss JCA:");
-                  e.printStackTrace();
+                  error("Failed to boot JBoss JCA", e);
                }
             }
          };
@@ -484,11 +587,11 @@
          });
 
          long l2 = System.currentTimeMillis();
-         System.out.println("Server started in " + (l2 - l1) + "ms");
+         info("Server started in " + (l2 - l1) + "ms");
       }
       catch (Exception e)
       {
-         e.printStackTrace(System.err);
+         error("Exception during main()", e);
       }
    }
 

Modified: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/Deployer.java
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/Deployer.java	2009-06-10 18:21:36 UTC (rev 90062)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/Deployer.java	2009-06-10 19:45:35 UTC (rev 90063)
@@ -33,8 +33,9 @@
    /**
     * Deploy
     * @param f The file
+    * @param parent The parent classloader
     * @return The deployment; or null if no deployment was made
     * @exception Exception Thrown if an error occurs
     */
-   public Deployment deploy(File f) throws Exception;
+   public Deployment deploy(File f, ClassLoader parent) throws Exception;
 }

Modified: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/Deployment.java
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/Deployment.java	2009-06-10 18:21:36 UTC (rev 90062)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/Deployment.java	2009-06-10 19:45:35 UTC (rev 90063)
@@ -33,4 +33,10 @@
     * @return The name
     */
    public String getName();
+
+   /**
+    * Get the classloader
+    * @return The classloader
+    */
+   public ClassLoader getClassLoader();
 }

Deleted: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/RarDeployer.java
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/RarDeployer.java	2009-06-10 18:21:36 UTC (rev 90062)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/RarDeployer.java	2009-06-10 19:45:35 UTC (rev 90063)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.jca.sjc.deployers;
-
-import java.io.File;
-
-/**
- * The RAR deployer for JCA/SJC
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public class RarDeployer implements Deployer
-{
-   /**
-    * Constructor
-    */
-   public RarDeployer()
-   {
-   }
-
-   /**
-    * Deploy
-    * @param f The file
-    * @return The deployment
-    * @exception Exception Thrown if an error occurs
-    */
-   public Deployment deploy(File f) throws Exception
-   {
-      System.out.println("Deploying: " + f.getAbsolutePath());
-
-      return null;
-   }
-}

Added: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/ExtractUtil.java
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/ExtractUtil.java	                        (rev 0)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/ExtractUtil.java	2009-06-10 19:45:35 UTC (rev 90063)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.sjc.deployers.ra;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Enumeration;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.jboss.logging.Logger;
+
+/**
+ * An extract utility for JAR type files
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class ExtractUtil
+{
+   private static Logger log = Logger.getLogger(ExtractUtil.class);
+
+   /**
+    * Constructor
+    */
+   private ExtractUtil()
+   {
+   }
+
+   /**
+    * Extract a JAR type file
+    * @param file The file
+    * @param directory The directory where the file should be extracted
+    * @return The root of the extracted JAR file
+    * @exception IOException Thrown if an error occurs
+    */
+   public static File extract(File file, File directory) throws IOException
+   {
+      if (file == null)
+         throw new IllegalArgumentException("File is null");
+
+      if (directory == null)
+         throw new IllegalArgumentException("Directory is null");
+
+      File target = new File(directory, file.getName());
+
+      if (target.exists())
+         target.delete();
+
+      target.mkdirs();
+
+      JarFile jar = new JarFile(file);
+      Enumeration<JarEntry> entries = jar.entries();
+
+      while (entries.hasMoreElements())
+      {
+         JarEntry je = entries.nextElement();
+         File copy = new File(target, je.getName());
+
+         if (!je.isDirectory())
+         {
+            InputStream in = new BufferedInputStream(jar.getInputStream(je));
+            OutputStream out = new BufferedOutputStream(new FileOutputStream(copy));
+
+            byte[] buffer = new byte[4096];
+            for (;;)
+            {
+               int nBytes = in.read(buffer);
+               if (nBytes <= 0)
+                  break;
+
+               out.write(buffer, 0, nBytes);
+            }
+            out.flush();
+            out.close();
+            in.close();
+         }
+         else
+         {
+            copy.mkdirs();
+         }
+      }
+
+      return target;
+   }
+}

Copied: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/RADeployer.java (from rev 89965, projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/RarDeployer.java)
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/RADeployer.java	                        (rev 0)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/RADeployer.java	2009-06-10 19:45:35 UTC (rev 90063)
@@ -0,0 +1,164 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.sjc.deployers.ra;
+
+import org.jboss.jca.sjc.deployers.Deployer;
+import org.jboss.jca.sjc.deployers.Deployment;
+
+import java.io.File;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.rar.jboss.JBossRAMetaData;
+import org.jboss.metadata.rar.spec.ConnectorMetaData;
+import org.jboss.metadata.rar.spec.JCA16MetaData;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+import org.jboss.xb.binding.resolver.MultiClassSchemaResolver;
+import org.jboss.xb.binding.resolver.MutableSchemaResolver;
+
+/**
+ * The RA deployer for JCA/SJC
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class RADeployer implements Deployer
+{
+   private static Logger log = Logger.getLogger(RADeployer.class);
+
+   /**
+    * Constructor
+    */
+   public RADeployer()
+   {
+   }
+
+   /**
+    * Deploy
+    * @param f The file
+    * @param parent The parent classloader
+    * @return The deployment
+    * @exception Exception Thrown if an error occurs
+    */
+   public Deployment deploy(File f, ClassLoader parent) throws Exception
+   {
+      if (f == null || !f.getAbsolutePath().endsWith(".rar"))
+         return null;
+
+      log.info("Deploying: " + f.getAbsolutePath());
+
+      File root = null;
+
+      if (f.isFile())
+      {
+         File destination = new File(SecurityActions.getSystemProperty("jboss.jca.home"), "/tmp/");
+         root = ExtractUtil.extract(f, destination);
+      }
+      else
+      {
+         root = f;
+      }
+
+      ConnectorMetaData cmd = getStandardMetaData(root);
+      JBossRAMetaData jrmd = getJBossMetaData(root);
+
+      return null;
+   }
+
+   /**
+    * Get the JCA standard metadata
+    * @param root The root of the deployment
+    * @return The metadata
+    * @exception Exception Thrown if an error occurs
+    */
+   private ConnectorMetaData getStandardMetaData(File root) throws Exception
+   {
+      ConnectorMetaData result = null;
+
+      UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+      Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+
+      MutableSchemaResolver resolver = new MultiClassSchemaResolver();
+      resolver.mapLocationToClass("http://java.sun.com/xml/ns/j2ee/connector_1_6.xsd", JCA16MetaData.class);
+
+      File metadataFile = new File(root, "/META-INF/ra.xml");
+
+      if (metadataFile.exists())
+      {
+         String url = metadataFile.getAbsolutePath();
+         try
+         {
+            long start = System.currentTimeMillis();
+
+            result = (JCA16MetaData)unmarshaller.unmarshal(url, resolver);
+            
+            log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms");
+         }
+         catch (Exception e)
+         {
+            log.error("Error during parsing: " + url, e);
+            throw e;
+         }
+      }
+      
+      return result;
+   }
+
+   /**
+    * Get the JBoss specific metadata
+    * @param root The root of the deployment
+    * @return The metadata
+    * @exception Exception Thrown if an error occurs
+    */
+   private JBossRAMetaData getJBossMetaData(File root) throws Exception
+   {
+      JBossRAMetaData result = null;
+
+      UnmarshallerFactory unmarshallerFactory = UnmarshallerFactory.newInstance();
+      Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
+
+      MutableSchemaResolver resolver = new MultiClassSchemaResolver();
+      resolver.mapLocationToClass("http://www.jboss.org/schema/jboss-ra_1_0.xsd", JBossRAMetaData.class);
+
+      File metadataFile = new File(root, "/META-INF/jboss-ra.xml");
+
+      if (metadataFile.exists())
+      {
+         String url = metadataFile.getAbsolutePath();
+         try
+         {
+            long start = System.currentTimeMillis();
+
+            result = (JBossRAMetaData)unmarshaller.unmarshal(url, resolver);
+            
+            log.debug("Total parse for " + url + " took " + (System.currentTimeMillis() - start) + "ms");
+         }
+         catch (Exception e)
+         {
+            log.error("Error during parsing: " + url, e);
+            throw e;
+         }
+      }
+      
+      return result;
+   }
+}


Property changes on: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/RADeployer.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Added: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/RADeployment.java
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/RADeployment.java	                        (rev 0)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/RADeployment.java	2009-06-10 19:45:35 UTC (rev 90063)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.sjc.deployers.ra;
+
+import org.jboss.jca.sjc.deployers.Deployment;
+
+/**
+ * A resource adapter deployment for JCA/SJC
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class RADeployment implements Deployment
+{
+   /** The name */
+   private String name;
+
+   /** The classloader */
+   private ClassLoader cl;
+
+   /**
+    * Constructor
+    * @param name The name of the deployment
+    * @param cl The classloader for the deployment
+    */
+   public RADeployment(String name, ClassLoader cl)
+   {
+      this.name = name;
+      this.cl = cl;
+   }
+
+   /**
+    * Get the name
+    * @return The name
+    */
+   public String getName()
+   {
+      return name;
+   }
+
+   /**
+    * Get the classloader
+    * @return The classloader
+    */
+   public ClassLoader getClassLoader()
+   {
+      return cl;
+   }
+}

Added: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/SecurityActions.java
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/SecurityActions.java	                        (rev 0)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/SecurityActions.java	2009-06-10 19:45:35 UTC (rev 90063)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.sjc.deployers.ra;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Properties;
+
+/**
+ * Privileged Blocks
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+class SecurityActions
+{ 
+   /**
+    * Constructor
+    */
+   private SecurityActions()
+   {
+   }
+
+   /**
+    * Get the thread context class loader
+    * @return The class loader
+    */
+   static ClassLoader getThreadContextClassLoader()
+   {
+      return (ClassLoader)AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            return Thread.currentThread().getContextClassLoader();
+         }
+      });
+   }
+
+   /**
+    * Set the thread context class loader
+    * @param cl The class loader
+    */
+   static void setThreadContextClassLoader(final ClassLoader cl)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            Thread.currentThread().setContextClassLoader(cl);
+            return null;
+         }
+      });
+   }
+
+   /**
+    * Get the system properties
+    * @return The properties
+    */
+   static Properties getSystemProperties()
+   {
+      return (Properties)AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            return System.getProperties();
+         }
+      });
+   }
+
+   /**
+    * Get a system property
+    * @param name The property name
+    * @return The property value
+    */
+   static String getSystemProperty(final String name)
+   {
+      return (String)AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            return System.getProperty(name);
+         }
+      });
+   }
+
+   /**
+    * Set a system property
+    * @param name The property name
+    * @param value The property value
+    */
+   static void setSystemProperty(final String name, final String value)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            System.setProperty(name, value);
+            return null;
+         }
+      });
+   }
+}

Added: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/package.html
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/package.html	2009-06-10 19:45:35 UTC (rev 90063)
@@ -0,0 +1,3 @@
+<body>
+This package contains the resource adapter deployer for the JBoss JCA/SJC container.
+</body>

Modified: projects/jboss-jca/trunk/sjc/src/main/resources/boot.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/boot.xml	2009-06-10 18:21:36 UTC (rev 90062)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/boot.xml	2009-06-10 19:45:35 UTC (rev 90063)
@@ -52,8 +52,8 @@
 
   <!-- Deployers -->
 
-  <!-- Rar deployer -->
-  <bean name="RarDeployer" interface="org.jboss.jca.sjc.deployers.Deployer" class="org.jboss.jca.sjc.deployers.RarDeployer">
+  <!-- RA deployer -->
+  <bean name="RADeployer" interface="org.jboss.jca.sjc.deployers.Deployer" class="org.jboss.jca.sjc.deployers.ra.RADeployer">
   </bean>
 
 </deployment>

Modified: projects/jboss-jca/trunk/sjc/src/main/resources/log4j.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/log4j.xml	2009-06-10 18:21:36 UTC (rev 90062)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/log4j.xml	2009-06-10 19:45:35 UTC (rev 90063)
@@ -24,7 +24,7 @@
    <appender name="FILE" class="org.jboss.logging.appender.DailyRollingFileAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
       <param name="File" value="${jboss.jca.home}/log/server.log"/>
-      <param name="Append" value="true"/>
+      <param name="Append" value="false"/>
       <!-- In AS 5.0.x the server log threshold was set by a system
            property. In 5.1 and later we are instead using the system
            property to set the priority on the root logger (see <root/> below)
@@ -206,12 +206,21 @@
       <priority value="INFO"/>
    </category>
    
-   <!-- Limit JBoss categories
+   <!-- Limit JBoss JCA categories -->
+   <category name="org.jboss.jca">
+      <priority value="DEBUG"/>
+   </category>
+
+   <!-- Limit JBoss categories -->
    <category name="org.jboss">
       <priority value="INFO"/>
    </category>
-   -->
 
+   <!-- Limit Arjuna -->
+   <category name="com.arjuna">
+      <priority value="INFO"/>
+   </category>
+
    <!-- Limit the JSR77 categories -->
    <category name="org.jboss.management">
       <priority value="INFO"/>

Added: projects/jboss-jca/trunk/sjc/src/main/resources/sjc-ra-manifest.mf
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/sjc-ra-manifest.mf	                        (rev 0)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/sjc-ra-manifest.mf	2009-06-10 19:45:35 UTC (rev 90063)
@@ -0,0 +1,4 @@
+Implementation-Title: JBoss JCA SJC RA Deployer
+Implementation-Vendor: Red Hat Middleware LLC
+Implementation-Vendor-Id: org.jboss
+Implementation-Version: 0.1




More information about the jboss-cvs-commits mailing list