servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r700985 - in /servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main: java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ConnectCommand.java resources/META-INF/spring/gshell-admin.xml
Date Thu, 02 Oct 2008 02:00:10 GMT
Author: gnodet
Date: Wed Oct  1 19:00:10 2008
New Revision: 700985

URL: http://svn.apache.org/viewvc?rev=700985&view=rev
Log:
SMX4KNL-107: Create a new 'admin connect' command to easily connect to a named instanceof
servicemix

Added:
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ConnectCommand.java
Modified:
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/spring/gshell-admin.xml

Added: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ConnectCommand.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/ConnectCommand.java?rev=700985&view=auto
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ConnectCommand.java
(added)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/commands/ConnectCommand.java
Wed Oct  1 19:00:10 2008
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.servicemix.kernel.gshell.admin.internal.commands;
+
+import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.apache.geronimo.gshell.command.CommandExecutor;
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.clp.Option;
+import org.osgi.framework.ServiceReference;
+
+@CommandComponent(id="admin:connect", description="Connect to the given instance")
+public class ConnectCommand extends AdminCommandSupport {
+
+    @Argument(index=0, required=true, description="The instance name")
+    private String instance = null;
+
+    @Option(name="-u", aliases={"--username"}, metaVar="USERNAME", description="Remote user
name")
+    private String username = "smx";
+
+    @Option(name="-p", aliases={"--password"}, metaVar="PASSWORD", description="Remote user
password")
+    private String password = "smx";
+
+    protected Object doExecute() throws Exception {
+        int port = getExistingInstance(instance).getPort();
+        ServiceReference ref = getBundleContext().getServiceReference(org.apache.geronimo.gshell.command.CommandExecutor.class.getName());
+        if (ref == null) {
+            io.out.println("CommandExecutor service is unavailable.");
+            return null;
+        }
+        try {
+            CommandExecutor exec = (CommandExecutor) getBundleContext().getService(ref);
+            if (exec == null) {
+                io.out.println("CommandExecutor service is unavailable.");
+                return null;
+            }
+
+            exec.execute("remote rsh -u " + username + " -p " + password + " tcp://localhost:"
+ port);
+        }
+        finally {
+            getBundleContext().ungetService(ref);
+        }
+
+        return SUCCESS;
+    }
+}

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/spring/gshell-admin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/spring/gshell-admin.xml?rev=700985&r1=700984&r2=700985&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/spring/gshell-admin.xml
(original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/spring/gshell-admin.xml
Wed Oct  1 19:00:10 2008
@@ -40,6 +40,10 @@
         <property name="adminService" ref="adminService" />
     </bean>
 
+    <bean id="connect" class="org.apache.servicemix.kernel.gshell.admin.internal.commands.ConnectCommand">
+        <property name="adminService" ref="adminService" />
+    </bean>
+
     <bean id="list" class="org.apache.servicemix.kernel.gshell.admin.internal.commands.ListCommand">
         <property name="adminService" ref="adminService" />
     </bean>
@@ -67,6 +71,13 @@
       </osgi:service-properties>
     </osgi:service>
 
+    <osgi:service ref="connect" interface="org.apache.geronimo.gshell.command.Command">
+      <osgi:service-properties>
+        <entry key="shell" value="admin"/>
+      	<entry key="name" value="connect"/>
+      </osgi:service-properties>
+    </osgi:service>
+
     <osgi:service ref="list" interface="org.apache.geronimo.gshell.command.Command">
       <osgi:service-properties>
         <entry key="shell" value="admin"/>



Mime
View raw message