[jboss-cvs] JBossAS SVN: r111734 - 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
Fri Jul 8 12:45:19 EDT 2011


Author: jesper.pedersen
Date: 2011-07-08 12:45:19 -0400 (Fri, 08 Jul 2011)
New Revision: 111734

Added:
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Set.java
Modified:
   projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Perf.java
Log:
Added a system property set 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-07-08 16:12:12 UTC (rev 111733)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Perf.java	2011-07-08 16:45:19 UTC (rev 111734)
@@ -624,6 +624,7 @@
          communicationServer.registerCommand(new Undeploy());
          communicationServer.registerCommand(new TestRunner());
          communicationServer.registerCommand(new Reload());
+         communicationServer.registerCommand(new org.jboss.jca.performance.perfenv.Set());
 
          communicationServer.start();
          getExecutorService().submit(communicationServer);

Added: projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Set.java
===================================================================
--- projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Set.java	                        (rev 0)
+++ projects/jboss-jca/branches/performance/perfenv/src/main/java/org/jboss/jca/performance/perfenv/Set.java	2011-07-08 16:45:19 UTC (rev 111734)
@@ -0,0 +1,107 @@
+/*
+ * 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 set command
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class Set implements Command
+{
+   /** Command name */
+   private static final String NAME = "set";
+
+   /** The logger */
+   private static Logger log = Logger.getLogger(Set.class.getName());
+
+   /**
+    * Constructor
+    */
+   public Set()
+   {
+   }
+
+   /**
+    * 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, String.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 String))
+         return new IllegalArgumentException("Unsupported argument list: " + Arrays.toString(args));
+
+      String property = (String)args[0];
+      String value = (String)args[1];
+
+      try
+      {
+         System.setProperty(property, value);
+
+         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;
+   }
+}



More information about the jboss-cvs-commits mailing list