You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/09/23 13:05:43 UTC
svn commit: r698136 - in /servicemix/smx4/kernel/trunk: assembly/
assembly/src/main/descriptors/ assembly/src/main/filtered-resources/etc/
gshell/ gshell/gshell-admin/ gshell/gshell-admin/src/
gshell/gshell-admin/src/main/ gshell/gshell-admin/src/main/...
Author: gnodet
Date: Tue Sep 23 04:05:41 2008
New Revision: 698136
URL: http://svn.apache.org/viewvc?rev=698136&view=rev
Log:
SMX4KNL-62, SMX4KNL-93: extract the admin commands in their own module, enhance the create command to use a different port each time
Added:
servicemix/smx4/kernel/trunk/gshell/gshell-admin/ (with props)
servicemix/smx4/kernel/trunk/gshell/gshell-admin/pom.xml
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/org/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/org/apache/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/org/apache/servicemix/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/org/apache/servicemix/kernel/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/org/apache/servicemix/kernel/gshell/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/org/apache/servicemix/kernel/gshell/admin/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/org/apache/servicemix/kernel/gshell/admin/etc/
- copied from r697778, servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/filtered-resources/org/apache/geronimo/gshell/spring/etc/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/CreateCommand.java
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/spring/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/spring/gshell-admin.xml
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/apache/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/apache/servicemix/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/apache/servicemix/kernel/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/apache/servicemix/kernel/gshell/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/apache/servicemix/kernel/gshell/admin/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/apache/servicemix/kernel/gshell/admin/bin/
- copied from r697778, servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/spring/bin/
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/apache/servicemix/kernel/gshell/admin/etc/
- copied from r697778, servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/spring/etc/
Removed:
servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/filtered-resources/org/apache/geronimo/gshell/spring/etc/
servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/CreateCommand.java
servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/spring/bin/
servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/spring/etc/
Modified:
servicemix/smx4/kernel/trunk/assembly/pom.xml
servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/unix-bin.xml
servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/windows-bin.xml
servicemix/smx4/kernel/trunk/assembly/src/main/filtered-resources/etc/startup.properties
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/org/apache/servicemix/kernel/gshell/admin/etc/startup.properties
servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/apache/servicemix/kernel/gshell/admin/etc/org.apache.servicemix.shell.cfg
servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-commands.xml
servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml
servicemix/smx4/kernel/trunk/gshell/pom.xml
Modified: servicemix/smx4/kernel/trunk/assembly/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/assembly/pom.xml?rev=698136&r1=698135&r2=698136&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/assembly/pom.xml (original)
+++ servicemix/smx4/kernel/trunk/assembly/pom.xml Tue Sep 23 04:05:41 2008
@@ -105,6 +105,11 @@
</dependency>
<dependency>
<groupId>org.apache.servicemix.kernel.gshell</groupId>
+ <artifactId>org.apache.servicemix.kernel.gshell.admin</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.kernel.gshell</groupId>
<artifactId>org.apache.servicemix.kernel.gshell.obr</artifactId>
<version>${pom.version}</version>
</dependency>
Modified: servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/unix-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/unix-bin.xml?rev=698136&r1=698135&r2=698136&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/unix-bin.xml (original)
+++ servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/unix-bin.xml Tue Sep 23 04:05:41 2008
@@ -188,6 +188,7 @@
<outputFileNameMapping>org/apache/servicemix/kernel/gshell/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
<include>org.apache.servicemix.kernel.gshell:org.apache.servicemix.kernel.gshell.core</include>
+ <include>org.apache.servicemix.kernel.gshell:org.apache.servicemix.kernel.gshell.admin</include>
<include>org.apache.servicemix.kernel.gshell:org.apache.servicemix.kernel.gshell.osgi</include>
<include>org.apache.servicemix.kernel.gshell:org.apache.servicemix.kernel.gshell.log</include>
<include>org.apache.servicemix.kernel.gshell:org.apache.servicemix.kernel.gshell.obr</include>
Modified: servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/windows-bin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/windows-bin.xml?rev=698136&r1=698135&r2=698136&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/windows-bin.xml (original)
+++ servicemix/smx4/kernel/trunk/assembly/src/main/descriptors/windows-bin.xml Tue Sep 23 04:05:41 2008
@@ -180,6 +180,7 @@
<outputFileNameMapping>org/apache/servicemix/kernel/gshell/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
<include>org.apache.servicemix.kernel.gshell:org.apache.servicemix.kernel.gshell.core</include>
+ <include>org.apache.servicemix.kernel.gshell:org.apache.servicemix.kernel.gshell.admin</include>
<include>org.apache.servicemix.kernel.gshell:org.apache.servicemix.kernel.gshell.osgi</include>
<include>org.apache.servicemix.kernel.gshell:org.apache.servicemix.kernel.gshell.log</include>
<include>org.apache.servicemix.kernel.gshell:org.apache.servicemix.kernel.gshell.obr</include>
Modified: servicemix/smx4/kernel/trunk/assembly/src/main/filtered-resources/etc/startup.properties
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/assembly/src/main/filtered-resources/etc/startup.properties?rev=698136&r1=698135&r2=698136&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/assembly/src/main/filtered-resources/etc/startup.properties (original)
+++ servicemix/smx4/kernel/trunk/assembly/src/main/filtered-resources/etc/startup.properties Tue Sep 23 04:05:41 2008
@@ -48,6 +48,7 @@
org/springframework/osgi/spring-osgi-io/${spring.osgi.version}/spring-osgi-io-${spring.osgi.version}.jar=50
org/apache/servicemix/kernel/org.apache.servicemix.kernel.spring/${pom.version}/org.apache.servicemix.kernel.spring-${pom.version}.jar=50
org/apache/felix/org.apache.felix.bundlerepository/${felix.bundlerepository.version}/org.apache.felix.bundlerepository-${felix.bundlerepository.version}.jar=50
+org/apache/servicemix/kernel/gshell/org.apache.servicemix.kernel.gshell.admin/${pom.version}/org.apache.servicemix.kernel.gshell.admin-${pom.version}.jar=50
org/apache/servicemix/kernel/gshell/org.apache.servicemix.kernel.gshell.obr/${pom.version}/org.apache.servicemix.kernel.gshell.obr-${pom.version}.jar=50
org/apache/servicemix/kernel/gshell/org.apache.servicemix.kernel.gshell.osgi/${pom.version}/org.apache.servicemix.kernel.gshell.osgi-${pom.version}.jar=50
org/apache/servicemix/kernel/gshell/org.apache.servicemix.kernel.gshell.features/${pom.version}/org.apache.servicemix.kernel.gshell.features-${pom.version}.jar=50
Propchange: servicemix/smx4/kernel/trunk/gshell/gshell-admin/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Sep 23 04:05:41 2008
@@ -0,0 +1,8 @@
+target
+*.iml
+*.ipr
+*.iws
+.classpath
+.project
+.settings
+eclipse-classes
Added: servicemix/smx4/kernel/trunk/gshell/gshell-admin/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/pom.xml?rev=698136&view=auto
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/pom.xml (added)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/pom.xml Tue Sep 23 04:05:41 2008
@@ -0,0 +1,118 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.servicemix.kernel.gshell</groupId>
+ <artifactId>gshell</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.servicemix.kernel.gshell</groupId>
+ <artifactId>org.apache.servicemix.kernel.gshell.admin</artifactId>
+ <packaging>bundle</packaging>
+ <version>1.1.0-SNAPSHOT</version>
+ <name>Apache ServiceMix Kernel :: GShell Admin</name>
+
+ <description>
+ Provides administration commands
+ </description>
+
+ <properties>
+ <gshell.osgi.import>
+ org.apache.servicemix.kernel.main.spi.*;resolution:=optional,
+ org.apache.geronimo.gshell*,
+ </gshell.osgi.import>
+ <gshell.osgi.export>
+ </gshell.osgi.export>
+ <gshell.osgi.private>
+ org.apache.servicemix.kernel.gshell.admin.*,
+ </gshell.osgi.private>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicemix.kernel.gshell</groupId>
+ <artifactId>org.apache.servicemix.kernel.gshell.core</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${felix.osgi.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>${felix.compendium.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-osgi-core</artifactId>
+ <version>${spring.osgi.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${pom.basedir}/src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>${pom.basedir}/src/main/filtered-resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <configuration>
+ <mainClass>Main</mainClass>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
+ <Export-Package>org.apache.servicemix.kernel.gshell.admin.*;version=${project.version}</Export-Package>
+ <Import-Package>*</Import-Package>
+ <Private-Package>!*</Private-Package>
+ <Spring-Context>*;publish-context:=false;create-asynchronously:=false</Spring-Context>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/org/apache/servicemix/kernel/gshell/admin/etc/startup.properties
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/org/apache/servicemix/kernel/gshell/admin/etc/startup.properties?rev=698136&r1=697778&r2=698136&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/org/apache/servicemix/kernel/gshell/admin/etc/startup.properties (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/filtered-resources/org/apache/servicemix/kernel/gshell/admin/etc/startup.properties Tue Sep 23 04:05:41 2008
@@ -48,6 +48,7 @@
org/springframework/osgi/spring-osgi-io/${spring.osgi.version}/spring-osgi-io-${spring.osgi.version}.jar=50
org/apache/servicemix/kernel/org.apache.servicemix.kernel.spring/${pom.version}/org.apache.servicemix.kernel.spring-${pom.version}.jar=50
org/apache/felix/org.apache.felix.bundlerepository/${felix.bundlerepository.version}/org.apache.felix.bundlerepository-${felix.bundlerepository.version}.jar=50
+org/apache/servicemix/kernel/gshell/org.apache.servicemix.kernel.gshell.admin/${pom.version}/org.apache.servicemix.kernel.gshell.admin-${pom.version}.jar=50
org/apache/servicemix/kernel/gshell/org.apache.servicemix.kernel.gshell.obr/${pom.version}/org.apache.servicemix.kernel.gshell.obr-${pom.version}.jar=50
org/apache/servicemix/kernel/gshell/org.apache.servicemix.kernel.gshell.osgi/${pom.version}/org.apache.servicemix.kernel.gshell.osgi-${pom.version}.jar=50
org/apache/servicemix/kernel/gshell/org.apache.servicemix.kernel.gshell.features/${pom.version}/org.apache.servicemix.kernel.gshell.features-${pom.version}.jar=50
Added: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/CreateCommand.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/CreateCommand.java?rev=698136&view=auto
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/CreateCommand.java (added)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/CreateCommand.java Tue Sep 23 04:05:41 2008
@@ -0,0 +1,238 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Scanner;
+import java.net.ServerSocket;
+
+import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.clp.Option;
+import org.apache.geronimo.gshell.command.annotation.CommandComponent;
+import org.apache.geronimo.gshell.support.OsgiCommandSupport;
+import org.osgi.service.prefs.PreferencesService;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * Creates a new servicemix instance
+ *
+ * @version $Rev: 679826 $ $Date: 2008-07-25 17:00:12 +0200 (Fri, 25 Jul 2008) $
+ */
+@CommandComponent(id="smx:create", description="Create a new ServiceMix instance")
+public class CreateCommand
+ extends OsgiCommandSupport
+{
+ @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")
+ private String instance = null;
+
+ private PreferencesService preferences;
+
+ private int defaultPortStart = 8101;
+
+ public PreferencesService getPreferences() {
+ return preferences;
+ }
+
+ public void setPreferences(PreferencesService preferences) {
+ this.preferences = preferences;
+ }
+
+ protected OsgiCommandSupport createCommand() throws Exception {
+ CreateCommand command = new CreateCommand();
+ command.setPreferences(getPreferences());
+ return command;
+ }
+
+ protected Object doExecute() throws Exception {
+ File serviceMixBase = new File(instance).getCanonicalFile();
+ int remoteShellPort = port;
+ if (remoteShellPort <= 0) {
+ try {
+ Preferences prefs = preferences.getUserPreferences("CreateCommandState");
+ remoteShellPort = prefs.getInt("port", defaultPortStart + 1);
+ prefs.putInt("port", remoteShellPort + 1);
+ prefs.flush();
+ prefs.sync();
+ } catch (Exception e) {
+ try {
+ ServerSocket ss = new ServerSocket(0);
+ remoteShellPort = ss.getLocalPort();
+ ss.close();
+ } catch (Exception t) {
+ }
+ }
+ if (remoteShellPort <= 0) {
+ remoteShellPort = defaultPortStart;
+ }
+ }
+ io.out.println("Creating new instance on port " + remoteShellPort + " at: @|bold " + serviceMixBase + "|");
+
+ mkdir(serviceMixBase, "bin");
+ mkdir(serviceMixBase, "etc");
+ mkdir(serviceMixBase, "system");
+ mkdir(serviceMixBase, "deploy");
+ mkdir(serviceMixBase, "data");
+
+ copyResourceToDir(serviceMixBase, "etc/config.properties", true);
+ copyResourceToDir(serviceMixBase, "etc/org.apache.servicemix.features.cfg", true);
+ copyResourceToDir(serviceMixBase, "etc/org.ops4j.pax.logging.cfg", true);
+ copyResourceToDir(serviceMixBase, "etc/org.ops4j.pax.url.mvn.cfg", true);
+ copyResourceToDir(serviceMixBase, "etc/startup.properties", true);
+ copyResourceToDir(serviceMixBase, "etc/system.properties", true);
+
+ HashMap<String, String> props = new HashMap<String, String>();
+ props.put("${servicemix.home}", System.getProperty("servicemix.home"));
+ props.put("${servicemix.base}", serviceMixBase.getPath());
+ props.put("${servicemix.remoteShellPort}", Integer.toString(remoteShellPort));
+ copyFilteredResourceToDir(serviceMixBase, "etc/org.apache.servicemix.shell.cfg", props);
+ if( System.getProperty("os.name").startsWith("Win") ) {
+ copyFilteredResourceToDir(serviceMixBase, "bin/servicemix.bat", props);
+ } else {
+ copyFilteredResourceToDir(serviceMixBase, "bin/servicemix", props);
+ chmod(new File(serviceMixBase, "bin/servicemix"), "a+x");
+ }
+ return SUCCESS;
+ }
+
+ private void copyResourceToDir(File target, String resource, boolean text) throws Exception {
+ File outFile = new File(target, resource);
+ if( !outFile.exists() ) {
+ io.out.println("Creating file: @|bold " + outFile.getPath() + "|");
+ InputStream is = CreateCommand.class.getResourceAsStream(resource);
+ try {
+ if( text ) {
+ // Read it line at a time so that we can use the platform line ending when we write it out.
+ PrintStream out = new PrintStream(new FileOutputStream(outFile));
+ try {
+ Scanner scanner = new Scanner(is);
+ while (scanner.hasNextLine() ) {
+ String line = scanner.nextLine();
+ out.println(line);
+ }
+ } finally {
+ safeClose(out);
+ }
+ } else {
+ // Binary so just write it out the way it came in.
+ FileOutputStream out = new FileOutputStream(new File(target, resource));
+ try {
+ int c=0;
+ while((c=is.read())>=0) {
+ out.write(c);
+ }
+ } finally {
+ safeClose(out);
+ }
+ }
+ } finally {
+ safeClose(is);
+ }
+ }
+ }
+
+ private void copyFilteredResourceToDir(File target, String resource, HashMap<String, String> props) throws Exception {
+ File outFile = new File(target, resource);
+ if( !outFile.exists() ) {
+ io.out.println("Creating file: @|bold "+outFile.getPath()+"|");
+ InputStream is = CreateCommand.class.getResourceAsStream(resource);
+ try {
+ // Read it line at a time so that we can use the platform line ending when we write it out.
+ PrintStream out = new PrintStream(new FileOutputStream(outFile));
+ try {
+ Scanner scanner = new Scanner(is);
+ while (scanner.hasNextLine() ) {
+ String line = scanner.nextLine();
+ line = filter(line, props);
+ out.println(line);
+ }
+ } finally {
+ safeClose(out);
+ }
+ } finally {
+ safeClose(is);
+ }
+ }
+ }
+
+ private void safeClose(InputStream is) throws IOException {
+ if (is == null) {
+ return;
+ }
+ try {
+ is.close();
+ } catch (Throwable ignore) {
+ }
+ }
+
+ private void safeClose(OutputStream is) throws IOException {
+ if (is == null) {
+ return;
+ }
+ try {
+ is.close();
+ } catch (Throwable ignore) {
+ }
+ }
+
+ private String filter(String line, HashMap<String, String> props) {
+ for (Map.Entry<String, String> i : props.entrySet()) {
+ int p1 = line.indexOf(i.getKey());
+ if( p1 >= 0 ) {
+ String l1 = line.substring(0, p1);
+ String l2 = line.substring(p1+i.getKey().length());
+ line = l1+i.getValue()+l2;
+ }
+ }
+ return line;
+ }
+
+ private void mkdir(File serviceMixBase, String path) {
+ File file = new File(serviceMixBase, path);
+ if( !file.exists() ) {
+ io.out.println("Creating dir: @|bold "+file.getPath()+"|");
+ file.mkdirs();
+ }
+ }
+
+ private int chmod(File serviceFile, String mode) throws Exception {
+ ProcessBuilder builder = new ProcessBuilder();
+ builder.command("chmod", mode, serviceFile.getCanonicalPath());
+ Process p = builder.start();
+
+ // gnodet: Fix SMX4KNL-46: cpu goes to 100% after running the 'admin create' command
+ // Not sure exactly what happens, but commenting the process io redirection seems
+ // to work around the problem.
+ //
+ //PumpStreamHandler handler = new PumpStreamHandler(io.inputStream, io.outputStream, io.errorStream);
+ //handler.attach(p);
+ //handler.start();
+ int status = p.waitFor();
+ //handler.stop();
+ return status;
+ }
+
+}
Added: 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=698136&view=auto
==============================================================================
--- 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/resources/META-INF/spring/gshell-admin.xml Tue Sep 23 04:05:41 2008
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd
+ http://www.springframework.org/schema/osgi
+ http://www.springframework.org/schema/osgi/spring-osgi.xsd">
+
+ <!-- osgi commands -->
+ <bean id="create" class="org.apache.servicemix.kernel.gshell.admin.CreateCommand">
+ <property name="preferences" ref="preferences" />
+ </bean>
+
+ <osgi:reference id="preferences" interface="org.osgi.service.prefs.PreferencesService" cardinality="0..1" />
+
+ <osgi:service ref="create" interface="org.apache.geronimo.gshell.command.Command">
+ <osgi:service-properties>
+ <entry key="shell" value="admin"/>
+ <entry key="name" value="create"/>
+ </osgi:service-properties>
+ </osgi:service>
+
+</beans>
\ No newline at end of file
Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/apache/servicemix/kernel/gshell/admin/etc/org.apache.servicemix.shell.cfg
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/apache/servicemix/kernel/gshell/admin/etc/org.apache.servicemix.shell.cfg?rev=698136&r1=697778&r2=698136&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/apache/servicemix/kernel/gshell/admin/etc/org.apache.servicemix.shell.cfg (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/org/apache/servicemix/kernel/gshell/admin/etc/org.apache.servicemix.shell.cfg Tue Sep 23 04:05:41 2008
@@ -20,4 +20,4 @@
#
startLocalConsole=${servicemix.startLocalConsole}
startRemoteShell=${servicemix.startRemoteShell}
-remoteShellLocation=tcp://0.0.0.0:8101/
+remoteShellLocation=tcp://0.0.0.0:${servicemix.remoteShellPort}/
Modified: servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-commands.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-commands.xml?rev=698136&r1=698135&r2=698136&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-commands.xml (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-commands.xml Tue Sep 23 04:05:41 2008
@@ -54,8 +54,6 @@
<bean id="unset" class="org.apache.geronimo.gshell.commands.builtins.UnsetCommand" />
- <bean id="create" class="org.apache.geronimo.gshell.spring.CreateCommand" />
-
<bean id="grep" class="org.apache.geronimo.gshell.commands.utils.GrepCommand" />
<bean id="cat" class="org.apache.geronimo.gshell.commands.utils.CatCommand" />
Modified: servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml?rev=698136&r1=698135&r2=698136&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/resources/META-INF/spring/gshell-osgi.xml Tue Sep 23 04:05:41 2008
@@ -94,13 +94,6 @@
</osgi:service-properties>
</osgi:service>
- <osgi:service ref="create" interface="org.apache.geronimo.gshell.command.Command">
- <osgi:service-properties>
- <entry key="shell" value="admin"/>
- <entry key="alias" value="create"/>
- </osgi:service-properties>
- </osgi:service>
-
<osgi:service ref="grep" interface="org.apache.geronimo.gshell.command.Command">
<osgi:service-properties>
<entry key="shell" value="utils"/>
@@ -143,7 +136,7 @@
<osgix:default-properties>
<prop key="startLocalConsole">true</prop>
<prop key="startRemoteShell">true</prop>
- <prop key="remoteShellLocation">tcp://0.0.0.0:8100/</prop>
+ <prop key="remoteShellLocation">tcp://0.0.0.0:8101/</prop>
<prop key="clientKeyAlias">servicemix</prop>
<prop key="clientKeystore">RshKeystore</prop>
<prop key="clientTruststore">RshTruststore</prop>
Modified: servicemix/smx4/kernel/trunk/gshell/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/pom.xml?rev=698136&r1=698135&r2=698136&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/pom.xml (original)
+++ servicemix/smx4/kernel/trunk/gshell/pom.xml Tue Sep 23 04:05:41 2008
@@ -34,6 +34,7 @@
<modules>
<module>gshell-core</module>
+ <module>gshell-admin</module>
<module>gshell-osgi</module>
<module>gshell-obr</module>
<module>gshell-wrapper</module>