[jboss-cvs] JBossAS SVN: r99188 - in projects/jboss-jca/trunk: embedded/src/main/java/org/jboss/jca/embedded and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jan 10 08:54:11 EST 2010


Author: jesper.pedersen
Date: 2010-01-10 08:54:11 -0500 (Sun, 10 Jan 2010)
New Revision: 99188

Added:
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/KernelConfiguration.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/KernelFactory.java
Removed:
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelConfiguration.java
Modified:
   projects/jboss-jca/trunk/doc/developerguide/en/modules/fungal.xml
   projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/EmbeddedJCA.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/Main.java
Log:
Use KernelFactory to create kernel instance

Modified: projects/jboss-jca/trunk/doc/developerguide/en/modules/fungal.xml
===================================================================
--- projects/jboss-jca/trunk/doc/developerguide/en/modules/fungal.xml	2010-01-10 12:56:38 UTC (rev 99187)
+++ projects/jboss-jca/trunk/doc/developerguide/en/modules/fungal.xml	2010-01-10 13:54:11 UTC (rev 99188)
@@ -509,15 +509,15 @@
 
       <programlisting>
 import org.jboss.jca.fungal.api.Kernel;
+import org.jboss.jca.fungal.api.KernelConfiguration;
+import org.jboss.jca.fungal.api.KernelFactory;
 import org.jboss.jca.fungal.api.MainDeployer;
-import org.jboss.jca.fungal.impl.KernelConfiguration;
-import org.jboss.jca.fungal.impl.KernelImpl;
 
 // Create a kernel configuration and start the kernel
 KernelConfiguration kernelConfiguration = new KernelConfiguration();
 kernelConfiguration = kernelConfiguration.remoteAccess(false);
 
-Kernel kernel = new KernelImpl(kernelConfiguration);
+Kernel kernel = KernelFactory.create(kernelConfiguration);
 kernel.startup();
 
 // Get the reference to the main deployer

Modified: projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/EmbeddedJCA.java
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/EmbeddedJCA.java	2010-01-10 12:56:38 UTC (rev 99187)
+++ projects/jboss-jca/trunk/embedded/src/main/java/org/jboss/jca/embedded/EmbeddedJCA.java	2010-01-10 13:54:11 UTC (rev 99188)
@@ -22,7 +22,8 @@
 
 package org.jboss.jca.embedded;
 
-import org.jboss.jca.fungal.impl.KernelConfiguration;
+import org.jboss.jca.fungal.api.KernelConfiguration;
+import org.jboss.jca.fungal.api.KernelFactory;
 import org.jboss.jca.fungal.impl.KernelImpl;
 
 import java.io.File;
@@ -82,7 +83,7 @@
       KernelConfiguration kernelConfiguration = new KernelConfiguration();
       kernelConfiguration = kernelConfiguration.remoteAccess(false);
 
-      kernel = new KernelImpl(kernelConfiguration);
+      kernel = (KernelImpl)KernelFactory.create(kernelConfiguration);
       kernel.startup();
 
       if (fullProfile)

Copied: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/KernelConfiguration.java (from rev 99180, 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/api/KernelConfiguration.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/KernelConfiguration.java	2010-01-10 13:54:11 UTC (rev 99188)
@@ -0,0 +1,164 @@
+/*
+ * 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.api;
+
+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;
+
+   /** Remote access */
+   private boolean remoteAccess;
+
+   /** Remote port */
+   private int remotePort;
+
+   /**
+    * Constructor
+    */
+   public KernelConfiguration()
+   {
+      home = null;
+      bindAddress = null;
+      threadGroup = null;
+      remoteAccess = true;
+      remotePort = 1202;
+   }
+
+   /**
+    * 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;
+   }
+
+   /**
+    * Set the remote access
+    * @param v The value
+    * @return The configuration
+    */
+   public KernelConfiguration remoteAccess(boolean v)
+   {
+      this.remoteAccess = v;
+
+      return this;
+   }
+
+   /**
+    * Is remote access enabled ?
+    * @return The value
+    */
+   public boolean isRemoteAccess()
+   {
+      return remoteAccess;
+   }
+
+   /**
+    * Set the port for remote access
+    * @param v The value
+    * @return The configuration
+    */
+   public KernelConfiguration remotePort(int v)
+   {
+      this.remotePort = v;
+
+      return this;
+   }
+
+   /**
+    * Get the remote port
+    * @return The value
+    */
+   public int getRemotePort()
+   {
+      return remotePort;
+   }
+}

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/KernelFactory.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/KernelFactory.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/KernelFactory.java	2010-01-10 13:54:11 UTC (rev 99188)
@@ -0,0 +1,60 @@
+/*
+ * 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.api;
+
+import java.lang.reflect.Constructor;
+
+/**
+ * The kernel factory
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public final class KernelFactory
+{
+   /** Kernel implementation */
+   private static final String KERNEL_IMPL = "org.jboss.jca.fungal.impl.KernelImpl";
+
+   /**
+    * Constructor
+    */
+   private KernelFactory()
+   {
+   }
+
+   /**
+    * Create a kernel instance
+    * @param kc The kernel configuration
+    * @return The kernel
+    * @exception Exception Thrown if an error occurs
+    */
+   @SuppressWarnings("unchecked") 
+   public static synchronized Kernel create(KernelConfiguration kc) throws Exception
+   {
+      if (kc == null)
+         throw new IllegalArgumentException("KernelConfiguration is null");
+
+      Class<?> clz = Class.forName(KERNEL_IMPL);
+      Constructor c = clz.getConstructor(KernelConfiguration.class);
+
+      return (Kernel)c.newInstance(kc);
+   }
+}

Deleted: 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	2010-01-10 12:56:38 UTC (rev 99187)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelConfiguration.java	2010-01-10 13:54:11 UTC (rev 99188)
@@ -1,164 +0,0 @@
-/*
- * 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;
-
-   /** Remote access */
-   private boolean remoteAccess;
-
-   /** Remote port */
-   private int remotePort;
-
-   /**
-    * Constructor
-    */
-   public KernelConfiguration()
-   {
-      home = null;
-      bindAddress = null;
-      threadGroup = null;
-      remoteAccess = true;
-      remotePort = 1202;
-   }
-
-   /**
-    * 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;
-   }
-
-   /**
-    * Set the remote access
-    * @param v The value
-    * @return The configuration
-    */
-   public KernelConfiguration remoteAccess(boolean v)
-   {
-      this.remoteAccess = v;
-
-      return this;
-   }
-
-   /**
-    * Is remote access enabled ?
-    * @return The value
-    */
-   public boolean isRemoteAccess()
-   {
-      return remoteAccess;
-   }
-
-   /**
-    * Set the port for remote access
-    * @param v The value
-    * @return The configuration
-    */
-   public KernelConfiguration remotePort(int v)
-   {
-      this.remotePort = v;
-
-      return this;
-   }
-
-   /**
-    * Get the remote port
-    * @return The value
-    */
-   public int getRemotePort()
-   {
-      return remotePort;
-   }
-}

Modified: 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	2010-01-10 12:56:38 UTC (rev 99187)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java	2010-01-10 13:54:11 UTC (rev 99188)
@@ -23,6 +23,7 @@
 package org.jboss.jca.fungal.impl;
 
 import org.jboss.jca.fungal.api.Kernel;
+import org.jboss.jca.fungal.api.KernelConfiguration;
 import org.jboss.jca.fungal.api.MainDeployer;
 import org.jboss.jca.fungal.deployers.Deployment;
 import org.jboss.jca.fungal.impl.remote.CommunicationServer;

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	2010-01-10 12:56:38 UTC (rev 99187)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/Main.java	2010-01-10 13:54:11 UTC (rev 99188)
@@ -23,8 +23,8 @@
 package org.jboss.jca.sjc;
 
 import org.jboss.jca.fungal.api.Kernel;
-import org.jboss.jca.fungal.impl.KernelConfiguration;
-import org.jboss.jca.fungal.impl.KernelImpl;
+import org.jboss.jca.fungal.api.KernelConfiguration;
+import org.jboss.jca.fungal.api.KernelFactory;
 
 import java.io.File;
 import java.lang.management.ManagementFactory;
@@ -88,7 +88,7 @@
          if (tg != null)
             kernelConfiguration.threadGroup(tg);
 
-         kernel = new KernelImpl(kernelConfiguration);
+         kernel = KernelFactory.create(kernelConfiguration);
          kernel.startup();
 
          initLogging(SecurityActions.getThreadContextClassLoader());




More information about the jboss-cvs-commits mailing list