[jboss-cvs] JBossAS SVN: r93221 - in projects/jboss-jca/trunk: fungal and 18 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Sep 5 13:11:24 EDT 2009


Author: jesper.pedersen
Date: 2009-09-05 13:11:23 -0400 (Sat, 05 Sep 2009)
New Revision: 93221

Added:
   projects/jboss-jca/trunk/fungal/
   projects/jboss-jca/trunk/fungal/build.xml
   projects/jboss-jca/trunk/fungal/src/
   projects/jboss-jca/trunk/fungal/src/main/
   projects/jboss-jca/trunk/fungal/src/main/java/
   projects/jboss-jca/trunk/fungal/src/main/java/org/
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/Kernel.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/package.html
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/DeployException.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/Deployer.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/Deployment.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/package.html
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/FungalThreadFactory.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/JarFilter.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelConfiguration.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/MainDeployer.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/SecurityActions.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/ServiceLifecycle.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/package.html
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/FileUtil.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/Injection.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/JarFilter.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/SecurityActions.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/package.html
   projects/jboss-jca/trunk/fungal/src/main/resources/
   projects/jboss-jca/trunk/fungal/src/main/resources/boot.xsd
   projects/jboss-jca/trunk/fungal/src/main/resources/deployment.xsd
   projects/jboss-jca/trunk/fungal/src/main/resources/fungal-manifest.mf
   projects/jboss-jca/trunk/fungal/src/main/resources/fungal-services-manifest.mf
Removed:
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/JarFilter.java
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/DeployException.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/java/org/jboss/jca/sjc/deployers/package.html
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/util/
   projects/jboss-jca/trunk/sjc/src/main/resources/boot.xsd
Modified:
   projects/jboss-jca/trunk/build.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/ra/Annotations.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/resources/boot.xml
   projects/jboss-jca/trunk/sjc/src/main/resources/sjc-manifest.mf
   projects/jboss-jca/trunk/tools/findbugs/filter.xml
Log:
[JBJCA-166] Embedded configuration

Modified: projects/jboss-jca/trunk/build.xml
===================================================================
--- projects/jboss-jca/trunk/build.xml	2009-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/build.xml	2009-09-05 17:11:23 UTC (rev 93221)
@@ -122,6 +122,15 @@
     </fileset>
   </path>
 
+  <path id="fungal.lib.path.id">
+    <fileset dir="${lib.dir}/sjc">
+      <include name="**/*.jar"/>
+    </fileset>
+    <fileset dir="${target.dir}">
+      <include name="**/*.jar"/>
+    </fileset>
+  </path>
+
   <path id="standalone.lib.path.id">
     <fileset dir="${lib.dir}/standalone">
       <include name="**/*.jar"/>
@@ -186,6 +195,7 @@
        Target: jars
        ================================= -->
   <target name="jars" depends="resolve">
+    <ant dir="fungal" inheritRefs="true" target="jars"/>
     <ant dir="api" inheritRefs="true" target="jars"/>
     <ant dir="common" inheritRefs="true" target="jars"/>
     <ant dir="core" inheritRefs="true" target="jars"/>
@@ -338,6 +348,8 @@
       <class location="${target.dir}/jboss-jca-core-impl.jar" />
       <class location="${target.dir}/jboss-jca-deployers-main.jar" />
       <class location="${target.dir}/jboss-jca-deployers-rar.jar" />
+      <class location="${target.dir}/jboss-jca-fungal.jar" />
+      <class location="${target.dir}/jboss-jca-fungal-services.jar" />
       <class location="${target.dir}/jboss-jca-sjc.jar" />
       <class location="${target.dir}/jboss-jca-sjc-ra-deployer.jar" />
       <class location="${target.dir}/jboss-jca-sjc-services.jar" />
@@ -360,6 +372,8 @@
       <class location="${target.dir}/jboss-jca-core-impl.jar" />
       <class location="${target.dir}/jboss-jca-deployers-main.jar" />
       <class location="${target.dir}/jboss-jca-deployers-rar.jar" />
+      <class location="${target.dir}/jboss-jca-fungal.jar" />
+      <class location="${target.dir}/jboss-jca-fungal-services.jar" />
       <class location="${target.dir}/jboss-jca-sjc.jar" />
       <class location="${target.dir}/jboss-jca-sjc-ra-deployer.jar" />
       <class location="${target.dir}/jboss-jca-sjc-services.jar" />

Added: projects/jboss-jca/trunk/fungal/build.xml
===================================================================
--- projects/jboss-jca/trunk/fungal/build.xml	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/build.xml	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,137 @@
+<!--
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.
+-->
+<project name="jboss-jca-fungal" 
+         default="compile" 
+         xmlns:ivy="antlib:org.apache.ivy.ant">
+
+  <!-- ================================= 
+       Properties              
+       ================================= -->
+  <property name="build.fungal.dir" value="${build.dir}/fungal" />
+
+  <!-- ================================= 
+       Target: init
+       ================================= -->
+  <target name="init">
+    <mkdir dir="${build.fungal.dir}" />
+    <mkdir dir="${build.fungal.dir}/impl" />
+  </target>
+
+  <!-- ================================= 
+       Target: compile boot.xsd
+       ================================= -->
+  <target name="compile-boot-xsd" depends="init">
+    <taskdef name="xjc"
+             classname="com.sun.tools.xjc.XJCTask"
+             classpathref="fungal.lib.path.id"/>
+    <xjc schema="src/main/resources/boot.xsd"
+         destdir="${build.fungal.dir}/impl"
+         package="org.jboss.jca.fungal.boot"/>
+    <javac srcdir="${build.fungal.dir}/impl"
+           destdir="${build.fungal.dir}/impl"
+           classpathref="fungal.lib.path.id"
+           debug="${javac.debug}"
+           deprecation="${javac.deprecation}"
+           optimize="${javac.optimize}">
+      <compilerarg value="-Xlint"/>
+    </javac>
+    <delete>
+      <fileset dir="${build.fungal.dir}/impl">
+        <include name="**/*.java"/>
+      </fileset>
+    </delete>
+  </target>
+
+  <!-- ================================= 
+       Target: compile deployment.xsd
+       ================================= -->
+  <target name="compile-deployment-xsd" depends="init">
+    <taskdef name="xjc"
+             classname="com.sun.tools.xjc.XJCTask"
+             classpathref="fungal.lib.path.id"/>
+    <xjc schema="src/main/resources/deployment.xsd"
+         destdir="${build.fungal.dir}/impl"
+         package="org.jboss.jca.fungal.deployment"/>
+    <javac srcdir="${build.fungal.dir}/impl"
+           destdir="${build.fungal.dir}/impl"
+           classpathref="fungal.lib.path.id"
+           debug="${javac.debug}"
+           deprecation="${javac.deprecation}"
+           optimize="${javac.optimize}">
+      <compilerarg value="-Xlint"/>
+    </javac>
+    <delete>
+      <fileset dir="${build.fungal.dir}/impl">
+        <include name="**/*.java"/>
+      </fileset>
+    </delete>
+  </target>
+
+  <!-- ================================= 
+       Target: compile
+       ================================= -->
+  <target name="compile" depends="compile-boot-xsd,compile-deployment-xsd">
+    <javac srcdir="src/main"
+           destdir="${build.fungal.dir}/impl"
+           classpathref="fungal.lib.path.id"
+           debug="${javac.debug}"
+           deprecation="${javac.deprecation}"
+           optimize="${javac.optimize}">
+      <compilerarg value="-Xlint"/>
+    </javac> 
+  </target>
+
+  <!-- ================================= 
+       Target: jars 
+       ================================= -->
+  <target name="jars" depends="compile">
+    <jar destfile="${target.dir}/jboss-jca-fungal.jar"
+         manifest="src/main/resources/fungal-manifest.mf"
+         basedir="${build.fungal.dir}/impl"
+         excludes="**/*.java,**/annotationscanner/**,**/util/**"/>
+    <jar destfile="${target.dir}/jboss-jca-fungal-services.jar"
+         manifest="src/main/resources/fungal-services-manifest.mf"
+         basedir="${build.fungal.dir}/impl"
+         includes="**/annotationscanner/**,**/util/**"
+         excludes="**/*.java"/>
+  </target>
+
+  <!-- ================================= 
+       Target: docs
+       ================================= -->
+  <target name="docs">
+    <mkdir dir="${target.dir}/docs/fungal"/>
+    <javadoc packagenames="org.*"
+             sourcepath="src/main/java"
+             destdir="${target.dir}/docs/fungal"
+             author="true"
+             version="true"
+             windowtitle="JBoss JCA Fungal"
+             doctitle="JBoss JCA Fungal"
+             use="true"
+             classpathref="fungal.lib.path.id"
+             bottom="Copyright &#169; 2008-2009 Red Hat Middleware LLC (http://www.jboss.com/)">
+      <link offline="true" href="http://java.sun.com/j2se/5/docs/api/" packagelistLoc="${java.home}/../docs/api"/>
+    </javadoc>
+  </target>
+
+</project>

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/Kernel.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/Kernel.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/Kernel.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,40 @@
+/*
+ * 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.fungal.api;
+
+/**
+ * The kernel API
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface Kernel
+{
+   /**
+    * Startup
+    */
+   public void startup();
+
+   /**
+    * Shutdown
+    */
+   public void shutdown();
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/package.html
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/package.html	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,3 @@
+<body>
+This package contains the API for the JBoss JCA/Fungal kernel
+</body>

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/DeployException.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/DeployException.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/DeployException.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,52 @@
+/*
+ * 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.fungal.deployers;
+
+/**
+ * The deploy exception for JCA/Fungal
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class DeployException extends Exception
+{
+   /** Serial version UID */
+   static final long serialVersionUID = 3820032266224196804L;
+
+   /**
+    * Constructs a new exception with the specified detail message.
+    * @param message The message
+    */
+   public DeployException(String message)
+   {
+      super(message);
+   }
+
+   /**
+    * Constructs a new exception with the specified detail message and cause.
+    * @param message The message
+    * @param cause The cause
+    */
+   public DeployException(String message, Throwable cause)
+   {
+      super(message, cause);
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/Deployer.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/Deployer.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/Deployer.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,41 @@
+/*
+ * 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.fungal.deployers;
+
+import java.net.URL;
+
+/**
+ * The deployer interface for JCA/Fungal
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface Deployer
+{
+   /**
+    * Deploy
+    * @param url The URL
+    * @param parent The parent classloader
+    * @return The deployment; or null if no deployment was made
+    * @exception DeployException Thrown if an error occurs during deployment
+    */
+   public Deployment deploy(URL url, ClassLoader parent) throws DeployException;
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/Deployment.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/Deployment.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/Deployment.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,42 @@
+/*
+ * 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.fungal.deployers;
+
+/**
+ * The deployment interface for JCA/Fungal
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface Deployment
+{
+   /**
+    * Get the name
+    * @return The name
+    */
+   public String getName();
+
+   /**
+    * Get the classloader
+    * @return The classloader
+    */
+   public ClassLoader getClassLoader();
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/package.html
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/package.html	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,3 @@
+<body>
+This package contains the deployer infrastructure for JCA/Fungal
+</body>

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,798 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.fungal.impl;
+
+import org.jboss.jca.fungal.deployers.DeployException;
+import org.jboss.jca.fungal.deployers.Deployer;
+import org.jboss.jca.fungal.deployers.Deployment;
+import org.jboss.jca.fungal.deployment.BeanType;
+import org.jboss.jca.fungal.deployment.ConstructorType;
+import org.jboss.jca.fungal.deployment.DependsType;
+import org.jboss.jca.fungal.deployment.InjectType;
+import org.jboss.jca.fungal.deployment.PropertyType;
+
+import java.lang.reflect.Method;
+import java.net.InetAddress;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+
+/**
+ * The deployment deployer (deploys .xml files)
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class DeploymentDeployer implements Deployer
+{
+   /** The kernel */
+   private KernelImpl kernel;
+
+   /** Bean latch */
+   private CountDownLatch beansLatch;
+
+   /** Logging */
+   private static Object logging;
+
+   static
+   {
+      initLogging();
+   }
+
+   /**
+    * Constructor
+    * @param kernel The kernel
+    */
+   public DeploymentDeployer(KernelImpl kernel)
+   {
+      this.kernel = kernel;
+      this.beansLatch = null;
+   }
+
+   /**
+    * Deploy
+    * @param url The URL
+    * @param parent The parent classloader
+    * @return The deployment; or null if no deployment was made
+    * @exception DeployException Thrown if an error occurs during deployment
+    */
+   public Deployment deploy(URL url, ClassLoader parent) throws DeployException
+   {
+      if (url == null || !url.toString().endsWith(".xml"))
+         return null;
+
+      try
+      {
+         JAXBContext deploymentJc = JAXBContext.newInstance("org.jboss.jca.fungal.deployment");
+         Unmarshaller deploymentU = deploymentJc.createUnmarshaller();
+         org.jboss.jca.fungal.deployment.Deployment deployment = 
+            (org.jboss.jca.fungal.deployment.Deployment)deploymentU.unmarshal(url);
+
+         if (deployment != null)
+         {
+            beansLatch = new CountDownLatch(deployment.getBean().size());
+
+            for (BeanType bt : deployment.getBean())
+            {
+               Runnable r = new ServiceRunnable(bt, kernel, beansLatch, parent);
+               kernel.getExecutorService().execute(r);
+            }
+
+            beansLatch.await();
+         }
+      }
+      catch (Throwable t)
+      {
+         error(t.getMessage(), t);
+      }
+
+      return null;
+   }
+
+   /**
+    * Service runnable
+    */
+   static class ServiceRunnable implements Runnable
+   {
+      /** The bean */
+      private BeanType bt;
+
+      /** The kernel */
+      private KernelImpl kernel;
+
+      /** The bean latch */
+      private CountDownLatch beansLatch;
+
+      /** The classloader */
+      private ClassLoader classLoader;
+
+      /**
+       * Constructor
+       * @param bt The bean
+       * @param kernel The kernel
+       * @param beansLatch The beans latch
+       * @param classLoader The class loader
+       */
+      public ServiceRunnable(BeanType bt, KernelImpl kernel, CountDownLatch beansLatch, ClassLoader classLoader)
+      {
+         this.bt = bt;
+         this.kernel = kernel;
+         this.beansLatch = beansLatch;
+         this.classLoader = classLoader;
+      }
+
+      /**
+       * Run
+       */
+      public void run()
+      {
+         SecurityActions.setThreadContextClassLoader(classLoader);
+
+         try
+         {
+            if (kernel.getBean(bt.getName()) == null)
+            {
+               kernel.setServiceStatus(bt.getName(), ServiceLifecycle.NOT_STARTED);
+
+               Set<String> dependencies = getDependencies(bt);
+               int notStarted = getNotStarted(dependencies);
+
+               while (notStarted > 0)
+               {
+                  try
+                  {
+                     Thread.sleep(10);
+                     notStarted = getNotStarted(dependencies);
+                  }
+                  catch (InterruptedException ie)
+                  {
+                     Thread.interrupted();
+                  }
+               }
+
+               kernel.setServiceStatus(bt.getName(), ServiceLifecycle.STARTING);
+
+               Object bean = createBean(bt, classLoader);
+
+               kernel.addBean(bt.getName(), bean);
+
+               kernel.setServiceStatus(bt.getName(), ServiceLifecycle.STARTED);
+            }
+            else
+            {
+               warn("Warning: A service with name " + bt.getName() + " already exists");
+            }
+         }
+         catch (Throwable t)
+         {
+            error("Installing bean " + bt.getName(), t);
+         }
+
+         beansLatch.countDown();
+      }
+
+      /**
+       * Get the depedencies for a bean
+       * @paran bt The bean type
+       * @return The set of dependencies; <code>null</code> if no dependencies
+       */
+      private Set<String> getDependencies(BeanType bt)
+      {
+         Set<String> result = null;
+
+         List<DependsType> dts = bt.getDepends();
+         if (dts != null)
+         {
+            result = new HashSet<String>();
+            for (DependsType dt : dts)
+            {
+               result.add(dt.getValue());
+            }
+         }
+
+         List<PropertyType> pts = bt.getProperty();
+         if (pts != null)
+         {
+            if (result == null)
+               result = new HashSet<String>();
+
+            for (PropertyType pt : pts)
+            {
+               Object e = pt.getContent().get(0);
+
+               if (e != null && e instanceof JAXBElement)
+               {
+                  Object element = ((JAXBElement)e).getValue();
+                  if (element instanceof InjectType)
+                  {
+                     InjectType it = (InjectType)element;
+                     result.add(it.getBean());
+                  }
+               }
+            }
+         }
+
+         return result;
+      }
+
+      /**
+       * Get the number of services that are not started yet
+       * @paran dependencies The dependencies for a service
+       * @return The number of not started services
+       */
+      private int getNotStarted(Set<String> dependencies)
+      {
+         if (dependencies == null || dependencies.size() == 0)
+            return 0;
+
+         int count = 0;
+         for (String dependency : dependencies)
+         {
+            ServiceLifecycle dependencyStatus = kernel.getServiceStatus(dependency);
+            if (dependencyStatus == null || dependencyStatus != ServiceLifecycle.STARTED)
+               count += 1;
+         }
+
+         return count;
+      }
+
+      /**
+       * Create a bean
+       * @param bt The bean type definition
+       * @param cl The classloader
+       * @return The new bean
+       * @exception Exception Thrown if an error occurs
+       */
+      private Object createBean(BeanType bt, ClassLoader cl) throws Exception
+      {
+         Class<?> clz = null;
+         Object instance = null;
+
+         if (bt.getClazz() != null)
+         {
+            clz = Class.forName(bt.getClazz(), true, cl);
+            instance = clz.newInstance();
+         }
+         else
+         {
+            ConstructorType ct = bt.getConstructor();
+            Class factoryClass = Class.forName(ct.getFactoryClass(), true, cl);
+            Method factoryMethod = null;
+            Object[] args = null;
+
+            if (ct.getParameter() == null)
+            {
+               factoryMethod = factoryClass.getMethod(ct.getFactoryMethod(), (Class[])null);
+            }
+            else
+            {
+               Method[] factoryMethods = factoryClass.getMethods();
+            
+               List<Method> candidates = new ArrayList<Method>();
+
+               for (Method m : factoryMethods)
+               {
+                  if (ct.getFactoryMethod().equals(m.getName()))
+                  {
+                     if (ct.getParameter().size() == m.getParameterTypes().length)
+                     {
+                        boolean include = true;
+                        for (int i = 0; include && i < m.getParameterTypes().length; i++)
+                        {
+                           Class<?> parameterClass = m.getParameterTypes()[i];
+
+                           if (!(parameterClass.equals(String.class) ||
+                                 parameterClass.equals(byte.class) || parameterClass.equals(Byte.class) ||
+                                 parameterClass.equals(short.class) || parameterClass.equals(Short.class) ||
+                                 parameterClass.equals(int.class) || parameterClass.equals(Integer.class) ||
+                                 parameterClass.equals(long.class) || parameterClass.equals(Long.class) ||
+                                 parameterClass.equals(float.class) || parameterClass.equals(Float.class) ||
+                                 parameterClass.equals(double.class) || parameterClass.equals(Double.class) ||
+                                 parameterClass.equals(boolean.class) || parameterClass.equals(Boolean.class) ||
+                                 parameterClass.equals(char.class) || parameterClass.equals(Character.class) ||
+                                 parameterClass.equals(InetAddress.class)))
+                           {
+                              include = false;
+                           }
+                        }
+
+                        if (include)
+                           candidates.add(m);
+                     }
+                  }
+               }
+
+               if (candidates.size() == 1)
+               {
+                  factoryMethod = candidates.get(0);
+                  args = new Object[ct.getParameter().size()];
+                  for (int i = 0; i < ct.getParameter().size(); i++)
+                  {
+                     args[i] = getValue(ct.getParameter().get(i).getValue(), factoryMethod.getParameterTypes()[i]);
+                  }
+               }
+               else
+               {
+                  boolean found = false;
+                  Iterator<Method> it = candidates.iterator();
+                  while (!found && it.hasNext())
+                  {
+                     try
+                     {
+                        Method m = it.next();
+                        args = new Object[ct.getParameter().size()];
+
+                        for (int i = 0; i < ct.getParameter().size(); i++)
+                        {
+                           args[i] = 
+                              getValue(ct.getParameter().get(i).getValue(), factoryMethod.getParameterTypes()[i]);
+                        }
+
+                        factoryMethod = m;
+                        found = true;
+                     }
+                     catch (Throwable t)
+                     {
+                        // ok - not this one...
+                     }
+                  }
+               }
+            }
+
+            instance = factoryMethod.invoke((Object)null, args);
+            clz = instance.getClass();
+         }
+
+         if (bt.getProperty() != null)
+         {
+            for (PropertyType pt : bt.getProperty())
+            {
+               setBeanProperty(instance, pt, cl);
+            }
+         }
+
+         try
+         {
+            Method createMethod = clz.getMethod("create", (Class[])null);
+            createMethod.invoke(instance, (Object[])null);
+         }
+         catch (Exception e)
+         {
+            // No create method
+         }
+
+         try
+         {
+            Method startMethod = clz.getMethod("start", (Class[])null);
+            startMethod.invoke(instance, (Object[])null);
+         }
+         catch (Exception e)
+         {
+            // No start method
+         }
+
+         // Register deployer
+         if (instance instanceof Deployer)
+         {
+            kernel.getMainDeployer().addDeployer((Deployer)instance);
+         }
+
+         return instance;
+      }
+
+      /**
+       * Get a value from a string
+       * @param s The string representation
+       * @param clz The class
+       * @return The value
+       * @exception Exception If the string cant be converted
+       */
+      private Object getValue(String s, Class<?> clz) throws Exception
+      {
+         if (clz.equals(String.class))
+         {
+            return s;
+         }
+         else if (clz.equals(byte.class) || clz.equals(Byte.class))
+         {
+            return Byte.valueOf(s);
+         }
+         else if (clz.equals(short.class) || clz.equals(Short.class))
+         {
+            return Short.valueOf(s);
+         }
+         else if (clz.equals(int.class) || clz.equals(Integer.class))
+         {
+            return Integer.valueOf(s);
+         }
+         else if (clz.equals(long.class) || clz.equals(Long.class))
+         {
+            return Long.valueOf(s);
+         }
+         else if (clz.equals(float.class) || clz.equals(Float.class))
+         {
+            return Float.valueOf(s);
+         }
+         else if (clz.equals(double.class) || clz.equals(Double.class))
+         {
+            return Double.valueOf(s);
+         }
+         else if (clz.equals(boolean.class) || clz.equals(Boolean.class))
+         {
+            return Boolean.valueOf(s);
+         }
+         else if (clz.equals(char.class) || clz.equals(Character.class))
+         {
+            return Character.valueOf(s.charAt(0));
+         }
+         else if (clz.equals(InetAddress.class))
+         {
+            return InetAddress.getByName(s);
+         }
+         
+         throw new Exception("Unknown class " + clz.getName() + " for " + s);
+      }
+
+      /**
+       * Set a property on an object instance
+       * @param instance The object instance
+       * @param pt The property type definition
+       * @param cl The classloader
+       * @exception Exception Thrown if an error occurs
+       */
+      private void setBeanProperty(Object instance, PropertyType pt, ClassLoader cl) throws Exception
+      {
+         String name = "set" + pt.getName().substring(0, 1).toUpperCase() + pt.getName().substring(1);
+         Method m = null;
+      
+         if (pt.getClazz() == null)
+         {
+            Method[] ms = instance.getClass().getMethods();
+            if (ms != null)
+            {
+               boolean found = false;
+
+               for (int i = 0; !found && i < ms.length; i++)
+               {
+                  if (ms[i].getName().equals(name) &&
+                      ms[i].getParameterTypes() != null &&
+                      ms[i].getParameterTypes().length == 1)
+                  {
+                     m = ms[i];
+                     found = true;
+                  }
+               }
+            }
+         }
+         else
+         {
+            Class clz = Class.forName(pt.getClazz(), true, cl);
+            m = instance.getClass().getMethod(name, clz);
+         }
+
+         if (m == null)
+            throw new Exception("Property " + pt.getName() + " not found on " + instance.getClass().getName());
+
+         Class parameterClass = m.getParameterTypes()[0];
+      
+         Object parameterValue = null;
+         Object e = pt.getContent().get(0);
+         Object element = null;
+
+         if (e != null && e instanceof JAXBElement)
+         {
+            element = ((JAXBElement)e).getValue();
+         }
+         else
+         {
+            if (e == null)
+               e = "";
+
+            element = e;
+         }
+
+         if (element instanceof InjectType)
+         {
+            InjectType it = (InjectType)element;
+
+            Object injectionObject = kernel.getBean(it.getBean());
+
+            if (injectionObject == null)
+               throw new Exception("Injection depedency " + it.getBean() + " not found");
+
+            if (it.getProperty() != null)
+            {
+               Method method = null;
+               try
+               {
+                  String getMethodName = "get" + 
+                     it.getProperty().substring(0, 1).toUpperCase() + it.getProperty().substring(1);
+                  method = injectionObject.getClass().getMethod(getMethodName, (Class[])null);
+               }
+               catch (NoSuchMethodException nsme)
+               {
+                  String isMethodName = "is" + 
+                     it.getProperty().substring(0, 1).toUpperCase() + it.getProperty().substring(1);
+                  method = injectionObject.getClass().getMethod(isMethodName, (Class[])null);
+               }
+
+               parameterValue = method.invoke(injectionObject, (Object[])null);
+            }
+            else
+            {
+               parameterValue = injectionObject;
+            }
+         }
+         else
+         {
+            if (parameterClass.equals(String.class))
+            {
+               parameterValue = getSubstitutionValue((String)element);
+            }
+            else if (parameterClass.equals(byte.class) || parameterClass.equals(Byte.class))
+            {
+               parameterValue = Byte.valueOf(getSubstitutionValue((String)element));
+            }
+            else if (parameterClass.equals(short.class) || parameterClass.equals(Short.class))
+            {
+               parameterValue = Short.valueOf(getSubstitutionValue((String)element));
+            }
+            else if (parameterClass.equals(int.class) || parameterClass.equals(Integer.class))
+            {
+               parameterValue = Integer.valueOf(getSubstitutionValue((String)element));
+            }
+            else if (parameterClass.equals(long.class) || parameterClass.equals(Long.class))
+            {
+               parameterValue = Long.valueOf(getSubstitutionValue((String)element));
+            }
+            else if (parameterClass.equals(float.class) || parameterClass.equals(Float.class))
+            {
+               parameterValue = Float.valueOf(getSubstitutionValue((String)element));
+            }
+            else if (parameterClass.equals(double.class) || parameterClass.equals(Double.class))
+            {
+               parameterValue = Double.valueOf(getSubstitutionValue((String)element));
+            }
+            else if (parameterClass.equals(boolean.class) || parameterClass.equals(Boolean.class))
+            {
+               parameterValue = Boolean.valueOf(getSubstitutionValue((String)element));
+            }
+            else if (parameterClass.equals(char.class) || parameterClass.equals(Character.class))
+            {
+               parameterValue = Character.valueOf((getSubstitutionValue((String)element)).charAt(0));
+            }
+            else if (parameterClass.equals(InetAddress.class))
+            {
+               parameterValue = InetAddress.getByName(getSubstitutionValue((String)element));
+            }
+         }
+
+         if (parameterValue == null)
+            throw new Exception("No parameter value assigned for class " + parameterClass.getName() + 
+                                " value " + element);
+
+         m.invoke(instance, parameterValue);
+      }
+
+      /**
+       * System property substitution
+       * @param input The input string
+       * @return The output
+       */
+      private String getSubstitutionValue(String input)
+      {
+         if (input == null || input.trim().equals(""))
+            return input;
+
+         if (input.indexOf("${") != -1)
+         {
+            int from = input.indexOf("${");
+            int to = input.indexOf("}");
+            int dv = input.indexOf(":");
+         
+            String systemProperty = "";
+            String defaultValue = "";
+            if (dv == -1)
+            {
+               systemProperty = SecurityActions.getSystemProperty(input.substring(from + 2, to));
+            }
+            else
+            {
+               systemProperty = SecurityActions.getSystemProperty(input.substring(from + 2, dv));
+               defaultValue = input.substring(dv + 1, to);
+            }
+            String prefix = "";
+            String postfix = "";
+
+            if (from != 0)
+            {
+               prefix = input.substring(0, from);
+            }
+         
+            if (to + 1 < input.length() - 1)
+            {
+               postfix = input.substring(to + 1);
+            }
+
+            if (systemProperty != null && !systemProperty.trim().equals(""))
+            {
+               return prefix + systemProperty + postfix;
+            }
+            else if (defaultValue != null && !defaultValue.trim().equals(""))
+            {
+               return prefix + defaultValue + postfix;
+            }
+         }
+         return input;
+      }
+   }
+
+   /**
+    * Init logging
+    */
+   private static void initLogging()
+   {
+      try
+      {
+         Class clz = Class.forName("org.jboss.logging.Logger");
+         
+         Method mGetLogger = clz.getMethod("getLogger", String.class);
+
+         logging = mGetLogger.invoke((Object)null, new Object[] {"org.jboss.jca.fungal.impl.DeploymentDeployer"});
+      }
+      catch (Throwable t)
+      {
+         // 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 (Throwable th)
+         {
+            // 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 (Throwable t)
+         {
+            // 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 (Throwable t)
+         {
+            // Nothing we can do
+         }
+      }
+      else
+      {
+         System.out.println(s);
+      }
+   }
+
+   /**
+    * Logging: Is DEBUG enabled
+    * @return True if debug is enabled; otherwise false
+    */
+   private static boolean isDebugEnabled()
+   {
+      if (logging != null)
+      {
+         try
+         {
+            Class clz = logging.getClass();
+            Method mIsDebugEnabled = clz.getMethod("isDebugEnabled", (Class[])null);
+            return ((Boolean)mIsDebugEnabled.invoke(logging, (Object[])null)).booleanValue();
+         }
+         catch (Throwable t)
+         {
+            // Nothing we can do
+         }
+      }
+      return true;
+   }
+
+   /**
+    * Logging: DEBUG
+    * @param s The string
+    */
+   private static void debug(String s)
+   {
+      if (logging != null)
+      {
+         try
+         {
+            Class clz = logging.getClass();
+            Method mDebug = clz.getMethod("debug", Object.class);
+            mDebug.invoke(logging, new Object[] {s});
+         }
+         catch (Throwable t)
+         {
+            // Nothing we can do
+         }
+      }
+      else
+      {
+         System.out.println(s);
+      }
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/FungalThreadFactory.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/FungalThreadFactory.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/FungalThreadFactory.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.fungal.impl;
+
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * The thread factory for JBoss JCA/Fungal
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class FungalThreadFactory implements ThreadFactory
+{
+   /** The thread group */
+   private ThreadGroup tg;
+
+   /**
+    * Constructor
+    * @param tg The thread group
+    */
+   public FungalThreadFactory(ThreadGroup tg)
+   {
+      this.tg = tg;
+   }
+
+   /**
+    * Create a new thread
+    * @param r The runnable
+    * @return The thread
+    */
+   public Thread newThread(Runnable r)
+   {
+      return new Thread(tg, r);
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/JarFilter.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/JarFilter.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/JarFilter.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,44 @@
+/*
+ * 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.fungal.impl;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+/**
+ * Jar filter
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class JarFilter implements FilenameFilter
+{
+   /**
+    * Accept
+    * @param dir The directory
+    * @param name The name
+    * @return True if accepts; otherwise false
+    */
+   public boolean accept(File dir, String name)
+   {
+      return name.endsWith(".jar");
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelConfiguration.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelConfiguration.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelConfiguration.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.fungal.impl;
+
+import java.net.URL;
+
+/**
+ * Kernel configuration implementation
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class KernelConfiguration
+{
+   /** Home */
+   private URL home;
+
+   /** Bind address */
+   private String bindAddress;
+
+   /** Thread group */
+   private ThreadGroup threadGroup;
+
+   /**
+    * Constructor
+    */
+   public KernelConfiguration()
+   {
+   }
+
+   /**
+    * Set the home
+    * @param h The home
+    * @return The configuration
+    */
+   public KernelConfiguration home(URL h)
+   {
+      this.home = h;
+
+      return this;
+   }
+
+   /**
+    * Get the home
+    * @return The home
+    */
+   public URL getHome()
+   {
+      return home;
+   }
+
+   /**
+    * Set the bind address
+    * @param ba The value
+    * @return The configuration
+    */
+   public KernelConfiguration bindAddress(String ba)
+   {
+      this.bindAddress = ba;
+
+      return this;
+   }
+
+   /**
+    * Get the bind address
+    * @return The value
+    */
+   public String getBindAddress()
+   {
+      return bindAddress;
+   }
+
+   /**
+    * Set the thread group
+    * @param tg The value
+    * @return The configuration
+    */
+   public KernelConfiguration threadGroup(ThreadGroup tg)
+   {
+      this.threadGroup = tg;
+
+      return this;
+   }
+
+   /**
+    * Get the thread group
+    * @return The value
+    */
+   public ThreadGroup getThreadGroup()
+   {
+      return threadGroup;
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,552 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.fungal.impl;
+
+import org.jboss.jca.fungal.api.Kernel;
+import org.jboss.jca.fungal.deployers.Deployment;
+
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+/**
+ * The kernel implementation for JBoss JCA/Fungal
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class KernelImpl implements Kernel
+{
+   /** Kernel configuration */
+   private KernelConfiguration kernelConfiguration;
+
+   /** Startup list */
+   private List<String> startup = Collections.synchronizedList(new LinkedList<String>());
+
+   /** Deployments */
+   private List<Deployment> deployments = Collections.synchronizedList(new LinkedList<Deployment>());
+
+   /** Services */
+   private ConcurrentMap<String, Object> services = new ConcurrentHashMap<String, Object>();
+
+   /** Services status */
+   private ConcurrentMap<String, ServiceLifecycle> servicesStatus = new ConcurrentHashMap<String, ServiceLifecycle>();
+
+   /** Executor service */
+   private ExecutorService executorService;
+
+   /** The old class loader */
+   private ClassLoader oldClassLoader;
+
+   /** Container class loader */
+   private URLClassLoader containerClassLoader;
+
+   /** Main deployer */
+   private MainDeployer mainDeployer;
+
+   /** Logging */
+   private Object logging;
+
+   /**
+    * Constructor
+    * @param kc The kernel configuration
+    */
+   public KernelImpl(KernelConfiguration kc)
+   {
+      this.kernelConfiguration = kc;
+   }
+
+   /**
+    * Startup
+    */
+   public void startup()
+   {
+      try
+      {
+         // TODO - remove File dependency
+
+         File root = new File(kernelConfiguration.getHome().toURI());
+
+         SecurityActions.setSystemProperty("jboss.jca.home", root.getAbsolutePath());
+
+         if (kernelConfiguration.getBindAddress() != null)
+            SecurityActions.setSystemProperty("jboss.jca.bindaddress", kernelConfiguration.getBindAddress().trim());
+            
+         ThreadGroup tg = kernelConfiguration.getThreadGroup();
+         if (tg == null)
+            tg = new ThreadGroup("jboss");
+         ThreadFactory tf = new FungalThreadFactory(tg);
+         executorService = Executors.newCachedThreadPool(tf);
+
+         File libDirectory = new File(root, "/lib/");
+         File configDirectory = new File(root, "/config/");
+         File deployDirectory = new File(root, "/deploy/");
+
+         oldClassLoader = SecurityActions.getThreadContextClassLoader();
+
+         URL[] libUrls = getUrls(libDirectory);
+         URL[] confUrls = getUrls(configDirectory);
+
+         URL[] urls = mergeUrls(libUrls, confUrls);
+
+         containerClassLoader = SecurityActions.createURLCLassLoader(urls, oldClassLoader);
+         SecurityActions.setThreadContextClassLoader(containerClassLoader);
+
+         SecurityActions.setSystemProperty("xb.builder.useUnorderedSequence", "true");
+         SecurityActions.setSystemProperty("jboss.deploy.url", deployDirectory.toURI().toURL().toString());
+         SecurityActions.setSystemProperty("jboss.lib.url", libDirectory.toURI().toURL().toString());
+         SecurityActions.setSystemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
+
+         // Init logging
+         initLogging(containerClassLoader);
+
+         // Main deployer
+         mainDeployer = new MainDeployer(this);
+
+         // Add the deployment deployer
+         mainDeployer.addDeployer(new DeploymentDeployer(this));
+
+         // Start all URLs defined in boot.xml
+         File bootXml = new File(configDirectory, "boot.xml");
+         JAXBContext bootJc = JAXBContext.newInstance("org.jboss.jca.fungal.boot");
+         Unmarshaller bootU = bootJc.createUnmarshaller();
+         org.jboss.jca.fungal.boot.Boot boot = 
+            (org.jboss.jca.fungal.boot.Boot)bootU.unmarshal(bootXml);
+
+         // Boot urls
+         if (boot != null)
+         {
+            for (String url : boot.getUrl())
+            {
+               URL fullPath = new URL(configDirectory.toURI().toURL().toExternalForm() + url);
+
+               if (isDebugEnabled())
+                  debug("URL=" + fullPath.toString());
+
+               mainDeployer.deploy(fullPath, containerClassLoader);
+            }
+         }
+
+         // Deploy all files in deploy/
+         if (deployDirectory != null && deployDirectory.exists() && deployDirectory.isDirectory())
+         {
+            for (File f : deployDirectory.listFiles())
+            {
+               if (isDebugEnabled())
+                  debug("URL=" + f.toURI().toURL().toExternalForm());
+
+               mainDeployer.deploy(f.toURI().toURL(), containerClassLoader);
+            }   
+         }
+      }
+      catch (Throwable t)
+      {
+         error(t.getMessage(), t);
+      }
+   }
+
+   /**
+    * Shutdown
+    */
+   public void shutdown()
+   {
+      SecurityActions.setThreadContextClassLoader(containerClassLoader);
+
+      executorService.shutdown();
+
+      List<Deployment> shutdownDeployments = new LinkedList<Deployment>(deployments);
+      Collections.reverse(shutdownDeployments);
+
+      for (Deployment deployment : shutdownDeployments)
+      {
+         try
+         {
+            Method stopMethod = deployment.getClass().getMethod("stop", (Class[])null);
+            stopMethod.invoke(deployment, (Object[])null);
+         }
+         catch (Exception e)
+         {
+            // No stop method
+         }
+
+         try
+         {
+            Method destroyMethod = deployment.getClass().getMethod("destroy", (Class[])null);
+            destroyMethod.invoke(deployment, (Object[])null);
+         }
+         catch (Exception e)
+         {
+            // No destroy method
+         }
+      }
+
+      List<String> shutdownServices = new LinkedList<String>(startup);
+      Collections.reverse(shutdownServices);
+
+      for (String name : shutdownServices)
+      {
+         setServiceStatus(name, ServiceLifecycle.STOPPING);
+
+         Object service = services.get(name);
+
+         try
+         {
+            Method stopMethod = service.getClass().getMethod("stop", (Class[])null);
+            stopMethod.invoke(service, (Object[])null);
+         }
+         catch (Exception e)
+         {
+            // No stop method
+         }
+
+         try
+         {
+            Method destroyMethod = service.getClass().getMethod("destroy", (Class[])null);
+            destroyMethod.invoke(service, (Object[])null);
+         }
+         catch (Exception e)
+         {
+            // No destroy method
+         }
+
+         setServiceStatus(name, ServiceLifecycle.NOT_STARTED);
+      }
+
+      info("Shutdown complete");
+
+      if (containerClassLoader != null && containerClassLoader instanceof Closeable)
+      {
+         try
+         {
+            ((Closeable)containerClassLoader).close();
+         }
+         catch (IOException ioe)
+         {
+            // Swallow
+         }
+      }
+
+      SecurityActions.setThreadContextClassLoader(oldClassLoader);
+   }
+
+   /** 
+    * Get the executor service
+    * @return The executor service
+    */
+   public ExecutorService getExecutorService()
+   {
+      return executorService;
+   }
+
+   /**
+    * Get the service status
+    * @param name The service name
+    * @return The status
+    */
+   public ServiceLifecycle getServiceStatus(String name)
+   {
+      return servicesStatus.get(name);
+   }
+
+   /**
+    * Set service status
+    * @param name The service name
+    * @param status The service status
+    */
+   public void setServiceStatus(String name, ServiceLifecycle status)
+   {
+      servicesStatus.put(name, status);
+   }
+
+   /**
+    * Add a bean
+    * @param name The name of the bean
+    * @param bean The bean
+    */
+   public void addBean(String name, Object bean)
+   {
+      startup.add(name);
+      services.put(name, bean);
+   }
+
+   /**
+    * Get a bean
+    * @param name The name of the bean
+    * @return The bean
+    */
+   public Object getBean(String name)
+   {
+      return services.get(name);
+   }
+
+   /**
+    * Register deployment
+    * @param deployment The deployment
+    */
+   public void registerDeployment(Deployment deployment)
+   {
+      deployments.add(deployment);
+   }
+
+   /**
+    * Get the main deployer
+    * @return The main deployer
+    */
+   public MainDeployer getMainDeployer()
+   {
+      return mainDeployer;
+   }
+
+   /**
+    * Get the URLs for the directory and all libraries located in the directory
+    * @param directrory The directory
+    * @return The URLs
+    * @exception MalformedURLException MalformedURLException
+    * @exception IOException IOException
+    */
+   private URL[] getUrls(File directory) throws MalformedURLException, IOException
+   {
+      if (directory != null && directory.exists() && directory.isDirectory())
+      {
+         List<URL> list = new LinkedList<URL>();
+
+         // Add directory
+         list.add(directory.toURI().toURL());
+
+         // Add the contents of the directory too
+         File[] jars = directory.listFiles(new JarFilter());
+
+         if (jars != null)
+         {
+            for (int j = 0; jars != null && j < jars.length; j++)
+            {
+               list.add(jars[j].getCanonicalFile().toURI().toURL());
+            }
+         }
+         
+         return list.toArray(new URL[list.size()]);      
+      }
+
+      return null;
+   }
+
+   /**
+    * Merge URLs into a single array
+    * @param urls The URLs
+    * @return The combined list
+    */
+   private URL[] mergeUrls(URL[]... urls)
+   {
+      if (urls != null)
+      {
+         List<URL> list = new LinkedList<URL>();
+
+         for (URL[] u : urls)
+         {
+            if (u != null)
+            {
+               for (URL url : u)
+               {
+                  list.add(url);
+               }
+            }
+         }
+
+         return list.toArray(new URL[list.size()]);      
+      }
+
+      return null;
+   }
+
+   /**
+    * Init logging
+    * @param cl The classloader to load from
+    */
+   private void initLogging(ClassLoader cl)
+   {
+      try
+      {
+         Class clz = Class.forName("org.jboss.logmanager.log4j.BridgeRepositorySelector", true, cl);
+         Method mStart = clz.getMethod("start", (Class[])null);
+
+         Object brs = clz.newInstance();
+
+         logging = mStart.invoke(brs, (Object[])null);
+      }
+      catch (Throwable t)
+      {
+         // Nothing we can do
+      }
+
+
+      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[] {"org.jboss.jca.fungal.impl.KernelImpl"});
+      }
+      catch (Throwable t)
+      {
+         // Nothing we can do
+      }
+   }
+
+   /**
+    * Logging: ERROR
+    * @param s The string
+    * @param t The throwable
+    */
+   private 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 (Throwable th)
+         {
+            // Nothing we can do
+         }
+      }
+      else
+      {
+         System.out.println(s);
+         t.printStackTrace(System.out);
+      }
+   }
+
+   /**
+    * Logging: WARN
+    * @param s The string
+    */
+   private 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 (Throwable t)
+         {
+            // Nothing we can do
+         }
+      }
+      else
+      {
+         System.out.println(s);
+      }
+   }
+
+   /**
+    * Logging: INFO
+    * @param s The string
+    */
+   private 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 (Throwable t)
+         {
+            // Nothing we can do
+         }
+      }
+      else
+      {
+         System.out.println(s);
+      }
+   }
+
+   /**
+    * Logging: Is DEBUG enabled
+    * @return True if debug is enabled; otherwise false
+    */
+   private boolean isDebugEnabled()
+   {
+      if (logging != null)
+      {
+         try
+         {
+            Class clz = logging.getClass();
+            Method mIsDebugEnabled = clz.getMethod("isDebugEnabled", (Class[])null);
+            return ((Boolean)mIsDebugEnabled.invoke(logging, (Object[])null)).booleanValue();
+         }
+         catch (Throwable t)
+         {
+            // Nothing we can do
+         }
+      }
+      return true;
+   }
+
+   /**
+    * Logging: DEBUG
+    * @param s The string
+    */
+   private void debug(String s)
+   {
+      if (logging != null)
+      {
+         try
+         {
+            Class clz = logging.getClass();
+            Method mDebug = clz.getMethod("debug", Object.class);
+            mDebug.invoke(logging, new Object[] {s});
+         }
+         catch (Throwable t)
+         {
+            // Nothing we can do
+         }
+      }
+      else
+      {
+         System.out.println(s);
+      }
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/MainDeployer.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/MainDeployer.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/MainDeployer.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,239 @@
+/*
+ * 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.fungal.impl;
+
+import org.jboss.jca.fungal.deployers.Deployer;
+import org.jboss.jca.fungal.deployers.Deployment;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The main deployer for JBoss JCA/Fungal
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class MainDeployer
+{
+   private KernelImpl kernel;
+   private List<Deployer> deployers;
+
+   /** Logging */
+   private static Object logging;
+
+   static
+   {
+      initLogging();
+   }
+
+   /**
+    * Constructor
+    * @param kernel The kernel
+    */
+   public MainDeployer(KernelImpl kernel)
+   {
+      this.kernel = kernel;
+      this.deployers = new ArrayList<Deployer>();
+   }
+
+   /**
+    * Add deployer
+    * @param deployer The deployer
+    */
+   public void addDeployer(Deployer deployer)
+   {
+      deployers.add(deployer);
+   }
+
+   /**
+    * Deploy
+    * @param url The URL for the deployment
+    * @param classLoader The class loader
+    */
+   public void deploy(URL url, ClassLoader classLoader)
+   {
+      boolean done = false;
+      try
+      {
+         for (int i = 0; !done && i < deployers.size(); i++)
+         {
+            Deployer deployer = deployers.get(i);
+            
+            Deployment deployment = deployer.deploy(url, classLoader);
+            if (deployment != null)
+            {
+               kernel.registerDeployment(deployment);
+               done = true;
+            }
+         }
+      }
+      catch (Throwable t)
+      {
+         error(t.getMessage(), t);
+      }
+   }
+
+   /**
+    * Init logging
+    */
+   private static void initLogging()
+   {
+      try
+      {
+         Class clz = Class.forName("org.jboss.logging.Logger");
+         
+         Method mGetLogger = clz.getMethod("getLogger", String.class);
+
+         logging = mGetLogger.invoke((Object)null, new Object[] {"org.jboss.jca.fungal.impl.MainDeployer"});
+      }
+      catch (Throwable t)
+      {
+         // 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 (Throwable th)
+         {
+            // 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 (Throwable t)
+         {
+            // 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 (Throwable t)
+         {
+            // Nothing we can do
+         }
+      }
+      else
+      {
+         System.out.println(s);
+      }
+   }
+
+   /**
+    * Logging: Is DEBUG enabled
+    * @return True if debug is enabled; otherwise false
+    */
+   private static boolean isDebugEnabled()
+   {
+      if (logging != null)
+      {
+         try
+         {
+            Class clz = logging.getClass();
+            Method mIsDebugEnabled = clz.getMethod("isDebugEnabled", (Class[])null);
+            return ((Boolean)mIsDebugEnabled.invoke(logging, (Object[])null)).booleanValue();
+         }
+         catch (Throwable t)
+         {
+            // Nothing we can do
+         }
+      }
+      return true;
+   }
+
+   /**
+    * Logging: DEBUG
+    * @param s The string
+    */
+   private static void debug(String s)
+   {
+      if (logging != null)
+      {
+         try
+         {
+            Class clz = logging.getClass();
+            Method mDebug = clz.getMethod("debug", Object.class);
+            mDebug.invoke(logging, new Object[] {s});
+         }
+         catch (Throwable t)
+         {
+            // Nothing we can do
+         }
+      }
+      else
+      {
+         System.out.println(s);
+      }
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/SecurityActions.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/SecurityActions.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/SecurityActions.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,139 @@
+/*
+ * 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.fungal.impl;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+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;
+         }
+      });
+   }
+
+   /**
+    * Create an URLClassLoader
+    * @param urls The urls
+    * @param parent The parent class loader
+    * @return The class loader
+    */
+   static URLClassLoader createURLCLassLoader(final URL[] urls, final ClassLoader parent)
+   {
+      return (URLClassLoader)AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            return new URLClassLoader(urls, parent);
+         }
+      });
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/ServiceLifecycle.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/ServiceLifecycle.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/ServiceLifecycle.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 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.fungal.impl;
+
+/**
+ * Constants for a service lifecycle
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public enum ServiceLifecycle
+{
+   /** Service not started */
+   NOT_STARTED,
+      
+   /** Service starting */
+   STARTING,
+      
+   /** Service started */
+   STARTED,
+         
+   /** Service stopping */
+   STOPPING
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/package.html
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/package.html	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,3 @@
+<body>
+This package contains the JBoss JCA/Fungal kernel implementation
+</body>

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/FileUtil.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/FileUtil.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/FileUtil.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,276 @@
+/*
+ * 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.fungal.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.logging.Logger;
+
+
+/**
+ * An utility for JAR type files
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class FileUtil
+{
+   private static Logger log = Logger.getLogger(FileUtil.class.getName());
+
+   /**
+    * Constructor
+    */
+   private FileUtil()
+   {
+   }
+
+   /**
+    * Compress a directory in a JAR layout to a file
+    * @param directory The directory
+    * @param target The JAR file
+    * @exception IOException Thrown if an error occurs
+    */
+   public static void compress(File directory, File target) throws IOException
+   {
+      if (directory == null)
+         throw new IllegalArgumentException("Directory is null");
+
+      if (target == null)
+         throw new IllegalArgumentException("Target is null");
+
+      if (target.exists())
+         recursiveDelete(target);
+
+      Manifest manifest = null;
+
+      File manifestFile = new File(directory, "META-INF/MANIFEST.MF");
+      if (manifestFile.exists())
+      {
+         FileInputStream fis = new FileInputStream(manifestFile);
+         manifest = new Manifest(fis);
+         fis.close();
+      }
+      else
+      {
+         log.fine("No META-INF/MANIFEST.MF found; creating one");
+         manifest = new Manifest();
+      }
+
+      FileOutputStream fos = new FileOutputStream(target);
+      JarOutputStream jos = new JarOutputStream(fos, manifest);
+
+      int bytesRead;
+      byte[] buffer = new byte[4096];
+
+      List<File> entries = findEntries(directory);
+
+      if (entries != null)
+      {
+         entries.remove(new File("META-INF/MANIFEST.MF"));
+
+         for (File file : entries)
+         {
+            File f = new File(directory, file.getPath());
+            JarEntry entry = new JarEntry(file.getPath());
+            jos.putNextEntry(entry);
+
+            FileInputStream in = null;
+            try
+            {
+               in = new FileInputStream(f);
+               while ((bytesRead = in.read(buffer)) != -1)
+                  jos.write(buffer, 0, bytesRead);
+            }
+            finally
+            {
+               if (in != null)
+               {
+                  try
+                  {
+                     in.close(); 
+                  }
+                  catch (IOException ioe)
+                  {
+                     // Ignore
+                  }
+               }
+            }
+         }
+      }
+
+      jos.flush();
+      jos.close();
+   }
+
+   /**
+    * 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())
+         recursiveDelete(target);
+
+      if (!target.mkdirs())
+         throw new IOException("Could not create " + target);
+
+      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
+         {
+            if (!copy.mkdirs())
+               throw new IOException("Could not create " + copy);
+         }
+      }
+
+      return target;
+   }
+
+   /**
+    * Recursive delete
+    * @param f The file handler
+    * @exception IOException Thrown if a file could not be deleted
+    */
+   public static void recursiveDelete(File f) throws IOException
+   {
+      if (f.exists())
+      {
+         File[] files = f.listFiles();
+         if (files != null)
+         {
+            for (int i = 0; i < files.length; i++)
+            {
+               if (files[i].isDirectory())
+               {
+                  recursiveDelete(files[i]);
+               } 
+               else
+               {
+                  if (!files[i].delete())
+                     throw new IOException("Could not delete " + files[i]);
+               }
+            }
+         }
+         if (!f.delete())
+            throw new IOException("Could not delete " + f);
+      }
+   }
+
+   /**
+    * Find all file entries for a directory
+    * @param file The root directory
+    * @return The list of files
+    */
+   private static List<File> findEntries(File root)
+   {
+      try
+      {
+         return getListing(root, root);
+      }
+      catch (Exception e)
+      {
+         log.severe(e.getMessage());
+      }
+
+      return null;
+   }
+
+   /**
+    * Recursively walk a directory tree and return a list of all files entries found
+    * @param root The root directory
+    * @param directory The current directory
+    * @return The list of files
+    * @exception Exception Thrown if an error occurs
+    */
+   private static List<File> getListing(File root, File directory) throws Exception 
+   {
+      List<File> result = new ArrayList<File>();
+
+      File[] filesAndDirs = directory.listFiles();
+
+      if (filesAndDirs != null)
+      {
+         for (File file : filesAndDirs) 
+         {
+            if (file.isDirectory()) 
+            {
+               List<File> deeperList = getListing(root, file);
+               result.addAll(deeperList);
+            }
+            else
+            {
+               String fileName = file.getPath().substring(root.getPath().length() + 1);
+               result.add(new File(fileName));
+            }
+         }
+      }
+
+      return result;
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/Injection.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/Injection.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/Injection.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,176 @@
+/*
+ * 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.fungal.util;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Injection utility
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Injection
+{
+
+   /**
+    * Inject a value into an object property
+    * @param propertyType The property type
+    * @param propertyName The property name
+    * @param propertyValue The property value
+    * @param object The object
+    * @exception NoSuchMethodException If the property method cannot be found
+    * @exception IllegalAccessException If the property method cannot be accessed
+    * @exception InvocationTargetException If the property method cannot be executed
+    */
+   public static void inject(String propertyType, String propertyName, String propertyValue, Object object)
+      throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
+   {
+      if (propertyType == null || propertyType.trim().equals(""))
+         throw new IllegalArgumentException("PropertyType is undefined");
+
+      if (propertyName == null || propertyName.trim().equals(""))
+         throw new IllegalArgumentException("PropertyName is undefined");
+
+      if (propertyValue == null || propertyValue.trim().equals(""))
+         throw new IllegalArgumentException("PropertyValue is undefined");
+
+      if (object == null)
+         throw new IllegalArgumentException("Object is null");
+
+
+      Class parameterClass = null;
+      Object parameterValue = null;
+
+      if (propertyType.equals("java.lang.String"))
+      {
+         parameterClass = String.class;
+         parameterValue = getSubstitutionValue(propertyValue);
+      }
+      else if (propertyType.equals("byte") || propertyType.equals("java.lang.Byte"))
+      {
+         parameterClass = Byte.class;
+         parameterValue = Byte.valueOf(getSubstitutionValue(propertyValue));
+      }
+      else if (propertyType.equals("short") || propertyType.equals("java.lang.Short"))
+      {
+         parameterClass = Short.class;
+         parameterValue = Short.valueOf(getSubstitutionValue(propertyValue));
+      }
+      else if (propertyType.equals("int") || propertyType.equals("java.lang.Integer"))
+      {
+         parameterClass = Integer.class;
+         parameterValue = Integer.valueOf(getSubstitutionValue(propertyValue));
+      }
+      else if (propertyType.equals("long") || propertyType.equals("java.lang.Long"))
+      {
+         parameterClass = Long.class;
+         parameterValue = Long.valueOf(getSubstitutionValue(propertyValue));
+      }
+      else if (propertyType.equals("float") || propertyType.equals("java.lang.Float"))
+      {
+         parameterClass = Float.class;
+         parameterValue = Float.valueOf(getSubstitutionValue(propertyValue));
+      }
+      else if (propertyType.equals("double") || propertyType.equals("java.lang.Double"))
+      {
+         parameterClass = Double.class;
+         parameterValue = Double.valueOf(getSubstitutionValue(propertyValue));
+      }
+      else if (propertyType.equals("boolean") || propertyType.equals("java.lang.Boolean"))
+      {
+         parameterClass = Boolean.class;
+         parameterValue = Boolean.valueOf(getSubstitutionValue(propertyValue));
+      }
+      else if (propertyType.equals("char") || propertyType.equals("java.lang.Character"))
+      {
+         parameterClass = Character.class;
+         parameterValue = Character.valueOf((getSubstitutionValue(propertyValue)).charAt(0));
+      }
+      else
+      {
+         throw new IllegalArgumentException("Unknown property type: " + propertyType + " for " +
+                                            "property " + propertyName);
+      }
+
+      String methodName = "set" + propertyName.substring(0, 1).toUpperCase();
+      if (propertyName.length() > 1)
+      {
+         methodName += propertyName.substring(1);
+      }
+
+      Method method = object.getClass().getMethod(methodName, parameterClass);
+      method.invoke(object, new Object[] {parameterValue});
+   }
+
+   /**
+    * System property substitution
+    * @param input The input string
+    * @return The output
+    */
+   private static String getSubstitutionValue(String input)
+   {
+      if (input == null || input.trim().equals(""))
+         return input;
+
+      if (input.indexOf("${") != -1)
+      {
+         int from = input.indexOf("${");
+         int to = input.indexOf("}");
+         int dv = input.indexOf(":");
+         
+         String systemProperty = "";
+         String defaultValue = "";
+         if (dv == -1)
+         {
+            systemProperty = SecurityActions.getSystemProperty(input.substring(from + 2, to));
+         }
+         else
+         {
+            systemProperty = SecurityActions.getSystemProperty(input.substring(from + 2, dv));
+            defaultValue = input.substring(dv + 1, to);
+         }
+         String prefix = "";
+         String postfix = "";
+
+         if (from != 0)
+         {
+            prefix = input.substring(0, from);
+         }
+         
+         if (to + 1 < input.length() - 1)
+         {
+            postfix = input.substring(to + 1);
+         }
+
+         if (systemProperty != null && !systemProperty.trim().equals(""))
+         {
+            return prefix + systemProperty + postfix;
+         }
+         else if (defaultValue != null && !defaultValue.trim().equals(""))
+         {
+            return prefix + defaultValue + postfix;
+         }
+      }
+      return input;
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/JarFilter.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/JarFilter.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/JarFilter.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,44 @@
+/*
+ * 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.fungal.util;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+/**
+ * Jar filter
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class JarFilter implements FilenameFilter
+{
+   /**
+    * Accept
+    * @param dir The directory
+    * @param name The name
+    * @return True if accepts; otherwise false
+    */
+   public boolean accept(File dir, String name)
+   {
+      return name.endsWith(".jar");
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/SecurityActions.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/SecurityActions.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/SecurityActions.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,139 @@
+/*
+ * 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.fungal.util;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+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;
+         }
+      });
+   }
+
+   /**
+    * Create an URLClassLoader
+    * @param urls The urls
+    * @param parent The parent class loader
+    * @return The class loader
+    */
+   static URLClassLoader createURLCLassLoader(final URL[] urls, final ClassLoader parent)
+   {
+      return (URLClassLoader)AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            return new URLClassLoader(urls, parent);
+         }
+      });
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/package.html
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/util/package.html	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,3 @@
+<body>
+This package contains various utilities for the JBoss JCA/Fungal container.
+</body>

Added: projects/jboss-jca/trunk/fungal/src/main/resources/boot.xsd
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/resources/boot.xsd	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/resources/boot.xsd	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Boot XML Schema
+-->
+<xsd:schema xmlns:boot="http://www.jboss.org/jca" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+   <xsd:element name="boot">
+     <xsd:complexType>
+       <xsd:sequence>
+         <xsd:element name="url" type="xsd:token" maxOccurs="unbounded" minOccurs="0"/>
+       </xsd:sequence>
+     </xsd:complexType>
+   </xsd:element>
+
+</xsd:schema>

Added: projects/jboss-jca/trunk/fungal/src/main/resources/deployment.xsd
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/resources/deployment.xsd	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/resources/deployment.xsd	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Deployment XML Schema
+-->
+<xsd:schema xmlns:boot="http://www.jboss.org/jca" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+   <xsd:complexType name="beanType">
+     <xsd:sequence>
+       <xsd:element name="constructor" type="constructorType" maxOccurs="1" minOccurs="0"/>
+       <xsd:element name="property" type="propertyType" maxOccurs="unbounded" minOccurs="0"/>
+       <xsd:element name="depends" type="dependsType" maxOccurs="unbounded" minOccurs="0"/>
+     </xsd:sequence>
+     <xsd:attribute name="name" type="xsd:token" use="required"/>
+     <xsd:attribute name="interface" type="xsd:token"/>
+     <xsd:attribute name="class" type="xsd:token"/>
+   </xsd:complexType>
+
+   <xsd:complexType name="propertyType" mixed="true">
+     <xsd:sequence>
+       <xsd:element name="inject" type="injectType" maxOccurs="1" minOccurs="0"/>
+     </xsd:sequence>
+     <xsd:attribute name="name" type="xsd:token" use="required"/>
+     <xsd:attribute name="class" type="xsd:token"/>
+   </xsd:complexType>
+
+   <xsd:complexType name="injectType">
+     <xsd:simpleContent>
+       <xsd:extension base="xsd:token">
+         <xsd:attribute name="bean" type="xsd:token" use="required"/>
+         <xsd:attribute name="property" type="xsd:token"/>
+       </xsd:extension>
+     </xsd:simpleContent>
+   </xsd:complexType>
+
+   <xsd:complexType name="constructorType">
+     <xsd:sequence>
+       <xsd:element name="parameter" type="parameterType" maxOccurs="unbounded" minOccurs="0"/>
+     </xsd:sequence>
+     <xsd:attribute name="factoryMethod" type="xsd:token" use="required"/>
+     <xsd:attribute name="factoryClass" type="xsd:token" use="required"/>
+   </xsd:complexType>
+
+   <xsd:complexType name="parameterType">
+     <xsd:simpleContent>
+       <xsd:extension base="xsd:token">
+       </xsd:extension>
+     </xsd:simpleContent>
+   </xsd:complexType>
+
+   <xsd:complexType name="dependsType">
+     <xsd:simpleContent>
+       <xsd:extension base="xsd:token">
+       </xsd:extension>
+     </xsd:simpleContent>
+   </xsd:complexType>
+
+   <xsd:element name="deployment">
+     <xsd:complexType>
+       <xsd:sequence>
+         <xsd:element name="bean" type="beanType" maxOccurs="unbounded" minOccurs="0"/>
+       </xsd:sequence>
+     </xsd:complexType>
+   </xsd:element>
+
+</xsd:schema>

Added: projects/jboss-jca/trunk/fungal/src/main/resources/fungal-manifest.mf
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/resources/fungal-manifest.mf	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/resources/fungal-manifest.mf	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,4 @@
+Implementation-Title: JBoss JCA Fungal
+Implementation-Vendor: Red Hat Middleware LLC
+Implementation-Vendor-Id: org.jboss
+Implementation-Version: 0.1

Added: projects/jboss-jca/trunk/fungal/src/main/resources/fungal-services-manifest.mf
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/resources/fungal-services-manifest.mf	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/resources/fungal-services-manifest.mf	2009-09-05 17:11:23 UTC (rev 93221)
@@ -0,0 +1,4 @@
+Implementation-Title: JBoss JCA Fungal Services
+Implementation-Vendor: Red Hat Middleware LLC
+Implementation-Vendor-Id: org.jboss
+Implementation-Version: 0.1

Modified: projects/jboss-jca/trunk/sjc/build.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/build.xml	2009-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/build.xml	2009-09-05 17:11:23 UTC (rev 93221)
@@ -37,34 +37,9 @@
   </target>
 
   <!-- ================================= 
-       Target: compile boot.xsd
-       ================================= -->
-  <target name="compile-boot-xsd" depends="init">
-    <taskdef name="xjc"
-             classname="com.sun.tools.xjc.XJCTask"
-             classpathref="sjc.lib.path.id"/>
-    <xjc schema="src/main/resources/boot.xsd"
-         destdir="${build.sjc.dir}/impl"
-         package="org.jboss.jca.sjc.boot"/>
-    <javac srcdir="${build.sjc.dir}/impl"
-           destdir="${build.sjc.dir}/impl"
-           classpathref="sjc.lib.path.id"
-           debug="${javac.debug}"
-           deprecation="${javac.deprecation}"
-           optimize="${javac.optimize}">
-      <compilerarg value="-Xlint"/>
-    </javac>
-    <delete>
-      <fileset dir="${build.sjc.dir}/impl">
-        <include name="**/*.java"/>
-      </fileset>
-    </delete>
-  </target>
-
-  <!-- ================================= 
        Target: compile
        ================================= -->
-  <target name="compile" depends="compile-boot-xsd">
+  <target name="compile" depends="init">
     <javac srcdir="src/main"
            destdir="${build.sjc.dir}/impl"
            classpathref="sjc.lib.path.id"
@@ -136,6 +111,7 @@
     <copy todir="${target.dir}/sjc/bin">
       <fileset dir="${target.dir}">
         <include name="*sjc.jar"/>
+        <include name="*fungal.jar"/>
       </fileset>
     </copy>
 
@@ -155,6 +131,7 @@
     <copy todir="${target.dir}/sjc/lib">
       <fileset dir="${target.dir}">
         <include name="*.jar"/>
+        <exclude name="*fungal.jar"/>
         <exclude name="*sjc.jar"/>
         <exclude name="jboss-jca-deployers*.jar"/>
         <exclude name="jboss-jca-standalone*.jar"/>

Deleted: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/JarFilter.java
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/JarFilter.java	2009-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/JarFilter.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -1,44 +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;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-/**
- * Jar filter
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public class JarFilter implements FilenameFilter
-{
-   /**
-    * Accept
-    * @param dir The directory
-    * @param name The name
-    * @return True if accepts; otherwise false
-    */
-   public boolean accept(File dir, String name)
-   {
-      return name.endsWith(".jar");
-   }
-}

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-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/Main.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -22,94 +22,29 @@
 
 package org.jboss.jca.sjc;
 
-import org.jboss.jca.sjc.boot.BeanType;
-import org.jboss.jca.sjc.boot.ConstructorType;
-import org.jboss.jca.sjc.boot.DependsType;
-import org.jboss.jca.sjc.boot.InjectType;
-import org.jboss.jca.sjc.boot.PropertyType;
-import org.jboss.jca.sjc.deployers.Deployer;
+import org.jboss.jca.fungal.api.Kernel;
+import org.jboss.jca.fungal.impl.KernelConfiguration;
+import org.jboss.jca.fungal.impl.KernelImpl;
 
-import java.io.Closeable;
 import java.io.File;
-import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.lang.management.MemoryMXBean;
 import java.lang.reflect.Method;
-import java.net.InetAddress;
-import java.net.MalformedURLException;
 import java.net.URI;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ThreadFactory;
 
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.Unmarshaller;
-
 /**
  * The main class for JBoss JCA SJC
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
  */
 public class Main
 {
-   /** Parallel startup */
-   private static boolean parallel = false;
+   /** Kernel */
+   private static Kernel kernel;
 
-   /** Startup list */
-   private static List<String> startup = Collections.synchronizedList(new LinkedList<String>());
-
-   /** Services */
-   private static ConcurrentMap<String, Object> services = new ConcurrentHashMap<String, Object>();
-
-   /** Services status */
-   private static ConcurrentMap<String, Status> servicesStatus = new ConcurrentHashMap<String, Status>();
-
-   /** Services latch */
-   private static CountDownLatch servicesLatch;
-
-   /** Executor service */
-   private static ExecutorService executorService;
-
-   /** Container classloader */
-   private static URLClassLoader containerClassLoader;
-
-   /** The deploy directory */
-   private static File deployDirectory;
-
    /** Logging */
    private static Object logging;
 
    /**
-    * Status
-    */
-   enum Status
-   {
-      /** Services not started */
-      NOT_STARTED,
-
-      /** Services starting */
-      STARTING,
-
-      /** Services started */
-      STARTED,
-         
-      /** Services stopped */
-      STOPPING
-   }
-
-   /**
     * Default constructor
     */
    private Main()
@@ -125,18 +60,18 @@
    {
       try
       {
-         String home = SecurityActions.getSystemProperty("jboss.jca.home");
-         File root = null;
+         KernelConfiguration kernelConfiguration = new KernelConfiguration();
 
+         String home = SecurityActions.getSystemProperty("jboss.jca.home");
          if (home != null)
          {
-            root = new File(new URI(home));
+            kernelConfiguration.home(new File(home).toURI().toURL());
          }
          else
          {
             home = new File(".").toURI().toURL().toString();
-            root = new File(new URI(home.substring(0, home.lastIndexOf("bin"))));
-            SecurityActions.setSystemProperty("jboss.jca.home", root.getAbsolutePath());
+            File root = new File(new URI(home.substring(0, home.lastIndexOf("bin"))));
+            kernelConfiguration.home(root.toURI().toURL());
          }
 
          if (args != null && args.length > 0)
@@ -145,92 +80,18 @@
             {
                if ("-b".equals(args[i]))
                {
-                  SecurityActions.setSystemProperty("jboss.jca.bindaddress", args[++i]);
+                  kernelConfiguration.bindAddress(args[++i]);
                }
-               else if ("-mt".equals(args[i]))
-               {
-                  parallel = true;
-               }
             }
          }
 
-         if (parallel)
-         {
-            ThreadFactory tf = new SJCThreadFactory(tg);
-            executorService = Executors.newCachedThreadPool(tf);
-         }
+         if (tg != null)
+            kernelConfiguration.threadGroup(tg);
 
-         File libDirectory = new File(root, "/lib/");
-         File configDirectory = new File(root, "/config/");
-         deployDirectory = new File(root, "/deploy/");
+         kernel = new KernelImpl(kernelConfiguration);
+         kernel.startup();
 
-         ClassLoader parent = SecurityActions.getThreadContextClassLoader();
-
-         URL[] libUrls = getUrls(libDirectory);
-         URL[] confUrls = getUrls(configDirectory);
-
-         URL[] urls = mergeUrls(libUrls, confUrls);
-
-         containerClassLoader = SecurityActions.createURLCLassLoader(urls, parent);
-         SecurityActions.setThreadContextClassLoader(containerClassLoader);
-
-         SecurityActions.setSystemProperty("xb.builder.useUnorderedSequence", "true");
-         SecurityActions.setSystemProperty("jboss.deploy.url", deployDirectory.toURI().toURL().toString());
-         SecurityActions.setSystemProperty("jboss.lib.url", libDirectory.toURI().toURL().toString());
-         SecurityActions.setSystemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
-
-         initLogging(containerClassLoader);
-
-         File bootXml = new File(configDirectory, "boot.xml");
-         JAXBContext bootJc = JAXBContext.newInstance("org.jboss.jca.sjc.boot");
-         Unmarshaller bootU = bootJc.createUnmarshaller();
-         org.jboss.jca.sjc.boot.Deployment boot = 
-            (org.jboss.jca.sjc.boot.Deployment)bootU.unmarshal(bootXml);
-
-         if (boot != null)
-         {
-            if (parallel)
-               servicesLatch = new CountDownLatch(boot.getBean().size());
-
-            for (BeanType bt : boot.getBean())
-            {
-               if (!parallel)
-               {
-                  try
-                  {
-                     if (services.get(bt.getName()) == null)
-                     {
-                        setServiceStatus(bt.getName(), Status.STARTING);
-
-                        Object bean = createBean(bt, containerClassLoader, deployDirectory);
-                        startup.add(bt.getName());
-                        services.put(bt.getName(), bean);
-
-                        setServiceStatus(bt.getName(), Status.STARTED);
-                     }
-                     else
-                     {
-                        warn("Warning: A service with name " + bt.getName() + " already exists");
-                     }
-                  }
-                  catch (Throwable t)
-                  {
-                     error("Installing bean " + bt.getName(), t);
-                  }
-               }
-               else
-               {
-                  Runnable r = new ServiceRunnable(bt);
-                  executorService.execute(r);
-               }
-            }
-
-            if (parallel)
-            {
-               servicesLatch.await();
-               executorService.shutdown();
-            }
-         }
+         initLogging(SecurityActions.getThreadContextClassLoader());
       }
       catch (Throwable t)
       {
@@ -239,693 +100,6 @@
    }
 
    /**
-    * Set service status
-    * @param name The service name
-    * @param status The service status
-    */
-   static void setServiceStatus(String name, Status status)
-   {
-      servicesStatus.put(name, status);
-   }
-
-   /**
-    * Service runnable
-    */
-   static class ServiceRunnable implements Runnable
-   {
-      /** The bean */
-      private BeanType bt;
-
-      /**
-       * Constructor
-       * @param bt The bean
-       */
-      public ServiceRunnable(BeanType bt)
-      {
-         this.bt = bt;
-      }
-
-      /**
-       * Run
-       */
-      public void run()
-      {
-         SecurityActions.setThreadContextClassLoader(containerClassLoader);
-
-         try
-         {
-            if (services.get(bt.getName()) == null)
-            {
-               setServiceStatus(bt.getName(), Status.NOT_STARTED);
-
-               Set<String> dependencies = getDependencies(bt);
-               int notStarted = getNotStarted(dependencies);
-
-               while (notStarted > 0)
-               {
-                  try
-                  {
-                     Thread.sleep(10);
-                     notStarted = getNotStarted(dependencies);
-                  }
-                  catch (InterruptedException ie)
-                  {
-                     Thread.interrupted();
-                  }
-               }
-
-               setServiceStatus(bt.getName(), Status.STARTING);
-
-               Object bean = createBean(bt, containerClassLoader, deployDirectory);
-               startup.add(bt.getName());
-               services.put(bt.getName(), bean);
-
-               setServiceStatus(bt.getName(), Status.STARTED);
-            }
-            else
-            {
-               warn("Warning: A service with name " + bt.getName() + " already exists");
-            }
-         }
-         catch (Throwable t)
-         {
-            error("Installing bean " + bt.getName(), t);
-         }
-
-         servicesLatch.countDown();
-      }
-
-      /**
-       * Get the depedencies for a bean
-       * @paran bt The bean type
-       * @return The set of dependencies; <code>null</code> if no dependencies
-       */
-      private Set<String> getDependencies(BeanType bt)
-      {
-         Set<String> result = null;
-
-         List<DependsType> dts = bt.getDepends();
-         if (dts != null)
-         {
-            result = new HashSet<String>();
-            for (DependsType dt : dts)
-            {
-               result.add(dt.getValue());
-            }
-         }
-
-         List<PropertyType> pts = bt.getProperty();
-         if (pts != null)
-         {
-            if (result == null)
-               result = new HashSet<String>();
-
-            for (PropertyType pt : pts)
-            {
-               Object e = pt.getContent().get(0);
-
-               if (e != null && e instanceof JAXBElement)
-               {
-                  Object element = ((JAXBElement)e).getValue();
-                  if (element instanceof InjectType)
-                  {
-                     InjectType it = (InjectType)element;
-                     result.add(it.getBean());
-                  }
-               }
-            }
-         }
-
-         return result;
-      }
-
-      /**
-       * Get the number of services that are not started yet
-       * @paran dependencies The dependencies for a service
-       * @return The number of not started services
-       */
-      private int getNotStarted(Set<String> dependencies)
-      {
-         if (dependencies == null || dependencies.size() == 0)
-            return 0;
-
-         int count = 0;
-         for (String dependency : dependencies)
-         {
-            Status dependencyStatus = servicesStatus.get(dependency);
-            if (dependencyStatus == null || dependencyStatus != Status.STARTED)
-               count += 1;
-         }
-
-         return count;
-      }
-   }
-
-   /**
-    * A thread factory for JCA/SJC
-    */
-   static class SJCThreadFactory implements ThreadFactory
-   {
-      /** The thread group */
-      private ThreadGroup tg;
-
-      /**
-       * Constructor
-       * @param tg The thread group
-       */
-      public SJCThreadFactory(ThreadGroup tg)
-      {
-         this.tg = tg;
-      }
-
-      /**
-       * Create a new thread
-       * @param r The runnable
-       * @return The thread
-       */
-      public Thread newThread(Runnable r)
-      {
-         return new Thread(tg, r);
-      }
-   }
-
-   /**
-    * Shutdown
-    */
-   private static void shutdown()
-   {
-      SecurityActions.setThreadContextClassLoader(containerClassLoader);
-
-      List<String> shutdown = new LinkedList<String>(startup);
-      Collections.reverse(shutdown);
-
-      for (String name : shutdown)
-      {
-         setServiceStatus(name, Status.STOPPING);
-
-         Object service = services.get(name);
-
-         try
-         {
-            Method stopMethod = service.getClass().getMethod("stop", (Class[])null);
-            stopMethod.invoke(service, (Object[])null);
-         }
-         catch (Exception e)
-         {
-            // No stop method
-         }
-
-         try
-         {
-            Method destroyMethod = service.getClass().getMethod("destroy", (Class[])null);
-            destroyMethod.invoke(service, (Object[])null);
-         }
-         catch (Exception e)
-         {
-            // No destroy method
-         }
-
-         setServiceStatus(name, Status.NOT_STARTED);
-      }
-
-      info("Shutdown complete");
-   }
-
-   /**
-    * Get the URLs for the directory and all libraries located in the directory
-    * @param directrory The directory
-    * @return The URLs
-    * @exception MalformedURLException MalformedURLException
-    * @exception IOException IOException
-    */
-   private static URL[] getUrls(File directory) throws MalformedURLException, IOException
-   {
-      List<URL> list = new LinkedList<URL>();
-
-      if (directory.exists() && directory.isDirectory())
-      {
-         // Add directory
-         list.add(directory.toURI().toURL());
-
-         // Add the contents of the directory too
-         File[] jars = directory.listFiles(new JarFilter());
-
-         for (int j = 0; jars != null && j < jars.length; j++)
-         {
-            list.add(jars[j].getCanonicalFile().toURI().toURL());
-         }
-      }
-      return list.toArray(new URL[list.size()]);      
-   }
-
-   /**
-    * Merge URLs into a single array
-    * @param urls The URLs
-    * @return The combined list
-    */
-   private static URL[] mergeUrls(URL[]... urls)
-   {
-      List<URL> list = new LinkedList<URL>();
-
-      for (URL[] all : urls)
-      {
-         for (URL url : all)
-         {
-            list.add(url);
-         }
-      }
-
-      return list.toArray(new URL[list.size()]);      
-   }
-
-   /**
-    * Create a bean
-    * @param bt The bean type definition
-    * @param cl The classloader
-    * @param deployDirectory The deploy directory
-    * @return The new bean
-    * @exception Exception Thrown if an error occurs
-    */
-   private static Object createBean(BeanType bt, ClassLoader cl, File deployDirectory) throws Exception
-   {
-      Class<?> clz = null;
-      Object instance = null;
-
-      if (bt.getClazz() != null)
-      {
-         clz = Class.forName(bt.getClazz(), true, cl);
-         instance = clz.newInstance();
-      }
-      else
-      {
-         ConstructorType ct = bt.getConstructor();
-         Class factoryClass = Class.forName(ct.getFactoryClass(), true, cl);
-         Method factoryMethod = null;
-         Object[] args = null;
-
-         if (ct.getParameter() == null)
-         {
-            factoryMethod = factoryClass.getMethod(ct.getFactoryMethod(), (Class[])null);
-         }
-         else
-         {
-            Method[] factoryMethods = factoryClass.getMethods();
-            
-            List<Method> candidates = new ArrayList<Method>();
-
-            for (Method m : factoryMethods)
-            {
-               if (ct.getFactoryMethod().equals(m.getName()))
-               {
-                  if (ct.getParameter().size() == m.getParameterTypes().length)
-                  {
-                     boolean include = true;
-                     for (int i = 0; include && i < m.getParameterTypes().length; i++)
-                     {
-                        Class<?> parameterClass = m.getParameterTypes()[i];
-
-                        if (!(parameterClass.equals(String.class) ||
-                              parameterClass.equals(byte.class) || parameterClass.equals(Byte.class) ||
-                              parameterClass.equals(short.class) || parameterClass.equals(Short.class) ||
-                              parameterClass.equals(int.class) || parameterClass.equals(Integer.class) ||
-                              parameterClass.equals(long.class) || parameterClass.equals(Long.class) ||
-                              parameterClass.equals(float.class) || parameterClass.equals(Float.class) ||
-                              parameterClass.equals(double.class) || parameterClass.equals(Double.class) ||
-                              parameterClass.equals(boolean.class) || parameterClass.equals(Boolean.class) ||
-                              parameterClass.equals(char.class) || parameterClass.equals(Character.class) ||
-                              parameterClass.equals(InetAddress.class)))
-                        {
-                           include = false;
-                        }
-                     }
-
-                     if (include)
-                        candidates.add(m);
-                  }
-               }
-            }
-
-            if (candidates.size() == 1)
-            {
-               factoryMethod = candidates.get(0);
-               args = new Object[ct.getParameter().size()];
-               for (int i = 0; i < ct.getParameter().size(); i++)
-               {
-                  args[i] = getValue(ct.getParameter().get(i).getValue(), factoryMethod.getParameterTypes()[i]);
-               }
-            }
-            else
-            {
-               boolean found = false;
-               Iterator<Method> it = candidates.iterator();
-               while (!found && it.hasNext())
-               {
-                  try
-                  {
-                     Method m = it.next();
-                     args = new Object[ct.getParameter().size()];
-
-                     for (int i = 0; i < ct.getParameter().size(); i++)
-                     {
-                        args[i] = getValue(ct.getParameter().get(i).getValue(), factoryMethod.getParameterTypes()[i]);
-                     }
-
-                     factoryMethod = m;
-                     found = true;
-                  }
-                  catch (Throwable t)
-                  {
-                     // ok - not this one...
-                  }
-               }
-            }
-         }
-
-         instance = factoryMethod.invoke((Object)null, args);
-         clz = instance.getClass();
-      }
-
-      if (bt.getProperty() != null)
-      {
-         for (PropertyType pt : bt.getProperty())
-         {
-            setBeanProperty(instance, pt, cl);
-         }
-      }
-
-      try
-      {
-         Method createMethod = clz.getMethod("create", (Class[])null);
-         createMethod.invoke(instance, (Object[])null);
-      }
-      catch (Exception e)
-      {
-         // No create method
-      }
-
-      try
-      {
-         Method startMethod = clz.getMethod("start", (Class[])null);
-         startMethod.invoke(instance, (Object[])null);
-      }
-      catch (Exception e)
-      {
-         // No start method
-      }
-
-      if (instance instanceof Deployer)
-      {
-         try
-         {
-            Method deployMethod = clz.getMethod("deploy", new Class[] {File.class, ClassLoader.class});
-
-            for (File f : deployDirectory.listFiles())
-            {
-               try
-               {
-                  Object[] parameters = new Object[] {f, cl};
-                  org.jboss.jca.sjc.deployers.Deployment deployment = 
-                     (org.jboss.jca.sjc.deployers.Deployment)deployMethod.invoke(instance, parameters);
-                  if (deployment != null)
-                  {
-                     if (services.get(deployment.getName()) == null)
-                     {
-                        startup.add(deployment.getName());
-                        services.put(deployment.getName(), deployment);
-                     }
-                     else
-                     {
-                        warn("Warning: A deployment with name " + deployment.getName() + " already exists");
-                     }
-                  }
-                  else
-                  {
-                     warn("Ignoring deployment " + f.getName());
-                  }
-               }
-               catch (Exception de)
-               {
-                  error("Deployment " + f.getName() + " failed.", de);
-               }
-            }
-         }
-         catch (Exception e)
-         {
-            error("Exception during createBean()", e);
-         }
-      }
-
-      return instance;
-   }
-
-   /**
-    * Get a value from a string
-    * @param s The string representation
-    * @param clz The class
-    * @return The value
-    * @exception Exception If the string cant be converted
-    */
-   private static Object getValue(String s, Class<?> clz) throws Exception
-   {
-      if (clz.equals(String.class))
-      {
-         return s;
-      }
-      else if (clz.equals(byte.class) || clz.equals(Byte.class))
-      {
-         return Byte.valueOf(s);
-      }
-      else if (clz.equals(short.class) || clz.equals(Short.class))
-      {
-         return Short.valueOf(s);
-      }
-      else if (clz.equals(int.class) || clz.equals(Integer.class))
-      {
-         return Integer.valueOf(s);
-      }
-      else if (clz.equals(long.class) || clz.equals(Long.class))
-      {
-         return Long.valueOf(s);
-      }
-      else if (clz.equals(float.class) || clz.equals(Float.class))
-      {
-         return Float.valueOf(s);
-      }
-      else if (clz.equals(double.class) || clz.equals(Double.class))
-      {
-         return Double.valueOf(s);
-      }
-      else if (clz.equals(boolean.class) || clz.equals(Boolean.class))
-      {
-         return Boolean.valueOf(s);
-      }
-      else if (clz.equals(char.class) || clz.equals(Character.class))
-      {
-         return Character.valueOf(s.charAt(0));
-      }
-      else if (clz.equals(InetAddress.class))
-      {
-         return InetAddress.getByName(s);
-      }
-
-      throw new Exception("Unknown class " + clz.getName() + " for " + s);
-   }
-
-
-   /**
-    * Set a property on an object instance
-    * @param instance The object instance
-    * @param pt The property type definition
-    * @param cl The classloader
-    * @exception Exception Thrown if an error occurs
-    */
-   private static void setBeanProperty(Object instance, PropertyType pt, ClassLoader cl) throws Exception
-   {
-      String name = "set" + pt.getName().substring(0, 1).toUpperCase() + pt.getName().substring(1);
-      Method m = null;
-
-      if (pt.getClazz() == null)
-      {
-         Method[] ms = instance.getClass().getMethods();
-         if (ms != null)
-         {
-            boolean found = false;
-
-            for (int i = 0; !found && i < ms.length; i++)
-            {
-               if (ms[i].getName().equals(name) &&
-                   ms[i].getParameterTypes() != null &&
-                   ms[i].getParameterTypes().length == 1)
-               {
-                  m = ms[i];
-                  found = true;
-               }
-            }
-         }
-      }
-      else
-      {
-         Class clz = Class.forName(pt.getClazz(), true, cl);
-         m = instance.getClass().getMethod(name, clz);
-      }
-
-      if (m == null)
-         throw new Exception("Property " + pt.getName() + " not found on " + instance.getClass().getName());
-
-      Class parameterClass = m.getParameterTypes()[0];
-
-      Object parameterValue = null;
-      Object e = pt.getContent().get(0);
-      Object element = null;
-
-      if (e != null && e instanceof JAXBElement)
-      {
-         element = ((JAXBElement)e).getValue();
-      }
-      else
-      {
-         if (e == null)
-            e = "";
-
-         element = e;
-      }
-
-      if (element instanceof InjectType)
-      {
-         InjectType it = (InjectType)element;
-
-         Object injectionObject = services.get(it.getBean());
-
-         if (injectionObject == null)
-            throw new Exception("Injection depedency " + it.getBean() + " not found");
-
-         if (it.getProperty() != null)
-         {
-            Method method = null;
-            try
-            {
-               String getMethodName = "get" + 
-                  it.getProperty().substring(0, 1).toUpperCase() + it.getProperty().substring(1);
-               method = injectionObject.getClass().getMethod(getMethodName, (Class[])null);
-            }
-            catch (NoSuchMethodException nsme)
-            {
-               String isMethodName = "is" + 
-                  it.getProperty().substring(0, 1).toUpperCase() + it.getProperty().substring(1);
-               method = injectionObject.getClass().getMethod(isMethodName, (Class[])null);
-            }
-
-            parameterValue = method.invoke(injectionObject, (Object[])null);
-         }
-         else
-         {
-            parameterValue = injectionObject;
-         }
-      }
-      else
-      {
-         if (parameterClass.equals(String.class))
-         {
-            parameterValue = getSubstitutionValue((String)element);
-         }
-         else if (parameterClass.equals(byte.class) || parameterClass.equals(Byte.class))
-         {
-            parameterValue = Byte.valueOf(getSubstitutionValue((String)element));
-         }
-         else if (parameterClass.equals(short.class) || parameterClass.equals(Short.class))
-         {
-            parameterValue = Short.valueOf(getSubstitutionValue((String)element));
-         }
-         else if (parameterClass.equals(int.class) || parameterClass.equals(Integer.class))
-         {
-            parameterValue = Integer.valueOf(getSubstitutionValue((String)element));
-         }
-         else if (parameterClass.equals(long.class) || parameterClass.equals(Long.class))
-         {
-            parameterValue = Long.valueOf(getSubstitutionValue((String)element));
-         }
-         else if (parameterClass.equals(float.class) || parameterClass.equals(Float.class))
-         {
-            parameterValue = Float.valueOf(getSubstitutionValue((String)element));
-         }
-         else if (parameterClass.equals(double.class) || parameterClass.equals(Double.class))
-         {
-            parameterValue = Double.valueOf(getSubstitutionValue((String)element));
-         }
-         else if (parameterClass.equals(boolean.class) || parameterClass.equals(Boolean.class))
-         {
-            parameterValue = Boolean.valueOf(getSubstitutionValue((String)element));
-         }
-         else if (parameterClass.equals(char.class) || parameterClass.equals(Character.class))
-         {
-            parameterValue = Character.valueOf((getSubstitutionValue((String)element)).charAt(0));
-         }
-         else if (parameterClass.equals(InetAddress.class))
-         {
-            parameterValue = InetAddress.getByName(getSubstitutionValue((String)element));
-         }
-      }
-
-      if (parameterValue == null)
-         throw new Exception("No parameter value assigned for class " + parameterClass.getName() + 
-                             " value " + element);
-
-      m.invoke(instance, parameterValue);
-   }
-
-   /**
-    * System property substitution
-    * @param input The input string
-    * @return The output
-    */
-   private static String getSubstitutionValue(String input)
-   {
-      if (input == null || input.trim().equals(""))
-         return input;
-
-      if (input.indexOf("${") != -1)
-      {
-         int from = input.indexOf("${");
-         int to = input.indexOf("}");
-         int dv = input.indexOf(":");
-         
-         String systemProperty = "";
-         String defaultValue = "";
-         if (dv == -1)
-         {
-            systemProperty = SecurityActions.getSystemProperty(input.substring(from + 2, to));
-         }
-         else
-         {
-            systemProperty = SecurityActions.getSystemProperty(input.substring(from + 2, dv));
-            defaultValue = input.substring(dv + 1, to);
-         }
-         String prefix = "";
-         String postfix = "";
-
-         if (from != 0)
-         {
-            prefix = input.substring(0, from);
-         }
-         
-         if (to + 1 < input.length() - 1)
-         {
-            postfix = input.substring(to + 1);
-         }
-
-         if (systemProperty != null && !systemProperty.trim().equals(""))
-         {
-            return prefix + systemProperty + postfix;
-         }
-         else if (defaultValue != null && !defaultValue.trim().equals(""))
-         {
-            return prefix + defaultValue + postfix;
-         }
-      }
-      return input;
-   }
-
-   /**
     * Init logging
     * @param cl The classloader to load from
     */
@@ -940,7 +114,7 @@
 
          logging = mStart.invoke(brs, (Object[])null);
       }
-      catch (Exception e)
+      catch (Throwable t)
       {
          // Nothing we can do
       }
@@ -954,7 +128,7 @@
 
          logging = mGetLogger.invoke((Object)null, new Object[] {"org.jboss.jca.sjc.Main"});
       }
-      catch (Exception e)
+      catch (Throwable t)
       {
          // Nothing we can do
       }
@@ -975,7 +149,7 @@
             Method mError = clz.getMethod("error", Object.class, Throwable.class);
             mError.invoke(logging, new Object[] {s, t});
          }
-         catch (Exception e)
+         catch (Throwable th)
          {
             // Nothing we can do
          }
@@ -1001,7 +175,7 @@
             Method mWarn = clz.getMethod("warn", Object.class);
             mWarn.invoke(logging, new Object[] {s});
          }
-         catch (Exception e)
+         catch (Throwable t)
          {
             // Nothing we can do
          }
@@ -1026,7 +200,7 @@
             Method mInfo = clz.getMethod("info", Object.class);
             mInfo.invoke(logging, new Object[] {s});
          }
-         catch (Exception e)
+         catch (Throwable t)
          {
             // Nothing we can do
          }
@@ -1051,7 +225,7 @@
             Method mIsDebugEnabled = clz.getMethod("isDebugEnabled", (Class[])null);
             return ((Boolean)mIsDebugEnabled.invoke(logging, (Object[])null)).booleanValue();
          }
-         catch (Exception e)
+         catch (Throwable t)
          {
             // Nothing we can do
          }
@@ -1073,7 +247,7 @@
             Method mDebug = clz.getMethod("debug", Object.class);
             mDebug.invoke(logging, new Object[] {s});
          }
-         catch (Exception e)
+         catch (Throwable t)
          {
             // Nothing we can do
          }
@@ -1093,31 +267,10 @@
       long l1 = System.currentTimeMillis();
       try
       {
-         final CountDownLatch latch = new CountDownLatch(1);
+         final ThreadGroup threads = new ThreadGroup("jboss-jca");
 
-         final ThreadGroup threads = new ThreadGroup("jboss");
+         Main.boot(args, threads);
 
-         Runnable worker = new Runnable()
-         {
-            public void run()
-            {
-               try
-               {
-                  Main.boot(args, threads);
-                  latch.countDown();
-               }
-               catch (Exception e)
-               {
-                  error("Failed to boot JBoss JCA", e);
-               }
-            }
-         };
-         
-         Thread bootThread = new Thread(threads, worker, "main");
-         bootThread.start();
-
-         latch.await();
-
          LifeThread lifeThread = new LifeThread(threads);
          lifeThread.start();
 
@@ -1125,19 +278,8 @@
             @Override
             public void run()
             {
-               Main.shutdown();
-
-               if (containerClassLoader != null && containerClassLoader instanceof Closeable)
-               {
-                  try
-                  {
-                     ((Closeable)containerClassLoader).close();
-                  }
-                  catch (IOException ioe)
-                  {
-                     // Swallow
-                  }
-               }
+               if (kernel != null)
+                  kernel.shutdown();
             }
          });
 
@@ -1149,14 +291,7 @@
          }
 
          long l2 = System.currentTimeMillis();
-         if (!parallel)
-         {
-            info("Server started in " + (l2 - l1) + "ms");
-         }
-         else
-         {
-            info("Server (MT mode) started in " + (l2 - l1) + "ms");
-         }
+         info("Server started in " + (l2 - l1) + "ms");
       }
       catch (Exception e)
       {

Deleted: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/DeployException.java
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/DeployException.java	2009-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/DeployException.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -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;
-
-/**
- * The deploy exception for JCA/SJC
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public class DeployException extends Exception
-{
-   /** Serial version UID */
-   static final long serialVersionUID = 3820032266224196804L;
-
-   /**
-    * Constructs a new exception with the specified detail message.
-    * @param message The message
-    */
-   public DeployException(String message)
-   {
-      super(message);
-   }
-
-   /**
-    * Constructs a new exception with the specified detail message and cause.
-    * @param message The message
-    * @param cause The cause
-    */
-   public DeployException(String message, Throwable cause)
-   {
-      super(message, cause);
-   }
-}

Deleted: 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-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/Deployer.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -1,41 +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 deployer interface for JCA/SJC
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public interface Deployer
-{
-   /**
-    * Deploy
-    * @param f The file
-    * @param parent The parent classloader
-    * @return The deployment; or null if no deployment was made
-    * @exception DeployException Thrown if an error occurs during deployment
-    */
-   public Deployment deploy(File f, ClassLoader parent) throws DeployException;
-}

Deleted: 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-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/Deployment.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -1,42 +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;
-
-/**
- * The deployment interface for JCA/SJC
- * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
- */
-public interface Deployment
-{
-   /**
-    * Get the name
-    * @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/package.html
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/package.html	2009-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/package.html	2009-09-05 17:11:23 UTC (rev 93221)
@@ -1,3 +0,0 @@
-<body>
-This package contains the deployer infrastructure for JCA/SJC
-</body>

Modified: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/Annotations.java
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/Annotations.java	2009-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/Annotations.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -22,8 +22,8 @@
 
 package org.jboss.jca.sjc.deployers.ra;
 
+import org.jboss.jca.fungal.deployers.DeployException;
 import org.jboss.jca.sjc.annotationscanner.Annotation;
-import org.jboss.jca.sjc.deployers.DeployException;
 
 import java.lang.reflect.Array;
 import java.util.ArrayList;

Modified: 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/RADeployer.java	2009-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/RADeployer.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -22,14 +22,14 @@
 
 package org.jboss.jca.sjc.deployers.ra;
 
+import org.jboss.jca.fungal.deployers.DeployException;
+import org.jboss.jca.fungal.deployers.Deployer;
+import org.jboss.jca.fungal.deployers.Deployment;
+import org.jboss.jca.fungal.util.FileUtil;
+import org.jboss.jca.fungal.util.Injection;
+import org.jboss.jca.fungal.util.JarFilter;
 import org.jboss.jca.sjc.annotationscanner.Annotation;
 import org.jboss.jca.sjc.annotationscanner.AnnotationScanner;
-import org.jboss.jca.sjc.deployers.DeployException;
-import org.jboss.jca.sjc.deployers.Deployer;
-import org.jboss.jca.sjc.deployers.Deployment;
-import org.jboss.jca.sjc.util.ExtractUtil;
-import org.jboss.jca.sjc.util.Injection;
-import org.jboss.jca.sjc.util.JarFilter;
 
 import java.io.File;
 import java.io.IOException;
@@ -97,27 +97,29 @@
    
    /**
     * Deploy
-    * @param f The file
+    * @param url The url
     * @param parent The parent classloader
     * @return The deployment
     * @exception DeployException Thrown if an error occurs during deployment
     */
-   public Deployment deploy(File f, ClassLoader parent) throws DeployException
+   public Deployment deploy(URL url, ClassLoader parent) throws DeployException
    {
-      if (f == null || !f.getAbsolutePath().endsWith(".rar"))
+      if (url == null || !(url.toExternalForm().endsWith(".rar") || url.toExternalForm().endsWith(".rar/")))
          return null;
 
-      log.info("Deploying: " + f.getAbsolutePath());
+      log.info("Deploying: " + url.toExternalForm());
 
       ClassLoader oldTCCL = SecurityActions.getThreadContextClassLoader();
       try
       {
+         File f = new File(url.toURI());
+
          File root = null;
 
          if (f.isFile())
          {
             File destination = new File(SecurityActions.getSystemProperty("jboss.jca.home"), "/tmp/");
-            root = ExtractUtil.extract(f, destination);
+            root = FileUtil.extract(f, destination);
          }
          else
          {
@@ -275,7 +277,7 @@
       }
       catch (Throwable t)
       {
-         throw new DeployException("Deployment " + f.getName() + " failed", t);
+         throw new DeployException("Deployment " + url.toExternalForm() + " failed", t);
       }
       finally
       {

Modified: 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	2009-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/deployers/ra/RADeployment.java	2009-09-05 17:11:23 UTC (rev 93221)
@@ -22,7 +22,7 @@
 
 package org.jboss.jca.sjc.deployers.ra;
 
-import org.jboss.jca.sjc.deployers.Deployment;
+import org.jboss.jca.fungal.deployers.Deployment;
 
 import java.io.Closeable;
 import java.io.File;

Modified: projects/jboss-jca/trunk/sjc/src/main/resources/boot.xml
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/boot.xml	2009-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/boot.xml	2009-09-05 17:11:23 UTC (rev 93221)
@@ -1,102 +1,7 @@
-<deployment>
+<boot>
 
-  <!-- Naming -->
-  <bean name="LookupPool">
-    <constructor factoryMethod="newFixedThreadPool"
-                 factoryClass="java.util.concurrent.Executors">
-      <parameter>2</parameter>
-    </constructor>
-  </bean>
+  <url>naming.xml</url>
+  <url>transaction.xml</url>
+  <url>jca.xml</url>
 
-  <bean name="NamingBeanImpl" class="org.jnp.server.NamingBeanImpl">
-    <!-- Install this bean as the global JVM NamingServer -->
-    <property name="installGlobalService">true</property>
-    
-    <property name="useGlobalService">false</property>
-  </bean>
-
-  <bean name="NamingServer" class="org.jnp.server.Main">
-    <property name="namingInfo"><inject bean="NamingBeanImpl"/></property>
-
-    <!-- The call by value mode. true if all lookups are unmarshalled using
-         the caller's TCL, false if in VM lookups return the value by reference.
-      -->
-    <property name="callByValue">false</property>
-    
-    <!-- The listening port for the bootstrap JNP service. Set this to -1
-         to run the NamingService without the JNP invoker listening port.
-      -->
-    <property name="port">1099</property>
-    
-    <!-- The bootstrap JNP server bind address. This also sets the default
-         RMI service bind address. Empty == all addresses
-      -->
-    <property name="bindAddress">${jboss.jca.bindaddress:localhost}</property>
-
-    <!-- The port of the RMI naming service, 0 == anonymous -->
-    <property name="rmiPort">0</property>
-
-    <!-- The RMI service bind address. Empty == all addresses -->
-    <property name="rmiBindAddress">${jboss.jca.bindaddress:localhost}</property>
-
-    <!-- Set the java.rmi.server.hostname system property to rmiBindAddress -->
-    <property name="enableRmiServerHostname">true</property>
-
-    <!-- The thread pool service used to control the bootstrap lookups -->
-    <property name="lookupExector"><inject bean="LookupPool"/></property>
-  </bean>
-  
-  <!-- JMX -->
-  <bean name="JMX" class="org.jboss.jca.sjc.hack.JMX"/>
-
-  <!-- Transaction manager -->
-  <bean name="TransactionManager" class="com.arjuna.ats.jbossatx.jta.TransactionManagerService">
-    <property name="transactionTimeout">300</property>
-    <property name="objectStoreDir">${jboss.jca.home}/tmp/tx-object-store</property>
-    <property name="mbeanServer"><inject bean="JMX" property="mbeanServer"/></property>
-    <property name="transactionStatusManagerInetAddress">localhost</property>
-    <property name="transactionStatusManagerPort">4713</property>
-    <property name="recoveryInetAddress">localhost</property>
-    <property name="recoveryPort">4712</property>
-    <property name="socketProcessIdPort">0</property>    
-    <depends>NamingServer</depends>
-  </bean>
-
-  <!-- Work Manager thread pool -->
-  <bean name="WorkManagerThreadPool" interface="org.jboss.jca.common.threadpool.ThreadPool" class="org.jboss.jca.common.threadpool.ThreadPoolImpl">
-    <!-- The name that appears in thread names -->
-    <property name="name">WorkManager</property>
-
-    <!-- The maximum amount of work in the queue -->
-    <property name="maximumQueueSize">1024</property>
-    
-    <!-- The maximum number of active threads -->
-    <property name="maximumPoolSize">100</property>
-    
-    <!-- How long to keep threads alive after their last work (default one minute) -->
-    <property name="keepAliveTime">60000</property>
-  </bean>
-
-  <!-- Work Manager -->
-  <bean name="WorkManager" interface="org.jboss.jca.core.api.WorkManager" class="org.jboss.jca.core.workmanager.WorkManagerImpl">
-    <!-- The thread pool -->
-    <property name="threadPool"><inject bean="WorkManagerThreadPool"/></property>
-
-    <!-- The XA terminator -->
-    <property name="XATerminator"><inject bean="TransactionManager" property="XATerminator"/></property>
-  </bean>
-  
-  <!-- Connection Manager -->
-  <bean name="ConnectionManager" interface="org.jboss.jca.core.api.ConnectionManager" class="org.jboss.jca.core.connectionmanager.ConnectionManagerImpl">
-  </bean>
-
-
-  <!-- Deployers -->
-
-  <!-- RA deployer -->
-  <bean name="RADeployer" interface="org.jboss.jca.sjc.deployers.Deployer" class="org.jboss.jca.sjc.deployers.ra.RADeployer">
-    <depends>ConnectionManager</depends>
-    <depends>WorkManager</depends>
-  </bean>
-
-</deployment>
+</boot>

Deleted: projects/jboss-jca/trunk/sjc/src/main/resources/boot.xsd
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/boot.xsd	2009-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/boot.xsd	2009-09-05 17:11:23 UTC (rev 93221)
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-   Boot XML Schema
--->
-<xsd:schema xmlns:boot="http://www.jboss.org/jca" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
-   <xsd:complexType name="beanType">
-     <xsd:sequence>
-       <xsd:element name="constructor" type="constructorType" maxOccurs="1" minOccurs="0"/>
-       <xsd:element name="property" type="propertyType" maxOccurs="unbounded" minOccurs="0"/>
-       <xsd:element name="depends" type="dependsType" maxOccurs="unbounded" minOccurs="0"/>
-     </xsd:sequence>
-     <xsd:attribute name="name" type="xsd:token" use="required"/>
-     <xsd:attribute name="interface" type="xsd:token"/>
-     <xsd:attribute name="class" type="xsd:token"/>
-   </xsd:complexType>
-
-   <xsd:complexType name="propertyType" mixed="true">
-     <xsd:sequence>
-       <xsd:element name="inject" type="injectType" maxOccurs="1" minOccurs="0"/>
-     </xsd:sequence>
-     <xsd:attribute name="name" type="xsd:token" use="required"/>
-     <xsd:attribute name="class" type="xsd:token"/>
-   </xsd:complexType>
-
-   <xsd:complexType name="injectType">
-     <xsd:simpleContent>
-       <xsd:extension base="xsd:token">
-         <xsd:attribute name="bean" type="xsd:token" use="required"/>
-         <xsd:attribute name="property" type="xsd:token"/>
-       </xsd:extension>
-     </xsd:simpleContent>
-   </xsd:complexType>
-
-   <xsd:complexType name="constructorType">
-     <xsd:sequence>
-       <xsd:element name="parameter" type="parameterType" maxOccurs="unbounded" minOccurs="0"/>
-     </xsd:sequence>
-     <xsd:attribute name="factoryMethod" type="xsd:token" use="required"/>
-     <xsd:attribute name="factoryClass" type="xsd:token" use="required"/>
-   </xsd:complexType>
-
-   <xsd:complexType name="parameterType">
-     <xsd:simpleContent>
-       <xsd:extension base="xsd:token">
-       </xsd:extension>
-     </xsd:simpleContent>
-   </xsd:complexType>
-
-   <xsd:complexType name="dependsType">
-     <xsd:simpleContent>
-       <xsd:extension base="xsd:token">
-       </xsd:extension>
-     </xsd:simpleContent>
-   </xsd:complexType>
-
-   <xsd:element name="deployment">
-     <xsd:complexType>
-       <xsd:sequence>
-         <xsd:element name="bean" type="beanType" maxOccurs="unbounded" minOccurs="0"/>
-       </xsd:sequence>
-     </xsd:complexType>
-   </xsd:element>
-
-</xsd:schema>

Modified: projects/jboss-jca/trunk/sjc/src/main/resources/sjc-manifest.mf
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/resources/sjc-manifest.mf	2009-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/sjc/src/main/resources/sjc-manifest.mf	2009-09-05 17:11:23 UTC (rev 93221)
@@ -1,4 +1,5 @@
 Main-Class: org.jboss.jca.sjc.Main
+Class-Path: jboss-jca-fungal.jar
 Implementation-Title: JBoss JCA SJC
 Implementation-Vendor: Red Hat Middleware LLC
 Implementation-Vendor-Id: org.jboss

Modified: projects/jboss-jca/trunk/tools/findbugs/filter.xml
===================================================================
--- projects/jboss-jca/trunk/tools/findbugs/filter.xml	2009-09-05 01:06:43 UTC (rev 93220)
+++ projects/jboss-jca/trunk/tools/findbugs/filter.xml	2009-09-05 17:11:23 UTC (rev 93221)
@@ -36,14 +36,6 @@
 
   <!--  org.jboss.jca.sjc filter -->
   <Match>
-    <Class name="org.jboss.jca.sjc.Main"/>
-    <Bug code="DE"/>
-  </Match>
-  <Match>
-    <Class name="org.jboss.jca.sjc.Main"/>
-    <Bug code="REC"/>
-  </Match>
-  <Match>
     <Class name="org.jboss.jca.sjc.Main$LifeThread"/>
     <Bug code="UW"/>
   </Match>
@@ -52,10 +44,6 @@
     <Bug code="Wa"/>
   </Match>
   <Match>
-    <Class name="org.jboss.jca.sjc.deployers.ra.ExtractUtil"/>
-    <Bug code="RV"/>
-  </Match>
-  <Match>
     <Class name="org.jboss.jca.sjc.deployers.ra.RADeployer"/>
     <Bug code="DLS"/>
   </Match>




More information about the jboss-cvs-commits mailing list