[jboss-cvs] JBossAS SVN: r111458 - projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 26 10:45:44 EDT 2011


Author: jesper.pedersen
Date: 2011-05-26 10:45:44 -0400 (Thu, 26 May 2011)
New Revision: 111458

Added:
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Reload.java
Modified:
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Perf.java
Log:
Implement reload command

Modified: 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	2011-05-26 13:54:33 UTC (rev 111457)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Perf.java	2011-05-26 14:45:44 UTC (rev 111458)
@@ -50,8 +50,11 @@
    /** The logger */
    private static Logger log = Logger.getLogger(Perf.class);
 
+   /** The home directory */
+   private static File home;
+
    /** The available installations and their root */
-   private static Map<String, File> installations = new HashMap<String, File>();
+   private static Map<String, File> installations;
 
    /** The active container name */
    private static String activeName = null;
@@ -455,6 +458,50 @@
    }
 
    /**
+    * Load setup
+    * @return The first profile found
+    */
+   static Profile load()
+   {
+      try
+      {
+         Profile profile = null;
+         File deploymentsRoot = new File(home, "deployments");
+         File installationsRoot = new File(home, "installations");
+
+         // Setup deployment class loader
+         deploymentsClassLoader = new URLClassLoader(getURLs(deploymentsRoot), Perf.class.getClassLoader());
+         Thread.currentThread().setContextClassLoader(deploymentsClassLoader);
+
+         // Init installations
+         installations = new HashMap<String, File>();
+
+         // 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);
+            }
+         }
+
+         return profile;
+      }
+      catch (Throwable t)
+      {
+         log.error(t.getMessage(), t);
+      }
+
+      return null;
+   }
+
+
+   /**
     * Main
     * @param args The arguments
     */
@@ -463,16 +510,12 @@
       long l1 = System.currentTimeMillis();
       try
       {
-         File home = new 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();
 
@@ -510,24 +553,8 @@
                                                      60, TimeUnit.SECONDS,
                                                      threadPoolQueue);
 
-         // Setup deployment class loader
-         deploymentsClassLoader = new URLClassLoader(getURLs(deploymentsRoot), Perf.class.getClassLoader());
-         Thread.currentThread().setContextClassLoader(deploymentsClassLoader);
+         Profile profile = load();
 
-         // 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)
          {
@@ -546,6 +573,7 @@
          communicationServer.registerCommand(new Deploy());
          communicationServer.registerCommand(new Undeploy());
          communicationServer.registerCommand(new TestRunner(deploymentsClassLoader));
+         communicationServer.registerCommand(new Reload());
 
          communicationServer.start();
          getExecutorService().submit(communicationServer);

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Reload.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Reload.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Reload.java	2011-05-26 14:45:44 UTC (rev 111458)
@@ -0,0 +1,89 @@
+/*
+ * 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 a reload command
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Reload implements Command
+{
+   /** Command name */
+   private static final String NAME = "reload";
+
+   /** The logger */
+   private static Logger log = Logger.getLogger(Reload.class.getName());
+
+   /**
+    * Constructor
+    */
+   public Reload()
+   {
+   }
+
+   /**
+    * 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));
+
+      Perf.load();
+
+      return Boolean.TRUE;
+   }
+
+   /**
+    * Is it a public command
+    * @return True if system-wide; false if internal
+    */
+   public boolean isPublic()
+   {
+      return true;
+   }
+}



More information about the jboss-cvs-commits mailing list