[jboss-cvs] JBossAS SVN: r111450 - in projects/jboss-jca/branches/performance: perfenv and 9 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 25 14:38:33 EDT 2011


Author: jesper.pedersen
Date: 2011-05-25 14:38:32 -0400 (Wed, 25 May 2011)
New Revision: 111450

Added:
   projects/jboss-jca/branches/performance/perfenv/
   projects/jboss-jca/branches/performance/perfenv/build.xml
   projects/jboss-jca/branches/performance/perfenv/src/
   projects/jboss-jca/branches/performance/perfenv/src/main/
   projects/jboss-jca/branches/performance/perfenv/src/main/java/
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Activate.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/CLI.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Command.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Communication.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/CommunicationServer.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Deactivate.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Deploy.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/DirectoryFileFilter.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/GetCommand.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/GetProfiles.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Help.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Perf.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Profile.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/SecurityActions.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Shutdown.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Test.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/TestRunner.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Undeploy.java
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/package.html
   projects/jboss-jca/branches/performance/perfenv/src/main/resources/
   projects/jboss-jca/branches/performance/perfenv/src/main/resources/logging.properties
   projects/jboss-jca/branches/performance/perfenv/src/main/resources/perf.sh
Modified:
   projects/jboss-jca/branches/performance/build.xml
   projects/jboss-jca/branches/performance/ivy.settings.xml
   projects/jboss-jca/branches/performance/ivy.xml
Log:
Initial performance environment platform

Modified: projects/jboss-jca/branches/performance/build.xml
===================================================================
--- projects/jboss-jca/branches/performance/build.xml	2011-05-25 18:28:57 UTC (rev 111449)
+++ projects/jboss-jca/branches/performance/build.xml	2011-05-25 18:38:32 UTC (rev 111450)
@@ -88,6 +88,25 @@
     </fileset>
   </path>
 
+  <path id="perfenv.lib.path.id">
+    <fileset dir="${lib.dir}/perfenv">
+      <include name="**/*.jar"/>
+    </fileset>
+    <fileset dir="${target.dir}">
+      <include name="**/*.jar"/>
+    </fileset>
+  </path>
+
+  <path id="checkstyle.lib.path.id">
+    <fileset dir="${tools.dir}/checkstyle/lib"/>
+    <fileset dir="${lib.dir}">
+      <include name="**/*.jar"/>
+    </fileset>
+    <fileset dir="${target.dir}">
+      <include name="**/*.jar"/>
+    </fileset>
+  </path>
+
   <path id="findbugs.lib.path.id">
     <fileset dir="${tools.dir}/findbugs/lib"/>
   </path>
@@ -109,7 +128,6 @@
   <property name="version.fungal" value="0.9.0.Beta3"/>
   <property name="version.jboss.test" value="1.1.9.GA"/>
   <property name="version.jboss.server.manager" value="1.0.3.GA"/>
-  <property name="version.jboss.logging" value="2.2.0.CR1"/>
   <property name="version.log4j" value="1.2.16"/>
   <property name="version.jboss.jnp-client" value="5.0.5.Final"/>
   <property name="version.jboss.serialization" value="1.0.3.GA"/>
@@ -117,7 +135,12 @@
   <property name="version.jboss.servlet-api" value="2.5.0.GA"/>
   <property name="version.jboss.jboss-transaction-api" value="1.0.1.GA"/>
 
+  <!-- Perfenv -->
+  <property name="version.apache-log4j" value="1.2.16"/>
+  <property name="version.jboss.logging" value="3.0.0.Beta5"/>
+  <property name="version.jboss.logmanager" value="1.2.0.CR9"/>
 
+
   <!-- ================================= 
        Bootstrap Ivy
        ================================= -->
@@ -374,4 +397,12 @@
     <ant dir="jmeter" target="jmeter.monitoring"/>
   </target>
 
+  <!-- ================================= 
+       Target: perfenv
+       ================================= -->
+  <target name="perfenv" depends="resolve">
+    <ant dir="perfenv" inheritRefs="true" target="jars"/>
+    <ant dir="perfenv" inheritRefs="true" target="dist"/>
+  </target>
+
 </project>

Modified: projects/jboss-jca/branches/performance/ivy.settings.xml
===================================================================
--- projects/jboss-jca/branches/performance/ivy.settings.xml	2011-05-25 18:28:57 UTC (rev 111449)
+++ projects/jboss-jca/branches/performance/ivy.settings.xml	2011-05-25 18:38:32 UTC (rev 111450)
@@ -20,10 +20,10 @@
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 -->
 <ivysettings>
+  <property name="ivy.checksums" value="" override="true"/>
   <settings defaultResolver="default"/>
   <caches defaultCacheDir="${user.home}/.ivy2/cache"
-          artifactPattern="[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]" 
-          checkUpToDate="true"/>
+          artifactPattern="[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]"/>
   <resolvers>
     <filesystem name="local">
       <ivy pattern="${ivy.cache.dir}/[module]/ivy-[revision].xml"/>

Modified: projects/jboss-jca/branches/performance/ivy.xml
===================================================================
--- projects/jboss-jca/branches/performance/ivy.xml	2011-05-25 18:28:57 UTC (rev 111449)
+++ projects/jboss-jca/branches/performance/ivy.xml	2011-05-25 18:38:32 UTC (rev 111450)
@@ -29,11 +29,12 @@
     <repository name="jboss" url="http://repository.jboss.org"/>
   </info>
 
-  <configurations defaultconfmapping="common->default;sjc->default;jbossas->default;web->default">
+  <configurations defaultconfmapping="common->default;sjc->default;jbossas->default;web->default;perfenv->default">
     <conf name="common" transitive="false"/>
     <conf name="sjc" transitive="false"/>
     <conf name="jbossas" transitive="false"/>
     <conf name="web" transitive="false"/>
+    <conf name="perfenv" transitive="false"/>
   </configurations>
 
   <dependencies>
@@ -46,10 +47,16 @@
     <dependency org="org.jboss.javaee" name="jboss-servlet-api" rev="${version.jboss.servlet-api}" conf="web"/>
     <dependency org="org.jboss.javaee" name="jboss-transaction-api" rev="${version.jboss.jboss-transaction-api}" conf="common"/>
     <dependency org="org.jboss.jbossas" name="jboss-server-manager" rev="${version.jboss.server.manager}" conf="jbossas"/>
-    <dependency org="org.jboss.logging" name="jboss-logging-log4j" rev="${version.jboss.logging}" conf="common"/>
+    <!-- <dependency org="org.jboss.logging" name="jboss-logging-log4j" rev="${version.jboss.logging}" conf="common"/> -->
     <dependency org="org.jboss.remoting" name="jboss-remoting" rev="${version.jboss.remoting}" conf="sjc"/>
     <dependency org="org.jboss.stdio" name="jboss-stdio" rev="${version.jboss.stdio}" conf="common"/>
     <dependency org="org.jboss.test" name="jboss-test" rev="${version.jboss.test}" conf="jbossas"/>
+
+    <!-- Perfenv -->
+    <dependency org="log4j" name="log4j" rev="${version.apache-log4j}" conf="perfenv"/>
+    <dependency org="org.jboss.logging" name="jboss-logging" rev="${version.jboss.logging}" conf="perfenv"/>
+    <dependency org="org.jboss.logmanager" name="jboss-logmanager" rev="${version.jboss.logmanager}" conf="perfenv"/>
+
   </dependencies>
 
 </ivy-module>

Added: projects/jboss-jca/branches/performance/perfenv/build.xml
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/build.xml	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/build.xml	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,131 @@
+<!--
+ * 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="ironjacamar-performance-perfenv" 
+         default="jars" 
+         xmlns:ivy="antlib:org.apache.ivy.ant">
+
+  <!-- ================================= 
+       Properties              
+       ================================= -->
+  <property name="build.perfenv.dir" value="${build.dir}/perfenv" />
+
+  <!-- ================================= 
+       Target: compile
+       ================================= -->
+  <target name="compile">
+    <mkdir dir="${build.perfenv.dir}" />
+    <mkdir dir="${build.perfenv.dir}/impl" />
+
+    <javac srcdir="src/main"
+           destdir="${build.perfenv.dir}/impl"
+           classpathref="perfenv.lib.path.id"
+           debug="${javac.debug}"
+           deprecation="${javac.deprecation}"
+           optimize="${javac.optimize}">
+      <compilerarg value="-Xlint"/>
+    </javac> 
+  </target>
+
+  <!-- ================================= 
+       Target: jars 
+       ================================= -->
+  <target name="jars" depends="compile">
+    <mkdir dir="${build.perfenv.dir}/jars" />
+
+    <copy todir="${build.perfenv.dir}/jars">
+      <fileset dir="src/main/resources" includes="**/*"/>
+    </copy>
+
+    <copy todir="${build.perfenv.dir}/jars">
+      <fileset dir="${build.perfenv.dir}/impl"
+               includes="**"/>
+    </copy>
+
+    <jar destfile="${target.dir}/ironjacamar-performance-perfenv.jar"
+         basedir="${build.perfenv.dir}/jars">
+      <manifest>
+        <attribute name="Implementation-Title" value="IronJacamar Performance (Perfenv)"/>
+        <attribute name="Implementation-Vendor" value="The IronJacamar project (http://www.jboss.org/ironjacamar)"/>
+        <attribute name="Implementation-Vendor-Id" value="org.jboss"/>
+      </manifest>
+    </jar>
+  </target>
+
+  <!-- ================================= 
+       Target: docs
+       ================================= -->
+  <target name="docs" depends="compile">
+    <mkdir dir="${target.dir}/docs/performance"/>
+    <mkdir dir="${target.dir}/docs/performance/perfenv"/>
+    <javadoc packagenames="org.*"
+             sourcepath="src/main/java"
+             destdir="${target.dir}/docs/performance/perfenv"
+             author="true"
+             version="true"
+             windowtitle="IronJacamar Performance Perfenv"
+             doctitle="IronJacamar Performance Perfenv"
+             use="true"
+             additionalparam="-author -version"
+             classpath="${build.perfenv.dir}/impl"
+             classpathref="lib.path.id"
+             bottom="Copyright &#169; 2010 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>
+    <copy todir="${target.dir}/docs/performance/perfenv" overwrite="true">
+      <fileset dir="${tools.dir}/api"/>
+    </copy>
+  </target>
+
+  <!-- ================================= 
+       Target: dist
+       ================================= -->
+  <target name="dist" depends="jars">
+    <mkdir dir="${target.dir}/perfenv" />
+    <mkdir dir="${target.dir}/perfenv/bin" />
+    <mkdir dir="${target.dir}/perfenv/config" />
+    <mkdir dir="${target.dir}/perfenv/deployments" />
+    <mkdir dir="${target.dir}/perfenv/lib" />
+    <mkdir dir="${target.dir}/perfenv/installations" />
+
+    <copy todir="${target.dir}/perfenv/bin">
+      <fileset dir="src/main/resources" includes="**/*.sh"/>
+    </copy>
+
+    <copy todir="${target.dir}/perfenv/config">
+      <fileset dir="src/main/resources" includes="**/*.properties"/>
+    </copy>
+
+    <copy todir="${target.dir}/perfenv/lib">
+      <fileset dir="${target.dir}"
+               includes="ironjacamar-performance-perfenv.jar"/>
+    </copy>
+
+    <copy todir="${target.dir}/perfenv/lib">
+      <fileset dir="${lib.dir}/perfenv"
+               includes="**"/>
+    </copy>
+
+    <chmod dir="${target.dir}/perfenv/bin" perm="ugo+rx" 
+           includes="**/*.sh"/>
+  </target>
+
+</project>

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Activate.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Activate.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Activate.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.util.Arrays;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Represents an activation command
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Activate implements Command
+{
+   /** Command name */
+   private static final String NAME = "activate";
+
+   /** The logger */
+   private static Logger log = Logger.getLogger(Activate.class.getName());
+
+   /**
+    * Activate
+    */
+   public Activate()
+   {
+   }
+
+   /**
+    * Get the name of the command
+    * @return The name
+    */
+   public String getName()
+   {
+      return NAME;
+   }
+
+   /**
+    * Get the parameter types of the command; <code>null</code> if none
+    * @return The types
+    */
+   public Class[] getParameterTypes()
+   {
+      return new Class<?>[] {String.class, Boolean.class};
+   }
+
+   /**
+    * Invoke
+    * @param args The arguments
+    * @return The return value
+    */
+   public Serializable invoke(Serializable[] args)
+   {
+      if (args == null || args.length != 2 || !(args[0] instanceof String) || !(args[1] instanceof Boolean))
+         return new IllegalArgumentException("Unsupported argument list: " + Arrays.toString(args));
+
+      String profileName = (String)args[0];
+      Boolean realTx = (Boolean)args[1];
+
+      if (!Perf.isProfileAvailable(profileName))
+         return Boolean.FALSE;
+
+      try
+      {
+         if (Perf.isActive())
+            Perf.deactivate();
+         
+         Profile profile = new Profile(profileName, realTx.booleanValue());
+         Perf.activate(profile);
+
+         return Boolean.TRUE;
+      }
+      catch (Throwable t)
+      {
+         StringWriter sw = new StringWriter();
+         sw.write(t.getMessage());
+         sw.write('\n');
+
+         t.printStackTrace(new PrintWriter(sw));
+
+         return new Exception(sw.toString());
+      }
+   }
+
+   /**
+    * Is it a public command
+    * @return True if system-wide; false if internal
+    */
+   public boolean isPublic()
+   {
+      return true;
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/CLI.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/CLI.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/CLI.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,332 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.EOFException;
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.net.Socket;
+import java.net.URL;
+import java.util.Arrays;
+
+/**
+ * The command line interface for the performance environment
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class CLI
+{
+   /**
+    * Constructor
+    */
+   private CLI()
+   {
+   }
+
+   /**
+    * Main
+    * @param args The command line arguments
+    */
+   public static void main(String[] args)
+   {
+      if (args.length < 1)
+      {
+         usage();
+      }
+      else
+      {
+         Socket socket = null;
+         try
+         {
+            String host = null;
+            int port = 7000;
+            int counter = 0;
+            String command = "";
+
+            if ("-h".equals(args[counter]))
+            {
+               counter++;
+               host = args[counter];
+               counter++;
+            }
+
+            if ("-p".equals(args[counter]))
+            {
+               counter++;
+               port = Integer.valueOf(args[counter]).intValue();
+               counter++;
+            }
+
+            command = args[counter];
+            counter++;
+
+            if (host == null)
+               host = "localhost";
+
+            socket = new Socket(host, port);
+
+            ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
+            
+            oos.writeUTF("getcommand");
+            oos.writeObject(command);
+            
+            oos.flush();
+            
+            ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
+            
+            Serializable result = (Serializable)ois.readObject();
+
+            if (result == null || result instanceof Class[])
+            {
+               Class[] parameterTypes = (Class[])result;
+               Serializable[] arguments = null;
+               if (parameterTypes != null)
+               {
+                  arguments = new Serializable[parameterTypes.length];
+                  for (int i = 0; i < parameterTypes.length; i++)
+                  {
+                     arguments[i] = getValue(parameterTypes[i], args[counter]);
+                     counter++;
+                  }
+               }
+
+               executeCommand(host, port, command, arguments);
+            }
+            else
+            {
+               System.err.println(result);
+            }
+         }
+         catch (Throwable t)
+         {
+            t.printStackTrace(System.err);
+         }
+         finally
+         {
+            try
+            {
+               if (socket != null)
+                  socket.close();
+            }
+            catch (IOException ignore)
+            {
+               // Ignore
+            }
+         }
+      }
+   }
+
+   /**
+    * Execute command
+    * @param host The host
+    * @param port The port
+    * @param command The command
+    * @param arguments The arguments
+    */
+   private static void executeCommand(String host, int port, String command, Serializable[] arguments)
+      throws Throwable
+   {
+      Socket socket = null;
+
+      try
+      {
+         socket = new Socket(host, port);
+
+         ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
+         
+         oos.writeUTF(command);
+         
+         if (arguments != null)
+         {
+            for (Serializable argument : arguments)
+            {
+               oos.writeObject(argument);
+            }
+         }
+         
+         oos.flush();
+
+         ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
+         
+         Serializable result = (Serializable)ois.readObject();
+
+         if (result != null)
+         {
+            if (result.getClass().isArray())
+            {
+               System.out.println(Arrays.toString((Object[])result));
+            }
+            else
+            {
+               System.out.println(result);
+            }
+         }
+      }
+      catch (EOFException ee)
+      {
+         // Nothing
+      }
+      finally
+      {
+         try
+         {
+            if (socket != null)
+               socket.close();
+         }
+         catch (IOException ignore)
+         {
+            // Ignore
+         }
+      }
+   }
+
+   /**
+    * Get an instance of the type
+    * @param type The type
+    * @param value The string representation
+    */
+   private static Serializable getValue(Class<?> type, String value)
+   {
+      if (value == null)
+         return null;
+
+      if (String.class.equals(type))
+      {
+         return value;
+      }
+      else if (boolean.class.equals(type))
+      {
+         return Boolean.valueOf(value).booleanValue();
+      }
+      else if (Boolean.class.equals(type))
+      {
+         return Boolean.valueOf(value);
+      }
+      else if (byte.class.equals(type))
+      {
+         return Byte.valueOf(value).byteValue();
+      }
+      else if (Byte.class.equals(type))
+      {
+         return Byte.valueOf(value);
+      }
+      else if (char.class.equals(type))
+      {
+         return Character.valueOf(value.charAt(0)).charValue();
+      }
+      else if (Character.class.equals(type))
+      {
+         return Character.valueOf(value.charAt(0));
+      }
+      else if (double.class.equals(type))
+      {
+         return Double.valueOf(value).doubleValue();
+      }
+      else if (Double.class.equals(type))
+      {
+         return Double.valueOf(value);
+      }
+      else if (float.class.equals(type))
+      {
+         return Float.valueOf(value).floatValue();
+      }
+      else if (Float.class.equals(type))
+      {
+         return Float.valueOf(value);
+      }
+      else if (int.class.equals(type))
+      {
+         return Integer.valueOf(value).intValue();
+      }
+      else if (Integer.class.equals(type))
+      {
+         return Integer.valueOf(value);
+      }
+      else if (long.class.equals(type))
+      {
+         return Long.valueOf(value).longValue();
+      }
+      else if (Long.class.equals(type))
+      {
+         return Long.valueOf(value);
+      }
+      else if (short.class.equals(type))
+      {
+         return Short.valueOf(value).shortValue();
+      }
+      else if (Short.class.equals(type))
+      {
+         return Short.valueOf(value);
+      }
+      else if (URL.class.equals(type))
+      {
+         try
+         {
+            URL url = null;
+
+            if (!(value.startsWith("file:") || value.startsWith("http:")))
+            {
+               url = new File(value).toURI().toURL();
+            }
+            else
+            {
+               url = new URL(value);
+            }
+            
+            return url;
+         }
+         catch (Throwable t)
+         {
+            System.err.println(t);
+         }
+
+         return null;
+      }
+      else
+      {
+         System.err.println("Unknown type: " + type.getName() + " Value: " + value);
+      }
+
+      return null;
+   }
+
+   /**
+    * 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: 7000)");
+
+      System.out.println("");
+
+      System.out.println(" Commands:");
+      System.out.println(" ---------");
+      System.out.println(" For a list of commands use \"help\"");
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Command.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Command.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Command.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.Serializable;
+
+/**
+ * Represents a command
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface Command
+{
+   /**
+    * Get the name of the command
+    * @return The name
+    */
+   public String getName();
+
+   /**
+    * Get the parameter types of the command; <code>null</code> if none
+    * @return The types
+    */
+   public Class[] getParameterTypes();
+
+   /**
+    * Invoke
+    * @param args The arguments
+    * @return The return value
+    */
+   public Serializable invoke(Serializable[] args);
+
+   /**
+    * Is it a public command
+    * @return True if system-wide; false if internal
+    */
+   public boolean isPublic();
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Communication.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Communication.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Communication.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.net.Socket;
+
+import org.jboss.logging.Logger;
+
+/**
+ * The communication between client and server
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Communication implements Runnable
+{
+   /** The logger */
+   private Logger log = Logger.getLogger(Communication.class.getName());
+
+   /** The communication server */
+   private CommunicationServer cs;
+
+   /** The socket */
+   private Socket socket;
+
+   /**
+    * Constructor
+    * @param cs The communication server
+    * @param socket The socket
+    */
+   public Communication(CommunicationServer cs, Socket socket)
+   {
+      this.cs = cs;
+      this.socket = socket;
+   }
+
+   /**
+    * Run
+    */
+   public void run()
+   {
+      try
+      {
+         ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
+
+         String commandName = ois.readUTF();
+         Command command = cs.getCommand(commandName);
+         Serializable result = null;
+
+         if (command != null)
+         {
+            Class[] parameterTypes = command.getParameterTypes();
+            Serializable[] arguments = null;
+
+            if (parameterTypes != null)
+            {
+               arguments = new Serializable[parameterTypes.length];
+               for (int i = 0; i < parameterTypes.length; i++)
+               {
+                  arguments[i] = (Serializable)ois.readObject();
+               }
+            }
+
+            result = command.invoke(arguments);
+         }
+         else
+         {
+            result = new IOException("Unknown command: " + commandName);
+         }
+
+         ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
+         oos.writeObject(result);
+         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.writeObject(sw.toString());
+            oos.flush();
+         }
+         catch (IOException ioe)
+         {
+            log.error(ioe.getMessage(), ioe);
+         }
+      }
+      finally
+      {
+         try
+         {
+            if (socket != null)
+               socket.close();
+         }
+         catch (IOException ignore)
+         {
+            // Ignore
+         }
+      }
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/CommunicationServer.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/CommunicationServer.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/CommunicationServer.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,173 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.jboss.logging.Logger;
+
+/**
+ * The communication server
+ * @author <a href="mailto:jesper.pedersen at comcast.net">Jesper Pedersen</a>
+ */
+public class CommunicationServer implements Runnable
+{
+   /** The logger */
+   private Logger log = Logger.getLogger(CommunicationServer.class.getName());
+
+   /** The bind address */
+   private String bindAddress;
+
+   /** The bind port */
+   private int bindPort;
+
+   /** Is the server running ? */
+   private AtomicBoolean running;
+
+   /** The server socket */
+   private ServerSocket ss;
+
+   /** The available commands */
+   private ConcurrentMap<String, Command> commands;
+
+   /**
+    * Constructor
+    * @param bindAddress The bind address
+    * @param bindPort The bind port
+    * @exception IOException Thrown if a server socket can not be created
+    */
+   public CommunicationServer(String bindAddress, int bindPort) throws IOException
+   {
+      if (bindAddress == null)
+         bindAddress = "localhost";
+
+      this.bindAddress = bindAddress;
+      this.bindPort = bindPort;
+      this.running = new AtomicBoolean(false);
+      this.ss = null;
+      this.commands = new ConcurrentHashMap<String, Command>();
+   }
+
+   /**
+    * Register command
+    * @param command The command
+    */
+   public void registerCommand(Command command)
+   {
+      if (command == null)
+         throw new IllegalArgumentException("Command is null");
+
+      if (!commands.containsKey(command.getName()))
+      {
+         commands.put(command.getName(), command);
+      }
+   }
+
+   /**
+    * Get command names
+    * @return The command names
+    */
+   public Set<String> getCommandNames()
+   {
+      return commands.keySet();
+   }
+
+   /**
+    * Get command
+    * @param name The name of the command
+    * @return The command
+    */
+   public Command getCommand(String name)
+   {
+      return commands.get(name);
+   }
+
+   /**
+    * Start
+    * @exception Throwable Thrown if an error occurs
+    */
+   public void start() throws Throwable
+   {
+      if (!running.get())
+      {
+         InetSocketAddress address = new InetSocketAddress(bindAddress, bindPort); 
+
+         ss = new ServerSocket();
+         ss.bind(address);
+
+         running.set(true);
+
+         log.infof("Started on %s:%s", bindAddress, bindPort);
+      }
+   }
+
+   /**
+    * Stop
+    * @exception Throwable Thrown if an error occurs
+    */
+   public void stop() throws Throwable
+   {
+      running.set(false);
+
+      if (ss != null)
+      {
+         log.infof("Stopped on %s:%s", bindAddress, bindPort);
+
+         try
+         {
+            ss.close();
+         }
+         catch (IOException ioe)
+         {
+            log.debug(ioe.getMessage());
+         }
+      }
+   }
+
+   /**
+    * Run
+    */
+   public void run()
+   {
+      while (running.get())
+      {
+         try
+         {
+            Socket socket = ss.accept();
+
+            Runnable r = new Communication(this, socket);
+            Perf.getExecutorService().submit(r);
+         }
+         catch (IOException ioe)
+         {
+            log.debug(ioe.getMessage());
+         }
+      }
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Deactivate.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Deactivate.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Deactivate.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.util.Arrays;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Represents a deactivation command
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Deactivate implements Command
+{
+   /** Command name */
+   private static final String NAME = "deactivate";
+
+   /** The logger */
+   private static Logger log = Logger.getLogger(Deactivate.class.getName());
+
+   /**
+    * Deactivate
+    */
+   public Deactivate()
+   {
+   }
+
+   /**
+    * Get the name of the command
+    * @return The name
+    */
+   public String getName()
+   {
+      return NAME;
+   }
+
+   /**
+    * Get the parameter types of the command; <code>null</code> if none
+    * @return The types
+    */
+   public Class[] getParameterTypes()
+   {
+      return null;
+   }
+
+   /**
+    * Invoke
+    * @param args The arguments
+    * @return The return value
+    */
+   public Serializable invoke(Serializable[] args)
+   {
+      if (args != null && args.length > 0)
+         return new IllegalArgumentException("Unsupported argument list: " + Arrays.toString(args));
+
+      try
+      {
+         if (Perf.isActive())
+         {
+            Perf.deactivate();
+            return Boolean.TRUE;
+         }
+
+         return Boolean.FALSE;
+      }
+      catch (Throwable t)
+      {
+         StringWriter sw = new StringWriter();
+         sw.write(t.getMessage());
+         sw.write('\n');
+
+         t.printStackTrace(new PrintWriter(sw));
+
+         return new Exception(sw.toString());
+      }
+   }
+
+   /**
+    * Is it a public command
+    * @return True if system-wide; false if internal
+    */
+   public boolean isPublic()
+   {
+      return true;
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Deploy.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Deploy.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Deploy.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.util.Arrays;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Represents a deploy command
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Deploy implements Command
+{
+   /** Command name */
+   private static final String NAME = "deploy";
+
+   /** The logger */
+   private static Logger log = Logger.getLogger(Deploy.class.getName());
+
+   /**
+    * Constructor
+    */
+   public Deploy()
+   {
+   }
+
+   /**
+    * Get the name of the command
+    * @return The name
+    */
+   public String getName()
+   {
+      return NAME;
+   }
+
+   /**
+    * Get the parameter types of the command; <code>null</code> if none
+    * @return The types
+    */
+   public Class[] getParameterTypes()
+   {
+      return new Class<?>[] {String.class};
+   }
+
+   /**
+    * Invoke
+    * @param args The arguments
+    * @return The return value
+    */
+   public Serializable invoke(Serializable[] args)
+   {
+      if (args == null || args.length != 1 || !(args[0] instanceof String))
+         return new IllegalArgumentException("Unsupported argument list: " + Arrays.toString(args));
+
+      String deployment = (String)args[0];
+      if (deployment == null || deployment.trim().isEmpty())
+         return Boolean.FALSE;
+
+      try
+      {
+         if (Perf.isActive())
+         {
+            Perf.deploy(deployment);
+            return Boolean.TRUE;
+         }
+      }
+      catch (Throwable t)
+      {
+         StringWriter sw = new StringWriter();
+         sw.write(t.getMessage());
+         sw.write('\n');
+
+         t.printStackTrace(new PrintWriter(sw));
+
+         return new Exception(sw.toString());
+      }
+
+      return Boolean.FALSE;
+   }
+
+   /**
+    * Is it a public command
+    * @return True if system-wide; false if internal
+    */
+   public boolean isPublic()
+   {
+      return true;
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/DirectoryFileFilter.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/DirectoryFileFilter.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/DirectoryFileFilter.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.File;
+import java.io.FileFilter;
+
+/**
+ * Directory filter
+ */
+public class DirectoryFileFilter implements FileFilter
+{
+   /**
+    * Constructor
+    */
+   public DirectoryFileFilter()
+   {
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public boolean accept(File pathname)
+   {
+      return pathname.isDirectory();
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/GetCommand.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/GetCommand.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/GetCommand.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Represents the getcommand command
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class GetCommand implements Command
+{
+   /** Command name */
+   private static final String NAME = "getcommand";
+
+   /** The logger */
+   private Logger log = Logger.getLogger(GetCommand.class.getName());
+
+   /** The communication server */
+   private CommunicationServer cs;
+
+   /**
+    * GetCommand
+    * @param cs The communication server
+    */
+   public GetCommand(CommunicationServer cs)
+   {
+      this.cs = cs;
+   }
+
+   /**
+    * Get the name of the command
+    * @return The name
+    */
+   public String getName()
+   {
+      return NAME;
+   }
+
+   /**
+    * Get the parameter types of the command; <code>null</code> if none
+    * @return The types
+    */
+   public Class[] getParameterTypes()
+   {
+      return new Class<?>[] {String.class};
+   }
+
+   /**
+    * Invoke
+    * @param args The arguments
+    * @return The return value
+    */
+   public Serializable invoke(Serializable[] args)
+   {
+      if (args == null || args.length != 1 || !(args[0] instanceof String))
+         return new IllegalArgumentException("Unsupported argument list: " + Arrays.toString(args));
+
+      String commandName = (String)args[0];
+
+      Command c = cs.getCommand(commandName);
+
+      if (c != null)
+      {
+         return c.getParameterTypes();
+      }
+      else
+      {
+         return new Exception("Unsupported command: " + commandName);
+      }
+   }
+
+   /**
+    * Is it a public command
+    * @return True if system-wide; false if internal
+    */
+   public boolean isPublic()
+   {
+      return false;
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/GetProfiles.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/GetProfiles.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/GetProfiles.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Represents a get profiles command
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class GetProfiles implements Command
+{
+   /** Command name */
+   private static final String NAME = "getprofiles";
+
+   /** The logger */
+   private static Logger log = Logger.getLogger(GetProfiles.class.getName());
+
+   /**
+    * Constructor
+    */
+   public GetProfiles()
+   {
+   }
+
+   /**
+    * Get the name of the command
+    * @return The name
+    */
+   public String getName()
+   {
+      return NAME;
+   }
+
+   /**
+    * Get the parameter types of the command; <code>null</code> if none
+    * @return The types
+    */
+   public Class[] getParameterTypes()
+   {
+      return null;
+   }
+
+   /**
+    * Invoke
+    * @param args The arguments
+    * @return The return value
+    */
+   public Serializable invoke(Serializable[] args)
+   {
+      if (args != null)
+         return new IllegalArgumentException("Unsupported argument list: " + Arrays.toString(args));
+
+      Set<String> profiles = Perf.getAvailableProfiles();
+
+      String[] result = null;
+      if (!profiles.isEmpty())
+      {
+         result = new String[profiles.size()];
+         int i = 0; 
+         for (String p : profiles)
+         {
+            result[i] = p;
+            i++;
+         }
+      }
+      else
+      {
+         result = new String[0];
+      }
+
+      return result;
+   }
+
+   /**
+    * Is it a public command
+    * @return True if system-wide; false if internal
+    */
+   public boolean isPublic()
+   {
+      return true;
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Help.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Help.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Help.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Represents the help command
+ * @author <a href="mailto:jesper.pedersen at comcast.net">Jesper Pedersen</a>
+ */
+public class Help implements Command
+{
+   /** Command name */
+   private static final String NAME = "help";
+
+   /** The logger */
+   private static Logger log = Logger.getLogger(Help.class.getName());
+
+   /** The communication server */
+   private CommunicationServer cs;
+
+   /**
+    * Help
+    * @param cs The communication server
+    */
+   public Help(CommunicationServer cs)
+   {
+      this.cs = cs;
+   }
+
+   /**
+    * Get the name of the command
+    * @return The name
+    */
+   public String getName()
+   {
+      return NAME;
+   }
+
+   /**
+    * Get the parameter types of the command; <code>null</code> if none
+    * @return The types
+    */
+   public Class[] getParameterTypes()
+   {
+      return null;
+   }
+
+   /**
+    * Invoke
+    * @param args The arguments
+    * @return The return value
+    */
+   public Serializable invoke(Serializable[] args)
+   {
+      if (args != null)
+         return new IllegalArgumentException("Unsupported argument list: " + Arrays.toString(args));
+
+      StringBuilder sb = new StringBuilder();
+
+      Set<String> commands = cs.getCommandNames();
+      if (commands != null)
+      {
+         List<String> sortedCommands = new ArrayList<String>(commands);
+         Collections.sort(sortedCommands);
+
+         for (String commandName : sortedCommands)
+         {
+            Command command = cs.getCommand(commandName);
+
+            if (command.isPublic())
+            {
+               sb = sb.append(commandName);
+
+               Class[] parameterTypes = command.getParameterTypes();
+               if (parameterTypes != null)
+               {
+                  sb = sb.append(" ");
+
+                  for (int i = 0; i < parameterTypes.length; i++)
+                  {
+                     Class<?> parameterType = parameterTypes[i];
+                     sb = sb.append("<");
+                     sb = sb.append(parameterType.getName());
+                     sb = sb.append(">");
+
+                     if (i < parameterTypes.length - 1)
+                        sb = sb.append(" ");
+                  }
+               }
+
+               sb = sb.append("\n");
+            }
+         }
+      }
+
+      return sb.toString();
+   }
+
+   /**
+    * Is it a public command
+    * @return True if system-wide; false if internal
+    */
+   public boolean isPublic()
+   {
+      return true;
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Perf.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Perf.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Perf.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,590 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.logging.Logger;
+
+/**
+ * The performance environment
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Perf
+{
+   /** The logger */
+   private static Logger log = Logger.getLogger(Perf.class);
+
+   /** The available installations and their root */
+   private static Map<String, File> installations = new HashMap<String, File>();
+
+   /** The active container name */
+   private static String activeName = null;
+
+   /** The active container */
+   private static Object active = null;
+
+   /** The active transaction manager */
+   private static boolean activeTx = false;
+
+   /** The executor service */
+   private static ThreadPoolExecutor threadPoolExecutor;
+
+   /** The communication server */
+   private static CommunicationServer communicationServer;
+
+   /** Deployments class loader */
+   private static URLClassLoader deploymentsClassLoader;
+
+   /**
+    * Get the installation directories available
+    * @param root The root directory
+    * @return The dictories
+    */
+   private static File[] getInstallations(File root)
+   {
+      return root.listFiles(new DirectoryFileFilter());
+   }
+
+   /**
+    * Find all file entries for a directory
+    * @param file The root directory
+    * @return The list of files
+    */
+   private static List<File> findEntries(File root)
+   {
+      return getListing(root, root);
+   }
+
+   /**
+    * 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
+    */
+   private static List<File> getListing(File root, File directory)
+   {
+      List<File> result = null;
+      File[] filesAndDirs = directory.listFiles();
+
+      if (filesAndDirs != null)
+      {
+         result = new ArrayList<File>(filesAndDirs.length);
+
+         for (File file : filesAndDirs) 
+         {
+            if (file.isDirectory()) 
+            {
+               List<File> deeperList = getListing(root, file);
+               result.addAll(deeperList);
+               result.add(file);
+            }
+            else
+            {
+               result.add(file);
+            }
+         }
+      }
+
+      return result;
+   }
+
+   private static URL[] getURLs(File root)
+   {
+      List<URL> result = new ArrayList<URL>();
+
+      List<File> entries = findEntries(root);
+      if (entries != null)
+      {
+         for (File f : entries)
+         {
+            try
+            {
+               if (f.isDirectory())
+               {
+                  result.add(f.toURI().toURL());
+               }
+               else
+               {
+                  if (f.getName().endsWith(".jar"))
+                  {
+                     result.add(f.toURI().toURL());
+                  }
+               }
+            }
+            catch (MalformedURLException mue)
+            {
+               // Nothing to do
+            }
+         }
+      }
+
+      return result.toArray(new URL[result.size()]);
+   }
+
+   /**
+    * Is the server active
+    * @return True if the server is active
+    */
+   static boolean isActive()
+   {
+      return active != null;
+   }
+
+   /**
+    * Is the specified profile available
+    * @param name The name of the profile
+    * @return True if available
+    */
+   static boolean isProfileAvailable(String name)
+   {
+      if (name == null)
+         return false;
+
+      return installations.containsKey(name);
+   }
+
+   /**
+    * Get the available profiles
+    * @return The profiles
+    */
+   static Set<String> getAvailableProfiles()
+   {
+      return installations.keySet();
+   }
+
+   /**
+    * Get the executor service
+    * @return The handle
+    */
+   static ExecutorService getExecutorService()
+   {
+      return threadPoolExecutor;
+   }
+
+   /**
+    * Activate a profile
+    * @param profile The profile
+    */
+   static void activate(final Profile profile)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            try
+            {
+               URLClassLoader cl = new URLClassLoader(getURLs(installations.get(profile.getName())),
+                                                      deploymentsClassLoader);
+               Thread.currentThread().setContextClassLoader(cl);
+
+               String home = new File(profile.getName()).toURI().toURL().toString();
+               System.setProperty("iron.jacamar.home", home);
+
+               Class<?> embeddedFactory = cl.loadClass("org.jboss.jca.embedded.EmbeddedFactory");
+               Method create = embeddedFactory.getMethod("create", new Class[] {boolean.class});
+
+               Object embedded = create.invoke(null, new Object[] {Boolean.FALSE});
+               Method startup = embedded.getClass().getMethod("startup", (Class[])null);
+               startup.setAccessible(true);
+
+               startup.invoke(embedded, (Object[])null);
+
+               activeName = profile.getName();
+               active = embedded;
+               activeTx = profile.isRealTransactionManager();
+
+               deployProfile(activeTx);
+
+               log.infof("Activated: %s (%s)", activeName, activeTx);
+            }
+            catch (Throwable t)
+            {
+               t.printStackTrace();
+            }
+
+            return null;
+         }
+      });
+   }
+
+   /**
+    * Deploy a profile
+    * @param realTx Should a real transaction manager be used
+    */
+   private static void deployProfile(final boolean realTx)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            try
+            {
+               ClassLoader cl = active.getClass().getClassLoader();
+               Thread.currentThread().setContextClassLoader(cl);
+
+               Method deploy = active.getClass().getMethod("deploy", new Class[] {URL.class});
+               deploy.setAccessible(true);
+
+               URL naming = cl.getResource("naming.xml");
+               deploy.invoke(active, naming);
+
+               URL stdio = cl.getResource("stdio.xml");
+               deploy.invoke(active, stdio);
+
+               if (realTx)
+               {
+                  URL tx = cl.getResource("transaction.xml");
+                  deploy.invoke(active, tx);
+               }
+               else
+               {
+                  URL tx = cl.getResource("noop-transaction.xml");
+                  deploy.invoke(active, tx);
+               }
+
+               URL jca = cl.getResource("jca.xml");
+               deploy.invoke(active, jca);
+
+               URL ds = cl.getResource("ds.xml");
+               deploy.invoke(active, ds);
+            }
+            catch (Throwable t)
+            {
+               t.printStackTrace();
+            }
+
+            return null;
+         }
+      });
+   }
+
+   /**
+    * Undeploy a profile
+    * @param realTx Is the real transaction manager being used
+    */
+   private static void undeployProfile(final boolean realTx)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            try
+            {
+               ClassLoader cl = active.getClass().getClassLoader();
+               Thread.currentThread().setContextClassLoader(cl);
+
+               Method undeploy = active.getClass().getMethod("undeploy", new Class[] {URL.class});
+               undeploy.setAccessible(true);
+
+               URL ds = cl.getResource("ds.xml");
+               undeploy.invoke(active, ds);
+
+               URL jca = cl.getResource("jca.xml");
+               undeploy.invoke(active, jca);
+
+               if (realTx)
+               {
+                  URL tx = cl.getResource("transaction.xml");
+                  undeploy.invoke(active, tx);
+               }
+               else
+               {
+                  URL tx = cl.getResource("noop-transaction.xml");
+                  undeploy.invoke(active, tx);
+               }
+
+               URL stdio = cl.getResource("stdio.xml");
+               undeploy.invoke(active, stdio);
+
+               URL naming = cl.getResource("naming.xml");
+               undeploy.invoke(active, naming);
+            }
+            catch (Throwable t)
+            {
+               t.printStackTrace();
+            }
+
+            return null;
+         }
+      });
+   }
+
+   /**
+    * Deactivate
+    * @return Was the deactivation successful
+    */
+   static boolean deactivate()
+   {
+      if (active == null)
+         return true;
+
+      return AccessController.doPrivileged(new PrivilegedAction<Boolean>() 
+      {
+         public Boolean run()
+         {
+            try
+            {
+               ClassLoader cl = active.getClass().getClassLoader();
+               Thread.currentThread().setContextClassLoader(cl);
+
+               undeployProfile(activeTx);
+
+               Method shutdown = active.getClass().getMethod("shutdown", (Class[])null);
+               shutdown.setAccessible(true);
+
+               shutdown.invoke(active, (Object[])null);
+
+               log.infof("Deactivated: %s (%s)", activeName, activeTx);
+
+               activeName = null;
+               active = null;
+               activeTx = false;
+
+               return Boolean.TRUE;
+            }
+            catch (Throwable t)
+            {
+               t.printStackTrace();
+            }
+            finally
+            {
+               Thread.currentThread().setContextClassLoader(deploymentsClassLoader);
+            }
+
+            return Boolean.FALSE;
+         }
+      });
+   }
+
+   /**
+    * Deploy
+    * @param deployment The deployment name
+    */
+   static void deploy(final String deployment)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            try
+            {
+               ClassLoader cl = active.getClass().getClassLoader();
+               Thread.currentThread().setContextClassLoader(cl);
+
+               Method deploy = active.getClass().getMethod("deploy", new Class[] {URL.class});
+               deploy.setAccessible(true);
+
+               URL url = cl.getResource(deployment);
+               deploy.invoke(active, url);
+            }
+            catch (Throwable t)
+            {
+               t.printStackTrace();
+            }
+
+            return null;
+         }
+      });
+   }
+
+   /**
+    * Undeploy
+    * @param deployment The deployment name
+    */
+   static void undeploy(final String deployment)
+   {
+      AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            try
+            {
+               ClassLoader cl = active.getClass().getClassLoader();
+               Thread.currentThread().setContextClassLoader(cl);
+
+               Method undeploy = active.getClass().getMethod("undeploy", new Class[] {URL.class});
+               undeploy.setAccessible(true);
+
+               URL url = cl.getResource(deployment);
+               undeploy.invoke(active, url);
+            }
+            catch (Throwable t)
+            {
+               t.printStackTrace();
+            }
+
+            return null;
+         }
+      });
+   }
+
+   /**
+    * Main
+    * @param args The arguments
+    */
+   public static void main(String[] args)
+   {
+      long l1 = System.currentTimeMillis();
+      try
+      {
+         File home = new File("..");
+         System.setProperty("perf.home", home.toURI().toURL().toString());
+
+         String hostname = "localhost";
+         int hostport = 7000;
+         Profile profile = null;
+
+         File deploymentsRoot = new File(home, "deployments");
+         File installationsRoot = new File(home, "installations");
+
+         LifeThread lifeThread = new LifeThread();
+         lifeThread.start();
+
+         Runtime.getRuntime().addShutdownHook(new Thread() {
+            @Override
+            public void run()
+            {
+               long l1 = System.currentTimeMillis();
+
+               if (communicationServer != null)
+               {
+                  try
+                  {
+                     communicationServer.stop();
+                  }
+                  catch (Throwable t)
+                  {
+                     log.debug(t.getMessage(), t);
+                  }
+               }
+
+               if (threadPoolExecutor != null)
+                  threadPoolExecutor.shutdown();
+
+               if (active != null)
+                  deactivate();
+
+               long l2 = System.currentTimeMillis();
+               log.info("Server stopped in " + (l2 - l1) + "ms");
+            }
+         });
+
+         BlockingQueue<Runnable> threadPoolQueue = new SynchronousQueue<Runnable>(true);
+         threadPoolExecutor = new ThreadPoolExecutor(0, Integer.MAX_VALUE,
+                                                     60, TimeUnit.SECONDS,
+                                                     threadPoolQueue);
+
+         // Setup deployment class loader
+         deploymentsClassLoader = new URLClassLoader(getURLs(deploymentsRoot), Perf.class.getClassLoader());
+         Thread.currentThread().setContextClassLoader(deploymentsClassLoader);
+
+         // Find installation profiles
+         File[] installationDirectories = getInstallations(installationsRoot);
+         if (installationDirectories != null)
+         {
+            for (File installation : installationDirectories)
+            {
+               log.infof("Adding installation: %s", installation.getName());
+               installations.put(installation.getName(), installation);
+
+               if (profile == null)
+                  profile = new Profile(installation.getName(), false);
+            }
+         }
+
+         // Activate first installation profile found
+         if (profile != null)
+         {
+            activate(profile);
+         }
+
+         // Start communication server
+         communicationServer = new CommunicationServer(hostname, hostport);
+
+         communicationServer.registerCommand(new Activate());
+         communicationServer.registerCommand(new Deactivate());
+         communicationServer.registerCommand(new Shutdown());
+         communicationServer.registerCommand(new Help(communicationServer));
+         communicationServer.registerCommand(new GetCommand(communicationServer));
+         communicationServer.registerCommand(new GetProfiles());
+         communicationServer.registerCommand(new Deploy());
+         communicationServer.registerCommand(new Undeploy());
+         communicationServer.registerCommand(new TestRunner(deploymentsClassLoader));
+
+         communicationServer.start();
+         getExecutorService().submit(communicationServer);
+
+         long l2 = System.currentTimeMillis();
+         log.info("Server started in " + (l2 - l1) + "ms");
+      }
+      catch (Throwable t)
+      {
+         log.error(t.getMessage(), t);
+      }
+   }
+
+   /** 
+    * A simple thread that keeps the vm alive in the event there are no
+    * other non-daemon threads started.
+    */
+   private static class LifeThread extends Thread
+   {
+      private Object lock = new Object();
+
+      LifeThread()
+      {
+         super("JBossLifeThread");
+      }
+
+      public void run()
+      {
+         synchronized (lock)
+         {
+            try
+            {
+               lock.wait();
+            }
+            catch (InterruptedException ignore)
+            {
+               //
+            }
+         }
+      }
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Profile.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Profile.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Profile.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+/**
+ * Represents a profile
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Profile
+{
+   /** The profile name */
+   private String name;
+
+   /** Running with a real transaction manager */
+   private boolean realTx;
+
+   /**
+    * Constructor
+    * @param name The name
+    * @param realTx Should a real transaction manager be used
+    */
+   public Profile(String name, boolean realTx)
+   {
+      this.name = name;
+      this.realTx = realTx;
+   }
+
+   /**
+    * Get the name
+    * @return The name
+    */
+   public String getName()
+   {
+      return name;
+   }
+
+   /**
+    * Is it a real transaction manager
+    * @return True if real; false if noop
+    */
+   public boolean isRealTransactionManager()
+   {
+      return realTx;
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/SecurityActions.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/SecurityActions.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/SecurityActions.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+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()
+   {
+      if (System.getSecurityManager() == null)
+         return Thread.currentThread().getContextClassLoader();
+
+      return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() 
+      {
+         public ClassLoader run()
+         {
+            return Thread.currentThread().getContextClassLoader();
+         }
+      });
+   }
+
+   /**
+    * Set the thread context class loader
+    * @param cl The class loader
+    */
+   static void setThreadContextClassLoader(final ClassLoader cl)
+   {
+      if (System.getSecurityManager() == null)
+         Thread.currentThread().setContextClassLoader(cl);
+
+      AccessController.doPrivileged(new PrivilegedAction<Object>() 
+      {
+         public Object run()
+         {
+            Thread.currentThread().setContextClassLoader(cl);
+            return null;
+         }
+      });
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Shutdown.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Shutdown.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Shutdown.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.Serializable;
+import java.util.Arrays;
+
+/**
+ * Shutdown command
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+class Shutdown implements Command
+{
+   /** Command name */
+   private static final String NAME = "shutdown";
+
+   /**
+    * Constructor
+    */
+   Shutdown()
+   {
+   }
+
+   /**
+    * Get the name of the command
+    * @return The name
+    */
+   public String getName()
+   {
+      return NAME;
+   }
+
+   /**
+    * Get the parameter types of the command; <code>null</code> if none
+    * @return The types
+    */
+   public Class[] getParameterTypes()
+   {
+      return null;
+   }
+
+   /**
+    * Invoke
+    * @param args The arguments
+    * @return The return value
+    */
+   public Serializable invoke(Serializable[] args)
+   {
+      if (args != null)
+         return new IllegalArgumentException("Unsupported argument list: " + Arrays.toString(args));
+
+      System.exit(0);
+
+      return null;
+   }
+
+   /**
+    * Is it a public command
+    * @return True if system-wide; false if internal
+    */
+   public boolean isPublic()
+   {
+      return true;
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Test.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Test.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Test.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.Serializable;
+
+/**
+ * Represents a performance test
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public interface Test
+{
+   /**
+    * Run
+    * @param args The arguments
+    * @return The result of the run
+    */
+   public Serializable run(Serializable[] args);
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/TestRunner.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/TestRunner.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/TestRunner.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.util.Arrays;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Represents a test runner command
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class TestRunner implements Command
+{
+   /** Command name */
+   private static final String NAME = "run";
+
+   /** The logger */
+   private static Logger log = Logger.getLogger(TestRunner.class.getName());
+
+   /** The classloader */
+   private ClassLoader cl;
+
+   /**
+    * Constructor
+    * @param cl The classloader
+    */
+   public TestRunner(ClassLoader cl)
+   {
+      this.cl = cl;
+   }
+
+   /**
+    * Get the name of the command
+    * @return The name
+    */
+   public String getName()
+   {
+      return NAME;
+   }
+
+   /**
+    * Get the parameter types of the command; <code>null</code> if none
+    * @return The types
+    */
+   public Class[] getParameterTypes()
+   {
+      return new Class<?>[] {String.class};
+   }
+
+   /**
+    * Invoke
+    * @param args The arguments
+    * @return The return value
+    */
+   public Serializable invoke(Serializable[] args)
+   {
+      if (args == null || args.length == 0 || !(args[0] instanceof String))
+         return new IllegalArgumentException("Unsupported argument list: " + Arrays.toString(args));
+
+      String testCase = (String)args[0];
+
+      try
+      {
+         Class<?> clz = Class.forName(testCase, true, cl);
+
+         Test test = (Test)clz.newInstance();
+
+         Serializable[] testArgs = null;
+         if (args.length > 1)
+         {
+            testArgs = new Serializable[args.length - 1];
+            for (int i = 1; i < args.length; i++)
+            {
+               testArgs[i - 1] = args[i];
+            }
+         }
+
+         return test.run(testArgs);
+      }
+      catch (Throwable t)
+      {
+         StringWriter sw = new StringWriter();
+         sw.write(t.getMessage());
+         sw.write('\n');
+
+         t.printStackTrace(new PrintWriter(sw));
+
+         return new Exception(sw.toString());
+      }
+   }
+
+   /**
+    * Is it a public command
+    * @return True if system-wide; false if internal
+    */
+   public boolean isPublic()
+   {
+      return true;
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Undeploy.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Undeploy.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Undeploy.java	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,112 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, 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.performance.perfenv;
+
+import java.io.PrintWriter;
+import java.io.Serializable;
+import java.io.StringWriter;
+import java.util.Arrays;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Represents an undeploy command
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Undeploy implements Command
+{
+   /** Command name */
+   private static final String NAME = "undeploy";
+
+   /** The logger */
+   private static Logger log = Logger.getLogger(Undeploy.class.getName());
+
+   /**
+    * Constructor
+    */
+   public Undeploy()
+   {
+   }
+
+   /**
+    * Get the name of the command
+    * @return The name
+    */
+   public String getName()
+   {
+      return NAME;
+   }
+
+   /**
+    * Get the parameter types of the command; <code>null</code> if none
+    * @return The types
+    */
+   public Class[] getParameterTypes()
+   {
+      return new Class<?>[] {String.class};
+   }
+
+   /**
+    * Invoke
+    * @param args The arguments
+    * @return The return value
+    */
+   public Serializable invoke(Serializable[] args)
+   {
+      if (args == null || args.length != 1 || !(args[0] instanceof String))
+         return new IllegalArgumentException("Unsupported argument list: " + Arrays.toString(args));
+
+      String deployment = (String)args[0];
+      if (deployment == null || deployment.trim().isEmpty())
+         return Boolean.FALSE;
+
+      try
+      {
+         if (Perf.isActive())
+         {
+            Perf.undeploy(deployment);
+            return Boolean.TRUE;
+         }
+      }
+      catch (Throwable t)
+      {
+         StringWriter sw = new StringWriter();
+         sw.write(t.getMessage());
+         sw.write('\n');
+
+         t.printStackTrace(new PrintWriter(sw));
+
+         return new Exception(sw.toString());
+      }
+
+      return Boolean.FALSE;
+   }
+
+   /**
+    * Is it a public command
+    * @return True if system-wide; false if internal
+    */
+   public boolean isPublic()
+   {
+      return true;
+   }
+}

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/package.html
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/package.html	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/package.html	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,3 @@
+<body>
+The performance environment.
+</body>

Added: projects/jboss-jca/branches/performance/perfenv/src/main/resources/logging.properties
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/resources/logging.properties	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/resources/logging.properties	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,65 @@
+#
+# JBoss, Home of Professional Open Source.
+# Copyright 2011, 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.
+#
+
+### $Id: $ ###
+
+# Additional logger names to configure (root logger is always configured)
+loggers=org.jboss.jca,org.jboss,org.jnp,com.arjuna,org.eclipse.jetty
+
+# Root logger level
+logger.level=${perf.log.level:INFO}
+logger.handlers=CONSOLE, FILE
+
+# org.jboss.jca
+logger.org.jboss.jca.level=INFO
+
+# org.jboss
+logger.org.jboss.level=INFO
+
+# org.jnp
+logger.org.jnp.level=INFO
+
+# com.arjuna
+logger.com.arjuna.level=WARN
+
+# org.eclipse.jetty
+logger.org.eclipse.jetty.level=WARN
+
+# Console handler configuration
+handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
+handler.CONSOLE.properties=autoFlush
+handler.CONSOLE.level=${perf.log.console.level:INFO}
+handler.CONSOLE.autoFlush=true
+handler.CONSOLE.formatter=PATTERN
+
+# File handler configuration
+handler.FILE=org.jboss.logmanager.handlers.FileHandler
+handler.FILE.level=${perf.log.file.level:DEBUG}
+handler.FILE.properties=autoFlush,fileName
+handler.FILE.autoFlush=true
+handler.FILE.fileName=${perf.home}/log/server.log
+handler.FILE.formatter=PATTERN
+
+# Formatter pattern configuration
+formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
+formatter.PATTERN.properties=pattern
+formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c{1}] %m%n

Added: projects/jboss-jca/branches/performance/perfenv/src/main/resources/perf.sh
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/resources/perf.sh	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/resources/perf.sh	2011-05-25 18:38:32 UTC (rev 111450)
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+PERF_HOME=`pwd`/../
+export PERF_HOME
+
+# Setup the JVM
+if [ "x$JAVA" = "x" ]; then
+    if [ "x$JAVA_HOME" != "x" ]; then
+        JAVA="$JAVA_HOME/bin/java"
+    else
+        JAVA="java"
+    fi
+fi
+
+# Setup the JVM options
+JAVA_OPTS="$JAVA_OPTS -Xmx512m"
+
+# Start Perf
+"$JAVA" $JAVA_OPTS \
+    -Djava.util.logging.manager=org.jboss.logmanager.LogManager \
+    -Dorg.jboss.logging.Logger.pluginClass=org.jboss.logging.logmanager.LoggerPluginImpl \
+    -Dlog4j.defaultInitOverride=true \
+    -Dlogging.configuration=file:$PERF_HOME/config/logging.properties \
+    -classpath $PERF_HOME/lib/ironjacamar-performance-perfenv.jar:$PERF_HOME/lib/jboss-logging.jar:$PERF_HOME/lib/jboss-logmanager.jar:$PERF_HOME/lib/log4j.jar org.jboss.jca.performance.perfenv.Perf "$@"


Property changes on: projects/jboss-jca/branches/performance/perfenv/src/main/resources/perf.sh
___________________________________________________________________
Added: svn:executable
   + *



More information about the jboss-cvs-commits mailing list