[jboss-cvs] JBossAS SVN: r95506 - in projects/jboss-jca/trunk: deployers/src/main/java/org/jboss/jca/deployers/fungal and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 23 10:13:54 EDT 2009
Author: jesper.pedersen
Date: 2009-10-23 10:13:54 -0400 (Fri, 23 Oct 2009)
New Revision: 95506
Added:
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/CLI.java
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/Communicator.java
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/package.html
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/Communication.java
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/CommunicationServer.java
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/SecurityActions.java
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/package.html
projects/jboss-jca/trunk/fungal/src/main/resources/fungal-cli-manifest.mf
Modified:
projects/jboss-jca/trunk/build.xml
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java
projects/jboss-jca/trunk/doc/developerguide/en/modules/fungal.xml
projects/jboss-jca/trunk/doc/developerguide/en/modules/issuetracking.xml
projects/jboss-jca/trunk/fungal/build.xml
projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
projects/jboss-jca/trunk/tools/findbugs/filter.xml
Log:
[JBJCA-199] Command line interface
Modified: projects/jboss-jca/trunk/build.xml
===================================================================
--- projects/jboss-jca/trunk/build.xml 2009-10-23 13:22:50 UTC (rev 95505)
+++ projects/jboss-jca/trunk/build.xml 2009-10-23 14:13:54 UTC (rev 95506)
@@ -361,6 +361,7 @@
<class location="${target.dir}/jboss-jca-deployers-rar.jar" />
<class location="${target.dir}/jboss-jca-embedded.jar" />
<class location="${target.dir}/jboss-jca-fungal.jar" />
+ <class location="${target.dir}/jboss-jca-fungal-cli.jar" />
<class location="${target.dir}/jboss-jca-fungal-services.jar" />
<class location="${target.dir}/jboss-jca-sjc.jar" />
<class location="${target.dir}/jboss-jca-standalone.jar" />
@@ -386,6 +387,7 @@
<class location="${target.dir}/jboss-jca-deployers-rar.jar" />
<class location="${target.dir}/jboss-jca-embedded.jar" />
<class location="${target.dir}/jboss-jca-fungal.jar" />
+ <class location="${target.dir}/jboss-jca-fungal-cli.jar" />
<class location="${target.dir}/jboss-jca-fungal-services.jar" />
<class location="${target.dir}/jboss-jca-sjc.jar" />
<class location="${target.dir}/jboss-jca-standalone.jar" />
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java 2009-10-23 13:22:50 UTC (rev 95505)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java 2009-10-23 14:13:54 UTC (rev 95506)
@@ -78,7 +78,7 @@
*/
public void destroy()
{
- log.info("Undeploying: " + adapter.toExternalForm());
+ log.debug("Undeploying: " + adapter.toExternalForm());
if (cl != null && cl instanceof Closeable)
{
@@ -91,5 +91,7 @@
// Swallow
}
}
+
+ log.info("Undeployed: " + adapter.toExternalForm());
}
}
Modified: projects/jboss-jca/trunk/doc/developerguide/en/modules/fungal.xml
===================================================================
--- projects/jboss-jca/trunk/doc/developerguide/en/modules/fungal.xml 2009-10-23 13:22:50 UTC (rev 95505)
+++ projects/jboss-jca/trunk/doc/developerguide/en/modules/fungal.xml 2009-10-23 14:13:54 UTC (rev 95506)
@@ -5,11 +5,38 @@
<section id="fungal_overview">
<title>Overview</title>
- <para>The JBoss JCA/Fungal kernel implements a sub-set of the JBoss Microcontainer functionality
- - basically just enough to boot the required services for a simple container environment.</para>
+ <para>The JBoss JCA/Fungal kernel is a Plain Old Java Object (POJO) based kernel which
+ can build a simple container environment for Java services.</para>
- <para>The JBoss JCA/Fungal kernel features parallel deployments using a simple dependency management
- algorithm, a simple deployment framework and a simple class loading model.</para>
+ <para>The kernel features</para>
+
+ <itemizedlist spacing="compact">
+ <listitem>
+ Bean definition language
+ </listitem>
+ <listitem>
+ Lifecycle of beans
+ </listitem>
+ <listitem>
+ Parallel deployment
+ </listitem>
+ <listitem>
+ Dependency management
+ </listitem>
+ <listitem>
+ Classloader architecture
+ </listitem>
+ <listitem>
+ Deployer framework
+ </listitem>
+ <listitem>
+ Communication protocol
+ </listitem>
+ <listitem>
+ Core services
+ </listitem>
+ </itemizedlist>
+
</section>
<section id="fungal_configuration">
@@ -129,11 +156,11 @@
<itemizedlist>
<listitem>
<para>Inside Fungal</para>
- <para>All logging is handled through reflection calls which are wrapped with methods inside <code>Main</code> itself.</para>
+ <para>All logging is handled through reflection calls</para>
</listitem>
<listitem>
<para>All other services</para>
- <para>Logging is handled by importing <code>org.jboss.logging.Logger</code> and using the class as you would normally do.</para>
+ <para>Logging is handled by importing <code>org.jboss.logging.Logger</code></para>
</listitem>
</itemizedlist>
</section>
@@ -230,6 +257,163 @@
</section>
+ <section id="fungal_remote_protocol">
+ <title>Remote protocol</title>
+
+ <para>JBoss JCA/Fungal features a remote protocol to allow deployment
+ and undeployment of units.</para>
+
+ <para>The protocol is based on the <code>java.io.ObjectInputStream</code> and
+ <code>java.io.ObjectOutputStream</code> format over a standard <code>java.net.Socket</code>
+ connection.</para>
+
+ <para>The kernel must be configured with <code>KernelConfiguration.remoteAccess(true)</code>
+ in order to enable remote access.</para>
+
+ <section id="fungal_remote_protocol_deploy">
+ <title>Deploy</title>
+
+ <para>Deploys a file.</para>
+
+ <table frame="all">
+ <title>Deploy: Input</title>
+ <tgroup cols="4" align="left" colsep="1" rowsep="1">
+ <colspec colname="c1"/>
+ <colspec colname="c2"/>
+ <colspec colname="c3"/>
+ <colspec colname="c4" colwidth="4*"/>
+ <thead>
+ <row>
+ <entry align="left">Order</entry>
+ <entry align="left">Type</entry>
+ <entry align="left">Value</entry>
+ <entry align="left">Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>1</entry>
+ <entry>int</entry>
+ <entry>0x00</entry>
+ <entry>Identification</entry>
+ </row>
+ <row>
+ <entry>2</entry>
+ <entry>UTF</entry>
+ <entry><file url></entry>
+ <entry>Location of the deployment unit</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table frame="all">
+ <title>Deploy: Output</title>
+ <tgroup cols="4" align="left" colsep="1" rowsep="1">
+ <colspec colname="c1"/>
+ <colspec colname="c2"/>
+ <colspec colname="c3"/>
+ <colspec colname="c4" colwidth="4*"/>
+ <thead>
+ <row>
+ <entry align="left">Order</entry>
+ <entry align="left">Type</entry>
+ <entry align="left">Value</entry>
+ <entry align="left">Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>1</entry>
+ <entry>boolean</entry>
+ <entry><boolean></entry>
+ <entry>True if deployment were successful. False if error</entry>
+ </row>
+ <row>
+ <entry>2</entry>
+ <entry>UTF</entry>
+ <entry><message></entry>
+ <entry>Empty string if successful. Otherwise error description</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ </section>
+
+ <section id="fungal_remote_protocol_undeploy">
+ <title>Undeploy</title>
+
+ <para>Undeploys a file.</para>
+
+ <table frame="all">
+ <title>Undeploy: Input</title>
+ <tgroup cols="4" align="left" colsep="1" rowsep="1">
+ <colspec colname="c1"/>
+ <colspec colname="c2"/>
+ <colspec colname="c3"/>
+ <colspec colname="c4" colwidth="4*"/>
+ <thead>
+ <row>
+ <entry align="left">Order</entry>
+ <entry align="left">Type</entry>
+ <entry align="left">Value</entry>
+ <entry align="left">Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>1</entry>
+ <entry>int</entry>
+ <entry>0x01</entry>
+ <entry>Identification</entry>
+ </row>
+ <row>
+ <entry>2</entry>
+ <entry>UTF</entry>
+ <entry><file url></entry>
+ <entry>Location of the deployment unit</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table frame="all">
+ <title>Undeploy: Output</title>
+ <tgroup cols="4" align="left" colsep="1" rowsep="1">
+ <colspec colname="c1"/>
+ <colspec colname="c2"/>
+ <colspec colname="c3"/>
+ <colspec colname="c4" colwidth="4*"/>
+ <thead>
+ <row>
+ <entry align="left">Order</entry>
+ <entry align="left">Type</entry>
+ <entry align="left">Value</entry>
+ <entry align="left">Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>1</entry>
+ <entry>boolean</entry>
+ <entry><boolean></entry>
+ <entry>True if undeployment were successful. False if error</entry>
+ </row>
+ <row>
+ <entry>2</entry>
+ <entry>UTF</entry>
+ <entry><message></entry>
+ <entry>Empty string if successful. Otherwise error description</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ </section>
+
+ </section>
+
<section id="fungal_usage">
<title>Usage</title>
Modified: projects/jboss-jca/trunk/doc/developerguide/en/modules/issuetracking.xml
===================================================================
--- projects/jboss-jca/trunk/doc/developerguide/en/modules/issuetracking.xml 2009-10-23 13:22:50 UTC (rev 95505)
+++ projects/jboss-jca/trunk/doc/developerguide/en/modules/issuetracking.xml 2009-10-23 14:13:54 UTC (rev 95506)
@@ -46,6 +46,10 @@
<entry>The documentation (Users Guide / Developers Guide) for the project.</entry>
</row>
<row>
+ <entry>Fungal</entry>
+ <entry>The JCA/Fungal kernel.</entry>
+ </row>
+ <row>
<entry>JDBC</entry>
<entry>A JDBC resource adapter.</entry>
</row>
Modified: projects/jboss-jca/trunk/fungal/build.xml
===================================================================
--- projects/jboss-jca/trunk/fungal/build.xml 2009-10-23 13:22:50 UTC (rev 95505)
+++ projects/jboss-jca/trunk/fungal/build.xml 2009-10-23 14:13:54 UTC (rev 95506)
@@ -57,11 +57,16 @@
<jar destfile="${target.dir}/jboss-jca-fungal.jar"
manifest="src/main/resources/fungal-manifest.mf"
basedir="${build.fungal.dir}/impl"
- excludes="**/*.java,**/annotationscanner/**,**/util/**"/>
+ excludes="**/*.java,**/cli/**,**/util/**"/>
+ <jar destfile="${target.dir}/jboss-jca-fungal-cli.jar"
+ manifest="src/main/resources/fungal-cli-manifest.mf"
+ basedir="${build.fungal.dir}/impl"
+ includes="**/cli/**"
+ excludes="**/*.java"/>
<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/**"
+ includes="**/util/**"
excludes="**/*.java"/>
</target>
Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/CLI.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/CLI.java (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/CLI.java 2009-10-23 14:13:54 UTC (rev 95506)
@@ -0,0 +1,152 @@
+/*
+ * 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.cli;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.Socket;
+
+/**
+ * The command line interface for the JCA/Fungal kernel
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class CLI
+{
+ /** Deploy */
+ private static final int DEPLOY = 0;
+
+ /** Undeploy */
+ private static final int UNDEPLOY = 1;
+
+ /**
+ * Constructor
+ */
+ private CLI()
+ {
+ }
+
+ /**
+ * Main
+ * @param args The command line arguments
+ */
+ public static void main(String[] args)
+ {
+ if (args.length < 2)
+ {
+ usage();
+ }
+ else
+ {
+ Socket socket = null;
+ try
+ {
+ String host = null;
+ int port = 1202;
+ int counter = 0;
+ int command = -1;
+
+ if ("-h".equals(args[counter]))
+ {
+ counter++;
+ host = args[counter];
+ counter++;
+ }
+
+ if ("-p".equals(args[counter]))
+ {
+ counter++;
+ port = Integer.valueOf(args[counter]).intValue();
+ counter++;
+ }
+
+ if ("deploy".equals(args[counter]))
+ {
+ command = DEPLOY;
+ }
+ else if ("undeploy".equals(args[counter]))
+ {
+ command = UNDEPLOY;
+ }
+ counter++;
+
+ File file = new File(args[counter]);
+
+ if (host == null)
+ host = "localhost";
+
+ socket = new Socket(host, port);
+
+ Communicator communicator = new Communicator();
+
+ if (command == DEPLOY)
+ {
+ communicator.deploy(socket, file.toURI().toURL());
+ }
+ else if (command == UNDEPLOY)
+ {
+ communicator.undeploy(socket, file.toURI().toURL());
+ }
+ else
+ {
+ System.err.println("Unknown command: " + command);
+ }
+ }
+ catch (IOException ioe)
+ {
+ ioe.printStackTrace(System.err);
+ }
+ finally
+ {
+ try
+ {
+ if (socket != null)
+ socket.close();
+ }
+ catch (IOException ignore)
+ {
+ // Ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Usage
+ */
+ private static void usage()
+ {
+ System.out.println("Usage: CLI <common> <command>");
+
+ System.out.println(" Common:");
+ System.out.println(" -------");
+ System.out.println(" -h <host> (default: localhost)");
+ System.out.println(" -p <port> (default: 1202)");
+
+ System.out.println("");
+
+ System.out.println(" Commands:");
+ System.out.println(" ---------");
+ System.out.println(" deploy <file>");
+ System.out.println(" undeploy <file>");
+ }
+}
Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/Communicator.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/Communicator.java (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/Communicator.java 2009-10-23 14:13:54 UTC (rev 95506)
@@ -0,0 +1,91 @@
+/*
+ * 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.cli;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.Socket;
+import java.net.URL;
+
+/**
+ * The client communicator
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Communicator
+{
+ /**
+ * Constructor
+ */
+ public Communicator()
+ {
+ }
+
+ /**
+ * Deploy
+ * @param socket The socket
+ * @param url The file URL
+ * @exception IOException Thrown if a communication error occurs
+ */
+ public void deploy(Socket socket, URL url) throws IOException
+ {
+ ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
+
+ oos.writeInt(0);
+ oos.writeUTF(url.toString());
+
+ oos.flush();
+
+ ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
+
+ boolean result = ois.readBoolean();
+ String message = ois.readUTF();
+
+ if (!result)
+ System.out.println(message);
+ }
+
+ /**
+ * Undeploy
+ * @param socket The socket
+ * @param url The file URL
+ * @exception IOException Thrown if a communication error occurs
+ */
+ public void undeploy(Socket socket, URL url) throws IOException
+ {
+ ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
+
+ oos.writeInt(1);
+ oos.writeUTF(url.toString());
+
+ oos.flush();
+
+ ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
+
+ boolean result = ois.readBoolean();
+ String message = ois.readUTF();
+
+ if (!result)
+ System.out.println(message);
+ }
+}
Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/package.html
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/package.html (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/cli/package.html 2009-10-23 14:13:54 UTC (rev 95506)
@@ -0,0 +1,3 @@
+<body>
+The command line interface for the JBoss JCA/Fungal kernel.
+</body>
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 2009-10-23 13:22:50 UTC (rev 95505)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java 2009-10-23 14:13:54 UTC (rev 95506)
@@ -24,6 +24,7 @@
import org.jboss.jca.fungal.api.Kernel;
import org.jboss.jca.fungal.deployers.Deployment;
+import org.jboss.jca.fungal.impl.remote.CommunicationServer;
import java.io.Closeable;
import java.io.File;
@@ -33,16 +34,15 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
@@ -51,9 +51,6 @@
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
/**
* The kernel implementation for JBoss JCA/Fungal
@@ -91,8 +88,8 @@
/** MBeanServer */
private MBeanServer mbeanServer;
- /** JMXConnectorServer */
- private JMXConnectorServer jmxConnectorServer;
+ /** Communition server */
+ private CommunicationServer remote;
/** Temporary environment */
private boolean temporaryEnvironment;
@@ -267,15 +264,10 @@
// Remote MBeanServer access
if (kernelConfiguration.isRemoteAccess())
{
- Map<String, Object> env = new HashMap<String, Object>();
- env.put("jmx.remote.protocol.provider.class.loader", kernelClassLoader);
-
- JMXServiceURL serviceURL = new JMXServiceURL("rmi",
- kernelConfiguration.getBindAddress(),
- kernelConfiguration.getRemotePort());
-
- jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, env, mbeanServer);
- jmxConnectorServer.start();
+ remote = new CommunicationServer(this,
+ kernelConfiguration.getBindAddress(),
+ kernelConfiguration.getRemotePort());
+ Future<?> f = threadPoolExecutor.submit(remote);
}
}
@@ -287,17 +279,10 @@
{
SecurityActions.setThreadContextClassLoader(kernelClassLoader);
- // Stop the JMX connector
- if (jmxConnectorServer != null)
+ // Stop the remote connector
+ if (remote != null)
{
- try
- {
- jmxConnectorServer.stop();
- }
- catch (IOException ioe)
- {
- // Nothing we can do
- }
+ remote.stop();
}
// Shutdown thread pool
@@ -407,7 +392,7 @@
* Get the kernel class loader
* @return The class loader
*/
- KernelClassLoader getKernelClassLoader()
+ public KernelClassLoader getKernelClassLoader()
{
return kernelClassLoader;
}
@@ -416,7 +401,7 @@
* Get the executor service
* @return The executor service
*/
- ExecutorService getExecutorService()
+ public ExecutorService getExecutorService()
{
return threadPoolExecutor;
}
Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/Communication.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/Communication.java (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/Communication.java 2009-10-23 14:13:54 UTC (rev 95506)
@@ -0,0 +1,282 @@
+/*
+ * 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.remote;
+
+import org.jboss.jca.fungal.impl.MainDeployer;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Method;
+import java.net.Socket;
+import java.net.URL;
+
+/**
+ * The communication between client and server
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Communication implements Runnable
+{
+ /** The socket */
+ private Socket socket;
+
+ /** The main deployer */
+ private MainDeployer mainDeployer;
+
+ /** Logging */
+ private static Object logging;
+
+ /**
+ * Constructor
+ * @param socket The socket
+ * @param mainDeployer The main deployer
+ */
+ public Communication(Socket socket, MainDeployer mainDeployer)
+ {
+ this.socket = socket;
+ this.mainDeployer = mainDeployer;
+
+ if (logging == null)
+ initLogging(SecurityActions.getThreadContextClassLoader());
+ }
+
+ /**
+ * Run
+ */
+ public void run()
+ {
+ try
+ {
+ ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
+
+ int command = ois.readInt();
+
+ if (command == 0)
+ {
+ URL url = new URL(ois.readUTF());
+ mainDeployer.deploy(url);
+ }
+ else if (command == 1)
+ {
+ URL url = new URL(ois.readUTF());
+ mainDeployer.undeploy(url);
+ }
+ else
+ {
+ throw new IOException("Unknown command: " + command);
+ }
+
+ ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
+
+ oos.writeBoolean(true);
+ oos.writeUTF("");
+
+ oos.flush();
+ }
+ catch (Throwable t)
+ {
+ try
+ {
+ StringWriter sw = new StringWriter();
+ sw.write(t.getMessage());
+ sw.write('\n');
+
+ t.printStackTrace(new PrintWriter(sw));
+
+ ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
+
+ oos.writeBoolean(false);
+ oos.writeUTF(sw.toString());
+
+ oos.flush();
+ }
+ catch (IOException ioe)
+ {
+ error(ioe.getMessage(), ioe);
+ }
+ }
+ finally
+ {
+ try
+ {
+ if (socket != null)
+ socket.close();
+ }
+ catch (IOException ignore)
+ {
+ // Ignore
+ }
+ }
+ }
+
+ /**
+ * Init logging
+ */
+ @SuppressWarnings("unchecked")
+ private static void initLogging(ClassLoader cl)
+ {
+ try
+ {
+ Class clz = Class.forName("org.jboss.logging.Logger", true, cl);
+
+ Method mGetLogger = clz.getMethod("getLogger", String.class);
+
+ logging = mGetLogger.invoke((Object)null, new Object[] {"org.jboss.jca.fungal.impl.remote.Communication"});
+ }
+ catch (Throwable t)
+ {
+ // Nothing we can do
+ }
+ }
+
+ /**
+ * Logging: ERROR
+ * @param o The object
+ * @param t The throwable
+ */
+ @SuppressWarnings("unchecked")
+ private static void error(Object o, Throwable t)
+ {
+ if (logging != null)
+ {
+ try
+ {
+ Class clz = logging.getClass();
+ Method mError = clz.getMethod("error", Object.class, Throwable.class);
+ mError.invoke(logging, new Object[] {o, t});
+ }
+ catch (Throwable th)
+ {
+ // Nothing we can do
+ }
+ }
+ else
+ {
+ System.out.println(o.toString());
+ t.printStackTrace(System.out);
+ }
+ }
+
+ /**
+ * Logging: WARN
+ * @param o The object
+ */
+ @SuppressWarnings("unchecked")
+ private static void warn(Object o)
+ {
+ if (logging != null)
+ {
+ try
+ {
+ Class clz = logging.getClass();
+ Method mWarn = clz.getMethod("warn", Object.class);
+ mWarn.invoke(logging, new Object[] {o});
+ }
+ catch (Throwable t)
+ {
+ // Nothing we can do
+ }
+ }
+ else
+ {
+ System.out.println(o.toString());
+ }
+ }
+
+ /**
+ * Logging: INFO
+ * @param o The object
+ */
+ @SuppressWarnings("unchecked")
+ private static void info(Object o)
+ {
+ if (logging != null)
+ {
+ try
+ {
+ Class clz = logging.getClass();
+ Method mInfo = clz.getMethod("info", Object.class);
+ mInfo.invoke(logging, new Object[] {o});
+ }
+ catch (Throwable t)
+ {
+ // Nothing we can do
+ }
+ }
+ else
+ {
+ System.out.println(o.toString());
+ }
+ }
+
+ /**
+ * Logging: Is DEBUG enabled
+ * @return True if debug is enabled; otherwise false
+ */
+ @SuppressWarnings("unchecked")
+ 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 o The object
+ */
+ @SuppressWarnings("unchecked")
+ private static void debug(Object o)
+ {
+ if (logging != null)
+ {
+ try
+ {
+ Class clz = logging.getClass();
+ Method mDebug = clz.getMethod("debug", Object.class);
+ mDebug.invoke(logging, new Object[] {o});
+ }
+ catch (Throwable t)
+ {
+ // Nothing we can do
+ }
+ }
+ else
+ {
+ System.out.println(o.toString());
+ }
+ }
+}
Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/CommunicationServer.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/CommunicationServer.java (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/CommunicationServer.java 2009-10-23 14:13:54 UTC (rev 95506)
@@ -0,0 +1,254 @@
+/*
+ * 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.remote;
+
+import org.jboss.jca.fungal.impl.KernelImpl;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * The communication server
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class CommunicationServer implements Runnable
+{
+ /** The kernel */
+ private KernelImpl kernel;
+
+ private AtomicBoolean running;
+
+ private ServerSocket ss;
+
+ /** Logging */
+ private static Object logging;
+
+ /**
+ * Constructor
+ * @param kernel The kernel
+ * @param bindAddress The bind address
+ * @param bindPort The bind port
+ * @exception IOException Thrown if a server socket can not be created
+ */
+ public CommunicationServer(KernelImpl kernel, String bindAddress, int bindPort) throws IOException
+ {
+ this.kernel = kernel;
+
+ if (bindAddress == null)
+ bindAddress = "localhost";
+
+ InetSocketAddress address = new InetSocketAddress(bindAddress, bindPort);
+
+ this.ss = new ServerSocket();
+ this.ss.bind(address);
+
+ this.running = new AtomicBoolean(true);
+
+ if (logging == null)
+ initLogging(kernel.getKernelClassLoader());
+ }
+
+ /**
+ * Run
+ */
+ public void run()
+ {
+ while (running.get())
+ {
+ try
+ {
+ Socket socket = ss.accept();
+
+ Runnable r = new Communication(socket, kernel.getMainDeployer());
+ Future<?> result = kernel.getExecutorService().submit(r);
+ }
+ catch (IOException ioe)
+ {
+ if (isDebugEnabled())
+ debug(ioe.getMessage());
+ }
+ }
+ }
+
+ /**
+ * Stop
+ */
+ public void stop()
+ {
+ running.set(false);
+ }
+
+ /**
+ * Init logging
+ */
+ @SuppressWarnings("unchecked")
+ private static void initLogging(ClassLoader cl)
+ {
+ try
+ {
+ Class clz = Class.forName("org.jboss.logging.Logger", true, cl);
+
+ Method mGetLogger = clz.getMethod("getLogger", String.class);
+
+ logging = mGetLogger.invoke((Object)null, new Object[] {"org.jboss.jca.fungal.impl.remote.Communication"});
+ }
+ catch (Throwable t)
+ {
+ // Nothing we can do
+ }
+ }
+
+ /**
+ * Logging: ERROR
+ * @param o The object
+ * @param t The throwable
+ */
+ @SuppressWarnings("unchecked")
+ private static void error(Object o, Throwable t)
+ {
+ if (logging != null)
+ {
+ try
+ {
+ Class clz = logging.getClass();
+ Method mError = clz.getMethod("error", Object.class, Throwable.class);
+ mError.invoke(logging, new Object[] {o, t});
+ }
+ catch (Throwable th)
+ {
+ // Nothing we can do
+ }
+ }
+ else
+ {
+ System.out.println(o.toString());
+ t.printStackTrace(System.out);
+ }
+ }
+
+ /**
+ * Logging: WARN
+ * @param o The object
+ */
+ @SuppressWarnings("unchecked")
+ private static void warn(Object o)
+ {
+ if (logging != null)
+ {
+ try
+ {
+ Class clz = logging.getClass();
+ Method mWarn = clz.getMethod("warn", Object.class);
+ mWarn.invoke(logging, new Object[] {o});
+ }
+ catch (Throwable t)
+ {
+ // Nothing we can do
+ }
+ }
+ else
+ {
+ System.out.println(o.toString());
+ }
+ }
+
+ /**
+ * Logging: INFO
+ * @param o The object
+ */
+ @SuppressWarnings("unchecked")
+ private static void info(Object o)
+ {
+ if (logging != null)
+ {
+ try
+ {
+ Class clz = logging.getClass();
+ Method mInfo = clz.getMethod("info", Object.class);
+ mInfo.invoke(logging, new Object[] {o});
+ }
+ catch (Throwable t)
+ {
+ // Nothing we can do
+ }
+ }
+ else
+ {
+ System.out.println(o.toString());
+ }
+ }
+
+ /**
+ * Logging: Is DEBUG enabled
+ * @return True if debug is enabled; otherwise false
+ */
+ @SuppressWarnings("unchecked")
+ 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 o The object
+ */
+ @SuppressWarnings("unchecked")
+ private static void debug(Object o)
+ {
+ if (logging != null)
+ {
+ try
+ {
+ Class clz = logging.getClass();
+ Method mDebug = clz.getMethod("debug", Object.class);
+ mDebug.invoke(logging, new Object[] {o});
+ }
+ catch (Throwable t)
+ {
+ // Nothing we can do
+ }
+ }
+ else
+ {
+ System.out.println(o.toString());
+ }
+ }
+}
Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/SecurityActions.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/SecurityActions.java (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/SecurityActions.java 2009-10-23 14:13:54 UTC (rev 95506)
@@ -0,0 +1,55 @@
+/*
+ * 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.remote;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * 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 AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+}
Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/package.html
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/package.html (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/remote/package.html 2009-10-23 14:13:54 UTC (rev 95506)
@@ -0,0 +1,4 @@
+<body>
+This package contains the classes that implements the remote communication
+protocol for the JBoss JCA/Fungal kernel.
+</body>
Added: projects/jboss-jca/trunk/fungal/src/main/resources/fungal-cli-manifest.mf
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/resources/fungal-cli-manifest.mf (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/resources/fungal-cli-manifest.mf 2009-10-23 14:13:54 UTC (rev 95506)
@@ -0,0 +1,5 @@
+Main-Class: org.jboss.jca.fungal.cli.CLI
+Implementation-Title: JBoss JCA Fungal CLI
+Implementation-Vendor: Red Hat Middleware LLC
+Implementation-Vendor-Id: org.jboss
+Implementation-Version: 0.1
Modified: projects/jboss-jca/trunk/tools/findbugs/filter.xml
===================================================================
--- projects/jboss-jca/trunk/tools/findbugs/filter.xml 2009-10-23 13:22:50 UTC (rev 95505)
+++ projects/jboss-jca/trunk/tools/findbugs/filter.xml 2009-10-23 14:13:54 UTC (rev 95506)
@@ -51,8 +51,16 @@
</Match>
<Match>
<Class name="org.jboss.jca.fungal.impl.KernelImpl"/>
+ <Bug code="DLS,UPM"/>
+ </Match>
+ <Match>
+ <Class name="org.jboss.jca.fungal.impl.remote.Communication"/>
<Bug code="UPM"/>
</Match>
+ <Match>
+ <Class name="org.jboss.jca.fungal.impl.remote.CommunicationServer"/>
+ <Bug code="DLS,UPM"/>
+ </Match>
<!-- org.jboss.jca.sjc filter -->
<Match>
More information about the jboss-cvs-commits
mailing list