servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r700987 - in /servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin: ./ internal/ internal/commands/
Date Thu, 02 Oct 2008 02:02:14 GMT
Author: gnodet
Date: Wed Oct  1 19:02:13 2008
New Revision: 700987

URL: http://svn.apache.org/viewvc?rev=700987&view=rev
Log:
SMX4KNL-97: dissociate the name and the location of ServiceMix Kernel instances managed by
the admin shell

Modified:
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminService.java
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminServiceMBean.java
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/Instance.java
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceImpl.java
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceMBeanImpl.java
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/InstanceImpl.java
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/CreateCommand.java
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ListCommand.java
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/StartCommand.java

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminService.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminService.java?rev=700987&r1=700986&r2=700987&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminService.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminService.java
Wed Oct  1 19:02:13 2008
@@ -18,7 +18,7 @@
 
 public interface AdminService {
 
-    Instance createInstance(String name, int port) throws Exception;
+    Instance createInstance(String name, int port, String location) throws Exception;
 
     Instance[] getInstances();
 

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminServiceMBean.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminServiceMBean.java?rev=700987&r1=700986&r2=700987&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminServiceMBean.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/AdminServiceMBean.java
Wed Oct  1 19:02:13 2008
@@ -18,7 +18,7 @@
 
 public interface AdminServiceMBean {
 
-    void createInstance(String name, int port) throws Exception;
+    void createInstance(String name, int port, String location) throws Exception;
 
     String[] getInstances();
 
@@ -28,7 +28,7 @@
 
     boolean isRunning(String name) throws Exception;
 
-    void start(String name) throws Exception;
+    void start(String name, String javaOpts) throws Exception;
 
     void stop(String name) throws Exception;
 

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/Instance.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/Instance.java?rev=700987&r1=700986&r2=700987&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/Instance.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/Instance.java
Wed Oct  1 19:02:13 2008
@@ -20,13 +20,15 @@
 
     String getName();
 
+    String getLocation();
+
     int getPid();
 
     int getPort() throws Exception;
 
     void changePort(int port) throws Exception;
 
-    void start() throws Exception;
+    void start(String javaOpts) throws Exception;
 
     void stop() throws Exception;
 

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceImpl.java?rev=700987&r1=700986&r2=700987&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceImpl.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceImpl.java
Wed Oct  1 19:02:13 2008
@@ -64,9 +64,10 @@
             Map<String, Instance> newInstances = new HashMap<String, Instance>();
             for (int i = 0; i < count; i++) {
                 String name = child.get("item." + i + ".name", null);
+                String loc = child.get("item." + i + ".loc", null);
                 int pid = child.getInt("item." + i + ".pid", 0);
                 if (name != null) {
-                    InstanceImpl instance = new InstanceImpl(this, name);
+                    InstanceImpl instance = new InstanceImpl(this, name, loc);
                     if (pid > 0) {
                         try {
                             instance.attach(pid);
@@ -83,11 +84,11 @@
         }
     }
 
-    public synchronized Instance createInstance(String name, int port) throws Exception {
+    public synchronized Instance createInstance(String name, int port, String location) throws
Exception {
         if (instances.get(name) != null) {
             throw new IllegalArgumentException("Instance '" + name + "' already exists");
         }
-        File serviceMixBase = new File(name).getCanonicalFile();
+        File serviceMixBase = new File(location != null ? location : ("instances/" + name)).getCanonicalFile();
         int remoteShellPort = port;
         if (remoteShellPort <= 0) {
             try {
@@ -134,7 +135,7 @@
             copyFilteredResourceToDir(serviceMixBase, "bin/servicemix", props);
             chmod(new File(serviceMixBase, "bin/servicemix"), "a+x");
         }
-        Instance instance = new InstanceImpl(this, name);
+        Instance instance = new InstanceImpl(this, name, serviceMixBase.toString());
         instances.put(name, instance);
         saveState();
         return instance;
@@ -160,6 +161,7 @@
         child.putInt("count", data.length);
         for (int i = 0; i < data.length; i++) {
             child.put("item." + i + ".name", data[i].getName());
+            child.put("item." + i + ".loc", data[i].getLocation());
             child.putInt("item." + i + ".pid", data[i].getPid());
         }
         prefs.flush();

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceMBeanImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceMBeanImpl.java?rev=700987&r1=700986&r2=700987&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceMBeanImpl.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/AdminServiceMBeanImpl.java
Wed Oct  1 19:02:13 2008
@@ -32,8 +32,8 @@
         this.adminService = adminService;
     }
 
-    public void createInstance(String name, int port) throws Exception {
-        adminService.createInstance(name, port);
+    public void createInstance(String name, int port, String location) throws Exception {
+        adminService.createInstance(name, port, location);
     }
 
     public String[] getInstances() {
@@ -57,8 +57,8 @@
         return getExistingInstance(name).isRunning();
     }
 
-    public void start(String name) throws Exception {
-        getExistingInstance(name).start();
+    public void start(String name, String javaOpts) throws Exception {
+        getExistingInstance(name).start(javaOpts);
     }
 
     public void stop(String name) throws Exception {

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/InstanceImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/InstanceImpl.java?rev=700987&r1=700986&r2=700987&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/InstanceImpl.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/InstanceImpl.java
Wed Oct  1 19:02:13 2008
@@ -41,12 +41,14 @@
 
     private AdminServiceImpl service;
     private String name;
+    private String location;
     private Process process;
     //private PumpStreamHandler handler;
 
-    public InstanceImpl(AdminServiceImpl service, String name) {
+    public InstanceImpl(AdminServiceImpl service, String name, String location) {
         this.service = service;
         this.name = name;
+        this.location = location;
     }
 
     public void attach(int pid) throws IOException {
@@ -61,6 +63,10 @@
         return this.name;
     }
 
+    public String getLocation() {
+        return location;
+    }
+
     public int getPid() {
         checkProcess();
         return this.process != null ? this.process.getPid() : 0;
@@ -69,7 +75,7 @@
     public int getPort() throws Exception {
         InputStream is = null;
         try {
-            File f = new File(name, "etc/org.apache.servicemix.shell.cfg");
+            File f = new File(location, "etc/org.apache.servicemix.shell.cfg");
             is = new FileInputStream(f);
             Properties props = new Properties();
             props.load(is);
@@ -89,7 +95,7 @@
             throw new IllegalStateException("Instance not stopped");
         }
         Properties props = new Properties();
-        File f = new File(name, "etc/org.apache.servicemix.shell.cfg");
+        File f = new File(location, "etc/org.apache.servicemix.shell.cfg");
         InputStream is = new FileInputStream(f);
         try {
             props.load(is);
@@ -107,15 +113,18 @@
         }
     }
 
-    public synchronized void start() throws Exception {
+    public synchronized void start(String javaOpts) throws Exception {
         checkProcess();
         if (this.process != null) {
             throw new IllegalStateException("Instance already started");
         }
+        if (javaOpts == null) {
+            javaOpts = "-server -Xms128M -Xmx512M -Dcom.sun.management.jmxremote";
+        }
         String command = new File(System.getProperty("java.home"), "bin/java" + (ScriptUtils.isWindows()
? ".exe" : "")).getCanonicalPath()
-                + " -server -Xms128M -Xmx512M -Dcom.sun.management.jmxremote"
+                + " " + javaOpts
                 + " -Dservicemix.home=\"" + System.getProperty("servicemix.home") + "\""
-                + " -Dservicemix.base=\"" + new File(name).getCanonicalPath() + "\""
+                + " -Dservicemix.base=\"" + new File(location).getCanonicalPath() + "\""
                 + " -Dservicemix.startLocalConsole=false"
                 + " -Dservicemix.startRemoteShell=true"
                 + " -classpath "
@@ -124,7 +133,7 @@
                 + new File(System.getProperty("servicemix.home"), "lib/servicemix-jaas-boot.jar").getCanonicalPath()
                 + " org.apache.servicemix.kernel.main.Main";
         this.process = ProcessBuilderFactory.newInstance().newBuilder()
-                        .directory(new File(name))
+                        .directory(new File(location))
                         .command(command)
                         .start();
         this.service.saveState();
@@ -143,7 +152,7 @@
         if (this.process != null) {
             throw new IllegalStateException("Instance not stopped");
         }
-        deleteFile(new File(name));
+        deleteFile(new File(location));
         this.service.forget(name);
         this.service.saveState();
     }

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/CreateCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/CreateCommand.java?rev=700987&r1=700986&r2=700987&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/CreateCommand.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/CreateCommand.java
Wed Oct  1 19:02:13 2008
@@ -31,11 +31,14 @@
     @Option(name = "-p", aliases = { "--port"}, description = "Port number for remote shell
connection")
     private int port = 0;
 
-    @Argument(index=0, required=true, description="Where to create the new ServiceMix instance")
+    @Option(name = "-l", aliases = { "--location"}, description = "Location of the new instance
on the file system")
+    private String location;
+
+    @Argument(index=0, required=true, description="Name of the new ServiceMix instance")
     private String instance = null;
 
     protected Object doExecute() throws Exception {
-        getAdminService().createInstance(instance, port);
+        getAdminService().createInstance(instance, port, location);
         return SUCCESS;
     }
 

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ListCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ListCommand.java?rev=700987&r1=700986&r2=700987&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ListCommand.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ListCommand.java
Wed Oct  1 19:02:13 2008
@@ -17,6 +17,7 @@
 package org.apache.servicemix.kernel.gshell.admin.internal.commands;
 
 import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.apache.geronimo.gshell.clp.Option;
 import org.apache.servicemix.kernel.gshell.admin.Instance;
 
 /**
@@ -25,9 +26,16 @@
 @CommandComponent(id="admin:list", description="List existing ServiceMix instances")
 public class ListCommand extends AdminCommandSupport {
 
+    @Option(name = "-l", aliases = { "--location" }, description = "Display instances location")
+    boolean location;
+
     protected Object doExecute() throws Exception {
         Instance[] instances = getAdminService().getInstances();
-        io.out.println("  Port   State       Pid  Name");
+        if (location) {
+            io.out.println("  Port   State       Pid  Location");
+        } else {
+            io.out.println("  Port   State       Pid  Name");
+        }
         for (Instance instance : instances) {
             StringBuilder sb = new StringBuilder();
             sb.append('[');
@@ -45,7 +53,11 @@
             }
             sb.append(s);
             sb.append("] ");
-            sb.append(instance.getName());
+            if (location) {
+                sb.append(instance.getLocation());
+            } else {
+                sb.append(instance.getName());
+            }
             io.out.println(sb.toString());
         }
         return SUCCESS;

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/StartCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/StartCommand.java?rev=700987&r1=700986&r2=700987&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/StartCommand.java
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/StartCommand.java
Wed Oct  1 19:02:13 2008
@@ -18,15 +18,19 @@
 
 import org.apache.geronimo.gshell.command.annotation.CommandComponent;
 import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.clp.Option;
 
 @CommandComponent(id="admin:start", description="Start an instance")
 public class StartCommand extends AdminCommandSupport {
 
+    @Option(name = "-o", aliases = { "--java-opts"}, description = "Java options when launching
the instance")
+    private String javaOpts;
+
     @Argument(index=0, required=true, description="The instance name")
     private String instance = null;
 
     protected Object doExecute() throws Exception {
-        getExistingInstance(instance).start();
+        getExistingInstance(instance).start(javaOpts);
         return SUCCESS;
     }
 }



Mime
View raw message