Switch from gshell to gogo
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@792445 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/assembly/pom.xml b/karaf/assembly/pom.xml
index 9ade34d..d07c601 100644
--- a/karaf/assembly/pom.xml
+++ b/karaf/assembly/pom.xml
@@ -60,11 +60,7 @@
</dependency>
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.run</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
</dependency>
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
@@ -95,6 +91,14 @@
<artifactId>org.apache.felix.karaf.gshell.packages</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.felix.karaf.gshell</groupId>
+ <artifactId>org.apache.felix.karaf.gshell.commands</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix.karaf.gshell</groupId>
+ <artifactId>org.apache.felix.karaf.gshell.ssh</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.felix.karaf.jaas</groupId>
<artifactId>org.apache.felix.karaf.jaas.boot</artifactId>
</dependency>
@@ -143,47 +147,15 @@
<artifactId>org.apache.felix.bundlerepository</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.servicemix.specs</groupId>
- <artifactId>org.apache.servicemix.specs.jaxp-api-1.4</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.jaxp-ri</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.aopalliance</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.cglib</artifactId>
</dependency>
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.commons-jexl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.commons-vfs</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.oro</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.commons-codec</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.commons-httpclient</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.jline</artifactId>
</dependency>
<dependency>
@@ -223,20 +195,12 @@
<artifactId>geronimo-servlet_2.5_spec</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-annotation_1.0_spec</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>jmx</artifactId>
- </dependency>
- <dependency>
- <groupId>com.oracle.osgi</groupId>
- <artifactId>jmx-impl</artifactId>
+ <artifactId>org.osgi.impl.bundle.jmx</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
diff --git a/karaf/assembly/src/main/descriptors/unix-bin.xml b/karaf/assembly/src/main/descriptors/unix-bin.xml
index 6c5c91c..494aaff 100644
--- a/karaf/assembly/src/main/descriptors/unix-bin.xml
+++ b/karaf/assembly/src/main/descriptors/unix-bin.xml
@@ -121,9 +121,6 @@
<useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>org/apache/felix/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
- <!--
- <include>org.apache.felix:org.osgi.compendium</include>
- -->
<include>org.apache.felix:org.apache.felix.configadmin</include>
<include>org.apache.felix:org.apache.felix.prefs</include>
<include>org.apache.felix:org.apache.felix.framework</include>
@@ -133,6 +130,16 @@
<outputDirectory>/system</outputDirectory>
<unpack>false</unpack>
<useProjectArtifact>false</useProjectArtifact>
+ <outputFileNameMapping>org/apache/felix/gogo/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ <includes>
+ <include>org.apache.felix.gogo:org.apache.felix.gogo.runtime</include>
+ <include>org.apache.felix.gogo:org.apache.felix.gogo.commands</include>
+ </includes>
+ </dependencySet>
+ <dependencySet>
+ <outputDirectory>/system</outputDirectory>
+ <unpack>false</unpack>
+ <useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>org/ops4j/pax/logging/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
<include>org.ops4j.pax.logging:pax-logging-api</include>
@@ -149,59 +156,12 @@
<include>org.ops4j.pax.url:pax-url-wrap</include>
</includes>
</dependencySet>
- <!--
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/springframework/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.springframework:spring-aop</include>
- <include>org.springframework:spring-beans</include>
- <include>org.springframework:spring-context</include>
- <include>org.springframework:spring-core</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/springframework/osgi/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.springframework.osgi:spring-osgi-core</include>
- <include>org.springframework.osgi:spring-osgi-extender</include>
- <include>org.springframework.osgi:spring-osgi-io</include>
- </includes>
- </dependencySet>
- -->
- <!--
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/geronimo/specs/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.geronimo.specs:geronimo-servlet_2.5_spec</include>
- <include>org.apache.geronimo.specs:geronimo-annotation_1.0_spec</include>
- </includes>
- </dependencySet>
- -->
<dependencySet>
<outputDirectory>/system</outputDirectory>
<unpack>false</unpack>
<useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>org/apache/servicemix/bundles/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
- <!--
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.aopalliance</include>
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.cglib</include>
- -->
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.jaxp-ri</include>
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.oro</include>
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.commons-jexl</include>
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.commons-vfs</include>
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.commons-codec</include>
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.commons-httpclient</include>
<include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.jline</include>
</includes>
</dependencySet>
@@ -209,15 +169,6 @@
<outputDirectory>/system</outputDirectory>
<unpack>false</unpack>
<useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/servicemix/specs/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.servicemix.specs:org.apache.servicemix.specs.jaxp-api-1.4</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>org/apache/felix/karaf/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
<include>org.apache.felix.karaf:org.apache.felix.karaf.management</include>
@@ -241,14 +192,15 @@
<useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>org/apache/felix/karaf/gshell/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
- <include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.core</include>
- <include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.run</include>
+ <include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.console</include>
<include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.admin</include>
<include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.osgi</include>
<include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.log</include>
<include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.features</include>
<include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.config</include>
<include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.packages</include>
+ <include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.ssh</include>
+ <include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.commands</include>
</includes>
</dependencySet>
<dependencySet>
@@ -285,16 +237,7 @@
<useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>org/osgi/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
- <include>org.osgi:jmx</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>com/oracle/osgi/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>com.oracle.osgi:jmx-impl</include>
+ <include>org.osgi:org.osgi.impl.bundle.jmx</include>
</includes>
</dependencySet>
<dependencySet>
diff --git a/karaf/assembly/src/main/descriptors/windows-bin.xml b/karaf/assembly/src/main/descriptors/windows-bin.xml
index 2df7e2e..667d5b6 100644
--- a/karaf/assembly/src/main/descriptors/windows-bin.xml
+++ b/karaf/assembly/src/main/descriptors/windows-bin.xml
@@ -113,9 +113,6 @@
<useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>org/apache/felix/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
- <!--
- <include>org.apache.felix:org.osgi.compendium</include>
- -->
<include>org.apache.felix:org.apache.felix.configadmin</include>
<include>org.apache.felix:org.apache.felix.prefs</include>
<include>org.apache.felix:org.apache.felix.framework</include>
@@ -141,59 +138,12 @@
<include>org.ops4j.pax.url:pax-url-wrap</include>
</includes>
</dependencySet>
- <!--
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/springframework/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.springframework:spring-aop</include>
- <include>org.springframework:spring-beans</include>
- <include>org.springframework:spring-context</include>
- <include>org.springframework:spring-core</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/springframework/osgi/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.springframework.osgi:spring-osgi-core</include>
- <include>org.springframework.osgi:spring-osgi-extender</include>
- <include>org.springframework.osgi:spring-osgi-io</include>
- </includes>
- </dependencySet>
- -->
- <!--
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/geronimo/specs/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.geronimo.specs:geronimo-servlet_2.5_spec</include>
- <include>org.apache.geronimo.specs:geronimo-annotation_1.0_spec</include>
- </includes>
- </dependencySet>
- -->
<dependencySet>
<outputDirectory>/system</outputDirectory>
<unpack>false</unpack>
<useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>org/apache/servicemix/bundles/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
- <!--
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.aopalliance</include>
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.cglib</include>
- -->
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.jaxp-ri</include>
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.oro</include>
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.commons-jexl</include>
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.commons-vfs</include>
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.commons-codec</include>
- <include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.commons-httpclient</include>
<include>org.apache.servicemix.bundles:org.apache.servicemix.bundles.jline</include>
</includes>
</dependencySet>
@@ -201,15 +151,6 @@
<outputDirectory>/system</outputDirectory>
<unpack>false</unpack>
<useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>org/apache/servicemix/specs/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>org.apache.servicemix.specs:org.apache.servicemix.specs.jaxp-api-1.4</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>org/apache/felix/karaf/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
<include>org.apache.felix.karaf:org.apache.felix.karaf.management</include>
@@ -233,14 +174,15 @@
<useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>org/apache/felix/karaf/gshell/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
- <include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.core</include>
- <include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.run</include>
+ <include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.console</include>
<include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.admin</include>
<include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.osgi</include>
<include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.log</include>
<include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.features</include>
<include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.config</include>
<include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.packages</include>
+ <include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.ssh</include>
+ <include>org.apache.felix.karaf.gshell:org.apache.felix.karaf.gshell.commands</include>
</includes>
</dependencySet>
<dependencySet>
@@ -277,16 +219,7 @@
<useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>org/osgi/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
<includes>
- <include>org.osgi:jmx</include>
- </includes>
- </dependencySet>
- <dependencySet>
- <outputDirectory>/system</outputDirectory>
- <unpack>false</unpack>
- <useProjectArtifact>false</useProjectArtifact>
- <outputFileNameMapping>com/oracle/osgi/${artifact.artifactId}/${artifact.baseVersion}/${artifact.artifactId}-${artifact.baseVersion}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
- <includes>
- <include>com.oracle.osgi:jmx-impl</include>
+ <include>org.osgi:org.osgi.impl.bundle.jmx</include>
</includes>
</dependencySet>
<dependencySet>
diff --git a/karaf/assembly/src/main/filtered-resources/etc/config.properties b/karaf/assembly/src/main/filtered-resources/etc/config.properties
index a310d64..43479ef 100644
--- a/karaf/assembly/src/main/filtered-resources/etc/config.properties
+++ b/karaf/assembly/src/main/filtered-resources/etc/config.properties
@@ -20,7 +20,7 @@
#
# Framework selection properties
#
-karaf.framework=felix
+karaf.framework=equinox
karaf.framework.equinox=system/org/eclipse/osgi/${equinox.version}/osgi-${equinox.version}.jar
karaf.framework.felix=system/org/apache/felix/org.apache.felix.framework/${felix.framework.version}/org.apache.felix.framework-${felix.framework.version}.jar
@@ -28,15 +28,10 @@
#
# Framework config properties.
#
-org.osgi.framework.system.packages=org.osgi.framework; version=1.4.0, \
- org.osgi.framework.hooks.service; version=1.4.0, \
- org.osgi.service.packageadmin; version=1.2.0, \
- org.osgi.service.startlevel; version=1.1.0, \
- org.osgi.service.url; version=1.0.0, \
- org.osgi.util.tracker; version=1.3.3, \
+org.osgi.framework.system.packages.extra=\
org.apache.felix.karaf.jaas.boot; version=${karaf.osgi.version}, \
- org.apache.felix.karaf.version; version=${karaf.osgi.version}, \
- ${jre-${java.specification.version}}
+ org.apache.felix.karaf.version; version=${karaf.osgi.version}
+
org.osgi.framework.bootdelegation=sun.*,com.sun.management*
# To enable the use of the startup.properties file to control the start level:
diff --git a/karaf/assembly/src/main/filtered-resources/etc/startup.properties b/karaf/assembly/src/main/filtered-resources/etc/startup.properties
index 123b01a..2143f41 100644
--- a/karaf/assembly/src/main/filtered-resources/etc/startup.properties
+++ b/karaf/assembly/src/main/filtered-resources/etc/startup.properties
@@ -27,12 +27,7 @@
org/ops4j/pax/url/pax-url-wrap/${pax.url.version}/pax-url-wrap-${pax.url.version}.jar=5
org/ops4j/pax/logging/pax-logging-api/${pax.logging.version}/pax-logging-api-${pax.logging.version}.jar=8
org/ops4j/pax/logging/pax-logging-service/${pax.logging.version}/pax-logging-service-${pax.logging.version}.jar=8
-#org/apache/geronimo/specs/geronimo-servlet_2.5_spec/${geronimo.servlet.version}/geronimo-servlet_2.5_spec-${geronimo.servlet.version}.jar=10
-org/apache/servicemix/specs/org.apache.servicemix.specs.jaxp-api-1.4/${servicemix.specs.version}/org.apache.servicemix.specs.jaxp-api-1.4-${servicemix.specs.version}.jar=10
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.jaxp-ri/${jaxp.ri.version}/org.apache.servicemix.bundles.jaxp-ri-${jaxp.ri.version}.jar=10
-#org/apache/felix/org.osgi.compendium/${felix.compendium.version}/org.osgi.compendium-${felix.compendium.version}.jar=10
org/apache/felix/org.apache.felix.configadmin/${felix.configadmin.version}/org.apache.felix.configadmin-${felix.configadmin.version}.jar=10
-#org/apache/geronimo/specs/geronimo-annotation_1.0_spec/${geronimo.annotation.version}/geronimo-annotation_1.0_spec-${geronimo.annotation.version}.jar=10
org/apache/felix/org.apache.felix.prefs/${felix.prefs.version}/org.apache.felix.prefs-${felix.prefs.version}.jar=10
org/apache/felix/karaf/deployer/org.apache.felix.karaf.deployer.filemonitor/${pom.version}/org.apache.felix.karaf.deployer.filemonitor-${pom.version}.jar=15
@@ -41,41 +36,26 @@
#
org/apache/geronimo/blueprint-bundle/${geronimo.blueprint.version}/blueprint-bundle-${geronimo.blueprint.version}.jar=20
-org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.core/${pom.version}/org.apache.felix.karaf.gshell.core-${pom.version}.jar=30
org/apache/servicemix/bundles/org.apache.servicemix.bundles.jline/${jline.version}/org.apache.servicemix.bundles.jline-${jline.version}.jar=30
-#org/apache/servicemix/bundles/org.apache.servicemix.bundles.aopalliance/${aopalliance.version}/org.apache.servicemix.bundles.aopalliance-${aopalliance.version}.jar=30
-#org/apache/servicemix/bundles/org.apache.servicemix.bundles.cglib/${cglib.version}/org.apache.servicemix.bundles.cglib-${cglib.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.oro/${oro.version}/org.apache.servicemix.bundles.oro-${oro.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.commons-codec/${commons.codec.version}/org.apache.servicemix.bundles.commons-codec-${commons.codec.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.commons-httpclient/${commons.httpclient.version}/org.apache.servicemix.bundles.commons-httpclient-${commons.httpclient.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.commons-jexl/${commons.jexl.version}/org.apache.servicemix.bundles.commons-jexl-${commons.jexl.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.commons-vfs/${commons.vfs.version}/org.apache.servicemix.bundles.commons-vfs-${commons.vfs.version}.jar=30
-#org/springframework/spring-aop/${spring.version}/spring-aop-${spring.version}.jar=30
-#org/springframework/spring-beans/${spring.version}/spring-beans-${spring.version}.jar=30
-#org/springframework/spring-context/${spring.version}/spring-context-${spring.version}.jar=30
-#org/springframework/spring-core/${spring.version}/spring-core-${spring.version}.jar=30
-#org/springframework/osgi/spring-osgi-core/${spring.osgi.version}/spring-osgi-core-${spring.osgi.version}.jar=30
-#org/springframework/osgi/spring-osgi-extender/${spring.osgi.version}/spring-osgi-extender-${spring.osgi.version}.jar=30
-#org/springframework/osgi/spring-osgi-io/${spring.osgi.version}/spring-osgi-io-${spring.osgi.version}.jar=30
+org/apache/felix/gogo/org.apache.felix.gogo.runtime/${felix.gogo.version}/org.apache.felix.gogo.runtime-${felix.gogo.version}.jar=30
+org/apache/felix/gogo/org.apache.felix.gogo.commands/${felix.gogo.version}/org.apache.felix.gogo.commands-${felix.gogo.version}.jar=30
+org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.console/${pom.version}/org.apache.felix.karaf.gshell.console-${pom.version}.jar=30
org/apache/felix/karaf/deployer/org.apache.felix.karaf.deployer.spring/${pom.version}/org.apache.felix.karaf.deployer.spring-${pom.version}.jar=30
org/apache/felix/karaf/deployer/org.apache.felix.karaf.deployer.blueprint/${pom.version}/org.apache.felix.karaf.deployer.blueprint-${pom.version}.jar=30
org/apache/felix/karaf/deployer/org.apache.felix.karaf.deployer.features/${pom.version}/org.apache.felix.karaf.deployer.features-${pom.version}.jar=30
-org/apache/felix/karaf/org.apache.felix.karaf.management/${pom.version}/org.apache.felix.karaf.management-${pom.version}.jar=30
org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.admin/${pom.version}/org.apache.felix.karaf.gshell.admin-${pom.version}.jar=30
org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.osgi/${pom.version}/org.apache.felix.karaf.gshell.osgi-${pom.version}.jar=30
org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.features/${pom.version}/org.apache.felix.karaf.gshell.features-${pom.version}.jar=30
org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.log/${pom.version}/org.apache.felix.karaf.gshell.log-${pom.version}.jar=30
org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.config/${pom.version}/org.apache.felix.karaf.gshell.config-${pom.version}.jar=30
org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.packages/${pom.version}/org.apache.felix.karaf.gshell.packages-${pom.version}.jar=30
+org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.commands/${pom.version}/org.apache.felix.karaf.gshell.commands-${pom.version}.jar=30
org/apache/felix/karaf/jaas/org.apache.felix.karaf.jaas.config/${pom.version}/org.apache.felix.karaf.jaas.config-${pom.version}.jar=30
org/apache/felix/karaf/jaas/org.apache.felix.karaf.jaas.modules/${pom.version}/org.apache.felix.karaf.jaas.modules-${pom.version}.jar=30
+
+org/apache/felix/karaf/org.apache.felix.karaf.management/${pom.version}/org.apache.felix.karaf.management-${pom.version}.jar=30
+org/osgi/org.osgi.impl.bundle.jmx/${osgi.jmx.version}/org.osgi.impl.bundle.jmx-${osgi.jmx.version}.jar=30
+
org/apache/mina/mina-core/${mina.version}/mina-core-${mina.version}.jar=30
org/apache/sshd/sshd-core/${sshd.version}/sshd-core-${sshd.version}.jar=30
-org/osgi/jmx/${osgi.jmx.version}/jmx-${osgi.jmx.version}.jar=30
-com/oracle/osgi/jmx-impl/${osgi.jmx.version}/jmx-impl-${osgi.jmx.version}.jar=30
-
-#
-# Start console last
-#
-org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.run/${pom.version}/org.apache.felix.karaf.gshell.run-${pom.version}.jar=40
-
+org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.ssh/${pom.version}/org.apache.felix.karaf.gshell.ssh-${pom.version}.jar=30
diff --git a/karaf/assembly/src/main/filtered-resources/features.xml b/karaf/assembly/src/main/filtered-resources/features.xml
index c1b4755..99c4105 100644
--- a/karaf/assembly/src/main/filtered-resources/features.xml
+++ b/karaf/assembly/src/main/filtered-resources/features.xml
@@ -59,4 +59,17 @@
<bundle>mvn:org.apache.felix/org.apache.felix.webconsole/${felix.webconsole.version}</bundle>
<bundle>mvn:org.apache.felix.karaf/org.apache.felix.karaf.webconsole/${version}</bundle>
</feature>
+ <feature name="ssh" version="${version}">
+ <config name="org.apache.felix.karaf.gshell.ssh">
+ sshPort=8101
+ sshRealm=karaf
+ </config>
+ <bundle>mvn:org.apache.mina/mina-core/${mina.version}</bundle>
+ <bundle>mvn:org.apache.sshd/sshd-core/${sshd.version}</bundle>
+ <bundle>mvn:org.apache.felix.karaf.gshell/org.apache.felix.karaf.gshell.ssh/${version}</bundle>
+ </feature>
+ <feature name="management" version="${version}">
+ <bundle>mvn:org.apache.felix.karaf/org.apache.felix.karaf.management/${version}</bundle>
+ <bundle>mvn:org.osgi/org.osgi.impl.bundle.jmx/${osgi.jmx.version}</bundle>
+ </feature>
</features>
diff --git a/karaf/client/pom.xml b/karaf/client/pom.xml
index e7deb86..c3c834f 100644
--- a/karaf/client/pom.xml
+++ b/karaf/client/pom.xml
@@ -35,14 +35,12 @@
<dependencies>
<dependency>
- <groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- </exclusion>
- </exclusions>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.jline</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/karaf/deployer/features/src/main/resources/OSGI-INF/blueprint/features-deployer.xml b/karaf/deployer/features/src/main/resources/OSGI-INF/blueprint/features-deployer.xml
index 08d5a96..89e7825 100644
--- a/karaf/deployer/features/src/main/resources/OSGI-INF/blueprint/features-deployer.xml
+++ b/karaf/deployer/features/src/main/resources/OSGI-INF/blueprint/features-deployer.xml
@@ -18,7 +18,8 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://www.osgi.org/xmlns/blueprint-cm/v1.0.0">
+ xmlns:cm="http://www.osgi.org/xmlns/blueprint-cm/v1.0.0"
+ default-activation="lazy">
<service interface="org.apache.felix.karaf.deployer.filemonitor.DeploymentListener"
ref="featureDeploymentListener"/>
diff --git a/karaf/deployer/filemonitor/pom.xml b/karaf/deployer/filemonitor/pom.xml
index aa8d908..f4eed26 100644
--- a/karaf/deployer/filemonitor/pom.xml
+++ b/karaf/deployer/filemonitor/pom.xml
@@ -55,11 +55,6 @@
<!-- testing -->
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.commons-io</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.junit</artifactId>
<scope>test</scope>
</dependency>
diff --git a/karaf/deployer/filemonitor/src/test/java/org/apache/felix/karaf/deployer/filemonitor/BundlePackerTest.java b/karaf/deployer/filemonitor/src/test/java/org/apache/felix/karaf/deployer/filemonitor/BundlePackerTest.java
index b710a30..be60315 100644
--- a/karaf/deployer/filemonitor/src/test/java/org/apache/felix/karaf/deployer/filemonitor/BundlePackerTest.java
+++ b/karaf/deployer/filemonitor/src/test/java/org/apache/felix/karaf/deployer/filemonitor/BundlePackerTest.java
@@ -17,16 +17,14 @@
*/
package org.apache.felix.karaf.deployer.filemonitor;
-import java.io.File;
-
import junit.framework.TestCase;
-import org.apache.commons.io.FileUtils;
/**
* @version $Revision: 1.1 $
*/
public class BundlePackerTest extends TestCase {
public void testFiles() throws Exception {
+/*
File bundleDir = new File("target/deploy");
File unpackDir = new File("target/data");
FileUtils.deleteDirectory(unpackDir);
@@ -36,7 +34,6 @@
FileUtils.copyDirectory(new File("src/test/data"), unpackDir);
-/*
FileMonitor packer = new FileMonitor(bundleDir, unpackDir);
packer.scan();
*/
diff --git a/karaf/gshell/gshell-admin/pom.xml b/karaf/gshell/gshell-admin/pom.xml
index 48ab09d..391d643 100644
--- a/karaf/gshell/gshell-admin/pom.xml
+++ b/karaf/gshell/gshell-admin/pom.xml
@@ -37,24 +37,10 @@
Provides administration commands
</description>
- <properties>
- <gshell.osgi.import>
- org.apache.felix.karaf.main.spi.*;resolution:=optional,
- org.apache.geronimo.gshell*,
- </gshell.osgi.import>
- <gshell.osgi.export>
- org.apache.felix.karaf.jpm
- </gshell.osgi.export>
- <gshell.osgi.private>
- org.apache.felix.karaf.gshell.admin.*,
- org.apache.feix.karaf.jpm.impl
- </gshell.osgi.private>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
</dependency>
<dependency>
@@ -70,11 +56,6 @@
</dependency>
<dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.junit</artifactId>
<scope>test</scope>
@@ -115,10 +96,16 @@
<outputDirectory>${basedir}/target/classes/org/apache/felix/karaf/gshell/admin/etc</outputDirectory>
<resources>
<resource>
- <directory>../../${config.location}</directory>
+ <directory>../../assembly/src/main/distribution/text/etc/</directory>
<includes>
- <include>config.properties</include>
+ <include>*.properties</include>
+ <include>*.cfg</include>
</includes>
+ <excludes>
+ <exclude>org.apache.felix.karaf.shell.cfg</exclude>
+ <exclude>org.ops4j.pax.url.mvn.cfg</exclude>
+ <exclude>system.properties</exclude>
+ </excludes>
</resource>
</resources>
</configuration>
@@ -131,14 +118,14 @@
<goal>copy-resources</goal>
</goals>
<configuration>
- <outputDirectory>${basedir}/target/classes</outputDirectory>
+ <outputDirectory>${basedir}/target/classes/org/apache/felix/karaf/gshell/admin/etc</outputDirectory>
<resources>
<resource>
- <directory>src/main/filtered-resources</directory>
+ <directory>../../assembly/src/main/filtered-resources/etc</directory>
<filtering>true</filtering>
<includes>
- <include>**/*.cfg</include>
- <include>**/*.properties</include>
+ <include>*.properties</include>
+ <include>*.cfg</include>
</includes>
</resource>
</resources>
@@ -161,10 +148,9 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
- org.apache.geronimo.gshell.command,
- org.apache.geronimo.gshell.wisdom.command,
- org.apache.geronimo.gshell.wisdom.registry,
- org.apache.felix.karaf.gshell.core,
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.felix.karaf.gshell.console,
*
</Import-Package>
<Private-Package>org.apache.felix.karaf.jpm.*</Private-Package>
diff --git a/karaf/gshell/gshell-admin/src/main/filtered-resources/org/apache/felix/karaf/gshell/admin/etc/org.apache.felix.karaf.features.cfg b/karaf/gshell/gshell-admin/src/main/filtered-resources/org/apache/felix/karaf/gshell/admin/etc/org.apache.felix.karaf.features.cfg
deleted file mode 100644
index 74e733d..0000000
--- a/karaf/gshell/gshell-admin/src/main/filtered-resources/org/apache/felix/karaf/gshell/admin/etc/org.apache.felix.karaf.features.cfg
+++ /dev/null
@@ -1,28 +0,0 @@
-################################################################################
-#
-# 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.
-#
-################################################################################
-
-#
-# Comma separated list of features repositories to register by default
-#
-featuresRepositories=mvn:org.apache.felix.karaf/apache-felix-karaf/${version}/xml/features
-
-#
-# Comma separated list of features to install at startup
-#
-featuresBoot=
diff --git a/karaf/gshell/gshell-admin/src/main/filtered-resources/org/apache/felix/karaf/gshell/admin/etc/startup.properties b/karaf/gshell/gshell-admin/src/main/filtered-resources/org/apache/felix/karaf/gshell/admin/etc/startup.properties
deleted file mode 100644
index cb99888..0000000
--- a/karaf/gshell/gshell-admin/src/main/filtered-resources/org/apache/felix/karaf/gshell/admin/etc/startup.properties
+++ /dev/null
@@ -1,79 +0,0 @@
-################################################################################
-#
-# 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.
-#
-################################################################################
-
-# This file allows you to control the start level of each bundle.
-#
-
-#
-# Startup core services like logging
-#
-org/ops4j/pax/url/pax-url-mvn/${pax.url.version}/pax-url-mvn-${pax.url.version}.jar=5
-org/ops4j/pax/url/pax-url-wrap/${pax.url.version}/pax-url-wrap-${pax.url.version}.jar=5
-org/ops4j/pax/logging/pax-logging-api/${pax.logging.version}/pax-logging-api-${pax.logging.version}.jar=8
-org/ops4j/pax/logging/pax-logging-service/${pax.logging.version}/pax-logging-service-${pax.logging.version}.jar=8
-org/apache/geronimo/specs/geronimo-servlet_2.5_spec/${geronimo.servlet.version}/geronimo-servlet_2.5_spec-${geronimo.servlet.version}.jar=10
-org/apache/servicemix/specs/org.apache.servicemix.specs.jaxp-api-1.4/${servicemix.specs.version}/org.apache.servicemix.specs.jaxp-api-1.4-${servicemix.specs.version}.jar=10
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.jaxp-ri/${jaxp.ri.version}/org.apache.servicemix.bundles.jaxp-ri-${jaxp.ri.version}.jar=10
-org/apache/felix/org.osgi.compendium/${felix.compendium.version}/org.osgi.compendium-${felix.compendium.version}.jar=10
-org/apache/felix/org.apache.felix.configadmin/${felix.configadmin.version}/org.apache.felix.configadmin-${felix.configadmin.version}.jar=10
-org/apache/geronimo/specs/geronimo-annotation_1.0_spec/${geronimo.annotation.version}/geronimo-annotation_1.0_spec-${geronimo.annotation.version}.jar=10
-org/apache/felix/org.apache.felix.prefs/${felix.prefs.version}/org.apache.felix.prefs-${felix.prefs.version}.jar=10
-org/apache/felix/karaf/deployer/org.apache.felix.karaf.deployer.filemonitor/${pom.version}/org.apache.felix.karaf.deployer.filemonitor-${pom.version}.jar=15
-
-#
-# The rest of the services..
-#
-org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.core/${pom.version}/org.apache.felix.karaf.gshell.core-${pom.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.jline/${jline.version}/org.apache.servicemix.bundles.jline-${jline.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.aopalliance/${aopalliance.version}/org.apache.servicemix.bundles.aopalliance-${aopalliance.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.cglib/${cglib.version}/org.apache.servicemix.bundles.cglib-${cglib.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.oro/${oro.version}/org.apache.servicemix.bundles.oro-${oro.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.commons-codec/${commons.codec.version}/org.apache.servicemix.bundles.commons-codec-${commons.codec.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.commons-httpclient/${commons.httpclient.version}/org.apache.servicemix.bundles.commons-httpclient-${commons.httpclient.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.commons-jexl/${commons.jexl.version}/org.apache.servicemix.bundles.commons-jexl-${commons.jexl.version}.jar=30
-org/apache/servicemix/bundles/org.apache.servicemix.bundles.commons-vfs/${commons.vfs.version}/org.apache.servicemix.bundles.commons-vfs-${commons.vfs.version}.jar=30
-org/springframework/spring-aop/${spring.version}/spring-aop-${spring.version}.jar=30
-org/springframework/spring-beans/${spring.version}/spring-beans-${spring.version}.jar=30
-org/springframework/spring-context/${spring.version}/spring-context-${spring.version}.jar=30
-org/springframework/spring-core/${spring.version}/spring-core-${spring.version}.jar=30
-org/springframework/osgi/spring-osgi-core/${spring.osgi.version}/spring-osgi-core-${spring.osgi.version}.jar=30
-org/springframework/osgi/spring-osgi-extender/${spring.osgi.version}/spring-osgi-extender-${spring.osgi.version}.jar=30
-org/springframework/osgi/spring-osgi-io/${spring.osgi.version}/spring-osgi-io-${spring.osgi.version}.jar=30
-org/apache/felix/karaf/deployer/org.apache.felix.karaf.deployer.spring/${pom.version}/org.apache.felix.karaf.deployer.spring-${pom.version}.jar=30
-org/apache/felix/karaf/deployer/org.apache.felix.karaf.deployer.blueprint/${pom.version}/org.apache.felix.karaf.deployer.blueprint-${pom.version}.jar=30
-org/apache/felix/karaf/deployer/org.apache.felix.karaf.deployer.features/${pom.version}/org.apache.felix.karaf.deployer.features-${pom.version}.jar=30
-org/apache/felix/karaf/org.apache.felix.karaf.management/${pom.version}/org.apache.felix.karaf.management-${pom.version}.jar=30
-org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.admin/${pom.version}/org.apache.felix.karaf.gshell.admin-${pom.version}.jar=30
-org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.osgi/${pom.version}/org.apache.felix.karaf.gshell.osgi-${pom.version}.jar=30
-org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.features/${pom.version}/org.apache.felix.karaf.gshell.features-${pom.version}.jar=30
-org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.log/${pom.version}/org.apache.felix.karaf.gshell.log-${pom.version}.jar=30
-org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.config/${pom.version}/org.apache.felix.karaf.gshell.config-${pom.version}.jar=30
-org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.packages/${pom.version}/org.apache.felix.karaf.gshell.packages-${pom.version}.jar=30
-org/apache/felix/karaf/jaas/org.apache.felix.karaf.jaas.config/${pom.version}/org.apache.felix.karaf.jaas.config-${pom.version}.jar=30
-org/apache/felix/karaf/jaas/org.apache.felix.karaf.jaas.modules/${pom.version}/org.apache.felix.karaf.jaas.modules-${pom.version}.jar=30
-org/apache/mina/mina-core/${mina.version}/mina-core-${mina.version}.jar=30
-org/apache/sshd/sshd-core/${sshd.version}/sshd-core-${sshd.version}.jar=30
-org/osgi/jmx/${osgi.jmx.version}/jmx-${osgi.jmx.version}.jar=30
-com/oracle/osgi/jmx-impl/${osgi.jmx.version}/jmx-impl-${osgi.jmx.version}.jar=30
-
-#
-# Start console last
-#
-org/apache/felix/karaf/gshell/org.apache.felix.karaf.gshell.run/${pom.version}/org.apache.felix.karaf.gshell.run-${pom.version}.jar=40
-
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/AdminServiceImpl.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/AdminServiceImpl.java
index 48d03b4..4aea5b5 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/AdminServiceImpl.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/AdminServiceImpl.java
@@ -27,19 +27,17 @@
import java.util.Map;
import java.util.Scanner;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.gshell.shell.ShellContext;
-import org.apache.geronimo.gshell.shell.ShellContextHolder;
import org.apache.felix.karaf.gshell.admin.AdminService;
import org.apache.felix.karaf.gshell.admin.Instance;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
import org.osgi.service.prefs.PreferencesService;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
public class AdminServiceImpl implements AdminService {
- private static final Log LOGGER = LogFactory.getLog(AdminServiceImpl.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(AdminServiceImpl.class);
private PreferencesService preferences;
@@ -117,11 +115,14 @@
mkdir(serviceMixBase, "data");
copyResourceToDir(serviceMixBase, "etc/config.properties", true);
+ copyResourceToDir(serviceMixBase, "etc/java.util.logging.properties", true);
+ copyResourceToDir(serviceMixBase, "etc/org.apache.felix.karaf.log.cfg", true);
copyResourceToDir(serviceMixBase, "etc/org.apache.felix.karaf.features.cfg", true);
- copyResourceToDir(serviceMixBase, "etc/users.properties", true);
+ copyResourceToDir(serviceMixBase, "etc/org.apache.felix.karaf.management.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/users.properties", true);
HashMap<String, String> props = new HashMap<String, String>();
props.put("${karaf.name}", name);
@@ -206,12 +207,7 @@
}
private void println(String st) {
- ShellContext ctx = ShellContextHolder.get(true);
- if (ctx != null) {
- ctx.getIo().out.println(st);
- } else {
- System.out.println(st);
- }
+ System.out.println(st);
}
private void copyFilteredResourceToDir(File target, String resource, HashMap<String, String> props) throws Exception {
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/InstanceImpl.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/InstanceImpl.java
index 0ab14c6..e851e1e 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/InstanceImpl.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/InstanceImpl.java
@@ -26,16 +26,16 @@
import java.net.Socket;
import java.util.Properties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.felix.karaf.gshell.admin.Instance;
import org.apache.felix.karaf.jpm.Process;
import org.apache.felix.karaf.jpm.ProcessBuilderFactory;
import org.apache.felix.karaf.jpm.impl.ScriptUtils;
-import org.apache.felix.karaf.gshell.admin.Instance;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class InstanceImpl implements Instance {
- private static final Log LOG = LogFactory.getLog(InstanceImpl.class);
+ private static final Logger LOG = LoggerFactory.getLogger(InstanceImpl.class);
private AdminServiceImpl service;
private String name;
@@ -130,12 +130,13 @@
}
String command = new File(System.getProperty("java.home"), ScriptUtils.isWindows() ? "bin\\java.exe" : "bin/java").getCanonicalPath()
+ " " + javaOpts
+ + " -Djava.util.logging.config.file=\"" + new File(location, "etc/java.util.logging.properties").getCanonicalPath() + "\""
+ " -Dkaraf.home=\"" + System.getProperty("karaf.home") + "\""
+ " -Dkaraf.base=\"" + new File(location).getCanonicalPath() + "\""
+ " -Dkaraf.startLocalConsole=false"
+ " -Dkaraf.startRemoteShell=true"
+ " -classpath " + classpath.toString()
- + " org.apache.felix.karaf.main.Main";
+ + " org.apache.felix.karaf.main.Bootstrap";
LOG.debug("Starting instance with command: " + command);
this.process = ProcessBuilderFactory.newInstance().newBuilder()
.directory(new File(location))
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/AdminCommandSupport.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/AdminCommandSupport.java
index 6880560..fa45e41 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/AdminCommandSupport.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/AdminCommandSupport.java
@@ -18,7 +18,7 @@
import org.apache.felix.karaf.gshell.admin.AdminService;
import org.apache.felix.karaf.gshell.admin.Instance;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
public abstract class AdminCommandSupport extends OsgiCommandSupport {
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ChangePortCommand.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ChangePortCommand.java
index 02d9bd9..08706af 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ChangePortCommand.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ChangePortCommand.java
@@ -16,7 +16,7 @@
*/
package org.apache.felix.karaf.gshell.admin.internal.commands;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
public class ChangePortCommand extends AdminCommandSupport {
@@ -28,6 +28,6 @@
protected Object doExecute() throws Exception {
getExistingInstance(instance).changePort(port);
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ConnectCommand.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ConnectCommand.java
index 83caa55..6c112ad 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ConnectCommand.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ConnectCommand.java
@@ -18,24 +18,23 @@
*/
package org.apache.felix.karaf.gshell.admin.internal.commands;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.shell.ShellContextHolder;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.gogo.commands.Argument;
public class ConnectCommand extends AdminCommandSupport {
- @Argument(index=0, required=true, description="The instance name")
+ @Argument(index=0, name="INSTANCE", required=true, description="The instance name")
private String instance = null;
- @Option(name="-u", aliases={"--username"}, token="USERNAME", description="Remote user name")
- private String username = "smx";
+ @Option(name="-u", aliases={"--username"}, description="Remote user name")
+ private String username = "karaf";
- @Option(name="-p", aliases={"--password"}, token="PASSWORD", description="Remote user password")
- private String password = "smx";
+ @Option(name="-p", aliases={"--password"}, description="Remote user password")
+ private String password = "karaf";
protected Object doExecute() throws Exception {
int port = getExistingInstance(instance).getPort();
- ShellContextHolder.get().getShell().execute("ssh -l " + username + " -P " + password + " -p " + port + " localhost");
- return Result.SUCCESS;
+ session.execute("ssh -l " + username + " -P " + password + " -p " + port + " localhost");
+ return null;
}
}
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/CreateCommand.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/CreateCommand.java
index 2bc1309..abf306e 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/CreateCommand.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/CreateCommand.java
@@ -16,8 +16,9 @@
*/
package org.apache.felix.karaf.gshell.admin.internal.commands;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Option;
+
/**
* Creates a new Karaf instance
@@ -37,7 +38,7 @@
protected Object doExecute() throws Exception {
getAdminService().createInstance(instance, port, location);
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/DestroyCommand.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/DestroyCommand.java
index b41dd8c..34f23c1 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/DestroyCommand.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/DestroyCommand.java
@@ -16,7 +16,7 @@
*/
package org.apache.felix.karaf.gshell.admin.internal.commands;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
/**
* Destroy an existing Karaf instance
@@ -30,7 +30,7 @@
protected Object doExecute() throws Exception {
getExistingInstance(instance).destroy();
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ListCommand.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ListCommand.java
index 62c0c22..eb4a118 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ListCommand.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/ListCommand.java
@@ -16,7 +16,7 @@
*/
package org.apache.felix.karaf.gshell.admin.internal.commands;
-import org.apache.geronimo.gshell.clp.Option;
+import org.apache.felix.gogo.commands.Option;
import org.apache.felix.karaf.gshell.admin.Instance;
/**
@@ -30,9 +30,9 @@
protected Object doExecute() throws Exception {
Instance[] instances = getAdminService().getInstances();
if (location) {
- io.out.println(" Port State Pid Location");
+ System.out.println(" Port State Pid Location");
} else {
- io.out.println(" Port State Pid Name");
+ System.out.println(" Port State Pid Name");
}
for (Instance instance : instances) {
StringBuilder sb = new StringBuilder();
@@ -60,9 +60,9 @@
} else {
sb.append(instance.getName());
}
- io.out.println(sb.toString());
+ System.out.println(sb.toString());
}
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/StartCommand.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/StartCommand.java
index f701797..dfd8068 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/StartCommand.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/StartCommand.java
@@ -16,8 +16,8 @@
*/
package org.apache.felix.karaf.gshell.admin.internal.commands;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.gogo.commands.Argument;
public class StartCommand extends AdminCommandSupport {
@@ -29,6 +29,6 @@
protected Object doExecute() throws Exception {
getExistingInstance(instance).start(javaOpts);
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/StopCommand.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/StopCommand.java
index 0d1e65e..4f80645 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/StopCommand.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/commands/StopCommand.java
@@ -16,7 +16,7 @@
*/
package org.apache.felix.karaf.gshell.admin.internal.commands;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
public class StopCommand extends AdminCommandSupport {
@@ -25,6 +25,6 @@
protected Object doExecute() throws Exception {
getExistingInstance(instance).stop();
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/completers/InstanceCompleter.java b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/completers/InstanceCompleter.java
index b202d3d..cbdb00b 100644
--- a/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/completers/InstanceCompleter.java
+++ b/karaf/gshell/gshell-admin/src/main/java/org/apache/felix/karaf/gshell/admin/internal/completers/InstanceCompleter.java
@@ -20,8 +20,8 @@
import org.apache.felix.karaf.gshell.admin.AdminService;
import org.apache.felix.karaf.gshell.admin.Instance;
-import org.apache.geronimo.gshell.console.completer.StringsCompleter;
-import jline.Completor;
+import org.apache.felix.karaf.gshell.console.completer.StringsCompleter;
+import org.apache.felix.karaf.gshell.console.Completer;
/**
* {@link jline.Completor} for server instance names.
@@ -29,7 +29,7 @@
* Displays a list of configured server instances for the Admin commands.
*
*/
-public class InstanceCompleter implements Completor {
+public class InstanceCompleter implements Completer {
private AdminService adminService;
public void setAdminService(AdminService adminService) {
diff --git a/karaf/gshell/gshell-admin/src/main/resources/OSGI-INF/blueprint/gshell-admin.xml b/karaf/gshell/gshell-admin/src/main/resources/OSGI-INF/blueprint/gshell-admin.xml
index 1e52c51..e82b4c1 100644
--- a/karaf/gshell/gshell-admin/src/main/resources/OSGI-INF/blueprint/gshell-admin.xml
+++ b/karaf/gshell/gshell-admin/src/main/resources/OSGI-INF/blueprint/gshell-admin.xml
@@ -22,13 +22,11 @@
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
<command name="admin/create">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.CreateCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
</command>
<command name="admin/connect">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.ConnectCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
<completers>
@@ -38,13 +36,11 @@
</command>
<command name="admin/list">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.ListCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
</command>
<command name="admin/start">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.StartCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
<completers>
@@ -54,7 +50,6 @@
</command>
<command name="admin/stop">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.StopCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
<completers>
@@ -64,7 +59,6 @@
</command>
<command name="admin/destroy">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.DestroyCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
<completers>
@@ -74,7 +68,6 @@
</command>
<command name="admin/change-port">
<action class="org.apache.felix.karaf.gshell.admin.internal.commands.ChangePortCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="adminService" ref="adminService" />
</action>
<completers>
@@ -94,5 +87,4 @@
<property name="adminService" ref="adminService" />
</bean>
-
</blueprint>
diff --git a/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/org.ops4j.pax.logging.cfg b/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/org.ops4j.pax.logging.cfg
deleted file mode 100644
index eca5c0e..0000000
--- a/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/org.ops4j.pax.logging.cfg
+++ /dev/null
@@ -1,36 +0,0 @@
-################################################################################
-#
-# 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.
-#
-################################################################################
-
-# Root logger
-log4j.rootLogger=INFO, out, osgi:VmLogAppender
-
-# Logger infos
-log4j.logger.org.apache.geronimo.gshell.remote=WARN
-
-# CONSOLE appender not used by default
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
-
-# File appender
-log4j.appender.out=org.apache.log4j.FileAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
-log4j.appender.out.file=${karaf.base}/data/log/karaf.log
-log4j.appender.out.append=true
diff --git a/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/org.ops4j.pax.url.mvn.cfg b/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/org.ops4j.pax.url.mvn.cfg
index 3f1ac71..9ae4b8a 100644
--- a/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/org.ops4j.pax.url.mvn.cfg
+++ b/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/org.ops4j.pax.url.mvn.cfg
@@ -55,7 +55,8 @@
#
# The following property value will add the system folder as a repo.
#
-org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}/system@snapshots,file:${karaf.base}/system@snapshots
+org.ops4j.pax.url.mvn.defaultRepositories=file:${karaf.home}/system@snapshots, \
+ file:${karaf.base}/system@snapshots
#
# Comma separated list of repositories scanned when resolving an artifact.
@@ -68,6 +69,12 @@
# @snapshots : the repository contains snaphots
# @noreleases : the repository does not contain any released artifacts
#
-# The following property value will add the system folders as a repo.
+# The following property value will add the system folder as a repo.
#
-org.ops4j.pax.url.mvn.repositories=file:${karaf.base}/system@snapshots,file:${user.home}/.m2/repository@snapshots,http://repo1.maven.org/maven2,http://people.apache.org/repo/m2-snapshot-repository@snapshots@noreleases,http://svn.apache.org/repos/asf/servicemix/m2-repo
+org.ops4j.pax.url.mvn.repositories= \
+ http://repo1.maven.org/maven2, \
+ http://people.apache.org/repo/m2-snapshot-repository@snapshots@noreleases, \
+ http://repository.ops4j.org/maven2, \
+ http://svn.apache.org/repos/asf/servicemix/m2-repo, \
+ http://repository.springsource.com/maven/bundles/release, \
+ http://repository.springsource.com/maven/bundles/external
diff --git a/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/system.properties b/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/system.properties
index 78fba0f..32f7f3d 100644
--- a/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/system.properties
+++ b/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/system.properties
@@ -19,3 +19,4 @@
org.ops4j.pax.logging.DefaultServiceLog.level=ERROR
karaf.name=${karaf.name}
+xml.catalog.files=
diff --git a/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/users.properties b/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/users.properties
deleted file mode 100644
index b91ac84..0000000
--- a/karaf/gshell/gshell-admin/src/main/resources/org/apache/felix/karaf/gshell/admin/etc/users.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-################################################################################
-#
-# 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.
-#
-################################################################################
-
-#
-karaf=karaf,admin
diff --git a/karaf/gshell/gshell-commands/pom.xml b/karaf/gshell/gshell-commands/pom.xml
new file mode 100644
index 0000000..86128a6
--- /dev/null
+++ b/karaf/gshell/gshell-commands/pom.xml
@@ -0,0 +1,76 @@
+<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.felix.karaf.gshell</groupId>
+ <artifactId>gshell</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.felix.karaf.gshell</groupId>
+ <artifactId>org.apache.felix.karaf.gshell.commands</artifactId>
+ <packaging>bundle</packaging>
+ <version>1.2.0-SNAPSHOT</version>
+ <name>Apache Felix Karaf :: GShell Various Commands</name>
+
+ <description>
+ Provides SSH support to the console
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix.karaf.gshell</groupId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${pom.basedir}/src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
+ <Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
+ <Import-Package>
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.felix.karaf.gshell.console,
+ *
+ </Import-Package>
+ <_versionpolicy>${bnd.version.policy}</_versionpolicy>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/CatAction.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/CatAction.java
new file mode 100644
index 0000000..3462320
--- /dev/null
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/CatAction.java
@@ -0,0 +1,103 @@
+/*
+ * 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.felix.karaf.gshell.commands;
+
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.FileReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URI;
+import java.net.MalformedURLException;
+import java.util.List;
+
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.gogo.commands.Command;
+
+/**
+ * Concatenate and print files and/or URLs.
+ *
+ * @version $Rev: 593392 $ $Date: 2007-11-09 03:14:15 +0100 (Fri, 09 Nov 2007) $
+ */
+@Command(scope = "shell", name = "cat", description = "Displays the content of a file or url")
+public class CatAction extends OsgiCommandSupport {
+
+ @Option(name="-n", description = "Number the output lines, starting at 1.")
+ private boolean displayLineNumbers;
+
+ @Argument(required = true, multiValued = true)
+ private List<String> paths;
+
+ protected Object doExecute() throws Exception {
+ //
+ // Support "-" if length is one, and read from io.in
+ // This will help test command pipelines.
+ //
+ if (paths.size() == 1 && "-".equals(paths.get(0))) {
+ log.info("Printing STDIN");
+ cat(new BufferedReader(new InputStreamReader(System.in)));
+ }
+ else {
+ for (String filename : paths) {
+ BufferedReader reader;
+
+ // First try a URL
+ try {
+ URL url = new URL(filename);
+ log.info("Printing URL: " + url);
+ reader = new BufferedReader(new InputStreamReader(url.openStream()));
+ }
+ catch (MalformedURLException ignore) {
+ // They try a file
+ File file = new File(filename);
+ log.info("Printing file: " + file);
+ reader = new BufferedReader(new FileReader(file));
+ }
+
+ try {
+ cat(reader);
+ }
+ finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+ private void cat(final BufferedReader reader) throws IOException
+ {
+ String line;
+ int lineno = 1;
+
+ while ((line = reader.readLine()) != null) {
+ if (displayLineNumbers) {
+ System.out.print(String.format("%6d ", lineno++));
+ }
+ System.out.println(line);
+ }
+ }
+}
diff --git a/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/EchoCommand.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/EchoCommand.java
new file mode 100644
index 0000000..4d575c7
--- /dev/null
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/EchoCommand.java
@@ -0,0 +1,11 @@
+package org.apache.felix.karaf.gshell.commands;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Jul 9, 2009
+ * Time: 1:06:45 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class EchoCommand {
+}
diff --git a/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/ExecuteAction.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/ExecuteAction.java
new file mode 100644
index 0000000..4b7643f
--- /dev/null
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/ExecuteAction.java
@@ -0,0 +1,60 @@
+/*
+ * 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.felix.karaf.gshell.commands;
+
+import java.util.List;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.karaf.gshell.commands.utils.PumpStreamHandler;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+
+/**
+ * Execute system processes.
+ *
+ * @version $Rev: 593392 $ $Date: 2007-11-09 03:14:15 +0100 (Fri, 09 Nov 2007) $
+ */
+@Command(scope = "shell", name = "exec", description = "Execute system processes")
+public class ExecuteAction extends OsgiCommandSupport {
+
+ @Argument(description = "Arguments", required = true, multiValued = true)
+ private List<String> args;
+
+ protected Object doExecute() throws Exception {
+ ProcessBuilder builder = new ProcessBuilder(args);
+
+ log.info("Executing: {}", builder.command());
+
+ Process p = builder.start();
+
+ PumpStreamHandler handler = new PumpStreamHandler(System.in, System.out, System.err);
+ handler.attach(p);
+ handler.start();
+
+ log.debug("Waiting for process to exit...");
+
+ int status = p.waitFor();
+
+
+ log.info("Process exited w/status: {}", status);
+
+ handler.stop();
+
+ return status;
+ }
+
+}
diff --git a/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/GrepAction.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/GrepAction.java
new file mode 100644
index 0000000..a8720c2
--- /dev/null
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/GrepAction.java
@@ -0,0 +1,98 @@
+/*
+ * 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.felix.karaf.gshell.commands;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.InputStreamReader;
+import java.util.regex.Pattern;
+
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.gogo.commands.Command;
+
+
+@Command(scope = "shell", name="grep", description="Print lines matching a pattern")
+public class GrepAction extends OsgiCommandSupport {
+
+ @Argument(required=true, description="Regular expression")
+ private String regex;
+
+ @Option(name="-n", aliases = { "--line-number" }, description="Prefix each line of output with the line number within its input file.")
+ private boolean lineNumber;
+
+ @Option(name = "-v", aliases = { "--invert-match" }, description = "Invert the sense of matching, to select non-matching lines.")
+ private boolean invertMatch;
+
+ @Option(name = "-w", aliases = { "--word-regexp" }, description = "Select only those lines containing matches that form whole " +
+ "words. The test is that the matching substring must either be " +
+ "at the beginning of the line, or preceded by a non-word constituent " +
+ "character. Similarly, it must be either at the end of " +
+ "the line or followed by a non-word constituent character. " +
+ "Word-constituent characters are letters, digits, and the underscore.")
+ private boolean wordRegexp;
+
+ @Option(name = "-x", aliases = { "--line-regexp" }, description = "Select only those matches that exactly match the whole line.")
+ private boolean lineRegexp;
+
+ protected Object doExecute() throws Exception {
+ String regexp = regex;
+ if (wordRegexp) {
+ regexp = "\\b" + regexp + "\\b";
+ }
+ if (lineRegexp) {
+ regexp = "^" + regexp + "$";
+ } else {
+ regexp = ".*" + regexp + ".*";
+ }
+ Pattern p = Pattern.compile(regexp);
+ try {
+ int lineno = 1;
+ String line;
+ Reader r = new InputStreamReader(System.in);
+ while ((line = readLine(r)) != null) {
+ if (p.matcher(line).matches() ^ invertMatch) {
+ if (lineNumber) {
+ System.out.print(String.format("%6d ", lineno++));
+ }
+ System.out.println(line);
+ lineno++;
+ }
+ }
+ } catch (IOException e) {
+ }
+ return null;
+ }
+
+ private String readLine(Reader in) throws IOException {
+ StringBuffer buf = new StringBuffer();
+ while (true) {
+ int i = in.read();
+ if (i == -1 && buf.length() == 0) {
+ throw new IOException("break");
+ }
+ if (i == -1 || i == '\n' || i == '\r') {
+ return buf.toString();
+ }
+ buf.append((char) i);
+ }
+ }
+
+}
diff --git a/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/HistoryAction.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/HistoryAction.java
new file mode 100644
index 0000000..c7607f1
--- /dev/null
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/HistoryAction.java
@@ -0,0 +1,23 @@
+/*
+ * 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.felix.karaf.gshell.commands;
+
+/**
+ * TODO
+ */
+public class HistoryAction {
+}
diff --git a/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/InfoAction.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/InfoAction.java
new file mode 100644
index 0000000..cd210eb
--- /dev/null
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/InfoAction.java
@@ -0,0 +1,23 @@
+/*
+ * 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.felix.karaf.gshell.commands;
+
+/**
+ * TODO
+ */
+public class InfoAction {
+}
diff --git a/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/JavaAction.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/JavaAction.java
new file mode 100644
index 0000000..693086b
--- /dev/null
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/JavaAction.java
@@ -0,0 +1,74 @@
+/*
+ * 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.felix.karaf.gshell.commands;
+
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+
+/**
+ * Execute a Java standard application.
+ *
+ * <p>By default looks for static main(String[]) to execute, but
+ * you can specify a different static method that takes a String[]
+ * to execute instead.
+ *
+ * @version $Rev: 593392 $ $Date: 2007-11-09 03:14:15 +0100 (Fri, 09 Nov 2007) $
+ */
+@Command(scope = "shell", name = "java", description = "Execute a Java standard application")
+public class JavaAction extends OsgiCommandSupport {
+
+ @Option(name="-m", aliases={"--method"}, description="Invoke a named method")
+ private String methodName = "main";
+
+ @Argument(index=0, name = "className", description="The name of the class to invoke", required=true)
+ private String className;
+
+ @Argument(index=1, name = "args", description="Arguments to pass to the METHOD of CLASSNAME")
+ private List<String> args;
+
+ protected Object doExecute() throws Exception {
+ boolean info = log.isInfoEnabled();
+
+ Class type = Thread.currentThread().getContextClassLoader().loadClass(className);
+ if (info) {
+ log.info("Using type: " + type);
+ }
+
+ Method method = type.getMethod(methodName, String[].class);
+ if (info) {
+ log.info("Using method: " + method);
+ }
+
+ if (info) {
+ log.info("Invoking w/arguments: {}", args);
+ }
+
+ Object result = method.invoke(null, args);
+
+ if (info) {
+ log.info("Result: " + result);
+ }
+
+ return null;
+ }
+
+}
diff --git a/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/PrintfAction.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/PrintfAction.java
new file mode 100644
index 0000000..10bb546
--- /dev/null
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/PrintfAction.java
@@ -0,0 +1,38 @@
+/*
+ * 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.felix.karaf.gshell.commands;
+
+import java.util.Collection;
+
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+@Command(scope = "shell", name = "printf", description = "Format and print arguments")
+public class PrintfAction extends OsgiCommandSupport {
+
+ @Argument(index=0, required=true)
+ private String format;
+
+ @Argument(index=1, multiValued=true, required=true)
+ private Collection<Object> arguments = null;
+
+ protected Object doExecute() throws Exception {
+ System.out.printf(format, arguments.toArray());
+ return null;
+ }
+}
diff --git a/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SleepAction.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SleepAction.java
new file mode 100644
index 0000000..ad8b831
--- /dev/null
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SleepAction.java
@@ -0,0 +1,42 @@
+/*
+ * 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.felix.karaf.gshell.commands;
+
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+@Command(scope = "shell", name = "sleep", description = "Sleep for a bit then wake up")
+public class SleepAction extends OsgiCommandSupport {
+
+ @Argument(required=true)
+ private int time = -1;
+
+ protected Object doExecute() throws Exception {
+ log.info("Sleeping for {}", time);
+
+ try {
+ Thread.sleep(time);
+ }
+ catch (InterruptedException ignore) {
+ log.debug("Sleep was interrupted... :-(");
+ }
+
+ log.info("Awake now");
+ return null;
+ }
+}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/text/SortAction.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SortAction.java
similarity index 80%
rename from karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/text/SortAction.java
rename to karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SortAction.java
index e81b247..d610fce 100644
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/text/SortAction.java
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SortAction.java
@@ -16,14 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.felix.karaf.gshell.commands;
-package org.apache.geronimo.gshell.commands.text;
-
-import java.io.BufferedInputStream;
import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.PrintWriter;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -31,89 +34,96 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.vfs.FileObject;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.io.Closer;
-import org.apache.geronimo.gshell.vfs.FileObjects;
-import org.apache.geronimo.gshell.vfs.support.VfsActionSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
/**
* Sort lines of text
*
- * TODO: remove this file when gshell is upgraded
- *
+ * @version $Rev: 722776 $ $Date: 2008-12-03 05:59:59 +0100 (Wed, 03 Dec 2008) $
*/
-public class SortAction extends VfsActionSupport {
+@Command(scope = "shell", name = "sort", description = "Write sorted concatenation of all FILE(s) to standard output.")
+public class SortAction extends OsgiCommandSupport {
- @Option(name = "-f")
+ @Option(name = "-f", aliases = { "-ignore-case" }, description = "fold lower case to upper case characters")
private boolean caseInsensitive;
- @Option(name = "-r")
+ @Option(name = "-r", aliases = { "--reverse" }, description = "reverse the result of comparisons")
private boolean reverse;
- @Option(name = "-u")
+ @Option(name = "-u", aliases = { "--unique" }, description = "output only the first of an equal run")
private boolean unique;
- @Option(name = "-t")
+ @Option(name = "-t", aliases = { "--field-separator" }, description = "use SEP instead of non-blank to blank transition")
private String separator;
- @Option(name = "-b")
+ @Option(name = "-b", aliases = { "--ignore-leading-blanks" }, description = "ignore leading blanks")
private boolean ignoreBlanks;
- @Option(name = "-k", argumentRequired = true, multiValued = true)
+ @Option(name = "-k", aliases = { "--key" }, multiValued = true)
private List<String> sortFields;
- @Option(name = "-n")
+ @Option(name = "-n", aliases = { "--numeric-sort" }, description = "compare according to string numerical value")
private boolean numeric;
- @Argument(index = 0, required=false)
- private String path;
+ @Argument(index = 0, required = false, multiValued = true)
+ private List<String> paths;
- public Object execute(CommandContext context) throws Exception {
- assert context != null;
+ public Object doExecute() throws Exception {
+ if (paths != null && paths.size() > 0) {
+ List<String> lines = new ArrayList<String>();
+ for (String filename : paths) {
+ BufferedReader reader;
- if (path != null) {
- FileObject file = resolveFile(context, path);
+ // First try a URL
+ try {
+ URL url = new URL(filename);
+ log.info("Printing URL: " + url);
+ reader = new BufferedReader(new InputStreamReader(url.openStream()));
+ }
+ catch (MalformedURLException ignore) {
+ // They try a file
+ File file = new File(filename);
+ log.info("Printing file: " + file);
+ reader = new BufferedReader(new FileReader(file));
+ }
- try {
- sort(context, file);
+ try {
+ read(reader, lines);
+ }
+ finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
}
- finally {
- FileObjects.close(file);
- }
+ sort(lines, System.out);
}
else {
- sort(context.getIo().inputStream, context.getIo().out);
+ sort(System.in, System.out);
}
- return Result.SUCCESS;
+ return null;
}
- protected void sort(final CommandContext context, final FileObject file) throws Exception {
- assert context != null;
- assert file != null;
-
- ensureFileExists(file);
- ensureFileHasContent(file);
- ensureFileIsReadable(file);
-
- BufferedInputStream input = new BufferedInputStream(file.getContent().getInputStream());
- try {
- sort(input, context.getIo().out);
- }
- finally {
- Closer.close(input);
- }
- }
-
- protected void sort(InputStream input, PrintWriter out) throws Exception {
- BufferedReader r = new BufferedReader(new InputStreamReader(input));
- List<String> strings = new ArrayList<String>();
+ protected void read(BufferedReader r, List<String> lines) throws Exception {
for (String s = r.readLine(); s != null; s = r.readLine()) {
- strings.add(s);
+ lines.add(s);
}
+ }
+
+ protected void sort(InputStream input, PrintStream out) throws Exception {
+ List<String> strings = new ArrayList<String>();
+ BufferedReader r = new BufferedReader(new InputStreamReader(input));
+ read(r, strings);
+ sort(strings, out);
+ }
+
+ protected void sort(List<String> strings, PrintStream out) throws Exception {
char sep = (separator == null || separator.length() == 0) ? '\0' : separator.charAt(0);
Collections.sort(strings, new SortComparator(caseInsensitive, reverse, ignoreBlanks, numeric, sep, sortFields));
String last = null;
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SourceAction.java
similarity index 70%
copy from karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java
copy to karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SourceAction.java
index f6b19e0..5c827e4 100644
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/SourceAction.java
@@ -16,14 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.felix.karaf.gshell.core.sshd;
+package org.apache.felix.karaf.gshell.commands;
-import org.apache.sshd.server.PasswordAuthenticator;
-
-public class BogusPasswordAuthenticator implements PasswordAuthenticator {
-
- public Object authenticate(String username, String password) {
- return (username != null && username.equals(password)) ? username : null;
- }
-
+/**
+ * TODO
+ */
+public class SourceAction {
}
diff --git a/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/PumpStreamHandler.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/PumpStreamHandler.java
new file mode 100644
index 0000000..78a5a56
--- /dev/null
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/PumpStreamHandler.java
@@ -0,0 +1,232 @@
+/*
+ * 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.felix.karaf.gshell.commands.utils;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
+//
+// Based on Apache Ant 1.6.5
+//
+
+/**
+ * Copies standard output and error of children streams to standard output and error of the parent.
+ *
+ * @version $Rev: 705608 $ $Date: 2008-10-17 15:28:45 +0200 (Fri, 17 Oct 2008) $
+ */
+public class PumpStreamHandler
+{
+ private InputStream in;
+
+ private OutputStream out;
+
+ private OutputStream err;
+
+ private Thread outputThread;
+
+ private Thread errorThread;
+
+ private StreamPumper inputPump;
+
+ //
+ // NOTE: May want to use a ThreadPool here, 3 threads per/pair seems kinda expensive :-(
+ //
+
+ public PumpStreamHandler(final InputStream in, final OutputStream out, final OutputStream err) {
+ assert in != null;
+ assert out != null;
+ assert err != null;
+
+ this.in = in;
+ this.out = out;
+ this.err = err;
+ }
+
+ public PumpStreamHandler(final OutputStream out, final OutputStream err) {
+ this(null, out, err);
+ }
+
+ public PumpStreamHandler(final OutputStream outAndErr) {
+ this(outAndErr, outAndErr);
+ }
+
+ /**
+ * Set the input stream from which to read the standard output of the child.
+ */
+ public void setChildOutputStream(final InputStream in) {
+ assert in != null;
+
+ createChildOutputPump(in, out);
+ }
+
+ /**
+ * Set the input stream from which to read the standard error of the child.
+ */
+ public void setChildErrorStream(final InputStream in) {
+ assert in != null;
+
+ if (err != null) {
+ createChildErrorPump(in, err);
+ }
+ }
+
+ /**
+ * Set the output stream by means of which input can be sent to the child.
+ */
+ public void setChildInputStream(final OutputStream out) {
+ assert out != null;
+
+ if (in != null) {
+ inputPump = createInputPump(in, out, true);
+ }
+ else {
+ try {
+ out.close();
+ } catch (IOException e) { }
+ }
+ }
+
+ /**
+ * Attach to a child streams from the given process.
+ *
+ * @param p The process to attach to.
+ */
+ public void attach(final Process p) {
+ assert p != null;
+
+ setChildInputStream(p.getOutputStream());
+ setChildOutputStream(p.getInputStream());
+ setChildErrorStream(p.getErrorStream());
+ }
+ /**
+ * Start pumping the streams.
+ */
+ public void start() {
+ if (outputThread != null) {
+ outputThread.start();
+ }
+
+ if (errorThread != null) {
+ errorThread.start();
+ }
+
+ if (inputPump != null) {
+ Thread inputThread = new Thread(inputPump);
+ inputThread.setDaemon(true);
+ inputThread.start();
+ }
+ }
+
+ /**
+ * Stop pumping the streams.
+ */
+ public void stop() {
+ if (outputThread != null) {
+ try {
+ outputThread.join();
+ }
+ catch (InterruptedException e) {
+ // ignore
+ }
+ }
+
+ if (errorThread != null) {
+ try {
+ errorThread.join();
+ }
+ catch (InterruptedException e) {
+ // ignore
+ }
+ }
+
+ if (inputPump != null) {
+ inputPump.stop();
+ }
+
+ try {
+ err.flush();
+ } catch (IOException e) { }
+ try {
+ out.flush();
+ } catch (IOException e) { }
+ }
+
+ /**
+ * Create the pump to handle child output.
+ */
+ protected void createChildOutputPump(final InputStream in, final OutputStream out) {
+ assert in != null;
+ assert out != null;
+
+ outputThread = createPump(in, out);
+ }
+
+ /**
+ * Create the pump to handle error output.
+ */
+ protected void createChildErrorPump(final InputStream in, final OutputStream out) {
+ assert in != null;
+ assert out != null;
+
+ errorThread = createPump(in, out);
+ }
+
+ /**
+ * Creates a stream pumper to copy the given input stream to the given output stream.
+ */
+ protected Thread createPump(final InputStream in, final OutputStream out) {
+ assert in != null;
+ assert out != null;
+
+ return createPump(in, out, false);
+ }
+
+ /**
+ * Creates a stream pumper to copy the given input stream to the
+ * given output stream.
+ *
+ * @param in The input stream to copy from.
+ * @param out The output stream to copy to.
+ * @param closeWhenExhausted If true close the inputstream.
+ * @return A thread object that does the pumping.
+ */
+ protected Thread createPump(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
+ assert in != null;
+ assert out != null;
+
+ final Thread result = new Thread(new StreamPumper(in, out, closeWhenExhausted));
+ result.setDaemon(true);
+ return result;
+ }
+
+ /**
+ * Creates a stream pumper to copy the given input stream to the
+ * given output stream. Used for standard input.
+ */
+ protected StreamPumper createInputPump(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
+ assert in != null;
+ assert out != null;
+
+ StreamPumper pumper = new StreamPumper(in, out, closeWhenExhausted);
+ pumper.setAutoflush(true);
+ return pumper;
+ }
+}
\ No newline at end of file
diff --git a/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/StreamPumper.java b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/StreamPumper.java
new file mode 100644
index 0000000..a2dd553
--- /dev/null
+++ b/karaf/gshell/gshell-commands/src/main/java/org/apache/felix/karaf/gshell/commands/utils/StreamPumper.java
@@ -0,0 +1,199 @@
+/*
+ * 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.felix.karaf.gshell.commands.utils;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
+//
+// Based on Apache Ant 1.6.5
+//
+
+/**
+ * Copies all data from an input stream to an output stream.
+ *
+ * @version $Rev: 705608 $ $Date: 2008-10-17 15:28:45 +0200 (Fri, 17 Oct 2008) $
+ */
+public class StreamPumper
+ implements Runnable
+{
+ private InputStream in;
+
+ private OutputStream out;
+
+ private volatile boolean finish;
+
+ private volatile boolean finished;
+
+ private boolean closeWhenExhausted;
+
+ private boolean autoflush;
+
+ private Exception exception;
+
+ private int bufferSize = 128;
+
+ private boolean started;
+
+ /**
+ * Create a new stream pumper.
+ *
+ * @param in Input stream to read data from
+ * @param out Output stream to write data to.
+ * @param closeWhenExhausted If true, the output stream will be closed when
+ * the input is exhausted.
+ */
+ public StreamPumper(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
+ assert in != null;
+ assert out != null;
+
+ this.in = in;
+ this.out = out;
+ this.closeWhenExhausted = closeWhenExhausted;
+ }
+
+ /**
+ * Create a new stream pumper.
+ *
+ * @param in Input stream to read data from
+ * @param out Output stream to write data to.
+ */
+ public StreamPumper(final InputStream in, final OutputStream out) {
+ this(in, out, false);
+ }
+
+ /**
+ * Set whether data should be flushed through to the output stream.
+ *
+ * @param autoflush If true, push through data; if false, let it be buffered
+ */
+ public void setAutoflush(boolean autoflush) {
+ this.autoflush = autoflush;
+ }
+
+ /**
+ * Copies data from the input stream to the output stream.
+ *
+ * Terminates as soon as the input stream is closed or an error occurs.
+ */
+ public void run() {
+ synchronized (this) {
+ started = true;
+ }
+ finished = false;
+ finish = false;
+
+ final byte[] buf = new byte[bufferSize];
+
+ int length;
+ try {
+ while ((length = in.read(buf)) > 0 && !finish) {
+ out.write(buf, 0, length);
+ if (autoflush) {
+ out.flush();
+ }
+ }
+ out.flush();
+ }
+ catch (Exception e) {
+ synchronized (this) {
+ exception = e;
+ }
+ }
+ finally {
+ if (closeWhenExhausted) {
+ try {
+ out.close();
+ } catch (IOException e) { }
+ }
+ finished = true;
+
+ synchronized (this) {
+ notifyAll();
+ }
+ }
+ }
+
+ /**
+ * Tells whether the end of the stream has been reached.
+ *
+ * @return true If the stream has been exhausted.
+ */
+ public boolean isFinished() {
+ return finished;
+ }
+
+ /**
+ * This method blocks until the stream pumper finishes.
+ *
+ * @see #isFinished()
+ */
+ public synchronized void waitFor() throws InterruptedException {
+ while (!isFinished()) {
+ wait();
+ }
+ }
+
+ /**
+ * Set the size in bytes of the read buffer.
+ *
+ * @param bufferSize the buffer size to use.
+ * @throws IllegalStateException if the StreamPumper is already running.
+ */
+ public synchronized void setBufferSize(final int bufferSize) {
+ if (started) {
+ throw new IllegalStateException("Cannot set buffer size on a running StreamPumper");
+ }
+
+ this.bufferSize = bufferSize;
+ }
+
+ /**
+ * Get the size in bytes of the read buffer.
+ *
+ * @return The size of the read buffer.
+ */
+ public synchronized int getBufferSize() {
+ return bufferSize;
+ }
+
+ /**
+ * Get the exception encountered, if any.
+ *
+ * @return The Exception encountered; or null if there was none.
+ */
+ public synchronized Exception getException() {
+ return exception;
+ }
+
+ /**
+ * Stop the pumper as soon as possible.
+ *
+ * Note that it may continue to block on the input stream
+ * but it will really stop the thread as soon as it gets EOF
+ * or any byte, and it will be marked as finished.
+ */
+ public synchronized void stop() {
+ finish = true;
+
+ notifyAll();
+ }
+}
\ No newline at end of file
diff --git a/karaf/gshell/gshell-commands/src/main/resources/OSGI-INF/blueprint/gshell-commands.xml b/karaf/gshell/gshell-commands/src/main/resources/OSGI-INF/blueprint/gshell-commands.xml
new file mode 100644
index 0000000..6b4d900
--- /dev/null
+++ b/karaf/gshell/gshell-commands/src/main/resources/OSGI-INF/blueprint/gshell-commands.xml
@@ -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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
+ <command name="shell/cat">
+ <action class="org.apache.felix.karaf.gshell.commands.CatAction"/>
+ </command>
+ <command name="shell/exec">
+ <action class="org.apache.felix.karaf.gshell.commands.ExecuteAction"/>
+ </command>
+ <command name="shell/grep">
+ <action class="org.apache.felix.karaf.gshell.commands.GrepAction"/>
+ </command>
+ <command name="shell/java">
+ <action class="org.apache.felix.karaf.gshell.commands.JavaAction"/>
+ </command>
+ <command name="shell/printf">
+ <action class="org.apache.felix.karaf.gshell.commands.PrintfAction"/>
+ </command>
+ <command name="shell/sleep">
+ <action class="org.apache.felix.karaf.gshell.commands.SleepAction"/>
+ </command>
+ <command name="shell/sort">
+ <action class="org.apache.felix.karaf.gshell.commands.SortAction"/>
+ </command>
+ </command-bundle>
+
+</blueprint>
diff --git a/karaf/gshell/gshell-core/src/test/java/org/apache/geronimo/gshell/commands/text/SortTest.java b/karaf/gshell/gshell-commands/src/test/java/org/apache/felix/karaf/gshell/commands/SortTest.java
similarity index 88%
rename from karaf/gshell/gshell-core/src/test/java/org/apache/geronimo/gshell/commands/text/SortTest.java
rename to karaf/gshell/gshell-commands/src/test/java/org/apache/felix/karaf/gshell/commands/SortTest.java
index 6bb77a5..6ca9972 100644
--- a/karaf/gshell/gshell-core/src/test/java/org/apache/geronimo/gshell/commands/text/SortTest.java
+++ b/karaf/gshell/gshell-commands/src/test/java/org/apache/felix/karaf/gshell/commands/SortTest.java
@@ -16,26 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.geronimo.gshell.commands.text;
+package org.apache.felix.karaf.gshell.commands;
import java.util.Arrays;
import java.util.List;
import java.util.Collections;
import junit.framework.TestCase;
-import org.apache.geronimo.gshell.ansi.AnsiRenderWriter;
-/**
- * TODO: remove this file when gshell is upgraded
- */
public class SortTest extends TestCase {
- public void testAnsi() {
- AnsiRenderWriter w = new AnsiRenderWriter(System.out);
- w.println("Hey, @|cyan Hello| world");
- w.flush();
- }
-
public void testFieldIndexesDefaultSep() {
SortAction.SortComparator comparator = new SortAction.SortComparator(false, false, false, false, '\0', null);
List<Integer> indexes = comparator.getFieldIndexes(" ad re t ");
diff --git a/karaf/gshell/gshell-config/pom.xml b/karaf/gshell/gshell-config/pom.xml
index 6bf1d97..6b53cf3 100644
--- a/karaf/gshell/gshell-config/pom.xml
+++ b/karaf/gshell/gshell-config/pom.xml
@@ -40,7 +40,7 @@
<dependencies>
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
</dependency>
<dependency>
@@ -54,16 +54,6 @@
<artifactId>org.osgi.compendium</artifactId>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-annotation_1.0_spec</artifactId>
- </dependency>
</dependencies>
<build>
@@ -76,10 +66,9 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
- org.apache.geronimo.gshell.command,
- org.apache.geronimo.gshell.wisdom.command,
- org.apache.geronimo.gshell.wisdom.registry,
- org.apache.felix.karaf.gshell.core,
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.felix.karaf.gshell.console,
*
</Import-Package>
<Private-Package>!*</Private-Package>
diff --git a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/CancelCommand.java b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/CancelCommand.java
index 93a3630..f6b3ff0 100644
--- a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/CancelCommand.java
+++ b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/CancelCommand.java
@@ -21,8 +21,8 @@
public class CancelCommand extends ConfigCommandSupport {
protected void doExecute(ConfigurationAdmin admin) throws Exception {
- this.variables.parent().unset(PROPERTY_CONFIG_PID);
- this.variables.parent().unset(PROPERTY_CONFIG_PROPS);
+ session.put(PROPERTY_CONFIG_PID, null);
+ session.put(PROPERTY_CONFIG_PROPS, null);
}
}
diff --git a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ConfigCommandSupport.java b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ConfigCommandSupport.java
index 8d4e64b..8ab53d1 100644
--- a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ConfigCommandSupport.java
+++ b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ConfigCommandSupport.java
@@ -18,7 +18,7 @@
import java.util.Dictionary;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -37,13 +37,13 @@
// Get config admin service.
ServiceReference ref = getBundleContext().getServiceReference(ConfigurationAdmin.class.getName());
if (ref == null) {
- io.out.println("ConfigurationAdmin service is unavailable.");
+ System.out.println("ConfigurationAdmin service is unavailable.");
return null;
}
try {
ConfigurationAdmin admin = (ConfigurationAdmin) getBundleContext().getService(ref);
if (admin == null) {
- io.out.println("ConfigAdmin service is unavailable.");
+ System.out.println("ConfigAdmin service is unavailable.");
return null;
}
@@ -56,7 +56,7 @@
}
protected Dictionary getEditedProps() throws Exception {
- return (Dictionary) this.variables.parent().get(PROPERTY_CONFIG_PROPS);
+ return (Dictionary) this.session.get(PROPERTY_CONFIG_PROPS);
}
protected abstract void doExecute(ConfigurationAdmin admin) throws Exception;
diff --git a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/EditCommand.java b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/EditCommand.java
index c32029a..75620d6 100644
--- a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/EditCommand.java
+++ b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/EditCommand.java
@@ -18,8 +18,8 @@
import java.util.Dictionary;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Option;
import org.osgi.service.cm.ConfigurationAdmin;
public class EditCommand extends ConfigCommandSupport {
@@ -31,13 +31,13 @@
boolean force;
protected void doExecute(ConfigurationAdmin admin) throws Exception {
- String oldPid = (String) this.variables.get(PROPERTY_CONFIG_PID);
+ String oldPid = (String) this.session.get(PROPERTY_CONFIG_PID);
if (oldPid != null && !oldPid.equals(pid) && !force) {
- io.err.println("Another config is being edited. Cancel / update first, or use the --force option");
+ System.err.println("Another config is being edited. Cancel / update first, or use the --force option");
return;
}
Dictionary props = admin.getConfiguration(pid).getProperties();
- this.variables.parent().set(PROPERTY_CONFIG_PID, pid);
- this.variables.parent().set(PROPERTY_CONFIG_PROPS, props);
+ this.session.put(PROPERTY_CONFIG_PID, pid);
+ this.session.put(PROPERTY_CONFIG_PROPS, props);
}
}
diff --git a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ListCommand.java b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ListCommand.java
index 51a41f0..0e24271 100644
--- a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ListCommand.java
+++ b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/ListCommand.java
@@ -19,9 +19,9 @@
import java.util.Dictionary;
import java.util.Enumeration;
-import org.apache.geronimo.gshell.clp.Argument;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
+import org.apache.felix.gogo.commands.Argument;
public class ListCommand extends ConfigCommandSupport {
@@ -31,18 +31,18 @@
protected void doExecute(ConfigurationAdmin admin) throws Exception {
Configuration[] configs = admin.listConfigurations(query);
for (Configuration config : configs) {
- io.out.println("----------------------------------------------------------------");
- io.out.println("Pid: " + config.getPid());
+ System.out.println("----------------------------------------------------------------");
+ System.out.println("Pid: " + config.getPid());
if (config.getFactoryPid() != null) {
- io.out.println("FactoryPid: " + config.getFactoryPid());
+ System.out.println("FactoryPid: " + config.getFactoryPid());
}
- io.out.println("BundleLocation: " + config.getBundleLocation());
+ System.out.println("BundleLocation: " + config.getBundleLocation());
if (config.getProperties() != null) {
- io.out.println("Properties:");
+ System.out.println("Properties:");
Dictionary props = config.getProperties();
for (Enumeration e = props.keys(); e.hasMoreElements();) {
Object key = e.nextElement();
- io.out.println(" " + key + " = " + props.get(key));
+ System.out.println(" " + key + " = " + props.get(key));
}
}
}
diff --git a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java
index 562ce8a..1db7a95 100644
--- a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java
+++ b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java
@@ -18,7 +18,7 @@
import java.util.Dictionary;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.service.cm.ConfigurationAdmin;
/**
diff --git a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropDelCommand.java b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropDelCommand.java
index b8eb07d..5c3a59c 100644
--- a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropDelCommand.java
+++ b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropDelCommand.java
@@ -18,12 +18,12 @@
import java.util.Dictionary;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.service.cm.ConfigurationAdmin;
public class PropDelCommand extends ConfigCommandSupport {
- @Argument(index = 0, required = true, description = "the property to delete")
+ @Argument(name = "prop", index = 0, required = true, description = "the property to delete")
String prop;
protected void doExecute(ConfigurationAdmin admin) throws Exception {
diff --git a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropListCommand.java b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropListCommand.java
index 9f09229..c5a8893 100644
--- a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropListCommand.java
+++ b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropListCommand.java
@@ -30,7 +30,7 @@
} else {
for (Enumeration e = props.keys(); e.hasMoreElements();) {
Object key = e.nextElement();
- io.out.println(" " + key + " = " + props.get(key));
+ System.out.println(" " + key + " = " + props.get(key));
}
}
}
diff --git a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropSetCommand.java b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropSetCommand.java
index 0d60b31..6ce4e25 100644
--- a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropSetCommand.java
+++ b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropSetCommand.java
@@ -18,7 +18,7 @@
import java.util.Dictionary;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.service.cm.ConfigurationAdmin;
public class PropSetCommand extends ConfigCommandSupport {
diff --git a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/UpdateCommand.java b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/UpdateCommand.java
index 8def27d..02b504a 100644
--- a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/UpdateCommand.java
+++ b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/UpdateCommand.java
@@ -28,11 +28,11 @@
if (props == null) {
System.err.println("No configuration is being edited. Run the edit command first");
} else {
- String pid = (String) this.variables.parent().get(PROPERTY_CONFIG_PID);
+ String pid = (String) this.session.get(PROPERTY_CONFIG_PID);
Configuration cfg = admin.getConfiguration(pid, null);
cfg.update(props);
- this.variables.parent().unset(PROPERTY_CONFIG_PID);
- this.variables.parent().unset(PROPERTY_CONFIG_PROPS);
+ this.session.put(PROPERTY_CONFIG_PID, null);
+ this.session.put(PROPERTY_CONFIG_PROPS, null);
}
}
}
diff --git a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationCompleter.java b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationCompleter.java
index c840e89..022596f 100644
--- a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationCompleter.java
+++ b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationCompleter.java
@@ -23,8 +23,8 @@
import java.util.Collection;
import java.util.List;
-import jline.Completor;
-import org.apache.geronimo.gshell.console.completer.StringsCompleter;
+import org.apache.felix.karaf.gshell.console.completer.StringsCompleter;
+import org.apache.felix.karaf.gshell.console.Completer;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.cm.ConfigurationEvent;
@@ -36,7 +36,7 @@
* Displays a list of existing config admin configurations for completion.
*
*/
-public class ConfigurationCompleter implements Completor, ConfigurationListener {
+public class ConfigurationCompleter implements Completer, ConfigurationListener {
private final StringsCompleter delegate = new StringsCompleter();
diff --git a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationPropertyCompleter.java b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationPropertyCompleter.java
index b44c00e..48472ba 100644
--- a/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationPropertyCompleter.java
+++ b/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/completers/ConfigurationPropertyCompleter.java
@@ -19,15 +19,9 @@
package org.apache.felix.karaf.gshell.config.completers;
-import java.util.Dictionary;
-import java.util.Enumeration;
import java.util.List;
-import jline.Completor;
-import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.console.completer.StringsCompleter;
-import org.apache.geronimo.gshell.shell.ShellContextHolder;
-import org.apache.felix.karaf.gshell.config.ConfigCommandSupport;
+import org.apache.felix.karaf.gshell.console.Completer;
/**
* {@link jline.Completor} for Configuration Admin properties.
@@ -35,22 +29,24 @@
* Displays a list of existing properties based on the current configuration being edited.
*
*/
-public class ConfigurationPropertyCompleter implements Completor {
+public class ConfigurationPropertyCompleter implements Completer {
public int complete(final String buffer, final int cursor, final List candidates) {
- Variables vars = ShellContextHolder.get().getVariables();
- if (vars.get(ConfigCommandSupport.PROPERTY_CONFIG_PID) == null) {
- return -1;
- }
+ // TODO: currently we have no way to access the session which is being run in this thread
+ return -1;
- Dictionary props = (Dictionary) vars.get(ConfigCommandSupport.PROPERTY_CONFIG_PROPS);
- StringsCompleter delegate = new StringsCompleter();
-
- for (Enumeration e = props.keys(); e.hasMoreElements();) {
- String key = (String) e.nextElement();
- delegate.getStrings().add(key);
- }
-
- return delegate.complete(buffer, cursor, candidates);
+// if (vars.get(ConfigCommandSupport.PROPERTY_CONFIG_PID) == null) {
+// return -1;
+// }
+//
+// Dictionary props = (Dictionary) vars.get(ConfigCommandSupport.PROPERTY_CONFIG_PROPS);
+// StringsCompleter delegate = new StringsCompleter();
+//
+// for (Enumeration e = props.keys(); e.hasMoreElements();) {
+// String key = (String) e.nextElement();
+// delegate.getStrings().add(key);
+// }
+//
+// return delegate.complete(buffer, cursor, candidates);
}
}
diff --git a/karaf/gshell/gshell-config/src/main/resources/OSGI-INF/blueprint/gshell-config.xml b/karaf/gshell/gshell-config/src/main/resources/OSGI-INF/blueprint/gshell-config.xml
index f213c20..673ec3e 100644
--- a/karaf/gshell/gshell-config/src/main/resources/OSGI-INF/blueprint/gshell-config.xml
+++ b/karaf/gshell/gshell-config/src/main/resources/OSGI-INF/blueprint/gshell-config.xml
@@ -21,62 +21,48 @@
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
<command name="config/cancel">
- <action class="org.apache.felix.karaf.gshell.config.CancelCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.CancelCommand"/>
</command>
<command name="config/edit">
- <action class="org.apache.felix.karaf.gshell.config.EditCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.EditCommand"/>
<completers>
<ref component-id="configCompleter" />
<null/>
</completers>
</command>
<command name="config/list">
- <action class="org.apache.felix.karaf.gshell.config.ListCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.ListCommand"/>
</command>
<command name="config/propdel">
- <action class="org.apache.felix.karaf.gshell.config.PropDelCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.PropDelCommand"/>
<completers>
<ref component-id="configPropertyCompleter" />
<null/>
</completers>
</command>
<command name="config/proplist">
- <action class="org.apache.felix.karaf.gshell.config.PropListCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.PropListCommand"/>
</command>
<command name="config/propset">
- <action class="org.apache.felix.karaf.gshell.config.PropSetCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.PropSetCommand"/>
<completers>
<ref component-id="configPropertyCompleter" />
<null/>
</completers>
</command>
<command name="config/update">
- <action class="org.apache.felix.karaf.gshell.config.UpdateCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.config.UpdateCommand"/>
</command>
</command-bundle>
<bean id="configCompleter" class="org.apache.felix.karaf.gshell.config.completers.ConfigurationCompleter" init-method="init">
<property name="admin" ref="configAdmin"/>
</bean>
+ <service ref="configCompleter" interface="org.osgi.service.cm.ConfigurationListener" />
<bean id="configPropertyCompleter" class="org.apache.felix.karaf.gshell.config.completers.ConfigurationPropertyCompleter" />
<reference id="configAdmin" interface="org.osgi.service.cm.ConfigurationAdmin" />
- <service ref="configCompleter" interface="org.osgi.service.cm.ConfigurationListener" />
</blueprint>
diff --git a/karaf/gshell/gshell-console/pom.xml b/karaf/gshell/gshell-console/pom.xml
new file mode 100644
index 0000000..546145e
--- /dev/null
+++ b/karaf/gshell/gshell-console/pom.xml
@@ -0,0 +1,113 @@
+<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.felix.karaf.gshell</groupId>
+ <artifactId>gshell</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.felix.karaf.gshell</groupId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
+ <packaging>bundle</packaging>
+ <version>1.2.0-SNAPSHOT</version>
+ <name>Apache Felix Karaf :: GShell Console</name>
+
+ <description>
+ Provides the OSGi GShell integration
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.jline</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo</groupId>
+ <artifactId>blueprint-bundle</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix.gogo</groupId>
+ <artifactId>org.apache.felix.gogo.runtime</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix.gogo</groupId>
+ <artifactId>org.apache.felix.gogo.commands</artifactId>
+ </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>
+ <Import-Package>
+ !javax.swing,
+ *
+ </Import-Package>
+ <Export-Package>
+ org.apache.felix.karaf.gshell.console*;version=${pom.version}
+ </Export-Package>
+ <_versionpolicy>${bnd.version.policy}</_versionpolicy>
+ </instructions>
+ <unpackBundle>true</unpackBundle>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/karaf/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/commands/text/SortAction.properties b/karaf/gshell/gshell-console/src/main/filtered-resources/org/apache/felix/karaf/gshell/console/branding.properties
similarity index 68%
rename from karaf/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/commands/text/SortAction.properties
rename to karaf/gshell/gshell-console/src/main/filtered-resources/org/apache/felix/karaf/gshell/console/branding.properties
index 094eda5..dbaa2f7 100644
--- a/karaf/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/commands/text/SortAction.properties
+++ b/karaf/gshell/gshell-console/src/main/filtered-resources/org/apache/felix/karaf/gshell/console/branding.properties
@@ -17,11 +17,16 @@
## under the License.
##
-##
-## $Rev: 703511 $ $Date: 2008-10-10 18:07:36 +0200 (Fri, 10 Oct 2008) $
-##
+welcome = \
+@|cyan __ __ ____ |\n\
+@|cyan / //_/____ __________ _/ __/ |\n\
+@|cyan / ,< / __ `/ ___/ __ `/ /_ |\n\
+@|cyan / /\\| \\|/ /_/ / / / /_/ / __/ |\n\
+@|cyan /_/ \\|_\\|\\__,_/_/ \\__,_/_/ |\n\
+\n\
+ @|bold Apache Felix Karaf| (${pom.version})\n\
+\n\
+Type '@|bold help|' for more information.\n
-command.description=Sort lines of text.
-command.manual=\
- TODO: about manual
+
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/BlueprintContainerAware.java
similarity index 70%
rename from karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java
rename to karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/BlueprintContainerAware.java
index f6b19e0..38ec43f 100644
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/BlueprintContainerAware.java
@@ -16,14 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.felix.karaf.gshell.core.sshd;
+package org.apache.felix.karaf.gshell.console;
-import org.apache.sshd.server.PasswordAuthenticator;
+import org.osgi.service.blueprint.container.BlueprintContainer;
-public class BogusPasswordAuthenticator implements PasswordAuthenticator {
+public interface BlueprintContainerAware {
- public Object authenticate(String username, String password) {
- return (username != null && username.equals(password)) ? username : null;
- }
+ void setBlueprintContainer(BlueprintContainer blueprintContainer);
}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/BundleContextAware.java
similarity index 70%
copy from karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java
copy to karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/BundleContextAware.java
index f6b19e0..50c1f21 100644
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/BundleContextAware.java
@@ -16,14 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.felix.karaf.gshell.core.sshd;
+package org.apache.felix.karaf.gshell.console;
-import org.apache.sshd.server.PasswordAuthenticator;
+import org.osgi.framework.BundleContext;
-public class BogusPasswordAuthenticator implements PasswordAuthenticator {
+public interface BundleContextAware {
- public Object authenticate(String username, String password) {
- return (username != null && username.equals(password)) ? username : null;
- }
+ void setBundleContext(BundleContext bundleContext);
}
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/CompletableFunction.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/CompletableFunction.java
new file mode 100644
index 0000000..077095b
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/CompletableFunction.java
@@ -0,0 +1,11 @@
+package org.apache.felix.karaf.gshell.console;
+
+import java.util.List;
+
+import org.osgi.service.command.Function;
+
+public interface CompletableFunction extends Function {
+
+ List<Completer> getCompleters();
+
+}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/Completer.java
similarity index 66%
copy from karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java
copy to karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/Completer.java
index f6b19e0..7bc3543 100644
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/BogusPasswordAuthenticator.java
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/Completer.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -16,14 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.felix.karaf.gshell.core.sshd;
+package org.apache.felix.karaf.gshell.console;
-import org.apache.sshd.server.PasswordAuthenticator;
+import java.util.List;
-public class BogusPasswordAuthenticator implements PasswordAuthenticator {
+public interface Completer {
- public Object authenticate(String username, String password) {
- return (username != null && username.equals(password)) ? username : null;
- }
+ int complete(String buffer, int cursor, List<String> candidates);
}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiCommandSupport.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/OsgiCommandSupport.java
similarity index 75%
rename from karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiCommandSupport.java
rename to karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/OsgiCommandSupport.java
index 17a44cc..983f7e2 100644
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiCommandSupport.java
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/OsgiCommandSupport.java
@@ -16,33 +16,27 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.felix.karaf.gshell.core;
+package org.apache.felix.karaf.gshell.console;
import java.util.ArrayList;
import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.gshell.command.CommandAction;
-import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.io.IO;
+import org.apache.felix.gogo.commands.Action;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
+import org.osgi.service.command.CommandSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-public abstract class OsgiCommandSupport implements CommandAction {
+public abstract class OsgiCommandSupport implements Action, BundleContextAware {
- protected Log log = LogFactory.getLog(getClass());
+ protected final Logger log = LoggerFactory.getLogger(getClass());
protected BundleContext bundleContext;
- protected CommandContext commandContext;
- protected IO io;
- protected Variables variables;
+ protected CommandSession session;
protected List<ServiceReference> usedReferences;
-
- public Object execute(CommandContext commandContext) throws Exception {
- this.commandContext = commandContext;
- this.io = commandContext.getIo();
- this.variables = commandContext.getVariables();
+
+ public Object execute(CommandSession session) throws Exception {
+ this.session = session;
try {
return doExecute();
} finally {
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/ansi/AnsiCode.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/ansi/AnsiCode.java
new file mode 100644
index 0000000..04f2790
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/ansi/AnsiCode.java
@@ -0,0 +1,49 @@
+package org.apache.felix.karaf.gshell.console.ansi;
+
+public enum AnsiCode
+{
+ OFF(0),
+ BOLD(1),
+ UNDERSCORE(4),
+ BLINK(5),
+ REVERSE(7),
+ CONCEALED(8),
+
+ FG_BLACK(30),
+ FG_RED(31),
+ FG_GREEN(32),
+ FG_YELLOW(33),
+ FG_BLUE(34),
+ FG_MAGENTA(35),
+ FG_CYAN(36),
+ FG_WHITE(37),
+
+ BLACK(FG_BLACK),
+ RED(FG_RED),
+ GREEN(FG_GREEN),
+ YELLOW(FG_YELLOW),
+ BLUE(FG_BLUE),
+ MAGENTA(FG_MAGENTA),
+ CYAN(FG_CYAN),
+ WHITE(FG_WHITE),
+
+ BG_BLACK(40),
+ BG_RED(41),
+ BG_GREEN(42),
+ BG_YELLOW(43),
+ BG_BLUE(44),
+ BG_MAGENTA(45),
+ BG_CYAN(46),
+ BG_WHITE(47);
+
+ final int code;
+
+ private AnsiCode(final int code) {
+ this.code = code;
+ }
+
+ private AnsiCode(final AnsiCode code) {
+ this(code.code);
+ }
+
+}
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/ansi/AnsiOutputStream.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/ansi/AnsiOutputStream.java
new file mode 100644
index 0000000..ed04c8b
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/ansi/AnsiOutputStream.java
@@ -0,0 +1,87 @@
+package org.apache.felix.karaf.gshell.console.ansi;
+
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.ByteArrayOutputStream;
+
+public class AnsiOutputStream extends FilterOutputStream
+{
+ char[] buf = new char[16];
+ int count = 0;
+ int ansiCodeState;
+
+ public AnsiOutputStream(OutputStream out)
+ {
+ super(out);
+ }
+
+ @Override
+ public void write(int b) throws IOException
+ {
+ if (ansiCodeState == 0) {
+ if (b == '@') {
+ ansiCodeState = 1;
+ } else {
+ super.write(b);
+ }
+ } else if (ansiCodeState == 1) {
+ if (b == '|') {
+ ansiCodeState = 2;
+ count = 0;
+ } else {
+ super.write('@');
+ super.write(b);
+ ansiCodeState = 0;
+ }
+ } else if (ansiCodeState == 2) {
+ if (b == ',') {
+ write(AnsiCode.valueOf(new String(buf, 0, count).toUpperCase()));
+ count = 0;
+ } else if (b == ' ') {
+ write(AnsiCode.valueOf(new String(buf, 0, count).toUpperCase()));
+ ansiCodeState = 3;
+ } else if (count < buf.length) {
+ buf[count++] = (char) b;
+ } else {
+ throw new IOException("Unknown ANSI code (too long): " + new String(buf, 0, count));
+ }
+ } else if (ansiCodeState == 3) {
+ if (b == '|') {
+ write(AnsiCode.OFF);
+ ansiCodeState = 0;
+ } else if (b == '\\') {
+ ansiCodeState = 4;
+ } else {
+ super.write(b);
+ }
+ } else if (ansiCodeState == 4) {
+ if (b != '|') {
+ super.write('\\');
+ }
+ super.write(b);
+ ansiCodeState = 3;
+ } else {
+ throw new IllegalStateException();
+ }
+ }
+
+ protected void write(AnsiCode code) throws IOException {
+ super.write(27); // ESC
+ super.write('[');
+ if (code.code >= 10) {
+ super.write((code.code / 10) + '0');
+ }
+ super.write((code.code % 10) + '0');
+ super.write('m');
+ }
+
+ public static String decode(String str) throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ AnsiOutputStream aos = new AnsiOutputStream(baos);
+ aos.write(str.getBytes());
+ aos.close();
+ return baos.toString();
+ }
+
+}
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/BlueprintCommand.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/BlueprintCommand.java
new file mode 100644
index 0000000..30eb423
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/BlueprintCommand.java
@@ -0,0 +1,90 @@
+/**
+ *
+ * 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.felix.karaf.gshell.console.commands;
+
+import java.lang.reflect.Type;
+import java.util.List;
+
+import org.apache.felix.gogo.commands.Action;
+import org.apache.felix.gogo.commands.basic.AbstractCommand;
+import org.apache.felix.gogo.commands.basic.ActionPreparator;
+import org.apache.felix.gogo.commands.basic.DefaultActionPreparator;
+import org.apache.felix.karaf.gshell.console.BlueprintContainerAware;
+import org.apache.felix.karaf.gshell.console.BundleContextAware;
+import org.apache.felix.karaf.gshell.console.CompletableFunction;
+import org.apache.felix.karaf.gshell.console.Completer;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.container.Converter;
+import org.osgi.service.command.CommandSession;
+
+public class BlueprintCommand extends AbstractCommand implements CompletableFunction
+{
+
+ protected BlueprintContainer blueprintContainer;
+ protected Converter blueprintConverter;
+ protected String actionId;
+ protected List<Completer> completers;
+
+ public void setBlueprintContainer(BlueprintContainer blueprintContainer) {
+ this.blueprintContainer = blueprintContainer;
+ }
+
+ public void setBlueprintConverter(Converter blueprintConverter) {
+ this.blueprintConverter = blueprintConverter;
+ }
+
+ public void setActionId(String actionId) {
+ this.actionId = actionId;
+ }
+
+ public List<Completer> getCompleters() {
+ return completers;
+ }
+
+ public void setCompleters(List<Completer> completers) {
+ this.completers = completers;
+ }
+
+ @Override
+ protected ActionPreparator getPreparator() throws Exception {
+ return new BlueprintActionPreparator();
+ }
+
+ class BlueprintActionPreparator extends DefaultActionPreparator {
+
+ @Override
+ protected Object convert(Action action, CommandSession commandSession, Object o, Type type) throws Exception {
+ return blueprintConverter.convert(o, new GenericType(type));
+ }
+
+ }
+
+ protected Action createNewAction() throws Exception {
+ Action action = (Action) blueprintContainer.getComponentInstance(actionId);
+ if (action instanceof BlueprintContainerAware) {
+ ((BlueprintContainerAware) action).setBlueprintContainer(blueprintContainer);
+ }
+ if (action instanceof BundleContextAware) {
+ BundleContext context = (BundleContext) blueprintContainer.getComponentInstance("blueprintBundleContext");
+ ((BundleContextAware) action).setBundleContext(context);
+ }
+ return action;
+ }
+
+}
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/GenericType.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/GenericType.java
new file mode 100644
index 0000000..9cb54f1
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/GenericType.java
@@ -0,0 +1,195 @@
+/**
+ *
+ * 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.felix.karaf.gshell.console.commands;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osgi.framework.Bundle;
+import org.osgi.service.blueprint.container.ReifiedType;
+
+public class GenericType extends ReifiedType {
+
+ private static final GenericType[] EMPTY = new GenericType[0];
+
+ private static final Map<String, Class> primitiveClasses = new HashMap<String, Class>();
+
+ static {
+ primitiveClasses.put("int", int.class);
+ primitiveClasses.put("short", short.class);
+ primitiveClasses.put("long", long.class);
+ primitiveClasses.put("byte", byte.class);
+ primitiveClasses.put("char", char.class);
+ primitiveClasses.put("float", float.class);
+ primitiveClasses.put("double", double.class);
+ primitiveClasses.put("boolean", boolean.class);
+ }
+
+ private GenericType[] parameters;
+
+ public GenericType(Type type) {
+ this(getConcreteClass(type), parametersOf(type));
+ }
+
+ public GenericType(Class clazz, GenericType... parameters) {
+ super(clazz);
+ this.parameters = parameters;
+ }
+
+ public static GenericType parse(String type, Object loader) throws ClassNotFoundException, IllegalArgumentException {
+ type = type.trim();
+ // Check if this is an array
+ if (type.endsWith("[]")) {
+ GenericType t = parse(type.substring(0, type.length() - 2), loader);
+ return new GenericType(Array.newInstance(t.getRawClass(), 0).getClass(), t);
+ }
+ // Check if this is a generic
+ int genericIndex = type.indexOf('<');
+ if (genericIndex > 0) {
+ if (!type.endsWith(">")) {
+ throw new IllegalArgumentException("Can not load type: " + type);
+ }
+ GenericType base = parse(type.substring(0, genericIndex), loader);
+ String[] params = type.substring(genericIndex + 1, type.length() - 1).split(",");
+ GenericType[] types = new GenericType[params.length];
+ for (int i = 0; i < params.length; i++) {
+ types[i] = parse(params[i], loader);
+ }
+ return new GenericType(base.getRawClass(), types);
+ }
+ // Primitive
+ if (primitiveClasses.containsKey(type)) {
+ return new GenericType(primitiveClasses.get(type));
+ }
+ // Class
+ if (loader instanceof ClassLoader) {
+ return new GenericType(((ClassLoader) loader).loadClass(type));
+ } else if (loader instanceof Bundle) {
+ return new GenericType(((Bundle) loader).loadClass(type));
+ } else {
+ throw new IllegalArgumentException("Unsupported loader: " + loader);
+ }
+ }
+
+ @Override
+ public ReifiedType getActualTypeArgument(int i) {
+ if (parameters.length == 0) {
+ return super.getActualTypeArgument(i);
+ }
+ return parameters[i];
+ }
+
+ @Override
+ public int size() {
+ return parameters.length;
+ }
+
+ @Override
+ public String toString() {
+ Class cl = getRawClass();
+ if (cl.isArray()) {
+ if (parameters.length > 0) {
+ return parameters[0].toString() + "[]";
+ } else {
+ return cl.getComponentType().getName() + "[]";
+ }
+ }
+ if (parameters.length > 0) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(cl.getName());
+ sb.append("<");
+ for (int i = 0; i < parameters.length; i++) {
+ if (i > 0) {
+ sb.append(",");
+ }
+ sb.append(parameters[i].toString());
+ }
+ sb.append(">");
+ return sb.toString();
+ }
+ return cl.getName();
+ }
+
+ static GenericType[] parametersOf(Type type ) {
+ if ( type instanceof Class ) {
+ Class clazz = (Class) type;
+ if (clazz.isArray()) {
+ GenericType t = new GenericType(clazz.getComponentType());
+ if (t.size() > 0) {
+ return new GenericType[] { t };
+ } else {
+ return EMPTY;
+ }
+ } else {
+ return EMPTY;
+ }
+ }
+ if ( type instanceof ParameterizedType ) {
+ ParameterizedType pt = (ParameterizedType) type;
+ Type [] parameters = pt.getActualTypeArguments();
+ GenericType[] gts = new GenericType[parameters.length];
+ for ( int i =0; i<gts.length; i++) {
+ gts[i] = new GenericType(parameters[i]);
+ }
+ return gts;
+ }
+ if ( type instanceof GenericArrayType ) {
+ return new GenericType[] { new GenericType(((GenericArrayType) type).getGenericComponentType()) };
+ }
+ throw new IllegalStateException();
+ }
+
+ static Class<?> getConcreteClass(Type type) {
+ Type ntype = collapse(type);
+ if ( ntype instanceof Class )
+ return (Class<?>) ntype;
+
+ if ( ntype instanceof ParameterizedType )
+ return getConcreteClass(collapse(((ParameterizedType)ntype).getRawType()));
+
+ throw new RuntimeException("Unknown type " + type );
+ }
+
+ static Type collapse(Type target) {
+ if (target instanceof Class || target instanceof ParameterizedType ) {
+ return target;
+ } else if (target instanceof TypeVariable) {
+ return collapse(((TypeVariable<?>) target).getBounds()[0]);
+ } else if (target instanceof GenericArrayType) {
+ Type t = collapse(((GenericArrayType) target)
+ .getGenericComponentType());
+ while ( t instanceof ParameterizedType )
+ t = collapse(((ParameterizedType)t).getRawType());
+ return Array.newInstance((Class<?>)t, 0).getClass();
+ } else if (target instanceof WildcardType) {
+ WildcardType wct = (WildcardType) target;
+ if (wct.getLowerBounds().length == 0)
+ return collapse(wct.getUpperBounds()[0]);
+ else
+ return collapse(wct.getLowerBounds()[0]);
+ }
+ throw new RuntimeException("Huh? " + target);
+ }
+
+}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/config/NamespaceHandler.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/NamespaceHandler.java
similarity index 62%
rename from karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/config/NamespaceHandler.java
rename to karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/NamespaceHandler.java
index 6a52865..d3c1fdf 100644
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/config/NamespaceHandler.java
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/NamespaceHandler.java
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.felix.karaf.gshell.core.config;
+package org.apache.felix.karaf.gshell.console.commands;
+
import java.net.URL;
import java.util.List;
@@ -26,23 +27,12 @@
import org.apache.geronimo.blueprint.ParserContext;
import org.apache.geronimo.blueprint.mutable.MutableBeanMetadata;
-import org.apache.geronimo.blueprint.mutable.MutableCollectionMetadata;
import org.apache.geronimo.blueprint.mutable.MutableIdRefMetadata;
import org.apache.geronimo.blueprint.mutable.MutableServiceMetadata;
import org.apache.geronimo.blueprint.mutable.MutableValueMetadata;
import org.apache.geronimo.blueprint.mutable.MutableRefMetadata;
-import org.apache.geronimo.gshell.command.Alias;
-import org.apache.geronimo.gshell.command.Command;
-import org.apache.geronimo.gshell.command.Link;
-import org.apache.geronimo.gshell.wisdom.command.AliasImpl;
-import org.apache.geronimo.gshell.wisdom.command.CommandMessageSource;
-import org.apache.geronimo.gshell.wisdom.command.LinkImpl;
-import org.apache.geronimo.gshell.wisdom.command.MessageSourceCommandDocumenter;
-import org.apache.geronimo.gshell.wisdom.command.StatefulCommand;
-import org.apache.geronimo.gshell.wisdom.command.StatelessCommand;
-import org.apache.geronimo.gshell.wisdom.command.ConfigurableCommandCompleter;
-import org.apache.geronimo.gshell.wisdom.registry.CommandLocationImpl;
-import org.apache.felix.karaf.gshell.core.BeanContainerWrapper;
+import org.apache.geronimo.blueprint.mutable.MutableCollectionMetadata;
+import org.apache.felix.karaf.gshell.console.CompletableFunction;
import org.osgi.service.blueprint.reflect.BeanArgument;
import org.osgi.service.blueprint.reflect.BeanProperty;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
@@ -53,7 +43,7 @@
import org.osgi.service.blueprint.reflect.NullMetadata;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.container.ComponentDefinitionException;
-import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.command.Function;
public class NamespaceHandler implements org.apache.geronimo.blueprint.NamespaceHandler {
@@ -69,7 +59,6 @@
public static final String LOCATION = "location";
public static final String COMMANDS = "commands";
public static final String COMMAND = "command";
- public static final String TYPE = "type";
public static final String DOCUMENTER = "documenter";
public static final String COMPLETER = "completer";
public static final String COMPLETERS = "completers";
@@ -84,14 +73,13 @@
public static final String LINK = "link";
public static final String LINKS = "links";
public static final String TARGET = "target";
-
- public static final String TYPE_STATEFUL = "stateful";
- public static final String TYPE_STATELESS = "stateless";
+ public static final String BLUEPRINT_CONTAINER = "blueprintContainer";
+ public static final String BLUEPRINT_CONVERTER = "blueprintConverter";
private int nameCounter = 0;
public URL getSchemaLocation(String namespace) {
- return getClass().getResource("/org/apache/felix/karaf/gshell/core/karaf-gshell.xsd");
+ return getClass().getResource("karaf-gshell.xsd");
}
public ComponentMetadata decorate(Node node, ComponentMetadata component, ParserContext context) {
@@ -118,62 +106,52 @@
if (nodeNameEquals(element, COMMAND)) {
parseCommand(element, context);
} else if (nodeNameEquals(element, LINK)) {
- parseLink(element, context);
+// parseLink(element, context);
} else if (nodeNameEquals(element, ALIAS)) {
- parseAlias(element, context);
+// parseAlias(element, context);
}
}
private void parseCommand(Element element, ParserContext context) {
MutableBeanMetadata command = context.createMetadata(MutableBeanMetadata.class);
- String type = element.hasAttribute(TYPE) ? element.getAttribute(TYPE) : TYPE_STATEFUL;
- boolean stateful;
- if (TYPE_STATEFUL.equals(type)) {
- command.setRuntimeClass(StatefulCommand.class);
- stateful = true;
- } else if (TYPE_STATELESS.equals(type)) {
- command.setRuntimeClass(StatelessCommand.class);
- stateful = false;
- } else {
- throw new ComponentDefinitionException("Bad xml syntax: unknown value '" + type + "' for attribute " + TYPE);
- }
- MutableBeanMetadata beanContainer = context.createMetadata(MutableBeanMetadata.class);
- beanContainer.setRuntimeClass(BeanContainerWrapper.class);
- beanContainer.addArgument(createRef(context, "blueprintContainer"), BlueprintContainer.class.getName(), 0);
- command.addProperty("beanContainer", beanContainer);
- MutableBeanMetadata documenter = context.createMetadata(MutableBeanMetadata.class);
- documenter.setRuntimeClass(MessageSourceCommandDocumenter.class);
- command.addProperty(DOCUMENTER, documenter);
- MutableBeanMetadata messages = context.createMetadata(MutableBeanMetadata.class);
- messages.setRuntimeClass(CommandMessageSource.class);
- command.addProperty(MESSAGES, messages);
- MutableBeanMetadata location = context.createMetadata(MutableBeanMetadata.class);
- location.setRuntimeClass(CommandLocationImpl.class);
- location.addArgument(createStringValue(context, element.getAttribute(NAME)), String.class.getName(), 0);
- command.addProperty(LOCATION, location);
+ command.setRuntimeClass(BlueprintCommand.class);
+ command.addProperty(BLUEPRINT_CONTAINER, createRef(context, BLUEPRINT_CONTAINER));
+ command.addProperty(BLUEPRINT_CONVERTER, createRef(context, BLUEPRINT_CONVERTER));
+// MutableBeanMetadata documenter = context.createMetadata(MutableBeanMetadata.class);
+// documenter.setRuntimeClass(MessageSourceCommandDocumenter.class);
+// command.addProperty(DOCUMENTER, documenter);
+// MutableBeanMetadata messages = context.createMetadata(MutableBeanMetadata.class);
+// messages.setRuntimeClass(CommandMessageSource.class);
+// command.addProperty(MESSAGES, messages);
+// MutableBeanMetadata location = context.createMetadata(MutableBeanMetadata.class);
+// location.setRuntimeClass(CommandLocationImpl.class);
+// location.addArgument(createStringValue(context, element.getAttribute(NAME)), String.class.getName(), 0);
+// command.addProperty(LOCATION, location);
- boolean hasAction = false;
+ String location = element.getAttribute(NAME);
+ location = location.replace('/', ':');
+ String scope;
+ String function;
+ if (location.lastIndexOf(':') >= 0) {
+ scope = location.substring(0, location.lastIndexOf(':'));
+ function = location.substring(location.lastIndexOf(':') + 1);
+ } else {
+ scope = "";
+ function = location;
+ }
+
NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child instanceof Element) {
Element childElement = (Element) child;
if (nodeNameEquals(childElement, ACTION)) {
- if (hasAction) {
- throw new ComponentDefinitionException("Only one " + ACTION + " element can be set for a given command");
- }
- hasAction = true;
MutableBeanMetadata action = parseAction(context, command, childElement);
- // TODO: parse other stuff or remove it from schema
- if (stateful) {
- action.setId(getName());
- context.getComponentDefinitionRegistry().registerComponentDefinition(action);
- command.addProperty(ACTION_ID, createIdRef(context, action.getId()));
- } else {
- command.addProperty(ACTION, action);
- }
+ action.setId(getName());
+ context.getComponentDefinitionRegistry().registerComponentDefinition(action);
+ command.addProperty(ACTION_ID, createIdRef(context, action.getId()));
} else if (nodeNameEquals(childElement, COMPLETERS)) {
- command.addProperty(COMPLETER, parseCompleters(context, command, childElement));
+ command.addProperty(COMPLETERS, parseCompleters(context, command, childElement));
} else {
throw new ComponentDefinitionException("Bad xml syntax: unknown element '" + childElement.getNodeName() + "'");
}
@@ -182,8 +160,13 @@
MutableServiceMetadata commandService = context.createMetadata(MutableServiceMetadata.class);
commandService.setId(getName());
- commandService.addInterface(Command.class.getName());
+ commandService.addInterface(Function.class.getName());
+ commandService.addInterface(CompletableFunction.class.getName());
commandService.setServiceComponent(command);
+ commandService.addServiceProperty(createStringValue(context, "osgi.command.scope"),
+ createStringValue(context, scope));
+ commandService.addServiceProperty(createStringValue(context, "osgi.command.function"),
+ createStringValue(context, function));
context.getComponentDefinitionRegistry().registerComponentDefinition(commandService);
}
@@ -208,8 +191,6 @@
}
private Metadata parseCompleters(ParserContext context, ComponentMetadata enclosingComponent, Element element) {
- MutableBeanMetadata completer = context.createMetadata(MutableBeanMetadata.class);
- completer.setRuntimeClass(ConfigurableCommandCompleter.class);
MutableCollectionMetadata collection = context.createMetadata(MutableCollectionMetadata.class);
collection.setCollectionClass(List.class);
NodeList children = element.getChildNodes();
@@ -229,36 +210,35 @@
collection.addValue(metadata);
}
}
- completer.addArgument(collection, List.class.getName(), 0);
- return completer;
+ return collection;
}
- private void parseLink(Element element, ParserContext context) {
- MutableBeanMetadata link = context.createMetadata(MutableBeanMetadata.class);
- link.setRuntimeClass(LinkImpl.class);
- link.addArgument(createStringValue(context, element.getAttribute(NAME)), String.class.getName(), 0);
- link.addArgument(createStringValue(context, element.getAttribute(TARGET)), String.class.getName(), 0);
-
- MutableServiceMetadata linkService = context.createMetadata(MutableServiceMetadata.class);
- linkService.setId(getName());
- linkService.addInterface(Link.class.getName());
- linkService.setServiceComponent(link);
- context.getComponentDefinitionRegistry().registerComponentDefinition(linkService);
- }
-
- private void parseAlias(Element element, ParserContext context) {
- MutableBeanMetadata alias = context.createMetadata(MutableBeanMetadata.class);
- alias.setRuntimeClass(AliasImpl.class);
- alias.addArgument(createStringValue(context, element.getAttribute(NAME)), String.class.getName(), 0);
- alias.addArgument(createStringValue(context, element.getAttribute(ALIAS)), String.class.getName(), 0);
-
- MutableServiceMetadata aliasService = context.createMetadata(MutableServiceMetadata.class);
- aliasService.setId(getName());
- aliasService.addInterface(Alias.class.getName());
- aliasService.setServiceComponent(alias);
- context.getComponentDefinitionRegistry().registerComponentDefinition(aliasService);
- }
-
+// private void parseLink(Element element, ParserContext context) {
+// MutableBeanMetadata link = context.createMetadata(MutableBeanMetadata.class);
+// link.setRuntimeClass(LinkImpl.class);
+// link.addArgument(createStringValue(context, element.getAttribute(NAME)), String.class.getName(), 0);
+// link.addArgument(createStringValue(context, element.getAttribute(TARGET)), String.class.getName(), 0);
+//
+// MutableServiceMetadata linkService = context.createMetadata(MutableServiceMetadata.class);
+// linkService.setId(getName());
+// linkService.addInterface(Link.class.getName());
+// linkService.setServiceComponent(link);
+// context.getComponentDefinitionRegistry().registerComponentDefinition(linkService);
+// }
+//
+// private void parseAlias(Element element, ParserContext context) {
+// MutableBeanMetadata alias = context.createMetadata(MutableBeanMetadata.class);
+// alias.setRuntimeClass(AliasImpl.class);
+// alias.addArgument(createStringValue(context, element.getAttribute(NAME)), String.class.getName(), 0);
+// alias.addArgument(createStringValue(context, element.getAttribute(ALIAS)), String.class.getName(), 0);
+//
+// MutableServiceMetadata aliasService = context.createMetadata(MutableServiceMetadata.class);
+// aliasService.setId(getName());
+// aliasService.addInterface(Alias.class.getName());
+// aliasService.setServiceComponent(alias);
+// context.getComponentDefinitionRegistry().registerComponentDefinition(aliasService);
+// }
+//
private ValueMetadata createStringValue(ParserContext context, String str) {
MutableValueMetadata value = context.createMetadata(MutableValueMetadata.class);
value.setStringValue(str);
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/AggregateCompleter.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/AggregateCompleter.java
new file mode 100644
index 0000000..7cd1364
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/AggregateCompleter.java
@@ -0,0 +1,91 @@
+/*
+ * 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.felix.karaf.gshell.console.completer;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Collection;
+
+import org.apache.felix.karaf.gshell.console.Completer;
+
+/**
+ * Completer which contains multipule completers and aggregates them together.
+ *
+ * @version $Rev: 699733 $ $Date: 2008-09-27 22:55:23 +0200 (Sat, 27 Sep 2008) $
+ */
+public class AggregateCompleter implements Completer
+{
+ private final Collection<Completer> completers;
+
+ public AggregateCompleter(final Collection<Completer> completers) {
+ assert completers != null;
+ this.completers = completers;
+ }
+
+ public int complete(final String buffer, final int cursor, final List candidates) {
+ // buffer could be null
+ assert candidates != null;
+
+ List<Completion> completions = new ArrayList<Completion>(completers.size());
+
+ // Run each completer, saving its completion results
+ int max = -1;
+ for (Completer completer : completers) {
+ Completion completion = new Completion(candidates);
+ completion.complete(completer, buffer, cursor);
+
+ // Compute the max cursor position
+ max = Math.max(max, completion.cursor);
+
+ completions.add(completion);
+ }
+
+ // Append candiates from completions which have the same cursor position as max
+ for (Completion completion : completions) {
+ if (completion.cursor == max) {
+ // noinspection unchecked
+ candidates.addAll(completion.candidates);
+ }
+ }
+
+ return max;
+ }
+
+ private class Completion
+ {
+ public final List<String> candidates;
+
+ public int cursor;
+
+ public Completion(final List candidates) {
+ assert candidates != null;
+
+ // noinspection unchecked
+ this.candidates = new LinkedList<String>(candidates);
+ }
+
+ public void complete(final Completer completer, final String buffer, final int cursor) {
+ assert completer != null;
+
+ this.cursor = completer.complete(buffer, cursor, candidates);
+ }
+ }
+}
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/ArgumentCompleter.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/ArgumentCompleter.java
new file mode 100644
index 0000000..4464928
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/ArgumentCompleter.java
@@ -0,0 +1,393 @@
+/*
+ * Copyright (c) 2002-2007, Marc Prud'hommeaux. All rights reserved.
+ *
+ * This software is distributable under the BSD license. See the terms of the
+ * BSD license in the documentation provided with this software.
+ */
+package org.apache.felix.karaf.gshell.console.completer;
+
+import java.util.*;
+
+import org.apache.felix.karaf.gshell.console.Completer;
+
+public class ArgumentCompleter implements Completer {
+ final Completer[] completers;
+ final ArgumentDelimiter delim;
+ boolean strict = true;
+
+ /**
+ * Constuctor: create a new completor with the default
+ * argument separator of " ".
+ *
+ * @param completer the embedded completer
+ */
+ public ArgumentCompleter(final Completer completer) {
+ this(new Completer[] {
+ completer
+ });
+ }
+
+ /**
+ * Constuctor: create a new completor with the default
+ * argument separator of " ".
+ *
+ * @param completers the List of completors to use
+ */
+ public ArgumentCompleter(final List<Completer> completers) {
+ this(completers.toArray(new Completer[completers.size()]));
+ }
+
+ /**
+ * Constuctor: create a new completor with the default
+ * argument separator of " ".
+ *
+ * @param completers the embedded argument completers
+ */
+ public ArgumentCompleter(final Completer[] completers) {
+ this(completers, new WhitespaceArgumentDelimiter());
+ }
+
+ /**
+ * Constuctor: create a new completor with the specified
+ * argument delimiter.
+ *
+ * @param completer the embedded completer
+ * @param delim the delimiter for parsing arguments
+ */
+ public ArgumentCompleter(final Completer completer,
+ final ArgumentDelimiter delim) {
+ this(new Completer[] {
+ completer
+ }, delim);
+ }
+
+ /**
+ * Constuctor: create a new completor with the specified
+ * argument delimiter.
+ *
+ * @param completers the embedded completers
+ * @param delim the delimiter for parsing arguments
+ */
+ public ArgumentCompleter(final Completer[] completers,
+ final ArgumentDelimiter delim) {
+ this.completers = completers;
+ this.delim = delim;
+ }
+
+ /**
+ * If true, a completion at argument index N will only succeed
+ * if all the completions from 0-(N-1) also succeed.
+ */
+ public void setStrict(final boolean strict) {
+ this.strict = strict;
+ }
+
+ /**
+ * Returns whether a completion at argument index N will succees
+ * if all the completions from arguments 0-(N-1) also succeed.
+ */
+ public boolean getStrict() {
+ return this.strict;
+ }
+
+ public int complete(final String buffer, final int cursor,
+ final List<String> candidates) {
+ ArgumentList list = delim.delimit(buffer, cursor);
+ int argpos = list.getArgumentPosition();
+ int argIndex = list.getCursorArgumentIndex();
+
+ if (argIndex < 0) {
+ return -1;
+ }
+
+ final Completer comp;
+
+ // if we are beyond the end of the completors, just use the last one
+ if (argIndex >= completers.length) {
+ comp = completers[completers.length - 1];
+ } else {
+ comp = completers[argIndex];
+ }
+
+ // ensure that all the previous completors are successful before
+ // allowing this completor to pass (only if strict is true).
+ for (int i = 0; getStrict() && (i < argIndex); i++) {
+ Completer sub = completers[(i >= completers.length) ? (completers.length - 1) : i];
+ String[] args = list.getArguments();
+ String arg = ((args == null) || (i >= args.length)) ? "" : args[i];
+
+ List<String> subCandidates = new LinkedList<String>();
+
+ if (sub.complete(arg, arg.length(), subCandidates) == -1) {
+ return -1;
+ }
+
+ if (subCandidates.size() == 0) {
+ return -1;
+ }
+ }
+
+ int ret = comp.complete(list.getCursorArgument(), argpos, candidates);
+
+ if (ret == -1) {
+ return -1;
+ }
+
+ int pos = ret + (list.getBufferPosition() - argpos);
+
+ /**
+ * Special case: when completing in the middle of a line, and the
+ * area under the cursor is a delimiter, then trim any delimiters
+ * from the candidates, since we do not need to have an extra
+ * delimiter.
+ *
+ * E.g., if we have a completion for "foo", and we
+ * enter "f bar" into the buffer, and move to after the "f"
+ * and hit TAB, we want "foo bar" instead of "foo bar".
+ */
+ if ((cursor != buffer.length()) && delim.isDelimiter(buffer, cursor)) {
+ for (int i = 0; i < candidates.size(); i++) {
+ String val = candidates.get(i);
+
+ while ((val.length() > 0)
+ && delim.isDelimiter(val, val.length() - 1)) {
+ val = val.substring(0, val.length() - 1);
+ }
+
+ candidates.set(i, val);
+ }
+ }
+
+ return pos;
+ }
+
+ /**
+ * The {@link ArgumentCompleter.ArgumentDelimiter} allows custom
+ * breaking up of a {@link String} into individual arguments in
+ * order to dispatch the arguments to the nested {@link Completer}.
+ *
+ * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
+ */
+ public static interface ArgumentDelimiter {
+ /**
+ * Break the specified buffer into individual tokens
+ * that can be completed on their own.
+ *
+ * @param buffer the buffer to split
+ * @param argumentPosition the current position of the
+ * cursor in the buffer
+ * @return the tokens
+ */
+ ArgumentList delimit(String buffer, int argumentPosition);
+
+ /**
+ * Returns true if the specified character is a whitespace
+ * parameter.
+ *
+ * @param buffer the complete command buffer
+ * @param pos the index of the character in the buffer
+ * @return true if the character should be a delimiter
+ */
+ boolean isDelimiter(String buffer, int pos);
+ }
+
+ /**
+ * Abstract implementation of a delimiter that uses the
+ * {@link #isDelimiter} method to determine if a particular
+ * character should be used as a delimiter.
+ *
+ * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
+ */
+ public abstract static class AbstractArgumentDelimiter
+ implements ArgumentDelimiter {
+ private char[] quoteChars = new char[] { '\'', '"' };
+ private char[] escapeChars = new char[] { '\\' };
+
+ public void setQuoteChars(final char[] quoteChars) {
+ this.quoteChars = quoteChars;
+ }
+
+ public char[] getQuoteChars() {
+ return this.quoteChars;
+ }
+
+ public void setEscapeChars(final char[] escapeChars) {
+ this.escapeChars = escapeChars;
+ }
+
+ public char[] getEscapeChars() {
+ return this.escapeChars;
+ }
+
+ public ArgumentList delimit(final String buffer, final int cursor) {
+ List<String> args = new LinkedList<String>();
+ StringBuffer arg = new StringBuffer();
+ int argpos = -1;
+ int bindex = -1;
+
+ for (int i = 0; (buffer != null) && (i <= buffer.length()); i++) {
+ // once we reach the cursor, set the
+ // position of the selected index
+ if (i == cursor) {
+ bindex = args.size();
+ // the position in the current argument is just the
+ // length of the current argument
+ argpos = arg.length();
+ }
+
+ if ((i == buffer.length()) || isDelimiter(buffer, i)) {
+ if (arg.length() > 0) {
+ args.add(arg.toString());
+ arg.setLength(0); // reset the arg
+ }
+ } else {
+ arg.append(buffer.charAt(i));
+ }
+ }
+
+ return new ArgumentList(args.
+ toArray(new String[args.size()]), bindex, argpos, cursor);
+ }
+
+ /**
+ * Returns true if the specified character is a whitespace
+ * parameter. Check to ensure that the character is not
+ * escaped by any of
+ * {@link #getQuoteChars}, and is not escaped by ant of the
+ * {@link #getEscapeChars}, and returns true from
+ * {@link #isDelimiterChar}.
+ *
+ * @param buffer the complete command buffer
+ * @param pos the index of the character in the buffer
+ * @return true if the character should be a delimiter
+ */
+ public boolean isDelimiter(final String buffer, final int pos) {
+ if (isQuoted(buffer, pos)) {
+ return false;
+ }
+
+ if (isEscaped(buffer, pos)) {
+ return false;
+ }
+
+ return isDelimiterChar(buffer, pos);
+ }
+
+ public boolean isQuoted(final String buffer, final int pos) {
+ return false;
+ }
+
+ public boolean isEscaped(final String buffer, final int pos) {
+ if (pos <= 0) {
+ return false;
+ }
+
+ for (int i = 0; (escapeChars != null) && (i < escapeChars.length);
+ i++) {
+ if (buffer.charAt(pos) == escapeChars[i]) {
+ return !isEscaped(buffer, pos - 1); // escape escape
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns true if the character at the specified position
+ * if a delimiter. This method will only be called if the
+ * character is not enclosed in any of the
+ * {@link #getQuoteChars}, and is not escaped by ant of the
+ * {@link #getEscapeChars}. To perform escaping manually,
+ * override {@link #isDelimiter} instead.
+ */
+ public abstract boolean isDelimiterChar(String buffer, int pos);
+ }
+
+ /**
+ * {@link ArgumentCompleter.ArgumentDelimiter}
+ * implementation that counts all
+ * whitespace (as reported by {@link Character#isWhitespace})
+ * as being a delimiter.
+ *
+ * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
+ */
+ public static class WhitespaceArgumentDelimiter
+ extends AbstractArgumentDelimiter {
+ /**
+ * The character is a delimiter if it is whitespace, and the
+ * preceeding character is not an escape character.
+ */
+ public boolean isDelimiterChar(String buffer, int pos) {
+ return Character.isWhitespace(buffer.charAt(pos));
+ }
+ }
+
+ /**
+ * The result of a delimited buffer.
+ *
+ * @author <a href="mailto:mwp1@cornell.edu">Marc Prud'hommeaux</a>
+ */
+ public static class ArgumentList {
+ private String[] arguments;
+ private int cursorArgumentIndex;
+ private int argumentPosition;
+ private int bufferPosition;
+
+ /**
+ * @param arguments the array of tokens
+ * @param cursorArgumentIndex the token index of the cursor
+ * @param argumentPosition the position of the cursor in the
+ * current token
+ * @param bufferPosition the position of the cursor in
+ * the whole buffer
+ */
+ public ArgumentList(String[] arguments, int cursorArgumentIndex,
+ int argumentPosition, int bufferPosition) {
+ this.arguments = arguments;
+ this.cursorArgumentIndex = cursorArgumentIndex;
+ this.argumentPosition = argumentPosition;
+ this.bufferPosition = bufferPosition;
+ }
+
+ public void setCursorArgumentIndex(int cursorArgumentIndex) {
+ this.cursorArgumentIndex = cursorArgumentIndex;
+ }
+
+ public int getCursorArgumentIndex() {
+ return this.cursorArgumentIndex;
+ }
+
+ public String getCursorArgument() {
+ if ((cursorArgumentIndex < 0)
+ || (cursorArgumentIndex >= arguments.length)) {
+ return null;
+ }
+
+ return arguments[cursorArgumentIndex];
+ }
+
+ public void setArgumentPosition(int argumentPosition) {
+ this.argumentPosition = argumentPosition;
+ }
+
+ public int getArgumentPosition() {
+ return this.argumentPosition;
+ }
+
+ public void setArguments(String[] arguments) {
+ this.arguments = arguments;
+ }
+
+ public String[] getArguments() {
+ return this.arguments;
+ }
+
+ public void setBufferPosition(int bufferPosition) {
+ this.bufferPosition = bufferPosition;
+ }
+
+ public int getBufferPosition() {
+ return this.bufferPosition;
+ }
+ }
+}
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/CommandsCompleter.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/CommandsCompleter.java
new file mode 100644
index 0000000..3030236
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/CommandsCompleter.java
@@ -0,0 +1,86 @@
+package org.apache.felix.karaf.gshell.console.completer;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.felix.karaf.gshell.console.Completer;
+import org.apache.felix.karaf.gshell.console.CompletableFunction;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.command.CommandProcessor;
+
+public class CommandsCompleter implements Completer {
+
+ private final Map<ServiceReference, Completer> completers = new ConcurrentHashMap<ServiceReference, Completer>();
+
+ private BundleContext bundleContext;
+
+ public void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+
+ public void register(ServiceReference reference) {
+ Set<String> functions = getNames(reference);
+ if (functions != null) {
+ List<Completer> cl = new ArrayList<Completer>();
+ cl.add(new StringsCompleter(functions));
+ try {
+ Object function = bundleContext.getService(reference);
+ if (function instanceof CompletableFunction) {
+ List<Completer> fcl = ((CompletableFunction) function).getCompleters();
+ if (fcl != null) {
+ for (Completer c : fcl) {
+ cl.add(c == null ? NullCompleter.INSTANCE : c);
+ }
+ } else {
+ cl.add(NullCompleter.INSTANCE);
+ }
+ } else {
+ cl.add(NullCompleter.INSTANCE);
+ }
+ } finally {
+ bundleContext.ungetService(reference);
+ }
+ ArgumentCompleter c = new ArgumentCompleter(cl);
+ completers.put(reference, c);
+ }
+ }
+
+ public void unregister(ServiceReference reference) {
+ completers.remove(reference);
+ }
+
+ private Set<String> getNames(ServiceReference reference) {
+ Set<String> names = new HashSet<String>();
+ Object scope = reference.getProperty(CommandProcessor.COMMAND_SCOPE);
+ Object function = reference.getProperty(CommandProcessor.COMMAND_FUNCTION);
+ if(scope != null && function != null)
+ {
+ if (function.getClass().isArray())
+ {
+ for (Object f : ((Object[]) function))
+ {
+ names.add(scope + ":" + f.toString());
+ }
+ }
+ else
+ {
+ names.add(scope + ":" + function.toString());
+ }
+ return names;
+ }
+ return null;
+ }
+
+ public int complete(String buffer, int cursor, List<String> candidates) {
+ int res = new AggregateCompleter(completers.values()).complete(buffer, cursor, candidates);
+ Collections.sort(candidates);
+ return res;
+ }
+}
+
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/NullCompleter.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/NullCompleter.java
new file mode 100644
index 0000000..fa80f40
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/NullCompleter.java
@@ -0,0 +1,14 @@
+package org.apache.felix.karaf.gshell.console.completer;
+
+import java.util.List;
+
+import org.apache.felix.karaf.gshell.console.Completer;
+
+public class NullCompleter implements Completer {
+
+ public static final NullCompleter INSTANCE = new NullCompleter();
+
+ public int complete(String buffer, int cursor, List<String> candidates) {
+ return -1;
+ }
+}
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/StringsCompleter.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/StringsCompleter.java
new file mode 100644
index 0000000..42391c8
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/completer/StringsCompleter.java
@@ -0,0 +1,81 @@
+/*
+ * 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.felix.karaf.gshell.console.completer;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.apache.felix.karaf.gshell.console.Completer;
+
+/**
+ * Completer for a set of strings.
+ *
+ * @version $Rev: 722797 $ $Date: 2008-12-03 08:18:16 +0100 (Wed, 03 Dec 2008) $
+ */
+public class StringsCompleter
+ implements Completer
+{
+ private final SortedSet<String> strings = new TreeSet<String>();
+
+ public StringsCompleter() {}
+
+ public StringsCompleter(final Collection<String> strings) {
+ assert strings != null;
+
+ getStrings().addAll(strings);
+ }
+
+ public StringsCompleter(final String[] strings) {
+ this(Arrays.asList(strings));
+ }
+
+ public Collection<String> getStrings() {
+ return strings;
+ }
+
+ public int complete(String buffer, final int cursor, final List candidates) {
+ // buffer could be null
+ assert candidates != null;
+
+ if (buffer == null) {
+ buffer = "";
+ }
+
+ SortedSet<String> matches = strings.tailSet(buffer);
+
+ for (String match : matches) {
+ if (!match.startsWith(buffer)) {
+ break;
+ }
+
+ // noinspection unchecked
+ candidates.add(match);
+ }
+
+ if (candidates.size() == 1) {
+ // noinspection unchecked
+ candidates.set(0, candidates.get(0) + " ");
+ }
+
+ return candidates.isEmpty() ? -1 : 0;
+ }
+}
\ No newline at end of file
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/CompleterAsCompletor.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/CompleterAsCompletor.java
new file mode 100644
index 0000000..db6a3ac
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/CompleterAsCompletor.java
@@ -0,0 +1,26 @@
+package org.apache.felix.karaf.gshell.console.jline;
+
+import java.util.List;
+
+import jline.Completor;
+import org.apache.felix.karaf.gshell.console.Completer;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Jul 6, 2009
+ * Time: 10:26:15 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class CompleterAsCompletor implements Completor {
+
+ private final Completer completer;
+
+ public CompleterAsCompletor(Completer completer) {
+ this.completer = completer;
+ }
+
+ public int complete(String buffer, int cursor, List candidates) {
+ return completer.complete(buffer, cursor, candidates);
+ }
+}
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java
new file mode 100644
index 0000000..24b5716
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/Console.java
@@ -0,0 +1,259 @@
+/*
+ * 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.felix.karaf.gshell.console.jline;
+
+import jline.*;
+import org.osgi.service.command.CommandSession;
+import org.osgi.service.command.Converter;
+import org.apache.felix.karaf.gshell.console.ansi.AnsiOutputStream;
+import org.apache.felix.karaf.gshell.console.Completer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InterruptedIOException;
+import java.io.PrintWriter;
+import java.lang.reflect.Method;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.BlockingQueue;
+import java.util.Properties;
+
+public class Console implements Runnable
+{
+
+ public static final String PROMPT = "PROMPT";
+ public static final String DEFAULT_PROMPT = "\"@|bold ${USER}|@${APPLICATION}:@|bold ${SCOPE}|> \"";
+
+ private CommandSession session;
+ private ConsoleReader reader;
+ private BlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(1024);
+ private boolean interrupt;
+ private Thread pipe;
+ private boolean running;
+ private Runnable closeCallback;
+ private Terminal terminal;
+
+ public Console(CommandSession session, Terminal term) throws Exception
+ {
+ this(session, term, null);
+ }
+
+ public Console(CommandSession session, Terminal term, Completer completer) throws Exception
+ {
+ this(session, term, completer, null);
+ }
+
+ public Console(CommandSession session, Terminal term, Completer completer, Runnable closeCallback) throws Exception
+ {
+ this.session = session;
+ this.terminal = term == null ? new UnsupportedTerminal() : term;
+ this.closeCallback = closeCallback;
+ reader = new ConsoleReader(new ConsoleInputStream(),
+ new PrintWriter(session.getConsole()),
+ getClass().getResourceAsStream("keybinding.properties"),
+ terminal);
+ if (completer != null) {
+ reader.addCompletor(new CompleterAsCompletor(completer));
+ }
+ pipe = new Thread(new Pipe());
+ pipe.setName("gogo shell pipe thread");
+ pipe.setDaemon(true);
+ }
+
+ public void close() {
+ //System.err.println("Closing");
+ running = false;
+ pipe.interrupt();
+ Thread.interrupted();
+ }
+
+ public void run()
+ {
+ running = true;
+ pipe.start();
+ welcome();
+ while (running) {
+ try {
+ String prompt = AnsiOutputStream.decode(getPrompt());
+ String line = reader.readLine(prompt);
+ if (line == null)
+ {
+ break;
+ }
+ //session.getConsole().println("Executing: " + line);
+ Object result = session.execute(line);
+ if (result != null)
+ {
+ session.getConsole().println(session.format(result, Converter.INSPECT));
+ }
+ }
+ catch (InterruptedIOException e)
+ {
+ //System.err.println("^C");
+ // TODO: interrupt current thread
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace(session.getConsole());
+ //System.err.println("Exception: " + t.getMessage());
+ }
+ }
+ //System.err.println("Exiting console...");
+ if (closeCallback != null)
+ {
+ closeCallback.run();
+ }
+ }
+
+ protected void welcome() {
+ Properties props = new Properties();
+ loadProps(props, "/org/apache/felix/karaf/gshell/console/branding.properties");
+ loadProps(props, "/org/apache/felix/karaf/branding/branding.properties");
+ String welcome = props.getProperty("welcome");
+ if (welcome != null && welcome.length() > 0) {
+ try {
+ session.getConsole().println(AnsiOutputStream.decode(welcome));
+ } catch (IOException e) {
+ //
+ }
+ }
+ }
+
+ private void loadProps(Properties props, String resource) {
+ InputStream is = null;
+ try {
+ is = getClass().getClassLoader().getResourceAsStream(resource);
+ if (is != null) {
+ props.load(is);
+ }
+ } catch (IOException e) {
+ // ignore
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+ }
+
+ protected String getPrompt() {
+ try {
+ String prompt;
+ try {
+ Object p = session.get(PROMPT);
+ prompt = p != null ? p.toString() : DEFAULT_PROMPT;
+ } catch (Throwable t) {
+ prompt = DEFAULT_PROMPT;
+ }
+ Object v = session.execute(prompt);
+ if (v != null) {
+ prompt = v.toString();
+ }
+ return prompt;
+ } catch (Throwable t) {
+ return "$ ";
+ }
+ }
+
+ private void checkInterrupt() throws IOException {
+ if (interrupt) {
+ interrupt = false;
+ throw new InterruptedIOException("Keyboard interruption");
+ }
+ }
+
+ private void interrupt() {
+ interrupt = true;
+ //System.err.println("Interrupt ^C");
+ }
+
+ private class ConsoleInputStream extends InputStream
+ {
+ @Override
+ public int read() throws IOException
+ {
+ if (!running)
+ {
+ return -1;
+ }
+ checkInterrupt();
+ int i;
+ try {
+ i = queue.take();
+ }
+ catch (InterruptedException e)
+ {
+ throw new InterruptedIOException();
+ }
+ if (i == 4)
+ {
+ return -1;
+ }
+ checkInterrupt();
+ return i;
+ }
+ }
+
+ private class Pipe implements Runnable
+ {
+ public void run()
+ {
+ try {
+ InputStream in = session.getKeyboard();
+ while (running)
+ {
+ try
+ {
+ int c = in.read();
+ if (c == -1 || c == 4)
+ {
+ //System.err.println("Received " + c + " ... closing");
+ session.getConsole().println("^D");
+ queue.put(c);
+ return;
+ }
+ else if (c == 3)
+ {
+ session.getConsole().println("^C");
+ reader.getCursorBuffer().clearBuffer();
+ interrupt();
+ queue.put(c);
+ }
+ else
+ {
+ queue.put(c);
+ }
+ }
+ catch (Throwable t) {
+ //System.err.println("Exception in pipe: " + t);
+ return;
+ }
+ }
+ }
+ finally
+ {
+ //System.err.println("Exiting pipe thread");
+ close();
+ }
+ }
+ }
+
+}
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/ConsoleFactory.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/ConsoleFactory.java
new file mode 100644
index 0000000..fcce928
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/ConsoleFactory.java
@@ -0,0 +1,106 @@
+/*
+ * 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.felix.karaf.gshell.console.jline;
+
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.felix.karaf.gshell.console.ansi.AnsiOutputStream;
+import org.apache.felix.karaf.gshell.console.Completer;
+import org.apache.felix.karaf.gshell.console.completer.AggregateCompleter;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.command.CommandProcessor;
+import org.osgi.service.command.CommandSession;
+import jline.Terminal;
+
+public class ConsoleFactory {
+
+ private BundleContext bundleContext;
+ private CommandProcessor commandProcessor;
+ private List<Completer> completers;
+ private Terminal terminal;
+ private Console console;
+ private boolean start;
+
+ public void setBundleContext(BundleContext bundleContext) {
+ this.bundleContext = bundleContext;
+ }
+
+ public synchronized void registerCommandProcessor(CommandProcessor commandProcessor) throws Exception {
+ this.commandProcessor = commandProcessor;
+ start();
+ }
+
+ public synchronized void unregisterCommandProcessor(CommandProcessor commandProcessor) throws Exception {
+ this.commandProcessor = null;
+ stop();
+ }
+
+ public void setCompleters(List<Completer> completers) {
+ this.completers = completers;
+ }
+
+ public void setTerminal(Terminal terminal) {
+ this.terminal = terminal;
+ }
+
+ public void setStart(boolean start) {
+ this.start = start;
+ }
+
+ protected void start() throws Exception {
+ if (start) {
+ InputStream in = unwrap(System.in);
+ PrintStream out = unwrap(System.out);
+ PrintStream err = unwrap(System.err);
+ CommandSession session = this.commandProcessor.createSession(
+ in, new PrintStream(new AnsiOutputStream(out)), new PrintStream(new AnsiOutputStream(err)));
+ session.put("USER", "karaf");
+ session.put("APPLICATION", System.getProperty("karaf.name", "root"));
+ Runnable callback = new Runnable() {
+ public void run() {
+ try {
+ bundleContext.getBundle(0).stop();
+ } catch (Exception e) {
+ // Ignore
+ }
+ }
+ };
+ this.console = new Console(session, terminal, new AggregateCompleter(completers), callback);
+ new Thread(console, "Karaf Shell Console Thread").start();
+ }
+ }
+
+ protected void stop() throws Exception {
+ if (console != null) {
+ console.close();
+ }
+ }
+
+ private static <T> T unwrap(T stream) {
+ try {
+ Method mth = stream.getClass().getMethod("getRoot");
+ return (T) mth.invoke(stream);
+ } catch (Throwable t) {
+ return stream;
+ }
+ }
+}
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/TerminalFactory.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/TerminalFactory.java
new file mode 100644
index 0000000..c0fed24
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/TerminalFactory.java
@@ -0,0 +1,61 @@
+package org.apache.felix.karaf.gshell.console.jline;
+
+import java.lang.reflect.Method;
+
+import jline.Terminal;
+import jline.WindowsTerminal;
+import jline.UnixTerminal;
+import jline.UnsupportedTerminal;
+
+public class TerminalFactory {
+
+ private Terminal term;
+ private Thread hook;
+
+ public Terminal getTerminal() throws Exception {
+ init();
+ return term;
+ }
+
+ public synchronized void init() throws Exception {
+ boolean windows = System.getProperty("os.name").toLowerCase().contains("windows");
+ try {
+ if (windows) {
+ WindowsTerminal t = new WindowsTerminal();
+ t.setDirectConsole(true);
+ t.initializeTerminal();
+ term = t;
+ } else {
+ UnixTerminal t = new UnixTerminal();
+ Method mth = UnixTerminal.class.getDeclaredMethod("stty", String.class);
+ mth.setAccessible(true);
+ mth.invoke(null, "intr undef");
+ t.initializeTerminal();
+ hook = new Thread() {
+ public void run() {
+ try {
+ Method mth = UnixTerminal.class.getDeclaredMethod("stty", String.class);
+ mth.setAccessible(true);
+ mth.invoke(null, "intr ^C");
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ };
+ Runtime.getRuntime().addShutdownHook(hook);
+ term = t;
+ }
+ } catch (Throwable e) {
+ term = new UnsupportedTerminal();
+ }
+ }
+
+ public synchronized void destroy() throws Exception {
+ if (hook != null) {
+ hook.run();
+ Runtime.getRuntime().removeShutdownHook(hook);
+ hook = null;
+ }
+ }
+
+}
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/keybindings.properties b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/keybindings.properties
new file mode 100644
index 0000000..6f13615
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/jline/keybindings.properties
@@ -0,0 +1,62 @@
+# Keybinding mapping for JLine. The format is:
+# [key code]: [logical operation]
+
+# CTRL-B: move to the previous character
+2: PREV_CHAR
+
+# CTRL-G: move to the previous word
+7: PREV_WORD
+
+# CTRL-F: move to the next character
+6: NEXT_CHAR
+
+# CTRL-A: move to the beginning of the line
+1: MOVE_TO_BEG
+
+# CTRL-D: close out the input stream
+4: EXIT
+
+# CTRL-E: move the cursor to the end of the line
+5: MOVE_TO_END
+
+# BACKSPACE, CTRL-H: delete the previous character
+# 8 is the ASCII code for backspace and therefor
+# deleting the previous character
+8: DELETE_PREV_CHAR
+
+# TAB, CTRL-I: signal that console completion should be attempted
+9: COMPLETE
+
+# CTRL-J, CTRL-M: newline
+10: NEWLINE
+
+# CTRL-K: erase the current line
+11: KILL_LINE
+
+# ENTER: newline
+13: NEWLINE
+
+# CTRL-L: clear screen
+12: CLEAR_SCREEN
+
+# CTRL-N: scroll to the next element in the history buffer
+14: NEXT_HISTORY
+
+# CTRL-P: scroll to the previous element in the history buffer
+16: PREV_HISTORY
+
+# CTRL-R: redraw the current line
+18: REDISPLAY
+
+# CTRL-U: delete all the characters before the cursor position
+21: KILL_LINE_PREV
+
+# CTRL-V: paste the contents of the clipboard (useful for Windows terminal)
+22: PASTE
+
+# CTRL-W: delete the word directly before the cursor
+23: DELETE_PREV_WORD
+
+# DELETE, CTRL-?: delete the previous character
+# 127 is the ASCII code for delete
+127: DELETE_PREV_CHAR
diff --git a/karaf/gshell/gshell-core/src/main/resources/OSGI-INF/blueprint/gshell-namespacehandler.xml b/karaf/gshell/gshell-console/src/main/resources/OSGI-INF/blueprint/gshell-namespacehandler.xml
similarity index 92%
rename from karaf/gshell/gshell-core/src/main/resources/OSGI-INF/blueprint/gshell-namespacehandler.xml
rename to karaf/gshell/gshell-console/src/main/resources/OSGI-INF/blueprint/gshell-namespacehandler.xml
index 453395d..1c0c01a 100644
--- a/karaf/gshell/gshell-core/src/main/resources/OSGI-INF/blueprint/gshell-namespacehandler.xml
+++ b/karaf/gshell/gshell-console/src/main/resources/OSGI-INF/blueprint/gshell-namespacehandler.xml
@@ -23,7 +23,7 @@
<service-properties>
<entry key="osgi.service.blueprint.namespace" value="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0"/>
</service-properties>
- <bean class="org.apache.felix.karaf.gshell.core.config.NamespaceHandler"/>
+ <bean class="org.apache.felix.karaf.gshell.console.commands.NamespaceHandler"/>
</service>
</blueprint>
diff --git a/karaf/gshell/gshell-console/src/main/resources/OSGI-INF/blueprint/karaf-console.xml b/karaf/gshell/gshell-console/src/main/resources/OSGI-INF/blueprint/karaf-console.xml
new file mode 100644
index 0000000..4182dae
--- /dev/null
+++ b/karaf/gshell/gshell-console/src/main/resources/OSGI-INF/blueprint/karaf-console.xml
@@ -0,0 +1,62 @@
+<?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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:ext="http://geronimo.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
+
+ <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
+
+ <reference id="commandProcessor" interface="org.osgi.service.command.CommandProcessor">
+ <reference-listener ref="consoleFactory"
+ bind-method="registerCommandProcessor"
+ unbind-method="unregisterCommandProcessor"/>
+ </reference>
+
+ <reference-list id="functions" filter="(&(osgi.command.scope=*)(osgi.command.function=*))"
+ availability="optional">
+ <reference-listener ref="commandCompleter"
+ bind-method="register"
+ unbind-method="unregister"/>
+ </reference-list>
+
+ <bean id="commandCompleter" class="org.apache.felix.karaf.gshell.console.completer.CommandsCompleter">
+ <property name="bundleContext" ref="blueprintBundleContext"/>
+ </bean>
+
+ <bean id="consoleFactory" class="org.apache.felix.karaf.gshell.console.jline.ConsoleFactory">
+ <property name="start" value="$[karaf.startLocalConsole]"/>
+ <property name="bundleContext" ref="blueprintBundleContext"/>
+ <property name="completers">
+ <list>
+ <ref component-id="commandCompleter"/>
+ </list>
+ </property>
+ <property name="terminal" ref="terminal"/>
+ </bean>
+
+ <bean id="terminal"
+ factory-ref="terminalFactory"
+ factory-method="getTerminal"/>
+
+ <bean id="terminalFactory" class="org.apache.felix.karaf.gshell.console.jline.TerminalFactory"
+ init-method="init"
+ destroy-method="destroy"/>
+
+
+</blueprint>
diff --git a/karaf/gshell/gshell-core/src/main/resources/org/apache/felix/karaf/gshell/core/karaf-gshell.xsd b/karaf/gshell/gshell-console/src/main/resources/org/apache/felix/karaf/gshell/console/commands/karaf-gshell.xsd
similarity index 100%
rename from karaf/gshell/gshell-core/src/main/resources/org/apache/felix/karaf/gshell/core/karaf-gshell.xsd
rename to karaf/gshell/gshell-console/src/main/resources/org/apache/felix/karaf/gshell/console/commands/karaf-gshell.xsd
diff --git a/karaf/gshell/gshell-core/pom.xml b/karaf/gshell/gshell-core/pom.xml
deleted file mode 100644
index 9dd60d2..0000000
--- a/karaf/gshell/gshell-core/pom.xml
+++ /dev/null
@@ -1,430 +0,0 @@
-<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.felix.karaf.gshell</groupId>
- <artifactId>gshell</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
- <packaging>bundle</packaging>
- <version>1.2.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: GShell Core</name>
-
- <description>
- Provides the OSGi GShell integration
- </description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf.jaas</groupId>
- <artifactId>org.apache.felix.karaf.jaas.config</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.commands</groupId>
- <artifactId>gshell-builtin</artifactId>
- <exclusions>
- <exclusion>
- <groupId>oro</groupId>
- <artifactId>oro</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-vfs</groupId>
- <artifactId>commons-vfs</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.commands</groupId>
- <artifactId>gshell-file</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.commands</groupId>
- <artifactId>gshell-network</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.commands</groupId>
- <artifactId>gshell-shell</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.commands</groupId>
- <artifactId>gshell-text</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.wisdom</groupId>
- <artifactId>gshell-wisdom-core</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.apache.geronimo.gshell.support</groupId>
- <artifactId>gshell-ivy</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.geronimo.gshell.support</groupId>
- <artifactId>gshell-xstore</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-jexl</groupId>
- <artifactId>commons-jexl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.commons-httpclient</artifactId>
- <exclusions>
- <exclusion>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.commons-codec</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.commons-jexl</artifactId>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.commons-vfs</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.oro</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.sshd</groupId>
- <artifactId>sshd-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.jline</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo</groupId>
- <artifactId>blueprint-bundle</artifactId>
- </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>
- <Import-Package>
- org.apache.commons.vfs.provider.temp,
- org.apache.commons.vfs.provider.ram,
- jline*,
- org.apache.felix.karaf.jaas.config;resolution:=optional,
- org.apache.felix.karaf.version;resolution:=optional,
- org.apache.felix.karaf.main.spi;resolution:=optional;version="1.0.0",
- org.apache.sshd.server.keyprovider,
- org.apache.sshd.server.jaas,
- !org.springframework*,
- *
- </Import-Package>
- <Export-Package>
- org.apache.geronimo.gshell*;version="1.0.0.alpha-2";-split-package:=merge-first,
- org.apache.felix.karaf.gshell.core*;version=${project.version};-split-package:=merge-first,
- </Export-Package>
- <Private-Package>
- org.codehaus.plexus.interpolation*,
- </Private-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- <unpackBundle>true</unpackBundle>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <includes>
- <include>org.apache.geronimo.gshell:gshell-api</include>
- <include>org.apache.geronimo.gshell:gshell-application</include>
- <include>org.apache.geronimo.gshell:gshell-parser</include>
- <include>org.apache.geronimo.gshell.commands:gshell-builtin</include>
- <include>org.apache.geronimo.gshell.commands:gshell-file</include>
- <include>org.apache.geronimo.gshell.commands:gshell-network</include>
- <include>org.apache.geronimo.gshell.commands:gshell-shell</include>
- <include>org.apache.geronimo.gshell.commands:gshell-text</include>
- <include>org.apache.geronimo.gshell.support:gshell-ansi</include>
- <include>org.apache.geronimo.gshell.support:gshell-artifact</include>
- <include>org.apache.geronimo.gshell.support:gshell-chronos</include>
- <include>org.apache.geronimo.gshell.support:gshell-clp</include>
- <include>org.apache.geronimo.gshell.support:gshell-console</include>
- <include>org.apache.geronimo.gshell.support:gshell-event</include>
- <include>org.apache.geronimo.gshell.support:gshell-i18n</include>
- <include>org.apache.geronimo.gshell.support:gshell-interpolation</include>
- <include>org.apache.geronimo.gshell.support:gshell-io</include>
- <include>org.apache.geronimo.gshell.support:gshell-spring</include>
- <include>org.apache.geronimo.gshell.support:gshell-terminal</include>
- <include>org.apache.geronimo.gshell.support:gshell-vfs</include>
- <include>org.apache.geronimo.gshell.support:gshell-vfs-meta</include>
- <include>org.apache.geronimo.gshell.support:gshell-yarn</include>
- <include>org.apache.geronimo.gshell.wisdom:gshell-wisdom-core</include>
- <include>org.apache.geronimo.gshell.wisdom:gshell-wisdom-bootstrap</include>
- <include>org.codehaus.plexus:plexus-interpolation</include>
- <include>${project.groupId}:${project.artifactId}</include>
- </includes>
- </artifactSet>
- <filters>
- <filter>
- <artifact>org.apache.geronimo.gshell:gshell-api</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell:gshell-application</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell:gshell-parser</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.commands:gshell-builtin</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.commands:gshell-file</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.commands:gshell-network</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.commands:gshell-shell</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.commands:gshell-text</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-ansi</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-artifact</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-chronos</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-clp</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-console</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-event</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-i18n</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-interpolation</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-io</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-spring</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-terminal</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-vfs</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-vfs-meta</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.support:gshell-yarn</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.wisdom:gshell-wisdom-core</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- <exclue>META-INF/spring.*</exclue>
- </excludes>
- </filter>
- <filter>
- <artifact>org.apache.geronimo.gshell.wisdom:gshell-wisdom-bootstrap</artifact>
- <excludes>
- <exclude>org/apache/geronimo/gshell/**</exclude>
- </excludes>
- </filter>
- <filter>
- <artifact>org.codehaus.plexus:plexus-interpolation</artifact>
- <excludes>
- <exclude>org/codehaus/plexus/**</exclude>
- </excludes>
- </filter>
- </filters>
- <createSourcesJar>${createSourcesJar}</createSourcesJar>
- <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
- <createDependencyReducedPom>true</createDependencyReducedPom>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/gshell/gshell-core/src/main/filtered-resources/org/apache/felix/karaf/gshell/core/karaf-version.properties b/karaf/gshell/gshell-core/src/main/filtered-resources/org/apache/felix/karaf/gshell/core/karaf-version.properties
deleted file mode 100644
index 1fc0355..0000000
--- a/karaf/gshell/gshell-core/src/main/filtered-resources/org/apache/felix/karaf/gshell/core/karaf-version.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-##
-## 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.
-##
-
-version=${pom.version}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/ApplicationImpl.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/ApplicationImpl.java
deleted file mode 100644
index 4c01969..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/ApplicationImpl.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.URL;
-import java.util.Properties;
-
-import org.apache.geronimo.gshell.application.Application;
-import org.apache.geronimo.gshell.application.ClassPath;
-import org.apache.geronimo.gshell.application.model.ApplicationModel;
-import org.apache.geronimo.gshell.artifact.Artifact;
-import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.io.IO;
-import org.springframework.beans.factory.InitializingBean;
-
-public class ApplicationImpl implements Application {
-
- private static final String EMBEDDED_PROPS = "org/apache/felix/karaf/version/embedded.properties";
- private static final String SERVICEMIX_VERSION ="org/apache/felix/karaf/gshell/core/karaf-version.properties";
- private static final String VERSION_PROPERTY = "version";
-
- private String id;
- private IO io;
- private ApplicationModel model;
- private Variables variables;
- private InetAddress localHost;
- private File homeDir;
- private URL embeddedResource = null;
-
- public ApplicationImpl() throws Exception {
- this.localHost = InetAddress.getLocalHost();
- this.homeDir = detectHomeDir();
- }
-
- public void init() throws Exception {
- Properties props = new Properties();
- props.load(getClass().getClassLoader().getResourceAsStream(SERVICEMIX_VERSION));
- String kernelVersion = props.getProperty(VERSION_PROPERTY);
- this.model.setVersion(kernelVersion);
- DefaultBranding branding = (DefaultBranding) this.model.getBranding();
- branding.setVersion(kernelVersion);
-
- if (this.getClass().getClassLoader().getResource(EMBEDDED_PROPS) != null) {
- embeddedResource = this.getClass().getClassLoader().getResource(EMBEDDED_PROPS);
- branding.setEmbeddedResource(embeddedResource);
- }
- }
-
- public URL getEmbeddedResource() {
- return embeddedResource;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public IO getIo() {
- return io;
- }
-
- public void setIo(IO io) {
- this.io = io;
- }
-
- public Variables getVariables() {
- return variables;
- }
-
- public void setVariables(Variables variables) {
- this.variables = variables;
- }
-
- public ApplicationModel getModel() {
- return model;
- }
-
- public void setModel(ApplicationModel model) {
- this.model = model;
- }
-
- public ClassPath getClassPath() {
- throw new UnsupportedOperationException();
- }
-
- public File getHomeDir() {
- if (homeDir == null) {
- throw new IllegalStateException();
- }
- return homeDir;
- }
-
- public InetAddress getLocalHost() {
- return localHost;
- }
-
- public String getUserName() {
- return System.getProperty("user.name");
- }
-
- public Artifact getArtifact() {
- return null;
- }
-
- private File detectHomeDir() {
- String homePath = System.getProperty("user.home");
- // And now lets resolve this sucker
- File dir;
- try {
- dir = new File(homePath).getCanonicalFile();
- }
- catch (IOException e) {
- throw new RuntimeException("Failed to resolve home directory: " + homePath, e);
- }
- // And some basic sanity too
- if (!dir.exists() || !dir.isDirectory()) {
- throw new RuntimeException("Home directory configured but is not a valid directory: " + dir);
- }
-
- return dir;
- }
-
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/ApplicationManagerImpl.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/ApplicationManagerImpl.java
deleted file mode 100644
index 3abab2d..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/ApplicationManagerImpl.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core;
-
-import org.apache.geronimo.gshell.application.Application;
-import org.apache.geronimo.gshell.application.ApplicationConfiguration;
-import org.apache.geronimo.gshell.application.ApplicationManager;
-import org.apache.geronimo.gshell.event.EventPublisher;
-import org.apache.geronimo.gshell.io.SystemOutputHijacker;
-import org.apache.geronimo.gshell.shell.Shell;
-import org.apache.geronimo.gshell.wisdom.application.ShellCreatedEvent;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-
-public class ApplicationManagerImpl implements ApplicationManager {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private EventPublisher eventPublisher;
-
- private Application application;
-
- private BlueprintContainer blueprintContainer;
-
- public ApplicationManagerImpl(EventPublisher eventPublisher, Application application, BlueprintContainer blueprintContainer) {
- this.eventPublisher = eventPublisher;
- this.application = application;
- this.blueprintContainer = blueprintContainer;
- }
-
- public void init() throws Exception {
- if (!SystemOutputHijacker.isInstalled()) {
- SystemOutputHijacker.install();
- }
- //SystemOutputHijacker.register(application.getIo().outputStream, application.getIo().errorStream);
- }
-
- public void destroy() {
- SystemOutputHijacker.uninstall();
- }
-
- public void configure(ApplicationConfiguration applicationConfiguration) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- public Application getApplication() {
- return application;
- }
-
- public Shell create() throws Exception {
- final Shell shell = (Shell) blueprintContainer.getComponentInstance("shell");
-
- log.debug("Created shell instance: {}", shell);
-
- eventPublisher.publish(new ShellCreatedEvent(shell));
-
- return shell;
- }
-
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/BeanContainerWrapper.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/BeanContainerWrapper.java
deleted file mode 100644
index 6b58107..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/BeanContainerWrapper.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core;
-
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Map;
-
-import org.apache.geronimo.gshell.spring.BeanContainer;
-import org.apache.geronimo.gshell.wisdom.command.GroupCommand;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.NoSuchBeanDefinitionException;
-import org.springframework.context.ApplicationContext;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-
-public class BeanContainerWrapper implements BeanContainer {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private BlueprintContainer container;
-
- public BeanContainerWrapper(BlueprintContainer container) {
- this.container = container;
- }
-
- public BeanContainer getParent() {
- return null;
- }
-
- public ClassLoader getClassLoader() {
- return null;
- }
-
- public void loadBeans(String[] strings) throws Exception {
- throw new UnsupportedOperationException();
- }
-
- public <T> T getBean(Class<T> type) {
- assert type != null;
-
- if (GroupCommand.class.isAssignableFrom(type)) {
- return type.cast(new GroupCommand());
- }
- throw new UnsupportedOperationException();
- }
-
- public <T> T getBean(String name, Class<T> requiredType) {
- assert name != null;
- assert requiredType != null;
-
- log.trace("Getting bean named '{}' of type: {}", name, requiredType);
-
- return requiredType.cast(container.getComponentInstance(name));
- }
-
- public <T> Map<String, T> getBeans(Class<T> type) {
- throw new UnsupportedOperationException();
- }
-
- public String[] getBeanNames() {
- throw new UnsupportedOperationException();
- }
-
- public String[] getBeanNames(Class type) {
- throw new UnsupportedOperationException();
- }
-
- public BeanContainer createChild(Collection<URL> urls) {
- throw new UnsupportedOperationException();
- }
-
- public BeanContainer createChild() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/CommandResolverImpl.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/CommandResolverImpl.java
deleted file mode 100644
index 23c3519..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/CommandResolverImpl.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core;
-
-import org.apache.commons.vfs.FileContent;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.geronimo.gshell.command.Command;
-import org.apache.geronimo.gshell.command.CommandException;
-import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.registry.CommandResolver;
-import org.apache.geronimo.gshell.registry.NoSuchCommandException;
-import org.apache.geronimo.gshell.spring.BeanContainer;
-import org.apache.geronimo.gshell.spring.BeanContainerAware;
-import org.apache.geronimo.gshell.vfs.FileSystemAccess;
-import org.apache.geronimo.gshell.wisdom.command.AliasCommand;
-import org.apache.geronimo.gshell.wisdom.command.GroupCommand;
-import org.apache.geronimo.gshell.wisdom.registry.GroupDirectoryResolver;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * {@link CommandResolver} component.
- *
- * @version $Rev: 741078 $ $Date: 2009-02-05 12:39:10 +0100 (Thu, 05 Feb 2009) $
- */
-public class CommandResolverImpl
- implements CommandResolver, BeanContainerAware
-{
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private final FileSystemAccess fileSystemAccess;
-
- private final GroupDirectoryResolver groupDirResolver;
-
- private FileObject commandsRoot;
-
- private FileObject aliasesRoot;
-
- private BeanContainer container;
-
- private String aliasCommandBeanId;
- private String groupCommandBeanId;
-
- public CommandResolverImpl(final FileSystemAccess fileSystemAccess, final GroupDirectoryResolver groupDirResolver) {
- assert fileSystemAccess != null;
- this.fileSystemAccess = fileSystemAccess;
-
- assert groupDirResolver != null;
- this.groupDirResolver = groupDirResolver;
- }
-
- public void setBeanContainer(final BeanContainer container) {
- assert container != null;
-
- this.container = container;
- }
-
- public void setAliasCommandBeanId(String aliasCommandBeanId) {
- this.aliasCommandBeanId = aliasCommandBeanId;
- }
-
- public void setGroupCommandBeanId(String groupCommandBeanId) {
- this.groupCommandBeanId = groupCommandBeanId;
- }
-
- //
- // TODO: Consider adding an undefined command handler to allow for even more customization of
- // execution when no defined command is found? So one can say directly execute a
- // *.gsh script, which under the covers will translate into 'source *.gsh' (or really
- // should be 'shell *.gsh' once we have a sub-shell command.
- //
-
- public Command resolveCommand(final String name, final Variables variables) throws CommandException {
- assert name != null;
- assert variables != null;
-
- log.debug("Resolving command name: {}", name);
-
- // Always try to resolve aliases before we resolve commands
- Command command = resolveAliasCommand(name, variables);
-
- if (command == null) {
- try {
- FileObject file = resolveCommandFile(name, variables);
-
- if (file != null) {
- command = createCommand(file);
- }
- }
- catch (FileSystemException e) {
- log.warn("Unable to resolve command for name: " + name, e);
- }
- }
-
- if (command == null) {
- throw new NoSuchCommandException(name);
- }
-
- log.debug("Resolved command: {}", command);
-
- return command;
- }
-
- private FileObject getAliasesRoot() throws FileSystemException {
- if (aliasesRoot == null) {
- aliasesRoot = fileSystemAccess.createVirtualFileSystem(ALIASES_ROOT);
- }
-
- return aliasesRoot;
- }
-
- private AliasCommand resolveAliasCommand(final String name, final Variables variables) {
- assert name != null;
- assert variables != null;
-
- log.trace("Resolving alias for name: {}", name);
-
- AliasCommand command = null;
-
- try {
- FileObject root = getAliasesRoot();
- FileObject file = root.resolveFile(name);
-
- if (file != null && file.exists()) {
- log.trace("Resolved file: {}", file);
-
- command = createAliasCommand(file);
- }
- }
- catch (FileSystemException e) {
- log.debug("Failed to resolve alias command for name: " + name, e);
- }
-
- return command;
- }
-
- private FileObject getCommandsRoot() throws FileSystemException {
- if (commandsRoot == null) {
- commandsRoot = fileSystemAccess.createVirtualFileSystem(COMMANDS_ROOT);
- }
-
- return commandsRoot;
- }
-
- private FileObject resolveCommandFile(final String name, final Variables variables) throws FileSystemException {
- assert name != null;
- assert variables != null;
-
- log.trace("Resolving command file: {}", name);
-
- FileObject root = getCommandsRoot();
-
- // Special handling for root & group
- if (name.equals("/")) {
- return root;
- }
- else if (name.equals(".")) {
- return groupDirResolver.getGroupDirectory(variables);
- }
-
- Collection<String> searchPath = getSearchPath(variables);
-
- log.trace("Search path: {}", searchPath);
-
- FileObject groupDir = groupDirResolver.getGroupDirectory(variables);
-
- log.trace("Group dir: {}", groupDir);
-
- FileObject file = null;
-
- for (String pathElement : searchPath) {
- log.trace("Resolving file; name={}, pathElement={}", name, pathElement);
-
- FileObject dir;
-
- if (pathElement.equals("/")) {
- dir = root;
- }
- else if (pathElement.startsWith("/")) {
- dir = fileSystemAccess.resolveFile(root, pathElement.substring(1, pathElement.length()));
- }
- else {
- dir = fileSystemAccess.resolveFile(groupDir, pathElement);
- }
-
- log.trace("Dir: {}", dir);
-
- FileObject tmp = fileSystemAccess.resolveFile(dir, name);
-
- log.trace("File: {}", tmp);
-
- if (tmp.exists()) {
- file = tmp;
- break;
- }
- }
-
- if (file != null) {
- log.trace("Resolved file: {}", file);
- }
-
- return file;
- }
-
- private Collection<String> getSearchPath(final Variables vars) {
- assert vars != null;
-
- Object tmp = vars.get(PATH);
-
- if (tmp instanceof String) {
- return Arrays.asList(((String)tmp).split(PATH_SEPARATOR));
- }
- else if (tmp != null) {
- log.error("Invalid type for variable '" + PATH + "'; expected String; found: " + tmp.getClass());
- }
-
- // Return the default search path (group then root)
- return Arrays.asList(".", "/");
- }
-
- public Collection<Command> resolveCommands(String name, Variables variables) throws CommandException {
- // name may be null
- assert variables != null;
-
- if (name == null) {
- name = "";
- }
-
- log.debug("Resolving commands for name: {}", name);
-
- List<Command> commands = new ArrayList<Command>();
-
- try {
- FileObject file = resolveCommandFile(name, variables);
-
- log.trace("Resolved (for commands): {}", file);
-
- if (file != null && file.exists()) {
- if (file.getType().hasChildren()) {
- for (FileObject child : file.getChildren()) {
- Command command = createCommand(child);
- commands.add(command);
- }
- }
- else {
- Command command = createCommand(file);
- commands.add(command);
- }
- }
- }
- catch (FileSystemException e) {
- log.warn("Failed to resolve commands for name: " + name, e);
- }
-
- log.debug("Resolved {} commands", commands.size());
- if (log.isTraceEnabled()) {
- for (Command command : commands) {
- log.trace(" {}", command);
- }
- }
-
- return commands;
- }
-
- private Command createCommand(FileObject file) throws FileSystemException, CommandException {
- assert file != null;
-
- // HACK: Must dereference to avoid problems with the DelegateFileObject impl
- file = fileSystemAccess.dereference(file);
-
- log.trace("Creating command for file: {} ({})", file, file.getClass());
-
- Command command = null;
-
- if (file.exists()) {
- FileContent content = file.getContent();
- command = (Command)content.getAttribute("COMMAND");
-
- if (command == null) {
- if (file.getType().hasChildren()) {
- command = createGroupCommand(file);
- content.setAttribute("COMMAND", command);
- }
-
- // TODO: Try to construct AliasCommand?
- }
- }
-
- if (command == null) {
- throw new CommandException("Unable to create command for file: " + file.getName());
- }
-
- return command;
- }
-
- private AliasCommand createAliasCommand(final FileObject file) throws FileSystemException {
- assert file != null;
-
- String name = file.getName().getBaseName();
-
- log.trace("Creating command for alias: {}", name);
-
- AliasCommand command = container.getBean(aliasCommandBeanId, AliasCommand.class);
-
- String alias = (String) file.getContent().getAttribute("ALIAS");
- if (alias == null) {
- throw new IllegalStateException("Alias meta-file does not contain 'ALIAS' attribute: " + file);
- }
-
- command.setName(name);
- command.setAlias(alias);
-
- return command;
- }
-
- private GroupCommand createGroupCommand(final FileObject file) throws FileSystemException {
- assert file != null;
-
- log.trace("Creating command for group: {}", file);
-
- GroupCommand command = container.getBean(groupCommandBeanId, GroupCommand.class);
- String path = fileSystemAccess.dereference(commandsRoot).getName().getRelativeName(file.getName());
- if (".".equals(path)) {
- path = "/";
- }
- command.setPath(path);
-
- return command;
- }
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/DefaultBranding.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/DefaultBranding.java
deleted file mode 100644
index 81e3546..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/DefaultBranding.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URL;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.apache.geronimo.gshell.ansi.AnsiBuffer;
-import org.apache.geronimo.gshell.ansi.AnsiCode;
-import org.apache.geronimo.gshell.ansi.AnsiRenderWriter;
-import org.apache.geronimo.gshell.application.model.Branding;
-
-public class DefaultBranding extends Branding {
-
- private String prompt;
- private String[] banner;
- private String displayName;
- private String displayVersion;
- private String displayLocation;
- private String applicationName;
- private String applicationVersion;
- private String applicationLocation;
-
- private String[] defaultBanner = {
-" __ __ ____",
-" / //_/____ __________ _/ __/",
-" / ,< / __ `/ ___/ __ `/ /_",
-" / /| |/ /_/ / / / /_/ / __/",
-" /_/ |_|\\__,_/_/ \\__,_/_/"
- };
-
- public DefaultBranding() {
- banner = defaultBanner;
- displayName = "Apache Felix Karaf";
- displayLocation = "http://felix.apache.org/site/apache-felix-karaf.html";
- }
-
- public void setEmbeddedResource(URL embeddedResource) {
- Properties brandProps = loadPropertiesFile(embeddedResource);
- String brandBanner = brandProps.getProperty("banner");
- int i = 0;
- char quot = '"';
-
- StringTokenizer st = new StringTokenizer(brandBanner, ",");
- banner = new String[st.countTokens()];
-
- while (st.hasMoreTokens()) {
- banner[i] = st.nextToken();
- banner[i] = banner[i].substring(1, banner[i].lastIndexOf(quot));
- i++;
- }
-
- applicationName = brandProps.getProperty("application.name");
- applicationVersion = brandProps.getProperty("application.version");
- applicationLocation = brandProps.getProperty("application.location");
- }
-
- public String getName() {
- return "karaf";
- }
-
- public String getDisplayName() {
- return displayName;
- }
-
- public void setVersion(String version) {
- displayVersion = version;
- }
-
- public String getVersion() {
- return displayVersion;
- }
-
- public String getApplicationName() {
- return applicationName;
- }
-
- public String getApplicationVersion() {
- return applicationVersion;
- }
-
- public String getProgramName() {
- throw new UnsupportedOperationException();
- }
-
- public String getPrompt() {
- return prompt;
- }
-
- public void setPrompt(String prompt) {
- this.prompt = prompt;
- }
-
- public String getAboutMessage() {
- StringWriter writer = new StringWriter();
- PrintWriter out = new AnsiRenderWriter(writer);
-
- out.println("For information about @|cyan " + displayName + "|, visit:");
- out.println(" @|bold " + displayLocation + "| ");
- out.flush();
-
- if (applicationName != null && applicationVersion != null) {
- out.println();
- out.println(applicationName + " " + applicationVersion);
- out.println();
- if (applicationLocation != null) {
- out.println("For information about @|cyan " + applicationName + "|, visit:");
- out.println(" @|bold " + applicationLocation + "| ");
- out.flush();
- }
- }
-
- return writer.toString();
- }
-
- public String getWelcomeMessage() {
- StringWriter writer = new StringWriter();
- PrintWriter out = new AnsiRenderWriter(writer);
-
- AnsiBuffer buff = new AnsiBuffer();
-
- for (String line : banner) {
- buff.attrib(line, AnsiCode.CYAN);
- out.println(buff);
- }
-
- out.println();
- out.println(" @|bold " + displayName + "| (" + displayVersion + ")");
- if (applicationName != null && applicationVersion != null) {
- out.println(" @|bold " + applicationName + "| (" + applicationVersion + ")");
- }
- out.println();
- out.println("Type '@|bold help|' for more information.");
- out.flush();
-
- return writer.toString();
- }
-
- private static Properties loadPropertiesFile(URL brandPropURL) {
- // Read the properties file.
- Properties brandProps = new Properties();
- InputStream is = null;
- try {
- is = brandPropURL.openConnection().getInputStream();
- brandProps.load(is);
- is.close();
- }
- catch (FileNotFoundException ex) {
- // Ignore file not found.
- }
- catch (Exception ex) {
- System.err.println(
- "Error loading embedded properties from " + brandPropURL);
- System.err.println("DefaultBranding: " + ex);
- try {
- if (is != null) is.close();
- }
- catch (IOException ex2) {
- // Nothing we can do.
- }
- return null;
- }
-
- return brandProps;
- }
-
-}
-
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/LocalConsole.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/LocalConsole.java
deleted file mode 100644
index 5c5c0d8..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/LocalConsole.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core;
-
-import java.util.Arrays;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.lang.reflect.Method;
-
-import org.apache.geronimo.gshell.notification.ExitNotification;
-import org.apache.geronimo.gshell.shell.Shell;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.util.tracker.ServiceTracker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class LocalConsole implements Runnable {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private Shell shell;
-
- private boolean createLocalShell;
-
- private BundleContext bundleContext;
-
- private CountDownLatch frameworkStarted;
-
- private ServiceTracker mainServiceTracker;
-
- public BundleContext getBundleContext() {
- return bundleContext;
- }
-
- public void setBundleContext(BundleContext bundleContext) {
- this.bundleContext = bundleContext;
- }
-
- public Shell getShell() {
- return shell;
- }
-
- public void setShell(Shell shell) {
- this.shell = shell;
- }
-
- public boolean isCreateLocalShell() {
- return createLocalShell;
- }
-
- public void setCreateLocalShell(boolean createLocalShell) {
- this.createLocalShell = createLocalShell;
- }
-
- public void init() {
- mainServiceTracker = new ServiceTracker(bundleContext, "org.apache.felix.karaf.main.spi.MainService", null);
- mainServiceTracker.open();
-
- shell.getContext().getVariables().set("gshell.username", "karaf");
- frameworkStarted = new CountDownLatch(1);
- getBundleContext().addFrameworkListener(new FrameworkListener(){
- public void frameworkEvent(FrameworkEvent event) {
- log.debug("Got event: " + event.getType());
- if( event.getType() == FrameworkEvent.STARTED ) {
- frameworkStarted.countDown();
- }
- }
- });
- if (createLocalShell) {
- new Thread(this, "localShell").start();
- }
- }
-
- public void destroy() {
- mainServiceTracker.close();
- if (createLocalShell) {
- shell.close();
- }
- }
-
- public void run() {
- try {
- String[] args = getMainServiceArgs();
- // If a command was specified on the command line, then just execute that command.
- if (args != null && args.length > 0) {
- waitForFrameworkToStart();
- log.info("Executing Shell with arguments: " + Arrays.toString(args));
- StringBuilder sb = new StringBuilder();
- for (String arg : args) {
- sb.append(arg).append(" ");
- }
- Object value = shell.execute(sb.toString());
- if (value instanceof Number) {
- setMainServiceExitCode(((Number) value).intValue());
- } else {
- setMainServiceExitCode(value != null ? 1 : 0);
- }
- log.info("Exiting shell due to terminated command");
- } else {
- shell.run();
- }
- } catch (ExitNotification e) {
- setMainServiceExitCode(0);
- log.info("Exiting shell due received exit notification");
- } catch (Throwable e) {
- setMainServiceExitCode(-1);
- log.error("Exiting shell due to caught exception " + e, e);
- } finally {
- try {
- shell.close();
- } catch (Throwable t) {}
- asyncShutdown();
- }
- }
-
- private String[] getMainServiceArgs() {
- try {
- Object mainService = mainServiceTracker.getService();
- if (mainService != null) {
- Method mth = mainService.getClass().getMethod("getArgs");
- return (String[]) mth.invoke(mainService);
- }
- } catch (Throwable t) {
- log.debug("Error getting MainService args", t);
- }
- return null;
- }
-
- private void setMainServiceExitCode(int exitCode) {
- try {
- Object mainService = mainServiceTracker.getService();
- if (mainService != null) {
- Method mth = mainService.getClass().getMethod("setExitCode", int.class);
- mth.invoke(mainService, exitCode);
- }
- } catch (Throwable t) {
- log.debug("Error setting MainService exit code", t);
- }
- }
-
- /**
- * Blocks until the framework has finished starting. We do this so that any installed
- * bundles for commands get fully registered.
- *
- * @throws InterruptedException
- */
- private void waitForFrameworkToStart() throws InterruptedException {
- log.info("Waiting from framework to start.");
- if (frameworkStarted.await(60, TimeUnit.SECONDS)) {
- log.info("System completed startup.");
- } else {
- log.warn("System took too long startup... continuing");
- }
- }
-
- private void asyncShutdown() {
- new Thread() {
- public void run() {
- try {
- getBundleContext().getBundle(0).stop();
- } catch (BundleException e) {
- log.info("Caught exception while shutting down framework: " + e, e);
- }
- }
- }.start();
- }
-
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiAliasRegistry.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiAliasRegistry.java
deleted file mode 100644
index d8d4732..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiAliasRegistry.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core;
-
-import java.util.Map;
-
-import org.apache.geronimo.gshell.command.Alias;
-import org.apache.geronimo.gshell.registry.AliasRegistry;
-
-public class OsgiAliasRegistry {
-
- public static final String NAME = "name";
- public static final String ALIAS = "alias";
-
- private AliasRegistry aliasRegistry;
-
- public OsgiAliasRegistry(AliasRegistry aliasRegistry) {
- this.aliasRegistry = aliasRegistry;
- }
-
- public synchronized void register(final Alias alias, Map<String, ?> properties) throws Exception {
- aliasRegistry.registerAlias(alias.getName(), alias.getAlias());
- }
-
- public synchronized void unregister(final Alias alias, Map<String, ?> properties) throws Exception {
- aliasRegistry.removeAlias(alias.getName());
- }
-
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiCommandRegistry.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiCommandRegistry.java
deleted file mode 100644
index 49ad0cb..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/OsgiCommandRegistry.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core;
-
-import java.util.Map;
-
-import org.apache.geronimo.gshell.command.Command;
-import org.apache.geronimo.gshell.command.Link;
-import org.apache.geronimo.gshell.registry.CommandRegistry;
-import org.apache.geronimo.gshell.wisdom.command.LinkCommand;
-import org.apache.geronimo.gshell.wisdom.registry.CommandLocationImpl;
-
-public class OsgiCommandRegistry {
-
- public static final String NAME = "name";
- public static final String TARGET = "target";
-
- private CommandRegistry commandRegistry;
-
- public OsgiCommandRegistry(CommandRegistry commandRegistry) {
- this.commandRegistry = commandRegistry;
- }
-
- public synchronized void register(final Command command, Map props) throws Exception {
- commandRegistry.registerCommand(command);
- }
-
- public synchronized void unregister(final Command command, Map props) throws Exception {
- commandRegistry.removeCommand(command);
- }
-
- public synchronized void register(final Link link, Map props) throws Exception {
- LinkCommand cmd = new LinkCommand(commandRegistry, link.getTarget());
- cmd.setLocation(new CommandLocationImpl(link.getName()));
- commandRegistry.registerCommand(cmd);
- }
-
- public synchronized void unregister(final Link link, Map props) throws Exception {
- commandRegistry.removeCommand(commandRegistry.getCommand(link.getName()));
- }
-
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/ShellWrapper.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/ShellWrapper.java
deleted file mode 100644
index 3a0b3c6..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/ShellWrapper.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core;
-
-import org.apache.geronimo.gshell.shell.Shell;
-import org.apache.geronimo.gshell.shell.ShellContext;
-import org.apache.geronimo.gshell.shell.ShellContextHolder;
-
-public class ShellWrapper implements Shell {
-
- private Shell delegate;
-
- public ShellWrapper(Shell delegate) {
- this.delegate = delegate;
- }
-
- public ShellContext getContext() {
- return delegate.getContext();
- }
-
- public Object execute(String s) throws Exception {
- ShellContext ctx = ShellContextHolder.get(true);
- try {
- ShellContextHolder.set(getContext());
- return delegate.execute(s);
- } finally {
- ShellContextHolder.set(ctx);
- }
- }
-
- public Object execute(String s, Object[] objects) throws Exception {
- ShellContext ctx = ShellContextHolder.get(true);
- try {
- ShellContextHolder.set(getContext());
- return delegate.execute(s, objects);
- } finally {
- ShellContextHolder.set(ctx);
- }
- }
-
- public Object execute(Object... objects) throws Exception {
- ShellContext ctx = ShellContextHolder.get(true);
- try {
- ShellContextHolder.set(getContext());
- return delegate.execute(objects);
- } finally {
- ShellContextHolder.set(ctx);
- }
- }
-
- public boolean isOpened() {
- return delegate.isOpened();
- }
-
- public void close() {
- delegate.close();
- }
-
- public boolean isInteractive() {
- return delegate.isInteractive();
- }
-
- public void run(Object... objects) throws Exception {
- ShellContext ctx = ShellContextHolder.get(true);
- try {
- ShellContextHolder.set(getContext());
- delegate.run(objects);
- } finally {
- ShellContextHolder.set(ctx);
- }
- }
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/WorkAroundAliasCommand.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/WorkAroundAliasCommand.java
deleted file mode 100644
index bf7bc49..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/WorkAroundAliasCommand.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.command.CommandAction;
-import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.command.CommandResult;
-import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
-import org.apache.geronimo.gshell.io.IO;
-import org.apache.geronimo.gshell.shell.Shell;
-import org.apache.geronimo.gshell.shell.ShellContext;
-import org.apache.geronimo.gshell.shell.ShellContextHolder;
-import org.apache.geronimo.gshell.wisdom.command.AliasCommand;
-
-public class WorkAroundAliasCommand extends AliasCommand {
-
- private final CommandLineExecutor executor;
-
- public WorkAroundAliasCommand(CommandLineExecutor executor) {
- super(executor);
- this.executor = executor;
- setAction(new AliasCommandAction());
- }
-
- @Override
- protected void prepareAction(final ShellContext context, final Object[] args) {
- // HACK: Reset state for proper appendArgs muck
- assert context != null;
- assert args != null;
-
- setAction(new AliasCommandAction());
- log.trace("Preparing action");
-
- IO io = context.getIo();
- CommandAction action = getAction();
-
- // Setup the command action
- try {
- // Process command line options/arguments
- processArguments(io, action, args);
- }
- catch (Exception e) {
- // Abort if preparation caused a failure
- throw new AbortExecutionNotification(new CommandResult.FailureResult(e));
- }
- }
-
- private class AliasCommandAction
- implements CommandAction
- {
- @Argument
- private List<String> appendArgs = null;
-
- public Object execute(final CommandContext context) throws Exception {
- assert context != null;
-
- StringBuilder buff = new StringBuilder();
- buff.append(getAlias());
-
- // If we have args to append, then do it
- if (appendArgs != null && !appendArgs.isEmpty()) {
- buff.append(" ");
-
- // Append args quoted as they have already been processed by the parser
- Iterator iter = appendArgs.iterator();
- while (iter.hasNext()) {
- //
- // HACK: Using double quote instead of single quote for now as the parser's handling of single quote is broken
- //
-
- buff.append('"').append(iter.next()).append('"');
- if (iter.hasNext()) {
- buff.append(" ");
- }
- }
- }
-
- log.debug("Executing alias: {}", buff);
-
- final Shell shell = ShellContextHolder.get().getShell();
- ShellContext shellContext = new ShellContext() {
- public Shell getShell() {
- return shell;
- }
- public IO getIo() {
- return context.getIo();
- }
- public Variables getVariables() {
- return context.getVariables();
- }
- };
- Object result = executor.execute(shellContext, buff.toString());
-
- log.debug("Alias result: {}", result);
-
- return result;
- }
- }
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/commands/InfoAction.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/commands/InfoAction.java
deleted file mode 100644
index 6f62660..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/commands/InfoAction.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core.commands;
-
-import java.lang.management.ClassLoadingMXBean;
-import java.lang.management.GarbageCollectorMXBean;
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryMXBean;
-import java.lang.management.OperatingSystemMXBean;
-import java.lang.management.RuntimeMXBean;
-import java.lang.management.ThreadMXBean;
-import java.lang.reflect.Method;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.text.NumberFormat;
-import java.util.Locale;
-
-import org.apache.geronimo.gshell.ansi.AnsiCode;
-import org.apache.geronimo.gshell.ansi.AnsiRenderer;
-import org.apache.geronimo.gshell.command.CommandAction;
-import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.io.IO;
-import org.apache.felix.karaf.gshell.core.DefaultBranding;
-
-public class InfoAction implements CommandAction {
-
- private DefaultBranding branding;
-
- private IO io;
-
- private AnsiRenderer renderer = new AnsiRenderer();
- private NumberFormat fmtI = new DecimalFormat("###,###", new DecimalFormatSymbols(Locale.ENGLISH));
- private NumberFormat fmtD = new DecimalFormat("###,##0.000", new DecimalFormatSymbols(Locale.ENGLISH));
-
- public InfoAction(DefaultBranding branding) {
- this.branding = branding;
- }
-
- public Object execute(CommandContext context) throws Exception {
- int maxNameLen;
-
- RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
- OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
- ThreadMXBean threads = ManagementFactory.getThreadMXBean();
- MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
- ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean();
- io = context.getIo();
-
- //
- // print Karaf informations
- //
- maxNameLen = 25;
- io.out.println("Apache Felix Karaf");
- printValue("Karaf home", maxNameLen, System.getProperty("karaf.home"));
- printValue("Karaf base", maxNameLen, System.getProperty("karaf.base"));
- printValue("Karaf version", maxNameLen, branding.getParent().getVersion());
-
- if (branding.getApplicationName() != null && branding.getApplicationVersion() != null) {
- printValue(branding.getApplicationName() + " version", maxNameLen, branding.getApplicationVersion());
- }
- io.out.println();
-
- io.out.println("JVM");
- printValue("Java Virtual Machine", maxNameLen, runtime.getVmName() + " version " + runtime.getVmVersion());
- printValue("Vendor", maxNameLen, runtime.getVmVendor());
- printValue("Uptime", maxNameLen, printDuration(runtime.getUptime()));
- try {
- printValue("Process CPU time", maxNameLen, printDuration(getSunOsValueAsLong(os, "getProcessCpuTime") / 1000000));
- } catch (Throwable t) {}
- printValue("Total compile time", maxNameLen, printDuration(ManagementFactory.getCompilationMXBean().getTotalCompilationTime()));
-
- io.out.println("Threads");
- printValue("Live threads", maxNameLen, Integer.toString(threads.getThreadCount()));
- printValue("Daemon threads", maxNameLen, Integer.toString(threads.getDaemonThreadCount()));
- printValue("Peak", maxNameLen, Integer.toString(threads.getPeakThreadCount()));
- printValue("Total started", maxNameLen, Long.toString(threads.getTotalStartedThreadCount()));
-
- io.out.println("Memory");
- printValue("Current heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getUsed()));
- printValue("Maximum heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getMax()));
- printValue("Committed heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getCommitted()));
- printValue("Pending objects", maxNameLen, Integer.toString(mem.getObjectPendingFinalizationCount()));
- for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
- String val = "Name = '" + gc.getName() + "', Collections = " + gc.getCollectionCount() + ", Time = " + printDuration(gc.getCollectionTime());
- printValue("Garbage collector", maxNameLen, val);
- }
-
- io.out.println("Classes");
- printValue("Current classes loaded", maxNameLen, printLong(cl.getLoadedClassCount()));
- printValue("Total classes loaded", maxNameLen, printLong(cl.getTotalLoadedClassCount()));
- printValue("Total classes unloaded", maxNameLen, printLong(cl.getUnloadedClassCount()));
-
- io.out.println("Operating system");
- printValue("Name", maxNameLen, os.getName() + " version " + os.getVersion());
- printValue("Architecture", maxNameLen, os.getArch());
- printValue("Processors", maxNameLen, Integer.toString(os.getAvailableProcessors()));
- try {
- printValue("Total physical memory", maxNameLen, printSizeInKb(getSunOsValueAsLong(os, "getTotalPhysicalMemorySize")));
- printValue("Free physical memory", maxNameLen, printSizeInKb(getSunOsValueAsLong(os, "getFreePhysicalMemorySize")));
- printValue("Committed virtual memory", maxNameLen, printSizeInKb(getSunOsValueAsLong(os, "getCommittedVirtualMemorySize")));
- printValue("Total swap space", maxNameLen, printSizeInKb(getSunOsValueAsLong(os, "getTotalSwapSpaceSize")));
- printValue("Free swap space", maxNameLen, printSizeInKb(getSunOsValueAsLong(os, "getFreeSwapSpaceSize")));
- } catch (Throwable t) {}
-
- return null;
- }
-
- private long getSunOsValueAsLong(OperatingSystemMXBean os, String name) throws Exception {
- Method mth = os.getClass().getMethod(name);
- return (Long) mth.invoke(os);
- }
-
- private String printLong(long i) {
- return fmtI.format(i);
- }
-
- private String printSizeInKb(double size) {
- return fmtI.format((long) (size / 1024)) + " kbytes";
- }
-
- private String printDuration(double uptime) {
- uptime /= 1000;
- if (uptime < 60) {
- return fmtD.format(uptime) + " seconds";
- }
- uptime /= 60;
- if (uptime < 60) {
- long minutes = (long) uptime;
- String s = fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute");
- return s;
- }
- uptime /= 60;
- if (uptime < 24) {
- long hours = (long) uptime;
- long minutes = (long) ((uptime - hours) * 60);
- String s = fmtI.format(hours) + (hours > 1 ? " hours" : " hour");
- if (minutes != 0) {
- s += " " + fmtI.format(minutes) + (minutes > 1 ? " minutes" : "minute");
- }
- return s;
- }
- uptime /= 24;
- long days = (long) uptime;
- long hours = (long) ((uptime - days) * 60);
- String s = fmtI.format(days) + (days > 1 ? " days" : " day");
- if (hours != 0) {
- s += " " + fmtI.format(hours) + (hours > 1 ? " hours" : "hour");
- }
- return s;
- }
-
- void printSysValue(String prop, int pad) {
- printValue(prop, pad, System.getProperty(prop));
- }
-
- void printValue(String name, int pad, String value) {
- io.out.println(" " + renderer.render(AnsiRenderer.encode(rightPad(name, pad, " "), AnsiCode.BOLD)) + " " + value);
- }
-
- //==== Plexus StringUtils =====
-
- public static String rightPad( String str, int size, String delim ) {
- size = ( size - str.length() ) / delim.length();
- if ( size > 0 ) {
- str += repeat( delim, size );
- }
- return str;
- }
-
- public static String repeat( String str, int repeat ) {
- StringBuffer buffer = new StringBuffer( repeat * str.length() );
- for ( int i = 0; i < repeat; i++ ) {
- buffer.append( str );
- }
- return buffer.toString();
- }
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/ShellCommandFactory.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/ShellCommandFactory.java
deleted file mode 100644
index 428da2c..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/ShellCommandFactory.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core.sshd;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-import org.apache.sshd.server.CommandFactory;
-import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
-import org.apache.geronimo.gshell.shell.ShellContext;
-import org.apache.geronimo.gshell.shell.Shell;
-import org.apache.geronimo.gshell.io.IO;
-import org.apache.geronimo.gshell.io.Closer;
-import org.apache.geronimo.gshell.command.Variables;
-
-public class ShellCommandFactory implements CommandFactory {
-
- private CommandLineExecutor executor;
-
- public CommandLineExecutor getExecutor() {
- return executor;
- }
-
- public void setExecutor(CommandLineExecutor executor) {
- this.executor = executor;
- }
-
- public Command createCommand(String command) {
- return new ShellCommand(command);
- }
-
- public class ShellCommand implements Command, ShellContext, Shell {
-
- private String command;
- private InputStream in;
- private OutputStream out;
- private OutputStream err;
- private ExitCallback callback;
- private Variables var;
- private IO io;
- private boolean closed;
-
- public ShellCommand(String command) {
- this.command = command;
- }
-
- public Shell getShell() {
- return this;
- }
-
- public IO getIo() {
- if (io == null) {
- io = new IO(in, out, err, true);
- }
- return io;
- }
-
- public Variables getVariables() {
- if (var == null) {
- var = new Variables();
- }
- return var;
- }
-
- public void setInputStream(InputStream in) {
- this.in = in;
- }
-
- public void setOutputStream(OutputStream out) {
- this.out = out;
- }
-
- public void setErrorStream(OutputStream err) {
- this.err = err;
- }
-
- public void setExitCallback(ExitCallback callback) {
- this.callback = callback;
- }
-
- public void start() throws IOException {
- try {
- try {
- executor.execute(this, command);
- } catch (Exception e) {
- e.printStackTrace();
- }
- } finally {
- callback.onExit(0);
- }
- }
-
- public Object execute(final String line) throws Exception {
-
- return executor.execute(getContext(), line);
- }
-
- public Object execute(final String command, final Object[] args) throws Exception {
- return executor.execute(getContext(), args);
- }
-
- public Object execute(final Object... args) throws Exception {
- return executor.execute(getContext(), args);
- }
-
- public boolean isOpened() {
- return !closed;
- }
-
- public void close() {
- closed = true;
- Closer.close(in, out, err);
- callback.onExit(0);
- }
-
- public boolean isInteractive() {
- return false;
- }
-
- public ShellContext getContext() {
- return this;
- }
-
- public void run(Object... args) throws Exception {
- throw new UnsupportedOperationException();
- }
- }
-
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/vfs/mvn/MvnFileObject.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/vfs/mvn/MvnFileObject.java
deleted file mode 100644
index a3635e6..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/vfs/mvn/MvnFileObject.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core.vfs.mvn;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.apache.commons.httpclient.URIException;
-import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.provider.URLFileName;
-import org.apache.commons.vfs.provider.url.UrlFileObject;
-
-public class MvnFileObject extends UrlFileObject {
-
- public MvnFileObject(MvnFileSystem fs, FileName fileName) {
- super(fs, fileName);
- }
-
- protected URL createURL(final FileName name) throws MalformedURLException, FileSystemException, URIException
- {
- String url;
- if (name instanceof URLFileName)
- {
- URLFileName urlName = (URLFileName) getName();
-
- // TODO: charset
- url = urlName.getURIEncoded(null);
- }
- else
- {
- url = getName().getURI();
- }
- if (url.startsWith("mvn:///")) {
- url = "mvn:" + url.substring("mvn:///".length());
- }
- return new URL(url);
- }
-
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/vfs/mvn/MvnFileProvider.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/vfs/mvn/MvnFileProvider.java
deleted file mode 100644
index 35f541e..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/vfs/mvn/MvnFileProvider.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core.vfs.mvn;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystem;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileSystemOptions;
-import org.apache.commons.vfs.provider.url.UrlFileProvider;
-
-public class MvnFileProvider extends UrlFileProvider {
-
- /**
- * Locates a file object, by absolute URI.
- */
- public synchronized FileObject findFile(final FileObject baseFile,
- final String uri,
- final FileSystemOptions fileSystemOptions)
- throws FileSystemException
- {
- try
- {
- final URL url = new URL(uri);
-
- URL rootUrl = new URL(url, "/");
- final String key = this.getClass().getName() + rootUrl.toString();
- FileSystem fs = findFileSystem(key, fileSystemOptions);
- if (fs == null)
- {
- String extForm = rootUrl.toExternalForm();
- final FileName rootName = getContext().parseURI(extForm);
- // final FileName rootName =
- // new BasicFileName(rootUrl, FileName.ROOT_PATH);
- fs = new MvnFileSystem(rootName, fileSystemOptions);
- addFileSystem(key, fs);
- }
- return fs.resolveFile(url.getPath());
- }
- catch (final MalformedURLException e)
- {
- throw new FileSystemException("vfs.provider.url/badly-formed-uri.error", uri, e);
- }
- }
-
-
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/vfs/mvn/MvnFileSystem.java b/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/vfs/mvn/MvnFileSystem.java
deleted file mode 100644
index 9f34267..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/vfs/mvn/MvnFileSystem.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * 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.felix.karaf.gshell.core.vfs.mvn;
-
-import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystemOptions;
-import org.apache.commons.vfs.provider.url.UrlFileSystem;
-
-public class MvnFileSystem extends UrlFileSystem {
-
- protected MvnFileSystem(FileName fileName, FileSystemOptions fileSystemOptions) {
- super(fileName, fileSystemOptions);
- }
-
- protected FileObject createFile(FileName fileName) {
- return new MvnFileObject(this, fileName);
- }
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/shell/FindAction.java b/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/shell/FindAction.java
deleted file mode 100644
index 99bfc2d..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/shell/FindAction.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * 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.geronimo.gshell.commands.shell;
-
-import java.net.URI;
-
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSelectInfo;
-import org.apache.commons.vfs.FileSelector;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileType;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.CommandAction;
-import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.io.IO;
-import org.apache.geronimo.gshell.vfs.FileObjects;
-import org.apache.geronimo.gshell.vfs.selector.AggregateFileSelector;
-import org.apache.geronimo.gshell.vfs.support.VfsActionSupport;
-import org.apache.oro.text.GlobCompiler;
-import org.apache.oro.text.regex.MalformedPatternException;
-import org.apache.oro.text.regex.Pattern;
-import org.apache.oro.text.regex.PatternCompiler;
-import org.apache.oro.text.regex.PatternMatcher;
-import org.apache.oro.text.regex.Perl5Matcher;
-
-/**
- * Find files in a hierarchy.
- *
- * TODO: remove this file when gshell is upgraded
- *
- * @version $Rev: 722797 $ $Date: 2008-12-03 08:18:16 +0100 (Wed, 03 Dec 2008) $
- */
-public class FindAction
- extends VfsActionSupport
-{
- private final AggregateFileSelector selector = new AggregateFileSelector();
-
- @Option(name="-name")
- private void addNameFilter(final String name) throws MalformedPatternException {
- log.debug("Adding -name selector for: {}", name);
- selector.getSelectors().add(new NameSelector(name));
- }
-
- @Option(name="-iname")
- private void addiNameFilter(final String name) throws MalformedPatternException {
- log.debug("Adding -iname selector for: {}", name);
- selector.getSelectors().add(new NameSelector(name, true));
- }
-
- @Option(name="-type")
- private void addTypeFilter(final Type type) {
- log.debug("Adding -type selector for: {}", type);
- selector.getSelectors().add(new TypeSelector(type));
- }
-
- @Argument(required=true)
- private String path;
-
- public Object execute(final CommandContext context) throws Exception {
- assert context != null;
- IO io = context.getIo();
-
- FileObject root = resolveFile(context, path);
-
- ensureFileExists(root);
-
- find(context, root, selector);
-
- FileObjects.close(root);
-
- return CommandAction.Result.SUCCESS;
- }
-
- private void find(final CommandContext context, final FileObject file, final FileSelector selector) throws FileSystemException {
- assert context != null;
- assert file != null;
- assert selector != null;
-
- FileObject[] files = file.findFiles(selector);
-
- if (files != null && files.length != 0) {
- for (FileObject child : files) {
- display(context, child, file);
- }
- }
- }
-
- private void display(final CommandContext context, final FileObject file, final FileObject root) throws FileSystemException {
- assert context != null;
- assert file != null;
-
- String path;
- try {
- path = new URI(this.path).resolve(root.getURL().toURI().relativize(file.getURL().toURI())).toString();
- } catch (Exception e) {
- path = file.getName().getPath();
- }
- IO io = context.getIo();
- io.info(path);
- }
-
- //
- // Type & TypeSelector
- //
-
- private enum Type
- {
- F, // normal file
- D, // directory
- }
-
- private class TypeSelector
- implements FileSelector
- {
- private final Type type;
-
- public TypeSelector(final Type type) {
- assert type != null;
-
- this.type = type;
-
- log.trace("Type: {}", type);
- }
-
- public boolean includeFile(final FileSelectInfo selection) throws Exception {
- assert selection != null;
-
- FileType ftype = selection.getFile().getType();
-
- switch (type) {
- case D:
- return ftype == FileType.FOLDER;
-
- case F:
- return ftype == FileType.FILE;
-
- // TODO: Handle FileType.FILE_OR_FOLDER
-
- default:
- return false;
- }
- }
-
- public boolean traverseDescendents(final FileSelectInfo selection) throws Exception {
- return true;
- }
- }
-
- //
- // NameSelector
- //
-
- private class NameSelector
- implements FileSelector
- {
- private final Pattern pattern;
-
- private final PatternMatcher matcher;
-
- public NameSelector(final String name, final boolean ignoreCase) throws MalformedPatternException {
- assert name != null;
-
- PatternCompiler compiler = new GlobCompiler();
- int options;
- if (ignoreCase) {
- options = GlobCompiler.CASE_INSENSITIVE_MASK;
- }
- else {
- options = GlobCompiler.DEFAULT_MASK;
- }
- this.pattern = compiler.compile(name, options);
- this.matcher = new Perl5Matcher();
-
- log.trace("Pattern: {}", pattern.getPattern());
- }
-
- public NameSelector(final String name) throws MalformedPatternException {
- this(name, false);
- }
-
- public boolean includeFile(final FileSelectInfo selection) throws Exception {
- assert selection != null;
- return matcher.matches(selection.getFile().getName().getBaseName(), pattern);
- }
-
- public boolean traverseDescendents(final FileSelectInfo selection) throws Exception {
- return true;
- }
- }
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/ssh/ShellFactoryImpl.java b/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/ssh/ShellFactoryImpl.java
deleted file mode 100644
index d173632..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/ssh/ShellFactoryImpl.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * 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.geronimo.gshell.commands.ssh;
-
-import org.apache.sshd.server.ShellFactory;
-import jline.Completor;
-import jline.History;
-import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
-import org.apache.geronimo.gshell.console.Console;
-import org.apache.geronimo.gshell.console.JLineConsole;
-import org.apache.geronimo.gshell.console.completer.AggregateCompleter;
-import org.apache.geronimo.gshell.io.Closer;
-import org.apache.geronimo.gshell.io.IO;
-import org.apache.geronimo.gshell.notification.ExitNotification;
-import org.apache.geronimo.gshell.shell.ShellContext;
-import org.apache.geronimo.gshell.shell.ShellContextHolder;
-import org.apache.geronimo.gshell.registry.CommandResolver;
-import org.apache.geronimo.gshell.application.Application;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-import java.util.Map;
-
-/**
- * SSHD {@link ShellFactory} which provides access to GShell.
- *
- * @version $Rev: 731517 $ $Date: 2009-01-05 11:25:19 +0100 (Mon, 05 Jan 2009) $
- */
-public class ShellFactoryImpl
- implements ShellFactory
-{
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private Application application;
-
- private Console.Prompter prompter;
-
- private CommandLineExecutor executor;
-
- private History history;
-
- private List<Completor> completers;
-
- private Console.ErrorHandler errorHandler;
-
- public Console.Prompter getPrompter() {
- return prompter;
- }
-
- public void setPrompter(final Console.Prompter prompter) {
- this.prompter = prompter;
- }
-
- public CommandLineExecutor getExecutor() {
- return executor;
- }
-
- public void setExecutor(final CommandLineExecutor executor) {
- this.executor = executor;
- }
-
- public History getHistory() {
- return history;
- }
-
- public void setHistory(final History history) {
- this.history = history;
- }
-
- public List<Completor> getCompleters() {
- return completers;
- }
-
- public void setCompleters(final List<Completor> completers) {
- this.completers = completers;
- }
-
- public Console.ErrorHandler getErrorHandler() {
- return errorHandler;
- }
-
- public void setErrorHandler(final Console.ErrorHandler errorHandler) {
- this.errorHandler = errorHandler;
- }
-
- public Application getApplication() {
- return application;
- }
-
- public void setApplication(Application application) {
- this.application = application;
- }
-
- public Shell createShell() {
- return new ShellImpl();
- }
-
- public class ShellImpl
- implements ShellFactory.Shell, org.apache.geronimo.gshell.shell.Shell, ShellContext, Runnable
- {
- private InputStream in;
-
- private OutputStream out;
-
- private OutputStream err;
-
- private ExitCallback callback;
-
- private IO io;
-
- private Variables variables;
-
- private boolean closed;
-
- public void setInputStream(final InputStream in) {
- this.in = in;
- }
-
- public void setOutputStream(final OutputStream out) {
- this.out = out;
- }
-
- public void setErrorStream(final OutputStream err) {
- this.err = err;
- }
-
- public void setExitCallback(ExitCallback callback) {
- this.callback = callback;
- }
-
- public void start(final Environment env) throws IOException {
- this.io = new IO(in, out, err, false);
-
- // Create variables, inheriting the application ones
- this.variables = new Variables(application.getVariables());
- // Set up additional env
- if (env != null) {
- for (Map.Entry<String,String> entry : env.getEnv().entrySet()) {
- this.variables.set(entry.getKey(), entry.getValue());
- }
- }
- this.variables.set("gshell.prompt", application.getModel().getBranding().getPrompt());
- this.variables.set(CommandResolver.GROUP, "/");
- this.variables.set("gshell.username", env.getEnv().get("USER"));
- this.variables.set("gshell.hostname", application.getLocalHost());
- // HACK: Add history for the 'history' command, since its not part of the Shell intf it can't really access it
- this.variables.set("gshell.internal.history", getHistory(), true);
- new Thread(this).start();
- }
-
- public void destroy() {
- close();
- }
-
- public ShellContext getContext() {
- return this;
- }
-
- public Object execute(final String line) throws Exception {
-
- return executor.execute(getContext(), line);
- }
-
- public Object execute(final String command, final Object[] args) throws Exception {
- return executor.execute(getContext(), args);
- }
-
- public Object execute(final Object... args) throws Exception {
- return executor.execute(getContext(), args);
- }
-
- public boolean isOpened() {
- return !closed;
- }
-
- public void close() {
- if (!closed) {
- closed = true;
- Closer.close(in, out, err);
- callback.onExit(0);
- }
- }
-
- public boolean isInteractive() {
- return false;
- }
-
- public void run(final Object... args) throws Exception {
- Console.Executor executor = new Console.Executor()
- {
- public Result execute(final String line) throws Exception {
- assert line != null;
- try {
- ShellImpl.this.execute(line);
- }
- catch (ExitNotification n) {
- return Result.STOP;
- }
- return Result.CONTINUE;
- }
- };
-
- IO io = getContext().getIo();
-
- // Setup the console runner
- JLineConsole console = new JLineConsole(executor, io);
- console.setPrompter(getPrompter());
- console.setErrorHandler(getErrorHandler());
- console.setHistory(getHistory());
-
- if (completers != null) {
- // Have to use aggregate here to get the completion list to update properly
- console.addCompleter(new AggregateCompleter(completers));
- }
-
- console.run();
- }
-
- public org.apache.geronimo.gshell.shell.Shell getShell() {
- return this;
- }
-
- public IO getIo() {
- return io;
- }
-
- public Variables getVariables() {
- return variables;
- }
-
- public void run() {
- ShellContext ctx = ShellContextHolder.get(true);
-
- try {
- ShellContextHolder.set(getContext());
- run(new Object[0]);
- }
- catch (Exception e) {
- log.error("Unhandled failure: " + e, e);
- }
- finally {
- ShellContextHolder.set(ctx);
- close();
- }
- }
- }
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshAction.java b/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshAction.java
deleted file mode 100644
index 4e2c148..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshAction.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * 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.geronimo.gshell.commands.ssh;
-
-import org.apache.sshd.ClientChannel;
-import org.apache.sshd.ClientSession;
-import org.apache.sshd.SshClient;
-import org.apache.sshd.client.future.ConnectFuture;
-import org.apache.sshd.common.util.NoCloseInputStream;
-import org.apache.sshd.common.util.NoCloseOutputStream;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.CommandAction;
-import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.i18n.MessageSource;
-import org.apache.geronimo.gshell.io.IO;
-import org.apache.geronimo.gshell.io.PromptReader;
-import org.apache.geronimo.gshell.spring.BeanContainer;
-import org.apache.geronimo.gshell.spring.BeanContainerAware;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Connect to a SSH server.
- *
- * @version $Rev: 721244 $ $Date: 2008-11-27 18:19:56 +0100 (Thu, 27 Nov 2008) $
- */
-public class SshAction
- implements CommandAction, BeanContainerAware
-{
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- @Option(name="-l", aliases={"--username"}, description = "Username")
- private String username;
-
- @Option(name="-P", aliases={"--password"}, description = "Password")
- private String password;
-
- @Argument(required=true, description = "Host")
- private String hostname;
-
- @Option(name="-p", aliases={"--port"}, description = "Port")
- private int port = 22;
-
- private BeanContainer container;
-
- private ClientSession session;
-
- public void setBeanContainer(final BeanContainer container) {
- assert container != null;
- this.container = container;
- }
-
- /**
- * Helper to validate that prompted username or password is not null or empty.
- */
- private class UsernamePasswordValidator
- implements PromptReader.Validator
- {
- private String type;
-
- private int count = 0;
-
- private int max = 3;
-
- public UsernamePasswordValidator(final String type) {
- assert type != null;
-
- this.type = type;
- }
-
- public boolean isValid(final String value) {
- count++;
-
- if (value != null && value.trim().length() > 0) {
- return true;
- }
-
- if (count >= max) {
- throw new RuntimeException("Too many attempts; failed to prompt user for " + type + " after " + max + " tries");
- }
-
- return false;
- }
- }
-
- public Object execute(final CommandContext context) throws Exception {
- assert context != null;
- IO io = context.getIo();
- MessageSource messages = context.getCommand().getMessages();
-
- //
- // TODO: Parse hostname for <username>@<hostname>
- //
-
- io.info(messages.format("info.connecting", hostname, port));
-
- // If the username/password was not configured via cli, then prompt the user for the values
- if (username == null || password == null) {
- PromptReader prompter = new PromptReader(io);
- String text;
-
- log.debug("Prompting user for credentials");
-
- if (username == null) {
- text = messages.getMessage("prompt.username");
- username = prompter.readLine(text + ": ", new UsernamePasswordValidator(text));
- }
-
- if (password == null) {
- text = messages.getMessage("prompt.password");
- password = prompter.readPassword(text + ": ", new UsernamePasswordValidator(text));
- }
- }
-
- // Create the client from prototype
- SshClient client = container.getBean(SshClient.class);
- log.debug("Created client: {}", client);
- client.start();;
-
- try {
- ConnectFuture future = client.connect(hostname, port);
- future.await();
- session = future.getSession();
- try {
- io.info(messages.getMessage("info.connected"));
-
- session.authPassword(username, password);
- int ret = session.waitFor(ClientSession.WAIT_AUTH | ClientSession.CLOSED | ClientSession.AUTHED, 0);
- if ((ret & ClientSession.AUTHED) == 0) {
- io.err.println("Authentication failed");
- return Result.FAILURE;
- }
-
- ClientChannel channel = session.createChannel("shell");
- channel.setIn(new NoCloseInputStream(io.inputStream));
- channel.setOut(new NoCloseOutputStream(io.outputStream));
- channel.setErr(new NoCloseOutputStream(io.errorStream));
- channel.open();
- channel.waitFor(ClientChannel.CLOSED, 0);
- } finally {
- session.close(false);
- }
- } finally {
- client.stop();
- }
-
- io.verbose(messages.getMessage("verbose.disconnected"));
-
- return Result.SUCCESS;
- }
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java b/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java
deleted file mode 100644
index 518b019..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * 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.geronimo.gshell.console;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-/**
- * Provides an abstraction of a console.
- *
- * @version $Rev: 706594 $ $Date: 2008-10-21 14:22:21 +0200 (Tue, 21 Oct 2008) $
- */
-public abstract class Console
- implements Runnable
-{
- protected final Logger log = LoggerFactory.getLogger(getClass());
-
- protected boolean running = false;
-
- protected boolean breakOnNull = true;
-
- protected boolean autoTrim = true;
-
- protected boolean ignoreEmpty = true;
-
- protected Prompter prompter = new Prompter() {
- public String prompt() {
- return "> ";
- }
- };
-
- protected Executor executor;
-
- protected ErrorHandler errorHandler = new ErrorHandler() {
- public Result handleError(Throwable error) {
- return Result.STOP;
- }
- };
-
- public Console(final Executor executor) {
- assert executor != null;
-
- this.executor = executor;
- }
-
- public boolean isRunning() {
- return running;
- }
-
- public void setRunning(final boolean running) {
- this.running = running;
- }
-
- public boolean isBreakOnNull() {
- return breakOnNull;
- }
-
- public void setBreakOnNull(final boolean breakOnNull) {
- this.breakOnNull = breakOnNull;
- }
-
- public boolean isAutoTrim() {
- return autoTrim;
- }
-
- public void setAutoTrim(final boolean autoTrim) {
- this.autoTrim = autoTrim;
- }
-
- public boolean isIgnoreEmpty() {
- return ignoreEmpty;
- }
-
- public void setIgnoreEmpty(final boolean ignoreEmpty) {
- this.ignoreEmpty = ignoreEmpty;
- }
-
- public ErrorHandler getErrorHandler() {
- return errorHandler;
- }
-
- public void setErrorHandler(final ErrorHandler errorHandler) {
- this.errorHandler = errorHandler;
- }
-
- public Prompter getPrompter() {
- return prompter;
- }
-
- public void setPrompter(final Prompter prompter) {
- this.prompter = prompter;
- }
-
- public Executor getExecutor() {
- return executor;
- }
-
- public void setExecutor(final Executor executor) {
- this.executor = executor;
- }
-
- public void run() {
- log.debug("Running");
-
- running = true;
-
- while (running) {
- try {
- running = work();
- }
- catch (Throwable t) {
- // Don't use {} here so we get the throwable detail in the log stream
- log.debug("Work failed: " + t, t);
-
- if (errorHandler != null) {
- ErrorHandler.Result result = errorHandler.handleError(t);
-
- // Allow the error handler to request that the loop stop
- if (result == ErrorHandler.Result.STOP) {
- log.debug("Error handler requested STOP");
- running = false;
- }
- }
- }
- }
-
- log.debug("Finished");
- }
-
- protected boolean work() throws Exception {
- String line;
-
- try {
- line = readLine(prompter.prompt());
- } catch (Throwable t) {
- log.debug("Closing shell due to an exception while reading input: " + t, t);
- return false;
- }
-
- // Stop on null (maybe, else ignore)
- if (line == null) {
- return !breakOnNull;
- }
-
- log.debug("Read line: {}", line);
-
- // Log the line as HEX if trace is enabled
- if (log.isTraceEnabled()) {
- StringBuilder idx = new StringBuilder();
- StringBuilder hex = new StringBuilder();
-
- byte[] bytes = line.getBytes();
- for (byte b : bytes) {
- String h = Integer.toHexString(b);
-
- hex.append("x").append(h).append(" ");
- idx.append(" ").append((char)b).append(" ");
- }
-
- log.trace("HEX: {}", hex);
- log.trace(" {}", idx);
- }
-
- // Auto trim the line (maybe)
- if (autoTrim) {
- line = line.trim();
- }
-
- // Ingore empty lines (maybe)
- if (ignoreEmpty && line.length() == 0) {
- return true;
- }
-
- // Execute the line
- Executor.Result result = executor.execute(line);
-
- // Allow executor to request that the loop stop
- if (result == Executor.Result.STOP) {
- log.debug("Executor requested STOP");
- return false;
- }
-
- return true;
- }
-
- protected abstract String readLine(String prompt) throws IOException;
-
- //
- // Prompter
- //
-
- public static interface Prompter
- {
- String prompt();
- }
-
- //
- // Executor
- //
-
- public static interface Executor
- {
- enum Result {
- CONTINUE,
- STOP
- }
-
- Result execute(String line) throws Exception;
- }
-
- //
- // ErrorHandler
- //
-
- public static interface ErrorHandler
- {
- enum Result {
- CONTINUE,
- STOP
- }
-
- Result handleError(Throwable error);
- }
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/vfs/config/CacheStrategyConverter.java b/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/vfs/config/CacheStrategyConverter.java
deleted file mode 100644
index 7e10ca5..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/vfs/config/CacheStrategyConverter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.geronimo.gshell.vfs.config;
-
-import org.osgi.service.blueprint.container.Converter;
-import org.osgi.service.blueprint.container.ReifiedType;
-import org.apache.commons.vfs.CacheStrategy;
-
-public class CacheStrategyConverter implements Converter {
-
- public boolean canConvert(Object o, ReifiedType type) {
- return o instanceof String && type.getRawClass() == CacheStrategy.class;
- }
-
- public Object convert(Object o, ReifiedType type) throws Exception {
- if (canConvert(o, type)) {
- String text = o.toString();
- if (text.equalsIgnoreCase("MANUAL")) {
- return CacheStrategy.MANUAL;
- }
- else if (text.equalsIgnoreCase("ON_RESOLVE")) {
- return CacheStrategy.ON_RESOLVE;
- }
- else if (text.equalsIgnoreCase("ON_CALL")) {
- return CacheStrategy.ON_CALL;
- }
- else {
- throw new IllegalArgumentException("Unknown cache strategy: " + text);
- }
- }
- return null;
- }
-
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerFactory.java b/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerFactory.java
deleted file mode 100644
index 8e3c884..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/vfs/config/FileSystemManagerFactory.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package org.apache.geronimo.gshell.vfs.config;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.commons.vfs.FilesCache;
-import org.apache.commons.vfs.CacheStrategy;
-import org.apache.commons.vfs.FileContentInfoFactory;
-import org.apache.commons.vfs.impl.DefaultFileReplicator;
-import org.apache.commons.vfs.impl.PrivilegedFileReplicator;
-import org.apache.commons.vfs.impl.FileContentInfoFilenameFactory;
-import org.apache.commons.vfs.cache.SoftRefFilesCache;
-import org.apache.commons.vfs.provider.FileReplicator;
-import org.apache.commons.vfs.provider.TemporaryFileStore;
-import org.apache.commons.vfs.provider.FileProvider;
-import org.apache.commons.vfs.provider.url.UrlFileProvider;
-
-/**
- * Factory to construct a {@link org.apache.commons.vfs.FileSystemManager} instance.
- *
- * @version $Rev: 707031 $ $Date: 2008-10-22 13:08:07 +0200 (Wed, 22 Oct 2008) $
- */
-public class FileSystemManagerFactory {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private FilesCache filesCache;
-
- private CacheStrategy cacheStrategy = CacheStrategy.ON_RESOLVE;
-
- private FileReplicator fileReplicator;
-
- private TemporaryFileStore temporaryFileStore;
-
- private FileContentInfoFactory fileContentInfoFactory;
-
- private FileProvider defaultProvider;
-
- // FileObjectDecorator (Class/Constructor of DecoratedFileObject? or make a factory?)
-
- public void setFilesCache(final FilesCache cache) {
- this.filesCache = cache;
- }
-
- public void setCacheStrategy(final CacheStrategy strategy) {
- this.cacheStrategy = strategy;
- }
-
- public void setFileReplicator(final FileReplicator replicator) {
- this.fileReplicator = replicator;
- }
-
- public void setTemporaryFileStore(final TemporaryFileStore store) {
- this.temporaryFileStore = store;
- }
-
- public void setFileContentInfoFactory(final FileContentInfoFactory factory) {
- this.fileContentInfoFactory = factory;
- }
-
- public void setDefaultProvider(final FileProvider provider) {
- this.defaultProvider = provider;
- }
-
- public void init() {
- if (filesCache == null) {
- filesCache = new SoftRefFilesCache();
- }
-
- if (fileReplicator == null || temporaryFileStore == null) {
- DefaultFileReplicator replicator = new DefaultFileReplicator();
- if (fileReplicator == null) {
- fileReplicator = new PrivilegedFileReplicator(replicator);
- }
- if (temporaryFileStore == null) {
- temporaryFileStore = replicator;
- }
- }
-
- if (fileContentInfoFactory == null) {
- fileContentInfoFactory = new FileContentInfoFilenameFactory();
- }
-
- if (defaultProvider == null) {
- defaultProvider = new UrlFileProvider();
- }
- }
-
- //
- // FactoryBean
- //
-
- public ConfigurableFileSystemManager getFileSystemManager() throws Exception {
- ConfigurableFileSystemManager fsm = new ConfigurableFileSystemManager();
-
- assert fileReplicator != null;
- log.debug("File replicator: {}", fileReplicator);
- fsm.setReplicator(fileReplicator);
-
- assert temporaryFileStore != null;
- log.debug("Temporary file store: {}", temporaryFileStore);
- fsm.setTemporaryFileStore(temporaryFileStore);
-
- assert filesCache != null;
- log.debug("Files cache: {}", filesCache);
- fsm.setFilesCache(filesCache);
-
- assert cacheStrategy != null;
- log.debug("Cache strategy: {}", cacheStrategy);
- fsm.setCacheStrategy(cacheStrategy);
-
- assert fileContentInfoFactory != null;
- log.debug("File content info factory: {}", fileContentInfoFactory);
- fsm.setFileContentInfoFactory(fileContentInfoFactory);
-
- assert defaultProvider != null;
- log.debug("Default provider: {}", defaultProvider);
- fsm.setDefaultProvider(defaultProvider);
-
- // Finally init the manager
- fsm.init();
-
- return fsm;
- }
-
-}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileObject.java b/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileObject.java
deleted file mode 100644
index 610e31a..0000000
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileObject.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * 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.geronimo.gshell.vfs.provider.meta;
-
-import org.apache.commons.vfs.FileContentInfoFactory;
-import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileType;
-import org.apache.commons.vfs.FileContent;
-import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.provider.AbstractFileObject;
-import org.apache.commons.vfs.provider.DefaultFileContent;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.Map;
-
-/**
- * Meta file object.
- *
- * TODO: remove this file when gshell version is upgraded
- *
- * @version $Rev: 706033 $ $Date: 2008-10-19 17:36:15 +0200 (Sun, 19 Oct 2008) $
- */
-public class MetaFileObject
- extends AbstractFileObject
-{
- private final MetaFileSystem fileSystem;
-
- private MetaData data;
- private FileContent content;
-
- public MetaFileObject(final FileName fileName, final MetaFileSystem fileSystem) {
- super(fileName, fileSystem);
-
- // Save for uncasted typed access
- this.fileSystem = fileSystem;
- }
-
- public MetaData getData() {
- if (data == null) {
- throw new IllegalStateException("Meta data has not been attached");
- }
-
- return data;
- }
-
- @Override
- protected FileType doGetType() throws Exception {
- return getData().getType();
- }
-
- @Override
- protected long doGetLastModifiedTime() throws Exception {
- return getData().getLastModified();
- }
-
- @Override
- protected boolean doIsReadable() throws Exception {
- return data.getBuffer() != null;
- }
-
- @Override
- protected boolean doIsWriteable() throws Exception {
- return false;
- }
-
- @Override
- protected FileContentInfoFactory getFileContentInfoFactory() {
- return fileSystem.getFileContentInfoFactory();
- }
-
- @Override
- protected long doGetContentSize() throws Exception {
- byte[] bytes = data.getBuffer();
- return bytes != null ? bytes.length : 0;
- }
-
- @Override
- protected InputStream doGetInputStream() throws Exception {
- byte[] bytes = data.getBuffer();
- if (bytes != null) {
- return new ByteArrayInputStream(bytes);
- }
-
- return null;
- }
-
- @Override
- protected Map<String,Object> doGetAttributes() {
- return getData().getAttributes();
- }
-
- @Override
- protected void doSetAttribute(final String name, final Object value) {
- getData().getAttributes().put(name, value);
- }
-
- protected void doRemoveAttribute(final String name) {
- getData().getAttributes().remove(name);
- }
-
- @Override
- protected String[] doListChildren() throws Exception {
- return fileSystem.listChildren(getName());
- }
-
- @Override
- protected void doAttach() throws Exception {
- if (data == null) {
- data = fileSystem.lookupData(this);
- }
- content = new DefaultFileContent(this, getFileContentInfoFactory());
- }
-
- @Override
- protected void doDetach() throws Exception {
- data = null;
- content = null;
- }
-
- @Override
- public FileContent getContent() throws FileSystemException {
- super.getContent();
- return content;
- }
-}
diff --git a/karaf/gshell/gshell-core/src/main/resources/org/apache/felix/karaf/gshell/core/commands/InfoAction.properties b/karaf/gshell/gshell-core/src/main/resources/org/apache/felix/karaf/gshell/core/commands/InfoAction.properties
deleted file mode 100644
index 6541173..0000000
--- a/karaf/gshell/gshell-core/src/main/resources/org/apache/felix/karaf/gshell/core/commands/InfoAction.properties
+++ /dev/null
@@ -1,27 +0,0 @@
-##
-## 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.
-##
-
-##
-## $Rev: 703511 $ $Date: 2008-10-10 18:07:36 +0200 (Fri, 10 Oct 2008) $
-##
-
-command.description=Display JVM informations about the current application.
-
-command.manual=\
- TODO: about manual
diff --git a/karaf/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/commands/ssh/SshAction.properties b/karaf/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/commands/ssh/SshAction.properties
deleted file mode 100644
index 75e134a..0000000
--- a/karaf/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/commands/ssh/SshAction.properties
+++ /dev/null
@@ -1,27 +0,0 @@
-##
-## 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.
-##
-
-##
-## $Rev: 703511 $ $Date: 2008-10-10 18:07:36 +0200 (Fri, 10 Oct 2008) $
-##
-
-command.description=SSH client.
-
-command.manual=\
- TODO: about manual
diff --git a/karaf/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/commands/ssh/SshServerAction.properties b/karaf/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/commands/ssh/SshServerAction.properties
deleted file mode 100644
index 777b4de..0000000
--- a/karaf/gshell/gshell-core/src/main/resources/org/apache/geronimo/gshell/commands/ssh/SshServerAction.properties
+++ /dev/null
@@ -1,27 +0,0 @@
-##
-## 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.
-##
-
-##
-## $Rev: 703511 $ $Date: 2008-10-10 18:07:36 +0200 (Fri, 10 Oct 2008) $
-##
-
-command.description=SSH server.
-
-command.manual=\
- TODO: about manual
diff --git a/karaf/gshell/gshell-core/src/test/resources/log4j.properties b/karaf/gshell/gshell-core/src/test/resources/log4j.properties
deleted file mode 100644
index 0ca7b6a..0000000
--- a/karaf/gshell/gshell-core/src/test/resources/log4j.properties
+++ /dev/null
@@ -1,33 +0,0 @@
-################################################################################
-#
-# 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.
-#
-################################################################################
-
-# Root logger
-log4j.rootLogger=INFO, stdout
-
-# CONSOLE appender not used by default
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
-
-# File appender
-log4j.appender.out=org.apache.log4j.FileAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
-log4j.appender.out.file=${karaf.base}/data/log/karaf.log
-log4j.appender.out.append=true
diff --git a/karaf/gshell/gshell-features/pom.xml b/karaf/gshell/gshell-features/pom.xml
index 6d2868e..38363b8 100644
--- a/karaf/gshell/gshell-features/pom.xml
+++ b/karaf/gshell/gshell-features/pom.xml
@@ -57,7 +57,7 @@
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
</dependency>
<dependency>
@@ -68,8 +68,8 @@
<dependency>
<groupId>org.springframework.osgi</groupId>
<artifactId>spring-osgi-core</artifactId>
+ <scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.junit</artifactId>
@@ -80,6 +80,11 @@
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -94,10 +99,9 @@
<Import-Package>
javax.management,
javax.management.loading,
- org.apache.geronimo.gshell.command,
- org.apache.geronimo.gshell.wisdom.command,
- org.apache.geronimo.gshell.wisdom.registry,
- org.apache.felix.karaf.gshell.core,
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.felix.karaf.gshell.console,
*
</Import-Package>
<Private-Package>!*</Private-Package>
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/AddUrlCommand.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/AddUrlCommand.java
index b3ed032..230f321 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/AddUrlCommand.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/AddUrlCommand.java
@@ -19,8 +19,8 @@
import java.net.URI;
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
import org.apache.felix.karaf.gshell.features.FeaturesService;
+import org.apache.felix.gogo.commands.Argument;
public class AddUrlCommand extends FeaturesCommandSupport {
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/FeaturesCommandSupport.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/FeaturesCommandSupport.java
index 6e98730..4f79be9 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/FeaturesCommandSupport.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/FeaturesCommandSupport.java
@@ -16,8 +16,8 @@
*/
package org.apache.felix.karaf.gshell.features.commands;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
import org.apache.felix.karaf.gshell.features.FeaturesService;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
import org.osgi.framework.ServiceReference;
public abstract class FeaturesCommandSupport extends OsgiCommandSupport {
@@ -26,13 +26,13 @@
// Get repository admin service.
ServiceReference ref = getBundleContext().getServiceReference(FeaturesService.class.getName());
if (ref == null) {
- io.out.println("FeaturesService service is unavailable.");
+ System.out.println("FeaturesService service is unavailable.");
return null;
}
try {
FeaturesService admin = (FeaturesService) getBundleContext().getService(ref);
if (admin == null) {
- io.out.println("FeaturesService service is unavailable.");
+ System.out.println("FeaturesService service is unavailable.");
return null;
}
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/InstallFeatureCommand.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/InstallFeatureCommand.java
index 590a5fa..8fb99bf 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/InstallFeatureCommand.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/InstallFeatureCommand.java
@@ -16,8 +16,8 @@
*/
package org.apache.felix.karaf.gshell.features.commands;
-import org.apache.geronimo.gshell.clp.Argument;
import org.apache.felix.karaf.gshell.features.FeaturesService;
+import org.apache.felix.gogo.commands.Argument;
public class InstallFeatureCommand extends FeaturesCommandSupport {
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/ListFeaturesCommand.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/ListFeaturesCommand.java
index e2f5120..c3495e6 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/ListFeaturesCommand.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/ListFeaturesCommand.java
@@ -16,8 +16,8 @@
*/
package org.apache.felix.karaf.gshell.features.commands;
-import org.apache.geronimo.gshell.clp.Option;
import org.apache.felix.karaf.gshell.features.FeaturesService;
+import org.apache.felix.gogo.commands.Option;
public class ListFeaturesCommand extends FeaturesCommandSupport {
@@ -30,18 +30,18 @@
features = admin.listInstalledFeatures();
} else {
// Print column headers.
- io.out.println(" State Version Name");
+ System.out.println(" State Version Name");
features = admin.listFeatures();
}
if ((features != null) && (features.length > 0)) {
for (int i = 0; i < features.length; i++) {
- io.out.println(features[i]);
+ System.out.println(features[i]);
}
} else {
if (installed) {
- io.out.println("No features installed.");
+ System.out.println("No features installed.");
} else {
- io.out.println("No features available.");
+ System.out.println("No features available.");
}
}
}
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/ListUrlCommand.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/ListUrlCommand.java
index 58bc462..10389b7 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/ListUrlCommand.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/ListUrlCommand.java
@@ -25,10 +25,10 @@
Repository[] repos = admin.listRepositories();
if ((repos != null) && (repos.length > 0)) {
for (int i = 0; i < repos.length; i++) {
- io.out.println(repos[i].getURI());
+ System.out.println(repos[i].getURI());
}
} else {
- io.out.println("No repository URLs are set.");
+ System.out.println("No repository URLs are set.");
}
}
}
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/RefreshUrlCommand.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/RefreshUrlCommand.java
index 8451eb2..5899766 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/RefreshUrlCommand.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/RefreshUrlCommand.java
@@ -20,9 +20,9 @@
import java.util.ArrayList;
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
import org.apache.felix.karaf.gshell.features.FeaturesService;
import org.apache.felix.karaf.gshell.features.Repository;
+import org.apache.felix.gogo.commands.Argument;
public class RefreshUrlCommand extends FeaturesCommandSupport {
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/RemoveUrlCommand.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/RemoveUrlCommand.java
index 7bf2153..3ff088a 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/RemoveUrlCommand.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/RemoveUrlCommand.java
@@ -19,8 +19,8 @@
import java.net.URI;
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
import org.apache.felix.karaf.gshell.features.FeaturesService;
+import org.apache.felix.gogo.commands.Argument;
public class RemoveUrlCommand extends FeaturesCommandSupport {
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/UninstallFeatureCommand.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/UninstallFeatureCommand.java
index 8f62a6a..bdee5da 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/UninstallFeatureCommand.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/commands/UninstallFeatureCommand.java
@@ -16,8 +16,8 @@
*/
package org.apache.felix.karaf.gshell.features.commands;
-import org.apache.geronimo.gshell.clp.Argument;
import org.apache.felix.karaf.gshell.features.FeaturesService;
+import org.apache.felix.gogo.commands.Argument;
public class UninstallFeatureCommand extends FeaturesCommandSupport {
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/completers/AvailableFeatureCompleter.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/completers/AvailableFeatureCompleter.java
index 718345b..a9855df 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/completers/AvailableFeatureCompleter.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/completers/AvailableFeatureCompleter.java
@@ -19,10 +19,10 @@
import java.util.Collection;
import java.util.List;
-import jline.Completor;
-import org.apache.geronimo.gshell.console.completer.StringsCompleter;
import org.apache.felix.karaf.gshell.features.management.ManagedFeature;
import org.apache.felix.karaf.gshell.features.management.ManagedFeaturesRegistry;
+import org.apache.felix.karaf.gshell.console.completer.StringsCompleter;
+import org.apache.felix.karaf.gshell.console.Completer;
/**
* {@link jline.Completor} for available features.
@@ -30,7 +30,7 @@
* Displays a list of available features from installed repositories.
*
*/
-public class AvailableFeatureCompleter implements Completor {
+public class AvailableFeatureCompleter implements Completer {
private ManagedFeaturesRegistry featuresRegistry;
private StringsCompleter delegate;
@@ -47,7 +47,7 @@
for (ManagedFeature feature : features) {
delegate.getStrings().add(feature.getName());
}
-
+
return delegate.complete(buffer, cursor, candidates);
}
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/completers/FeatureRepositoryCompleter.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/completers/FeatureRepositoryCompleter.java
index b89ba2c..6c6f7be 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/completers/FeatureRepositoryCompleter.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/completers/FeatureRepositoryCompleter.java
@@ -18,9 +18,9 @@
import java.util.List;
-import jline.Completor;
-import org.apache.geronimo.gshell.console.completer.StringsCompleter;
import org.apache.felix.karaf.gshell.features.management.ManagedFeaturesRegistry;
+import org.apache.felix.karaf.gshell.console.completer.StringsCompleter;
+import org.apache.felix.karaf.gshell.console.Completer;
/**
* {@link jline.Completor} for Feature Repository URLs.
@@ -29,7 +29,7 @@
*
*/
-public class FeatureRepositoryCompleter implements Completor {
+public class FeatureRepositoryCompleter implements Completer {
private ManagedFeaturesRegistry featuresRegistry;
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/completers/InstalledFeatureCompleter.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/completers/InstalledFeatureCompleter.java
index 261f62a..8f03998 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/completers/InstalledFeatureCompleter.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/completers/InstalledFeatureCompleter.java
@@ -19,8 +19,8 @@
import java.util.Collection;
import java.util.List;
-import jline.Completor;
-import org.apache.geronimo.gshell.console.completer.StringsCompleter;
+import org.apache.felix.karaf.gshell.console.Completer;
+import org.apache.felix.karaf.gshell.console.completer.StringsCompleter;
import org.apache.felix.karaf.gshell.features.management.ManagedFeature;
import org.apache.felix.karaf.gshell.features.management.ManagedFeaturesRegistry;
@@ -30,7 +30,7 @@
* Displays a list of currently installed features.
*
*/
-public class InstalledFeatureCompleter implements Completor {
+public class InstalledFeatureCompleter implements Completer {
private ManagedFeaturesRegistry featuresRegistry;
private StringsCompleter delegate;
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/internal/FeaturesServiceImpl.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/internal/FeaturesServiceImpl.java
index 0243f71..6f4fdd1 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/internal/FeaturesServiceImpl.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/internal/FeaturesServiceImpl.java
@@ -36,8 +36,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.felix.karaf.gshell.features.Feature;
import org.apache.felix.karaf.gshell.features.FeaturesRegistry;
import org.apache.felix.karaf.gshell.features.FeaturesService;
@@ -53,6 +51,8 @@
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.service.prefs.Preferences;
import org.osgi.service.prefs.PreferencesService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The Features service implementation.
@@ -65,7 +65,7 @@
private static final String ALIAS_KEY = "_alias_factory_pid";
- private static final Log LOGGER = LogFactory.getLog(FeaturesServiceImpl.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(FeaturesServiceImpl.class);
private BundleContext bundleContext;
private ConfigurationAdmin configAdmin;
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/management/ManagedFeaturesRegistry.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/management/ManagedFeaturesRegistry.java
index e8a0ec0..77af08d 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/management/ManagedFeaturesRegistry.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/management/ManagedFeaturesRegistry.java
@@ -22,12 +22,12 @@
import javax.management.MBeanServer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.felix.karaf.gshell.features.Feature;
import org.apache.felix.karaf.gshell.features.FeaturesRegistry;
import org.apache.felix.karaf.gshell.features.FeaturesService;
import org.apache.felix.karaf.gshell.features.Repository;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
/**
* The FeaturesServiceRegistry maintains the managed Features and Repositories
@@ -35,7 +35,7 @@
*/
public class ManagedFeaturesRegistry implements FeaturesRegistry, ManagedFeaturesRegistryMBean {
- private static final transient Log LOG = LogFactory.getLog(ManagedFeaturesRegistry.class);
+ private static final transient Logger LOG = LoggerFactory.getLogger(ManagedFeaturesRegistry.class);
private NamingStrategy namingStrategy;
private ManagementAgent managementAgent;
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/management/ManagementAgent.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/management/ManagementAgent.java
index 8c4f054..4275d09 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/management/ManagementAgent.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/management/ManagementAgent.java
@@ -26,15 +26,15 @@
import javax.management.ObjectInstance;
import javax.management.ObjectName;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
/**
* Management Agent that registers MBeans with JMX MBeanServer.
*/
public class ManagementAgent {
- private static final transient Log LOG = LogFactory.getLog(ManagementAgent.class);
+ private static final transient Logger LOG = LoggerFactory.getLogger(ManagementAgent.class);
private MBeanServer mbeanServer;
private Set<ObjectName> mbeans = new HashSet<ObjectName>();
diff --git a/karaf/gshell/gshell-features/src/main/resources/OSGI-INF/blueprint/gshell-features.xml b/karaf/gshell/gshell-features/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
index e337afb..7c784c0 100644
--- a/karaf/gshell/gshell-features/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
+++ b/karaf/gshell/gshell-features/src/main/resources/OSGI-INF/blueprint/gshell-features.xml
@@ -32,48 +32,34 @@
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
<command name="features/addUrl">
- <action class="org.apache.felix.karaf.gshell.features.commands.AddUrlCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.features.commands.AddUrlCommand"/>
</command>
<command name="features/listUrl">
- <action class="org.apache.felix.karaf.gshell.features.commands.ListUrlCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.features.commands.ListUrlCommand"/>
</command>
<command name="features/removeUrl">
- <action class="org.apache.felix.karaf.gshell.features.commands.RemoveUrlCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.features.commands.RemoveUrlCommand"/>
<completers>
<ref component-id="removeUrlCompleter" />
</completers>
</command>
<command name="features/refreshUrl">
- <action class="org.apache.felix.karaf.gshell.features.commands.RefreshUrlCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.features.commands.RefreshUrlCommand"/>
</command>
<command name="features/install">
- <action class="org.apache.felix.karaf.gshell.features.commands.InstallFeatureCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.features.commands.InstallFeatureCommand"/>
<completers>
<ref component-id="installFeatureCompleter" />
</completers>
</command>
<command name="features/uninstall">
- <action class="org.apache.felix.karaf.gshell.features.commands.UninstallFeatureCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.features.commands.UninstallFeatureCommand"/>
<completers>
<ref component-id="uninstallFeatureCompleter" />
</completers>
</command>
<command name="features/list">
- <action class="org.apache.felix.karaf.gshell.features.commands.ListFeaturesCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.features.commands.ListFeaturesCommand"/>
</command>
</command-bundle>
diff --git a/karaf/gshell/gshell-log/pom.xml b/karaf/gshell/gshell-log/pom.xml
index c5d7dc8..37721e3 100644
--- a/karaf/gshell/gshell-log/pom.xml
+++ b/karaf/gshell/gshell-log/pom.xml
@@ -40,7 +40,7 @@
<dependencies>
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
</dependency>
<dependency>
@@ -56,11 +56,6 @@
</dependency>
<dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-service</artifactId>
</dependency>
@@ -77,11 +72,9 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
- org.apache.geronimo.gshell.command,
- org.apache.geronimo.gshell.wisdom.command,
- org.apache.geronimo.gshell.wisdom.registry,
- org.apache.felix.karaf.gshell.core,
- org.ops4j.pax.logging,
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.felix.karaf.gshell.console,
*
</Import-Package>
<Private-Package>!*</Private-Package>
diff --git a/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/DisplayException.java b/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/DisplayException.java
index bae8977..a4f5b9d 100644
--- a/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/DisplayException.java
+++ b/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/DisplayException.java
@@ -16,18 +16,18 @@
*/
package org.apache.felix.karaf.gshell.log;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
import org.ops4j.pax.logging.spi.PaxLoggingEvent;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
public class DisplayException extends OsgiCommandSupport {
- protected LruList<PaxLoggingEvent> events;
+ protected LruList events;
- public LruList<PaxLoggingEvent> getEvents() {
+ public LruList getEvents() {
return events;
}
- public void setEvents(LruList<PaxLoggingEvent> events) {
+ public void setEvents(LruList events) {
this.events = events;
}
@@ -42,11 +42,11 @@
}
if (throwableEvent != null) {
for (String r : throwableEvent.getThrowableStrRep()) {
- io.out.println(r);
+ System.out.println(r);
}
- io.out.println();
+ System.out.println();
}
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/DisplayLog.java b/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/DisplayLog.java
index 3a86f3b..2235de6 100644
--- a/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/DisplayLog.java
+++ b/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/DisplayLog.java
@@ -16,15 +16,17 @@
*/
package org.apache.felix.karaf.gshell.log;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
import org.apache.felix.karaf.gshell.log.layout.PatternConverter;
import org.apache.felix.karaf.gshell.log.layout.PatternParser;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.gogo.commands.Command;
import org.ops4j.pax.logging.spi.PaxLoggingEvent;
/**
* Displays the last log entries
*/
+@Command(scope = "log", name = "display", description = "Display log entries.")
public class DisplayLog extends OsgiCommandSupport {
@Option(name = "-n", description="Number of entries to display")
@@ -35,13 +37,13 @@
protected String pattern;
- protected LruList<PaxLoggingEvent> events;
+ protected LruList events;
- public LruList<PaxLoggingEvent> getEvents() {
+ public LruList getEvents() {
return events;
}
- public void setEvents(LruList<PaxLoggingEvent> events) {
+ public void setEvents(LruList events) {
this.events = events;
}
@@ -63,16 +65,16 @@
for (PatternConverter pc = cnv; pc != null; pc = pc.next) {
pc.format(sb, event);
}
- io.out.print(sb.toString());
+ System.out.print(sb.toString());
if (event.getThrowableStrRep() != null) {
for (String r : event.getThrowableStrRep()) {
- io.out.println(r);
+ System.out.println(r);
}
}
}
- io.out.println();
+ System.out.println();
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/GetLogLevel.java b/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/GetLogLevel.java
index fb4884e..5cb6f15 100644
--- a/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/GetLogLevel.java
+++ b/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/GetLogLevel.java
@@ -21,11 +21,11 @@
import java.util.Map;
import java.util.TreeMap;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
/**
* Get the log level for a given logger
@@ -59,9 +59,9 @@
loggers.put(prop.substring(LOGGER_PREFIX.length()), val);
}
}
- io.out.println("ROOT: " + root);
+ System.out.println("ROOT: " + root);
for (String logger : loggers.keySet()) {
- io.out.println(logger + ": " + loggers.get(logger));
+ System.out.println(logger + ": " + loggers.get(logger));
}
} else {
String logger = this.logger;
@@ -89,9 +89,9 @@
if (logger != this.logger) {
st += " (inherited from " + (logger != null ? logger : "ROOT") + ")";
}
- io.out.println(st);
+ System.out.println(st);
}
- return Result.SUCCESS;
+ return null;
}
protected String getLevel(String prop) {
diff --git a/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/LruList.java b/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/LruList.java
index 8da08eb..5c22668 100644
--- a/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/LruList.java
+++ b/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/LruList.java
@@ -20,12 +20,14 @@
import java.util.Arrays;
+import org.ops4j.pax.logging.spi.PaxLoggingEvent;
+
/**
* A list that only keep the last N elements added
*/
-public class LruList<E> {
+public class LruList {
- private E[] elements;
+ private PaxLoggingEvent[] elements;
private transient int start = 0;
private transient int end = 0;
private transient boolean full = false;
@@ -35,7 +37,7 @@
if (size <= 0) {
throw new IllegalArgumentException("The size must be greater than 0");
}
- elements = (E[]) new Object[size];
+ elements = new PaxLoggingEvent[size];
maxElements = elements.length;
}
@@ -53,7 +55,7 @@
}
}
- public void add(E element) {
+ public void add(PaxLoggingEvent element) {
synchronized (elements) {
if (null == element) {
throw new NullPointerException("Attempted to add null object to buffer");
@@ -78,17 +80,17 @@
}
}
- public Iterable<E> getElements() {
+ public Iterable<PaxLoggingEvent> getElements() {
synchronized (elements) {
return getElements(size());
}
}
- public Iterable<E> getElements(int nb) {
+ public Iterable<PaxLoggingEvent> getElements(int nb) {
synchronized (elements) {
int s = size();
nb = Math.min(Math.max(0, nb), s);
- E[] e = (E[]) new Object[nb];
+ PaxLoggingEvent[] e = new PaxLoggingEvent[nb];
for (int i = 0; i < nb; i++) {
e[i] = elements[(i + s - nb + start) % maxElements];
}
diff --git a/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/SetLogLevel.java b/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/SetLogLevel.java
index d855f87..4b196d2 100644
--- a/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/SetLogLevel.java
+++ b/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/SetLogLevel.java
@@ -18,8 +18,8 @@
import java.util.Dictionary;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
@@ -57,12 +57,12 @@
!WARN.equals(level) &&
!ERROR.equals(level) &&
!INHERITED.equals(level)) {
- io.err.println("level must be set to TRACE, DEBUG, INFO, WARN or ERROR (or - to unset it)");
- return Result.FAILURE;
+ System.err.println("level must be set to TRACE, DEBUG, INFO, WARN or ERROR (or - to unset it)");
+ return null;
}
if (INHERITED.equals(level) && logger == null) {
- io.err.println("Can not unset the ROOT logger");
- return Result.FAILURE;
+ System.err.println("Can not unset the ROOT logger");
+ return null;
}
ConfigurationAdmin cfgAdmin = getConfigAdmin();
@@ -108,7 +108,7 @@
}
cfg.update(props);
- return Result.SUCCESS;
+ return null;
}
protected ConfigurationAdmin getConfigAdmin() {
diff --git a/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/VmLogAppender.java b/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/VmLogAppender.java
index 38613e4..20ddd1f 100644
--- a/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/VmLogAppender.java
+++ b/karaf/gshell/gshell-log/src/main/java/org/apache/felix/karaf/gshell/log/VmLogAppender.java
@@ -26,13 +26,13 @@
*/
public class VmLogAppender implements PaxAppender {
- protected LruList<PaxLoggingEvent> events;
+ protected LruList events;
- public LruList<PaxLoggingEvent> getEvents() {
+ public LruList getEvents() {
return events;
}
- public void setEvents(LruList<PaxLoggingEvent> events) {
+ public void setEvents(LruList events) {
this.events = events;
}
diff --git a/karaf/gshell/gshell-log/src/main/resources/OSGI-INF/blueprint/gshell-log.xml b/karaf/gshell/gshell-log/src/main/resources/OSGI-INF/blueprint/gshell-log.xml
index e0d2744..0d2e213 100644
--- a/karaf/gshell/gshell-log/src/main/resources/OSGI-INF/blueprint/gshell-log.xml
+++ b/karaf/gshell/gshell-log/src/main/resources/OSGI-INF/blueprint/gshell-log.xml
@@ -32,7 +32,6 @@
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
<command name="log/display">
<action class="org.apache.felix.karaf.gshell.log.DisplayLog">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="events" ref="events"/>
<property name="pattern" value="${pattern}"/>
</action>
@@ -40,20 +39,15 @@
<link name="log/d" target="log/display"/>
<command name="log/display-exception">
<action class="org.apache.felix.karaf.gshell.log.DisplayException">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="events" ref="events"/>
</action>
</command>
<link name="log/de" target="log/display-exception"/>
<command name="log/get">
- <action class="org.apache.felix.karaf.gshell.log.GetLogLevel">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.log.GetLogLevel" />
</command>
<command name="log/set">
- <action class="org.apache.felix.karaf.gshell.log.SetLogLevel">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.log.SetLogLevel" />
</command>
<alias name="ld" alias="log/d"/>
diff --git a/karaf/gshell/gshell-obr/pom.xml b/karaf/gshell/gshell-obr/pom.xml
index 152c5b8..dd590bb 100644
--- a/karaf/gshell/gshell-obr/pom.xml
+++ b/karaf/gshell/gshell-obr/pom.xml
@@ -51,12 +51,7 @@
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
</dependency>
</dependencies>
@@ -72,10 +67,9 @@
${pom.artifactId}*;version=${project.version}
</Export-Package>
<Import-Package>
- org.apache.geronimo.gshell.command,
- org.apache.geronimo.gshell.wisdom.command,
- org.apache.geronimo.gshell.wisdom.registry,
- org.apache.felix.karaf.gshell.core,
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.felix.karaf.gshell.console,
*
</Import-Package>
<Private-Package>!*</Private-Package>
diff --git a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/AddUrlCommand.java b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/AddUrlCommand.java
index a8f5df3..a89a4a6 100644
--- a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/AddUrlCommand.java
+++ b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/AddUrlCommand.java
@@ -19,8 +19,8 @@
import java.net.URL;
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
import org.osgi.service.obr.RepositoryAdmin;
+import org.apache.felix.gogo.commands.Argument;
public class AddUrlCommand extends ObrCommandSupport {
diff --git a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/DeployCommand.java b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/DeployCommand.java
index 97d0edc..8d77bdf 100644
--- a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/DeployCommand.java
+++ b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/DeployCommand.java
@@ -18,8 +18,8 @@
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
import org.osgi.service.obr.RepositoryAdmin;
+import org.apache.felix.gogo.commands.Argument;
public class DeployCommand extends ObrCommandSupport {
diff --git a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/FileUtil.java b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/FileUtil.java
index ddcc304..21941a5 100644
--- a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/FileUtil.java
+++ b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/FileUtil.java
@@ -26,6 +26,7 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
+import java.io.PrintStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.jar.JarEntry;
@@ -34,7 +35,7 @@
public class FileUtil
{
public static void downloadSource(
- PrintWriter out, PrintWriter err,
+ PrintStream out, PrintStream err,
URL srcURL, String dirStr, boolean extract)
{
// Get the file name from the URL.
diff --git a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/InfoCommand.java b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/InfoCommand.java
index 2ca3dbf..3f1149a 100644
--- a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/InfoCommand.java
+++ b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/InfoCommand.java
@@ -16,13 +16,13 @@
*/
package org.apache.felix.karaf.gshell.obr;
-import java.io.PrintWriter;
+import java.io.PrintStream;
import java.lang.reflect.Array;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.service.obr.Capability;
import org.osgi.service.obr.RepositoryAdmin;
import org.osgi.service.obr.Requirement;
@@ -39,7 +39,7 @@
Resource[] resources = searchRepository(admin, target[0], target[1]);
if (resources == null)
{
- io.err.println("Unknown bundle and/or version: "
+ System.err.println("Unknown bundle and/or version: "
+ target[0]);
}
else
@@ -48,15 +48,15 @@
{
if (resIdx > 0)
{
- io.out.println("");
+ System.out.println("");
}
- printResource(io.out, resources[resIdx]);
+ printResource(System.out, resources[resIdx]);
}
}
}
}
- private void printResource(PrintWriter out, Resource resource)
+ private void printResource(PrintStream out, Resource resource)
{
printUnderline(out, resource.getPresentationName().length());
out.println(resource.getPresentationName());
diff --git a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/ListCommand.java b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/ListCommand.java
index 7a9aa7f..c8c65c3 100644
--- a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/ListCommand.java
+++ b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/ListCommand.java
@@ -18,10 +18,10 @@
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
import org.osgi.framework.Version;
import org.osgi.service.obr.RepositoryAdmin;
import org.osgi.service.obr.Resource;
+import org.apache.felix.gogo.commands.Argument;
public class ListCommand extends ObrCommandSupport {
@@ -68,17 +68,17 @@
Version version = resources[resIdx].getVersion();
if (version != null)
{
- io.out.println(name + " (" + version + ")");
+ System.out.println(name + " (" + version + ")");
}
else
{
- io.out.println(name);
+ System.out.println(name);
}
}
if (resources == null)
{
- io.out.println("No matching bundles.");
+ System.out.println("No matching bundles.");
}
}
diff --git a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/ListUrlCommand.java b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/ListUrlCommand.java
index 3f6f6db..9705656 100644
--- a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/ListUrlCommand.java
+++ b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/ListUrlCommand.java
@@ -25,10 +25,10 @@
Repository[] repos = admin.listRepositories();
if ((repos != null) && (repos.length > 0)) {
for (int i = 0; i < repos.length; i++) {
- io.out.println(repos[i].getURL());
+ System.out.println(repos[i].getURL());
}
} else {
- io.out.println("No repository URLs are set.");
+ System.out.println("No repository URLs are set.");
}
}
diff --git a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/ObrCommandSupport.java b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/ObrCommandSupport.java
index 56845c5..f709545 100644
--- a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/ObrCommandSupport.java
+++ b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/ObrCommandSupport.java
@@ -16,10 +16,10 @@
*/
package org.apache.felix.karaf.gshell.obr;
-import java.io.PrintWriter;
+import java.io.PrintStream;
import java.util.List;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
@@ -36,13 +36,13 @@
// Get repository admin service.
ServiceReference ref = getBundleContext().getServiceReference(RepositoryAdmin.class.getName());
if (ref == null) {
- io.out.println("RepositoryAdmin service is unavailable.");
+ System.out.println("RepositoryAdmin service is unavailable.");
return null;
}
try {
RepositoryAdmin admin = (RepositoryAdmin) getBundleContext().getService(ref);
if (admin == null) {
- io.out.println("RepositoryAdmin service is unavailable.");
+ System.out.println("RepositoryAdmin service is unavailable.");
return null;
}
@@ -123,7 +123,7 @@
return target;
}
- protected void printUnderline(PrintWriter out, int length)
+ protected void printUnderline(PrintStream out, int length)
{
for (int i = 0; i < length; i++)
{
@@ -143,7 +143,7 @@
}
else
{
- io.err.println("Unknown bundle - " + target[0]);
+ System.err.println("Unknown bundle - " + target[0]);
}
}
if ((resolver.getAddedResources() != null) &&
@@ -151,46 +151,46 @@
{
if (resolver.resolve())
{
- io.out.println("Target resource(s):");
- printUnderline(io.out, 19);
+ System.out.println("Target resource(s):");
+ printUnderline(System.out, 19);
Resource[] resources = resolver.getAddedResources();
for (int resIdx = 0; (resources != null) && (resIdx < resources.length); resIdx++)
{
- io.out.println(" " + resources[resIdx].getPresentationName()
+ System.out.println(" " + resources[resIdx].getPresentationName()
+ " (" + resources[resIdx].getVersion() + ")");
}
resources = resolver.getRequiredResources();
if ((resources != null) && (resources.length > 0))
{
- io.out.println("\nRequired resource(s):");
- printUnderline(io.out, 21);
+ System.out.println("\nRequired resource(s):");
+ printUnderline(System.out, 21);
for (int resIdx = 0; resIdx < resources.length; resIdx++)
{
- io.out.println(" " + resources[resIdx].getPresentationName()
+ System.out.println(" " + resources[resIdx].getPresentationName()
+ " (" + resources[resIdx].getVersion() + ")");
}
}
resources = resolver.getOptionalResources();
if ((resources != null) && (resources.length > 0))
{
- io.out.println("\nOptional resource(s):");
- printUnderline(io.out, 21);
+ System.out.println("\nOptional resource(s):");
+ printUnderline(System.out, 21);
for (int resIdx = 0; resIdx < resources.length; resIdx++)
{
- io.out.println(" " + resources[resIdx].getPresentationName()
+ System.out.println(" " + resources[resIdx].getPresentationName()
+ " (" + resources[resIdx].getVersion() + ")");
}
}
try
{
- io.out.print("\nDeploying...");
+ System.out.print("\nDeploying...");
resolver.deploy(start);
- io.out.println("done.");
+ System.out.println("done.");
}
catch (IllegalStateException ex)
{
- io.err.println(ex);
+ System.err.println(ex);
}
}
else
@@ -198,21 +198,21 @@
Requirement[] reqs = resolver.getUnsatisfiedRequirements();
if ((reqs != null) && (reqs.length > 0))
{
- io.out.println("Unsatisfied requirement(s):");
- printUnderline(io.out, 27);
+ System.out.println("Unsatisfied requirement(s):");
+ printUnderline(System.out, 27);
for (int reqIdx = 0; reqIdx < reqs.length; reqIdx++)
{
- io.out.println(" " + reqs[reqIdx].getFilter());
+ System.out.println(" " + reqs[reqIdx].getFilter());
Resource[] resources = resolver.getResources(reqs[reqIdx]);
for (int resIdx = 0; resIdx < resources.length; resIdx++)
{
- io.out.println(" " + resources[resIdx].getPresentationName());
+ System.out.println(" " + resources[resIdx].getPresentationName());
}
}
}
else
{
- io.out.println("Could not resolve targets.");
+ System.out.println("Could not resolve targets.");
}
}
}
diff --git a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/RefreshUrlCommand.java b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/RefreshUrlCommand.java
index 1a2e417..12a1043 100644
--- a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/RefreshUrlCommand.java
+++ b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/RefreshUrlCommand.java
@@ -19,9 +19,9 @@
import java.net.URL;
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
import org.osgi.service.obr.Repository;
import org.osgi.service.obr.RepositoryAdmin;
+import org.apache.felix.gogo.commands.Argument;
public class RefreshUrlCommand extends ObrCommandSupport {
diff --git a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/RemoveUrlCommand.java b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/RemoveUrlCommand.java
index 8cfb209..ac72a65 100644
--- a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/RemoveUrlCommand.java
+++ b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/RemoveUrlCommand.java
@@ -19,7 +19,7 @@
import java.net.URL;
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.service.obr.RepositoryAdmin;
public class RemoveUrlCommand extends ObrCommandSupport {
diff --git a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/SourceCommand.java b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/SourceCommand.java
index 159837d..b6b5dc1 100644
--- a/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/SourceCommand.java
+++ b/karaf/gshell/gshell-obr/src/main/java/org/apache/felix/karaf/gshell/obr/SourceCommand.java
@@ -19,8 +19,8 @@
import java.net.URL;
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.service.obr.RepositoryAdmin;
import org.osgi.service.obr.Resource;
@@ -41,18 +41,18 @@
Resource resource = selectNewestVersion(searchRepository(admin, target[0], target[1]));
if (resource == null)
{
- io.err.println("Unknown bundle and/or version: " + target[0]);
+ System.err.println("Unknown bundle and/or version: " + target[0]);
}
else
{
URL srcURL = (URL) resource.getProperties().get(Resource.SOURCE_URL);
if (srcURL != null)
{
- FileUtil.downloadSource(io.out, io.err, srcURL, localDir, extract);
+ FileUtil.downloadSource(System.out, System.err, srcURL, localDir, extract);
}
else
{
- io.err.println("Missing source URL: " + target[0]);
+ System.err.println("Missing source URL: " + target[0]);
}
}
}
diff --git a/karaf/gshell/gshell-obr/src/main/resources/OSGI-INF/blueprint/gshell-obr.xml b/karaf/gshell/gshell-obr/src/main/resources/OSGI-INF/blueprint/gshell-obr.xml
index 7308e32..4100852 100644
--- a/karaf/gshell/gshell-obr/src/main/resources/OSGI-INF/blueprint/gshell-obr.xml
+++ b/karaf/gshell/gshell-obr/src/main/resources/OSGI-INF/blueprint/gshell-obr.xml
@@ -21,49 +21,31 @@
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
<command name="obr/addUrl">
- <action class="org.apache.felix.karaf.gshell.obr.AddUrlCommand">
- <property name="bundleContext" ref="bundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.obr.AddUrlCommand"/>
</command>
<command name="obr/deploy">
- <action class="org.apache.felix.karaf.gshell.obr.DeployCommand">
- <property name="bundleContext" ref="bundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.obr.DeployCommand"/>
</command>
<command name="obr/info">
- <action class="org.apache.felix.karaf.gshell.obr.InfoCommand">
- <property name="bundleContext" ref="bundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.obr.InfoCommand"/>
</command>
<command name="obr/list">
- <action class="org.apache.felix.karaf.gshell.obr.ListCommand">
- <property name="bundleContext" ref="bundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.obr.ListCommand"/>
</command>
<command name="obr/listUrl">
- <action class="org.apache.felix.karaf.gshell.obr.ListUrlCommand">
- <property name="bundleContext" ref="bundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.obr.ListUrlCommand"/>
</command>
<command name="obr/removeUrl">
- <action class="org.apache.felix.karaf.gshell.obr.RemoveUrlCommand">
- <property name="bundleContext" ref="bundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.obr.RemoveUrlCommand"/>
</command>
<command name="obr/refreshUrl">
- <action class="org.apache.felix.karaf.gshell.obr.RefreshUrlCommand">
- <property name="bundleContext" ref="bundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.obr.RefreshUrlCommand"/>
</command>
<command name="obr/source">
- <action class="org.apache.felix.karaf.gshell.obr.SourceCommand">
- <property name="bundleContext" ref="bundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.obr.SourceCommand"/>
</command>
<command name="obr/start">
- <action class="org.apache.felix.karaf.gshell.obr.StartCommand">
- <property name="bundleContext" ref="bundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.obr.StartCommand"/>
</command>
</command-bundle>
diff --git a/karaf/gshell/gshell-osgi/pom.xml b/karaf/gshell/gshell-osgi/pom.xml
index 87dbe2b..4ef12eb 100644
--- a/karaf/gshell/gshell-osgi/pom.xml
+++ b/karaf/gshell/gshell-osgi/pom.xml
@@ -40,7 +40,7 @@
<dependencies>
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
</dependency>
<dependency>
@@ -48,16 +48,6 @@
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-extender</artifactId>
- </dependency>
</dependencies>
<build>
@@ -70,10 +60,9 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
- org.apache.geronimo.gshell.command,
- org.apache.geronimo.gshell.wisdom.command,
- org.apache.geronimo.gshell.wisdom.registry,
- org.apache.felix.karaf.gshell.core,
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.felix.karaf.gshell.console,
*
</Import-Package>
<Private-Package>!*</Private-Package>
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BlueprintListener.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BlueprintListener.java
index 7cb1666..b80c3d3 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BlueprintListener.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BlueprintListener.java
@@ -19,13 +19,13 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import org.osgi.service.blueprint.container.BlueprintEvent;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Logger;
/**
*
@@ -45,7 +45,7 @@
Waiting
}
- private static final Log LOG = LogFactory.getLog(BlueprintListener.class);
+ private static final Logger LOG = LoggerFactory.getLogger(BlueprintListener.class);
private final Map<Long, BlueprintState> states;
private BundleContext bundleContext;
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BundleCommand.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BundleCommand.java
index 019462e..436969e 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BundleCommand.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BundleCommand.java
@@ -16,9 +16,9 @@
*/
package org.apache.felix.karaf.gshell.osgi;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Option;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.framework.Bundle;
public abstract class BundleCommand extends OsgiCommandSupport {
@@ -32,15 +32,15 @@
protected Object doExecute() throws Exception {
Bundle bundle = getBundleContext().getBundle(id);
if (bundle == null) {
- io.out.println("Bundle " + id + " not found");
- return Result.FAILURE;
+ System.out.println("Bundle " + id + " not found");
+ return null;
}
- if (!force && Util.isASystemBundle(getBundleContext(), bundle) && !Util.accessToSystemBundleIsAllowed(bundle.getBundleId(), io)) {
- return Result.FAILURE;
+ if (!force && Util.isASystemBundle(getBundleContext(), bundle) && !Util.accessToSystemBundleIsAllowed(bundle.getBundleId(), session)) {
+ return null;
} else {
doExecute(bundle);
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BundleLevel.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BundleLevel.java
index 1fe59f0..05aa0cb 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BundleLevel.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BundleLevel.java
@@ -16,7 +16,7 @@
*/
package org.apache.felix.karaf.gshell.osgi;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
import org.osgi.service.startlevel.StartLevel;
@@ -30,29 +30,29 @@
// Get package admin service.
ServiceReference ref = getBundleContext().getServiceReference(StartLevel.class.getName());
if (ref == null) {
- io.out.println("StartLevel service is unavailable.");
+ System.out.println("StartLevel service is unavailable.");
return;
}
StartLevel sl = getService(StartLevel.class, ref);
if (sl == null) {
- io.out.println("StartLevel service is unavailable.");
+ System.out.println("StartLevel service is unavailable.");
return;
}
if (level == null) {
- io.out.println("Level " + sl.getBundleStartLevel(bundle));
+ System.out.println("Level " + sl.getBundleStartLevel(bundle));
}
else if ((level < 50) && sl.getBundleStartLevel(bundle) > 50){
for (;;) {
StringBuffer sb = new StringBuffer();
- io.err.println("You are about to designate bundle as a system bundle. Do you want to continue (yes/no): ");
- io.err.flush();
+ System.err.println("You are about to designate bundle as a system bundle. Do you want to continue (yes/no): ");
+ System.err.flush();
for (;;) {
- int c = io.in.read();
+ int c = System.in.read();
if (c < 0) {
return;
}
- io.err.println((char) c);
+ System.err.println((char) c);
if (c == '\r' || c == '\n') {
break;
}
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BundlesCommand.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BundlesCommand.java
index 0dd52bf..71bf3da 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BundlesCommand.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/BundlesCommand.java
@@ -19,9 +19,9 @@
import java.util.ArrayList;
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Option;
import org.osgi.framework.Bundle;
public abstract class BundlesCommand extends OsgiCommandSupport {
@@ -38,16 +38,16 @@
for (long id : ids) {
Bundle bundle = getBundleContext().getBundle(id);
if (bundle == null) {
- io.err.println("Bundle ID" + id + " is invalid");
+ System.err.println("Bundle ID" + id + " is invalid");
} else {
- if (force || !Util.isASystemBundle(getBundleContext(), bundle) || Util.accessToSystemBundleIsAllowed(bundle.getBundleId(), io)) {
+ if (force || !Util.isASystemBundle(getBundleContext(), bundle) || Util.accessToSystemBundleIsAllowed(bundle.getBundleId(), session)) {
bundles.add(bundle);
}
}
}
}
doExecute(bundles);
- return Result.SUCCESS;
+ return null;
}
protected abstract void doExecute(List<Bundle> bundles) throws Exception;
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Headers.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Headers.java
index 3b9b60a..adfb997 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Headers.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Headers.java
@@ -20,8 +20,8 @@
import java.util.Enumeration;
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.framework.Bundle;
public class Headers extends OsgiCommandSupport {
@@ -37,7 +37,7 @@
printHeaders(bundle);
}
else {
- io.err.println("Bundle ID " + id + " is invalid.");
+ System.err.println("Bundle ID " + id + " is invalid.");
}
}
}
@@ -47,20 +47,20 @@
printHeaders(bundles[i]);
}
}
- return Result.SUCCESS;
+ return null;
}
protected void printHeaders(Bundle bundle) throws Exception {
String title = Util.getBundleName(bundle);
- io.out.println("\n" + title);
- io.out.println(Util.getUnderlineString(title));
+ System.out.println("\n" + title);
+ System.out.println(Util.getUnderlineString(title));
Dictionary dict = bundle.getHeaders();
Enumeration keys = dict.keys();
while (keys.hasMoreElements())
{
Object k = (String) keys.nextElement();
Object v = dict.get(k);
- io.out.println(k + " = " + Util.getValueString(v));
+ System.out.println(k + " = " + Util.getValueString(v));
}
}
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/InstallBundle.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/InstallBundle.java
index 4cf58cd..1eedcf8 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/InstallBundle.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/InstallBundle.java
@@ -16,13 +16,13 @@
*/
package org.apache.felix.karaf.gshell.osgi;
-import java.io.PrintWriter;
+import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Option;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -38,7 +38,7 @@
List<Bundle> bundles = new ArrayList<Bundle>();
StringBuffer sb = new StringBuffer();
for (String url : urls) {
- Bundle bundle = install(url, io.out, io.err);
+ Bundle bundle = install(url, System.out, System.err);
if (bundle != null) {
bundles.add(bundle);
if (sb.length() > 0) {
@@ -53,14 +53,14 @@
}
}
if (sb.toString().indexOf(',') > 0) {
- io.out.println("Bundle IDs: " + sb.toString());
+ System.out.println("Bundle IDs: " + sb.toString());
} else if (sb.length() > 0) {
- io.out.println("Bundle ID: " + sb.toString());
+ System.out.println("Bundle ID: " + sb.toString());
}
- return Result.SUCCESS;
+ return null;
}
- protected Bundle install(String location, PrintWriter out, PrintWriter err) {
+ protected Bundle install(String location, PrintStream out, PrintStream err) {
try {
return getBundleContext().installBundle(location, null);
} catch (IllegalStateException ex) {
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListBundles.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListBundles.java
index 5c69962..c9ca6f0 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListBundles.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListBundles.java
@@ -16,8 +16,8 @@
*/
package org.apache.felix.karaf.gshell.osgi;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Option;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
@@ -52,7 +52,7 @@
sl = (StartLevel) getBundleContext().getService(ref);
}
if (sl == null) {
- io.out.println("StartLevel service is unavailable.");
+ System.out.println("StartLevel service is unavailable.");
}
ServiceReference pkgref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
@@ -60,7 +60,7 @@
if (pkgref != null) {
admin = (PackageAdmin) getBundleContext().getService(pkgref);
if (admin == null) {
- io.out.println("PackageAdmin service is unavailable.");
+ System.out.println("PackageAdmin service is unavailable.");
}
}
@@ -68,7 +68,7 @@
if (bundles != null) {
// Display active start level.
if (sl != null) {
- io.out.println("START LEVEL " + sl.getStartLevel());
+ System.out.println("START LEVEL " + sl.getStartLevel());
}
// Print column headers.
@@ -83,7 +83,7 @@
msg = " Update location";
}
String level = (sl == null) ? "" : " Level ";
- io.out.println(" ID State Blueprint " + level + msg);
+ System.out.println(" ID State Blueprint " + level + msg);
for (int i = 0; i < bundles.length; i++) {
// Get the bundle name or location.
String name = (String) bundles[i].getHeaders().get(Constants.BUNDLE_NAME);
@@ -122,7 +122,7 @@
while (id.length() < 4) {
id = " " + id;
}
- io.out.println("[" + id + "] ["
+ System.out.println("[" + id + "] ["
+ getStateString(bundles[i])
+ "] [" + getBlueprintStateString(bundles[i])
+ "] [" + level + "] " + name);
@@ -132,42 +132,42 @@
Bundle[] hosts = admin.getHosts(bundles[i]);
if (fragments != null) {
- io.out.print(" Fragments: ");
+ System.out.print(" Fragments: ");
int ii = 0;
for (Bundle fragment : fragments) {
ii++;
- io.out.print(fragment.getBundleId());
+ System.out.print(fragment.getBundleId());
if ((fragments.length > 1) && ii < (fragments.length)) {
- io.out.print(",");
+ System.out.print(",");
}
}
- io.out.println();
+ System.out.println();
}
if (hosts != null) {
- io.out.print(" Hosts: ");
+ System.out.print(" Hosts: ");
int ii = 0;
for (Bundle host : hosts) {
ii++;
- io.out.print(host.getBundleId());
+ System.out.print(host.getBundleId());
if ((hosts.length > 1) && ii < (hosts.length)) {
- io.out.print(",");
+ System.out.print(",");
}
}
- io.out.println();
+ System.out.println();
}
}
}
}
else {
- io.out.println("There are no installed bundles.");
+ System.out.println("There are no installed bundles.");
}
getBundleContext().ungetService(ref);
getBundleContext().ungetService(pkgref);
- return Result.SUCCESS;
+ return null;
}
public String getStateString(Bundle bundle)
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListServices.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListServices.java
index 8214de7..bf1d1ff 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListServices.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListServices.java
@@ -18,12 +18,12 @@
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.Command;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Option;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
+import org.osgi.service.command.Function;
public class ListServices extends OsgiCommandSupport {
@@ -65,7 +65,7 @@
for (int ocIdx = 0;
!showAll && (ocIdx < objectClass.length);
ocIdx++) {
- if (objectClass[ocIdx].equals(Command.class.getName())) {
+ if (objectClass[ocIdx].equals(Function.class.getName())) {
print = false;
}
}
@@ -77,15 +77,15 @@
title = (inUse)
? title + " uses:"
: title + " provides:";
- io.out.println("");
- io.out.println(title);
- io.out.println(Util.getUnderlineString(title));
+ System.out.println("");
+ System.out.println(title);
+ System.out.println(Util.getUnderlineString(title));
}
if (showAll || print) {
// Print service separator if necessary.
if (needSeparator) {
- io.out.println("----");
+ System.out.println("----");
}
// Print service properties.
@@ -94,7 +94,7 @@
(keys != null) && (keyIdx < keys.length);
keyIdx++) {
Object v = refs[refIdx].getProperty(keys[keyIdx]);
- io.out.println(
+ System.out.println(
keys[keyIdx] + " = " + Util.getValueString(v));
}
@@ -102,7 +102,7 @@
}
}
} else {
- io.err.println("Bundle ID " + id + " is invalid.");
+ System.err.println("Bundle ID " + id + " is invalid.");
}
}
}
@@ -139,7 +139,7 @@
!showAll && (ocIdx < objectClass.length);
ocIdx++)
{
- if (objectClass[ocIdx].equals(Command.class.getName()))
+ if (objectClass[ocIdx].equals(Function.class.getName()))
{
print = false;
}
@@ -155,20 +155,20 @@
title = (inUse)
? title + " uses:"
: title + " provides:";
- io.out.println("\n" + title);
- io.out.println(Util.getUnderlineString(title));
+ System.out.println("\n" + title);
+ System.out.println(Util.getUnderlineString(title));
}
- io.out.println(Util.getValueString(objectClass));
+ System.out.println(Util.getValueString(objectClass));
}
}
}
}
else
{
- io.out.println("There are no registered services.");
+ System.out.println("There are no registered services.");
}
}
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/RefreshBundle.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/RefreshBundle.java
index 84e6cd1..cef9cac 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/RefreshBundle.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/RefreshBundle.java
@@ -16,8 +16,8 @@
*/
package org.apache.felix.karaf.gshell.osgi;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
import org.osgi.service.packageadmin.PackageAdmin;
@@ -31,14 +31,14 @@
// Get package admin service.
ServiceReference ref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
if (ref == null) {
- io.out.println("PackageAdmin service is unavailable.");
- return Result.FAILURE;
+ System.out.println("PackageAdmin service is unavailable.");
+ return null;
}
try {
PackageAdmin pa = (PackageAdmin) getBundleContext().getService(ref);
if (pa == null) {
- io.out.println("PackageAdmin service is unavailable.");
- return Result.FAILURE;
+ System.out.println("PackageAdmin service is unavailable.");
+ return null;
}
if (id == null) {
pa.refreshPackages(null);
@@ -46,8 +46,8 @@
else {
Bundle bundle = getBundleContext().getBundle(id);
if (bundle == null) {
- io.out.println("Bundle " + id + " not found");
- return Result.FAILURE;
+ System.out.println("Bundle " + id + " not found");
+ return null;
}
pa.refreshPackages(new Bundle[] { bundle });
}
@@ -55,6 +55,6 @@
finally {
getBundleContext().ungetService(ref);
}
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ResolveBundle.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ResolveBundle.java
index 1af32e3..0abd965 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ResolveBundle.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ResolveBundle.java
@@ -26,13 +26,13 @@
// Get package admin service.
ServiceReference ref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
if (ref == null) {
- io.out.println("PackageAdmin service is unavailable.");
+ System.out.println("PackageAdmin service is unavailable.");
return;
}
try {
PackageAdmin pa = (PackageAdmin) getBundleContext().getService(ref);
if (pa == null) {
- io.out.println("PackageAdmin service is unavailable.");
+ System.out.println("PackageAdmin service is unavailable.");
return;
}
pa.resolveBundles(new Bundle[] { bundle });
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Shutdown.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Shutdown.java
index f73161a..3a2c3a9 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Shutdown.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Shutdown.java
@@ -16,7 +16,7 @@
*/
package org.apache.felix.karaf.gshell.osgi;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
import org.osgi.framework.Bundle;
/**
@@ -35,7 +35,7 @@
}
}
}.start();
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartBundle.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartBundle.java
index 28d931e..dff6282 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartBundle.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartBundle.java
@@ -18,7 +18,6 @@
import java.util.List;
-import org.apache.geronimo.gshell.clp.Option;
import org.osgi.framework.Bundle;
public class StartBundle extends BundlesCommand {
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartLevel.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartLevel.java
index f139815..2265500 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartLevel.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartLevel.java
@@ -16,8 +16,8 @@
*/
package org.apache.felix.karaf.gshell.osgi;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.framework.ServiceReference;
public class StartLevel extends OsgiCommandSupport {
@@ -29,18 +29,18 @@
// Get package admin service.
ServiceReference ref = getBundleContext().getServiceReference(org.osgi.service.startlevel.StartLevel.class.getName());
if (ref == null) {
- io.out.println("StartLevel service is unavailable.");
+ System.out.println("StartLevel service is unavailable.");
return null;
}
try {
org.osgi.service.startlevel.StartLevel sl = (org.osgi.service.startlevel.StartLevel) getBundleContext().getService(ref);
if (sl == null) {
- io.out.println("StartLevel service is unavailable.");
+ System.out.println("StartLevel service is unavailable.");
return null;
}
if (level == null) {
- io.out.println("Level " + sl.getStartLevel());
+ System.out.println("Level " + sl.getStartLevel());
}
else {
sl.setStartLevel(level);
@@ -49,7 +49,7 @@
finally {
getBundleContext().ungetService(ref);
}
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java
index 72addaa..4204f22 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java
@@ -18,7 +18,6 @@
import java.util.List;
-import org.apache.geronimo.gshell.clp.Option;
import org.osgi.framework.Bundle;
public class StopBundle extends BundlesCommand {
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/UpdateBundle.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/UpdateBundle.java
index 272459d..9a4afdb 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/UpdateBundle.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/UpdateBundle.java
@@ -19,7 +19,7 @@
import java.io.InputStream;
import java.net.URL;
-import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.felix.gogo.commands.Argument;
import org.osgi.framework.Bundle;
public class UpdateBundle extends BundleCommand {
diff --git a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Util.java b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Util.java
index b43e720..e57579e 100644
--- a/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Util.java
+++ b/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Util.java
@@ -20,12 +20,12 @@
import java.io.IOException;
-import org.apache.geronimo.gshell.io.IO;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.service.startlevel.StartLevel;
+import org.osgi.service.command.CommandSession;
public class Util
{
@@ -139,21 +139,21 @@
* Ask the user to confirm the access to a system bundle
*
* @param bundleId
- * @param io
+ * @param session
* @return true if the user confirm
* @throws IOException
*/
- public static boolean accessToSystemBundleIsAllowed(long bundleId, IO io) throws IOException {
+ public static boolean accessToSystemBundleIsAllowed(long bundleId, CommandSession session) throws IOException {
for (;;) {
StringBuffer sb = new StringBuffer();
- io.err.print("You are about to access system bundle " + bundleId + ". Do you want to continue (yes/no): ");
- io.err.flush();
+ System.err.print("You are about to access system bundle " + bundleId + ". Do you want to continue (yes/no): ");
+ System.err.flush();
for (;;) {
- int c = io.in.read();
+ int c = session.getKeyboard().read();
if (c < 0) {
return false;
}
- io.err.print((char) c);
+ System.err.print((char) c);
if (c == '\r' || c == '\n') {
break;
}
diff --git a/karaf/gshell/gshell-osgi/src/main/resources/OSGI-INF/blueprint/gshell-osgi.xml b/karaf/gshell/gshell-osgi/src/main/resources/OSGI-INF/blueprint/gshell-osgi.xml
index e2cc24e..8dcc553 100644
--- a/karaf/gshell/gshell-osgi/src/main/resources/OSGI-INF/blueprint/gshell-osgi.xml
+++ b/karaf/gshell/gshell-osgi/src/main/resources/OSGI-INF/blueprint/gshell-osgi.xml
@@ -21,75 +21,48 @@
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
<command name="osgi/bundle-level">
- <action class="org.apache.felix.karaf.gshell.osgi.BundleLevel">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.BundleLevel"/>
</command>
<command name="osgi/headers">
- <action class="org.apache.felix.karaf.gshell.osgi.Headers">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.Headers"/>
</command>
<command name="osgi/install">
- <action class="org.apache.felix.karaf.gshell.osgi.InstallBundle">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.InstallBundle"/>
</command>
<command name="osgi/list">
<action class="org.apache.felix.karaf.gshell.osgi.ListBundles">
- <property name="bundleContext" ref="blueprintBundleContext"/>
<property name="blueprintListener" ref="blueprintListener"/>
</action>
</command>
<command name="osgi/ls">
- <action class="org.apache.felix.karaf.gshell.osgi.ListServices">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.ListServices"/>
</command>
<command name="osgi/refresh">
- <action class="org.apache.felix.karaf.gshell.osgi.RefreshBundle">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.RefreshBundle"/>
</command>
<command name="osgi/update">
- <action class="org.apache.felix.karaf.gshell.osgi.UpdateBundle">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.UpdateBundle"/>
</command>
<command name="osgi/resolve">
- <action class="org.apache.felix.karaf.gshell.osgi.ResolveBundle">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.ResolveBundle"/>
</command>
<command name="osgi/restart">
- <action class="org.apache.felix.karaf.gshell.osgi.RestartBundle">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.RestartBundle"/>
</command>
<command name="osgi/shutdown">
- <action class="org.apache.felix.karaf.gshell.osgi.Shutdown">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.Shutdown"/>
</command>
<command name="osgi/start">
- <action class="org.apache.felix.karaf.gshell.osgi.StartBundle">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.StartBundle"/>
</command>
<command name="osgi/start-level">
- <action class="org.apache.felix.karaf.gshell.osgi.StartLevel">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.StartLevel"/>
</command>
<command name="osgi/stop">
- <action class="org.apache.felix.karaf.gshell.osgi.StopBundle">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.StopBundle"/>
</command>
<command name="osgi/uninstall">
- <action class="org.apache.felix.karaf.gshell.osgi.UninstallBundle">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.osgi.UninstallBundle"/>
</command>
</command-bundle>
diff --git a/karaf/gshell/gshell-packages/pom.xml b/karaf/gshell/gshell-packages/pom.xml
index 1a23182..4fd1b65 100644
--- a/karaf/gshell/gshell-packages/pom.xml
+++ b/karaf/gshell/gshell-packages/pom.xml
@@ -40,7 +40,7 @@
<dependencies>
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
</dependency>
<dependency>
@@ -54,11 +54,6 @@
<artifactId>org.osgi.compendium</artifactId>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
</dependencies>
<build>
@@ -71,10 +66,9 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
- org.apache.geronimo.gshell.command,
- org.apache.geronimo.gshell.wisdom.command,
- org.apache.geronimo.gshell.wisdom.registry,
- org.apache.felix.karaf.gshell.core,
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.felix.karaf.gshell.console,
*
</Import-Package>
<Private-Package>!*</Private-Package>
diff --git a/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ExportsCommand.java b/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ExportsCommand.java
index 92d164f..b007dcf 100644
--- a/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ExportsCommand.java
+++ b/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ExportsCommand.java
@@ -16,11 +16,11 @@
*/
package org.apache.felix.karaf.gshell.packages;
-import java.io.PrintWriter;
+import java.io.PrintStream;
import java.util.List;
-import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.clp.Option;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Option;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.osgi.service.packageadmin.ExportedPackage;
@@ -39,18 +39,18 @@
for (long id : ids) {
Bundle bundle = getBundleContext().getBundle(id);
if (bundle != null) {
- printExports(io.out, bundle, admin.getExportedPackages(bundle));
+ printExports(System.out, bundle, admin.getExportedPackages(bundle));
} else {
- io.err.println("Bundle ID " + id + " is invalid.");
+ System.err.println("Bundle ID " + id + " is invalid.");
}
}
}
else {
- printExports(io.out, null, admin.getExportedPackages((Bundle) null));
+ printExports(System.out, null, admin.getExportedPackages((Bundle) null));
}
}
- protected void printExports(PrintWriter out, Bundle target, ExportedPackage[] exports) {
+ protected void printExports(PrintStream out, Bundle target, ExportedPackage[] exports) {
if ((exports != null) && (exports.length > 0)) {
for (int i = 0; i < exports.length; i++) {
Bundle bundle = exports[i].getExportingBundle();
diff --git a/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ImportsCommand.java b/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ImportsCommand.java
index 7bddfbf..9a8e179 100644
--- a/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ImportsCommand.java
+++ b/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ImportsCommand.java
@@ -16,17 +16,17 @@
*/
package org.apache.felix.karaf.gshell.packages;
-import java.io.PrintWriter;
+import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.geronimo.gshell.clp.Argument;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.osgi.service.packageadmin.ExportedPackage;
import org.osgi.service.packageadmin.PackageAdmin;
+import org.apache.felix.gogo.commands.Argument;
public class ImportsCommand extends PackageCommandSupport {
@@ -53,9 +53,9 @@
for (long id : ids) {
Bundle bundle = getBundleContext().getBundle(id);
if (bundle != null) {
- printImports(io.out, bundle, packages.get(bundle.getBundleId()));
+ printImports(System.out, bundle, packages.get(bundle.getBundleId()));
} else {
- io.err.println("Bundle ID " + id + " is invalid.");
+ System.err.println("Bundle ID " + id + " is invalid.");
}
}
}
@@ -64,11 +64,11 @@
for (List<ExportedPackage> l : packages.values()) {
pkgs.addAll(l);
}
- printImports(io.out, null, pkgs);
+ printImports(System.out, null, pkgs);
}
}
- protected void printImports(PrintWriter out, Bundle target, List<ExportedPackage> imports) {
+ protected void printImports(PrintStream out, Bundle target, List<ExportedPackage> imports) {
if ((imports != null) && (imports.size() > 0)) {
for (ExportedPackage p : imports) {
Bundle bundle = p.getExportingBundle();
diff --git a/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/PackageCommandSupport.java b/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/PackageCommandSupport.java
index 7486601..d01c653 100644
--- a/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/PackageCommandSupport.java
+++ b/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/PackageCommandSupport.java
@@ -16,7 +16,7 @@
*/
package org.apache.felix.karaf.gshell.packages;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
import org.osgi.framework.ServiceReference;
import org.osgi.service.packageadmin.PackageAdmin;
@@ -32,13 +32,13 @@
// Get package admin service.
ServiceReference ref = getBundleContext().getServiceReference(PackageAdmin.class.getName());
if (ref == null) {
- io.out.println("PackageAdmin service is unavailable.");
+ System.out.println("PackageAdmin service is unavailable.");
return null;
}
try {
PackageAdmin admin = (PackageAdmin) getBundleContext().getService(ref);
if (admin == null) {
- io.out.println("PackageAdmin service is unavailable.");
+ System.out.println("PackageAdmin service is unavailable.");
return null;
}
diff --git a/karaf/gshell/gshell-packages/src/main/resources/OSGI-INF/blueprint/gshell-packages.xml b/karaf/gshell/gshell-packages/src/main/resources/OSGI-INF/blueprint/gshell-packages.xml
index b591606..972e8cb 100644
--- a/karaf/gshell/gshell-packages/src/main/resources/OSGI-INF/blueprint/gshell-packages.xml
+++ b/karaf/gshell/gshell-packages/src/main/resources/OSGI-INF/blueprint/gshell-packages.xml
@@ -21,14 +21,10 @@
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
<command name="packages/exports">
- <action class="org.apache.felix.karaf.gshell.packages.ExportsCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.packages.ExportsCommand"/>
</command>
<command name="packages/imports">
- <action class="org.apache.felix.karaf.gshell.packages.ImportsCommand">
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.packages.ImportsCommand"/>
</command>
</command-bundle>
diff --git a/karaf/gshell/gshell-run/pom.xml b/karaf/gshell/gshell-run/pom.xml
deleted file mode 100644
index 27b06ca..0000000
--- a/karaf/gshell/gshell-run/pom.xml
+++ /dev/null
@@ -1,144 +0,0 @@
-<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.felix.karaf.gshell</groupId>
- <artifactId>gshell</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.run</artifactId>
- <packaging>bundle</packaging>
- <version>1.2.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: GShell Run</name>
-
- <description>
- GShell configuration
- </description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-extender</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
- <Import-Package>
- org.apache.commons.vfs,
- org.apache.commons.vfs.cache,
- org.apache.commons.vfs.impl,
- org.apache.commons.vfs.provider.url,
- org.apache.commons.vfs.provider.temp,
- org.apache.commons.vfs.provider.ram,
- org.apache.commons.vfs.provider.local,
- org.apache.felix.karaf.gshell.core,
- org.apache.felix.karaf.gshell.core.commands,
- org.apache.felix.karaf.gshell.core.config,
- org.apache.felix.karaf.gshell.core.sshd,
- org.apache.felix.karaf.gshell.core.vfs.mvn,
- org.apache.geronimo.gshell.ansi,
- org.apache.geronimo.gshell.application,
- org.apache.geronimo.gshell.application.model,
- org.apache.geronimo.gshell.application.plugin,
- org.apache.geronimo.gshell.application.plugin.activation,
- org.apache.geronimo.gshell.application.plugin.bundle,
- org.apache.geronimo.gshell.chronos,
- org.apache.geronimo.gshell.clp,
- org.apache.geronimo.gshell.clp.handler,
- org.apache.geronimo.gshell.clp.setter,
- org.apache.geronimo.gshell.command,
- org.apache.geronimo.gshell.commandline,
- org.apache.geronimo.gshell.commands.builtin,
- org.apache.geronimo.gshell.commands.file,
- org.apache.geronimo.gshell.commands.network,
- org.apache.geronimo.gshell.commands.shell,
- org.apache.geronimo.gshell.commands.ssh,
- org.apache.geronimo.gshell.commands.text,
- org.apache.geronimo.gshell.console,
- org.apache.geronimo.gshell.console.completer,
- org.apache.geronimo.gshell.event,
- org.apache.geronimo.gshell.i18n,
- org.apache.geronimo.gshell.interpolation,
- org.apache.geronimo.gshell.io,
- org.apache.geronimo.gshell.notification,
- org.apache.geronimo.gshell.parser,
- org.apache.geronimo.gshell.parser.visitor,
- org.apache.geronimo.gshell.registry,
- org.apache.geronimo.gshell.shell,
- org.apache.geronimo.gshell.spring,
- org.apache.geronimo.gshell.terminal,
- org.apache.geronimo.gshell.vfs,
- org.apache.geronimo.gshell.vfs.config,
- org.apache.geronimo.gshell.vfs.provider.meta,
- org.apache.geronimo.gshell.vfs.provider.meta.data,
- org.apache.geronimo.gshell.wisdom.application,
- org.apache.geronimo.gshell.wisdom.branding,
- org.apache.geronimo.gshell.wisdom.builder,
- org.apache.geronimo.gshell.wisdom.command,
- org.apache.geronimo.gshell.wisdom.completer,
- org.apache.geronimo.gshell.wisdom.config,
- org.apache.geronimo.gshell.wisdom.meta,
- org.apache.geronimo.gshell.wisdom.plugin,
- org.apache.geronimo.gshell.wisdom.plugin.activation,
- org.apache.geronimo.gshell.wisdom.plugin.bundle,
- org.apache.geronimo.gshell.wisdom.registry,
- org.apache.geronimo.gshell.wisdom.scope,
- org.apache.geronimo.gshell.wisdom.shell,
- org.apache.sshd,
- org.apache.sshd.server.keyprovider,
- org.apache.sshd.server.jaas,
- org.osgi.service.blueprint.container,
- *
- </Import-Package>
- <_versionpolicy>${bnd.version.policy}</_versionpolicy>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-commands.xml b/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-commands.xml
deleted file mode 100644
index 1acd1f9..0000000
--- a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-commands.xml
+++ /dev/null
@@ -1,271 +0,0 @@
-<?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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
- <command name="about">
- <action class="org.apache.geronimo.gshell.commands.builtin.AboutAction">
- <argument ref="application"/>
- </action>
- </command>
-
- <command name="help">
- <action class="org.apache.geronimo.gshell.commands.builtin.HelpAction">
- <argument ref="commandResolver"/>
- </action>
- <completers>
- <bean class="org.apache.geronimo.gshell.console.completer.AggregateCompleter">
- <argument xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
- <list>
- <ref component-id="aliasNameCompleter"/>
- <ref component-id="commandNameCompleter"/>
- </list>
- </argument>
- </bean>
- <null/>
- </completers>
- </command>
-
- <command name="exit">
- <action class="org.apache.geronimo.gshell.commands.builtin.ExitAction"/>
- </command>
-
- <link name="quit" target="exit"/>
-
- <command name="echo">
- <action class="org.apache.geronimo.gshell.commands.builtin.EchoAction"/>
- </command>
-
- <command name="clear">
- <action class="org.apache.geronimo.gshell.commands.builtin.ClearAction"/>
- </command>
-
- <command name="source">
- <action class="org.apache.geronimo.gshell.commands.builtin.SourceAction">
- <argument ref="commandLineExecutor"/>
- <argument ref="fileSystemAccess"/>
- </action>
- <completers>
- <ref component-id="fileObjectNameCompleter"/>
- <null/>
- </completers>
- </command>
-
- <command name="set">
- <action class="org.apache.geronimo.gshell.commands.builtin.SetAction"/>
- </command>
-
- <command name="unset">
- <action class="org.apache.geronimo.gshell.commands.builtin.UnsetAction"/>
- <completers>
- <ref component-id="variableNameCompleter"/>
- <null/>
- </completers>
- </command>
-
- <command name="alias">
- <action class="org.apache.geronimo.gshell.commands.builtin.AliasAction">
- <argument ref="aliasRegistry"/>
- </action>
- </command>
-
- <command name="unalias">
- <action class="org.apache.geronimo.gshell.commands.builtin.UnaliasAction">
- <argument ref="aliasRegistry"/>
- </action>
- <completers>
- <ref component-id="aliasNameCompleter"/>
- <null/>
- </completers>
- </command>
-
- <command name="history">
- <action class="org.apache.geronimo.gshell.commands.builtin.HistoryAction"/>
- </command>
-
- <command name="info">
- <action class="org.apache.felix.karaf.gshell.core.commands.InfoAction">
- <argument ref="branding" />
- </action>
- </command>
- </command-bundle>
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
- <command name="ssh">
- <action class="org.apache.geronimo.gshell.commands.ssh.SshAction"/>
- </command>
-
- <command name="sshd">
- <action class="org.apache.geronimo.gshell.commands.ssh.SshServerAction"/>
- </command>
- </command-bundle>
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
- <command name="exec">
- <action class="org.apache.geronimo.gshell.commands.shell.ExecuteAction"/>
- </command>
-
- <command name="java">
- <action class="org.apache.geronimo.gshell.commands.shell.JavaAction"/>
- </command>
-
- <command name="sleep">
- <action class="org.apache.geronimo.gshell.commands.shell.SleepAction"/>
- </command>
-
- <command name="date">
- <action class="org.apache.geronimo.gshell.commands.shell.DateAction"/>
- </command>
-
- <command name="edit">
- <action class="org.apache.geronimo.gshell.commands.shell.EditAction">
- <property name="fileSystemAccess" ref="fileSystemAccess"/>
- </action>
- <completers>
- <ref component-id="fileObjectNameCompleter"/>
- <null/>
- </completers>
- </command>
-
- <command name="find">
- <action class="org.apache.geronimo.gshell.commands.shell.FindAction">
- <property name="fileSystemAccess" ref="fileSystemAccess"/>
- </action>
- <completers>
- <ref component-id="fileObjectNameCompleter"/>
- <null/>
- </completers>
- </command>
-
- <command name="sort">
- <action class="org.apache.geronimo.gshell.commands.text.SortAction">
- <property name="fileSystemAccess" ref="fileSystemAccess"/>
- </action>
- <completers>
- <ref component-id="fileObjectNameCompleter"/>
- <null/>
- </completers>
- </command>
- </command-bundle>
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
- <command name="hostname">
- <action class="org.apache.geronimo.gshell.commands.network.HostnameAction"/>
- </command>
- </command-bundle>
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
- <link name="print" target="echo"/>
-
- <command name="printf">
- <action class="org.apache.geronimo.gshell.commands.text.PrintfAction"/>
- </command>
-
- <command name="cat">
- <action class="org.apache.geronimo.gshell.commands.text.CatAction">
- <property name="fileSystemAccess" ref="fileSystemAccess"/>
- </action>
- <completers>
- <ref component-id="fileObjectNameCompleter"/>
- <null/>
- </completers>
- </command>
-
- <command name="grep">
- <action class="org.apache.geronimo.gshell.commands.text.GrepAction"/>
- </command>
- </command-bundle>
-
- <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
- <command name="cd">
- <action class="org.apache.geronimo.gshell.commands.file.ChangeDirectoryAction">
- <property name="fileSystemAccess" ref="fileSystemAccess"/>
- </action>
- <completers>
- <ref component-id="fileObjectNameCompleter"/>
- <null/>
- </completers>
- </command>
-
- <command name="pwd">
- <action class="org.apache.geronimo.gshell.commands.file.CurrentDirectoryAction">
- <property name="fileSystemAccess" ref="fileSystemAccess"/>
- </action>
- </command>
-
- <command name="ls">
- <action class="org.apache.geronimo.gshell.commands.file.ListDirectoryAction">
- <property name="fileSystemAccess" ref="fileSystemAccess"/>
- </action>
- <completers>
- <ref component-id="fileObjectNameCompleter"/>
- <null/>
- </completers>
- </command>
-
- <link name="dir" target="ls"/>
-
- <command name="cp">
- <action class="org.apache.geronimo.gshell.commands.file.CopyAction">
- <property name="fileSystemAccess" ref="fileSystemAccess"/>
- </action>
- <completers>
- <ref component-id="fileObjectNameCompleter"/>
- <ref component-id="fileObjectNameCompleter"/>
- <null/>
- </completers>
- </command>
-
- <link name="copy" target="cp"/>
-
- <command name="rm">
- <action class="org.apache.geronimo.gshell.commands.file.RemoveAction">
- <property name="fileSystemAccess" ref="fileSystemAccess"/>
- </action>
- <completers>
- <ref component-id="fileObjectNameCompleter"/>
- <null/>
- </completers>
- </command>
-
- <link name="del" target="rm"/>
-
- <command name="fileinfo">
- <action class="org.apache.geronimo.gshell.commands.file.FileInfoAction">
- <property name="fileSystemAccess" ref="fileSystemAccess"/>
- </action>
- <completers>
- <ref component-id="fileObjectNameCompleter"/>
- <null/>
- </completers>
- </command>
-
- <command name="touch">
- <action class="org.apache.geronimo.gshell.commands.file.TouchAction">
- <property name="fileSystemAccess" ref="fileSystemAccess"/>
- </action>
- <completers>
- <ref component-id="fileObjectNameCompleter"/>
- <null/>
- </completers>
- </command>
- </command-bundle>
-
-</blueprint>
diff --git a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-local.xml b/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-local.xml
deleted file mode 100644
index db5d9f0..0000000
--- a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-local.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <bean id="localShell" class="org.apache.felix.karaf.gshell.core.ShellWrapper">
- <argument ref="shell" />
- </bean>
-
- <bean id="localConsole" class="org.apache.felix.karaf.gshell.core.LocalConsole" init-method="init" destroy-method="destroy">
- <property name="createLocalShell" value="$[karaf.startLocalConsole]"/>
- <property name="shell" ref="localShell"/>
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </bean>
-
-</blueprint>
\ No newline at end of file
diff --git a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-osgi.xml b/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-osgi.xml
deleted file mode 100644
index 7237d29..0000000
--- a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-osgi.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<?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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:cm="http://www.osgi.org/xmlns/blueprint-cm/v1.0.0"
- default-availability="optional">
-
- <cm:property-placeholder persistent-id="org.apache.felix.karaf.shell">
- <cm:default-properties>
- <cm:property name="sshPort" value="8101"/>
- <cm:property name="sshRealm" value="karaf"/>
- <cm:property name="hostKey" value="${karaf.base}/etc/host.key"/>
- </cm:default-properties>
- </cm:property-placeholder>
-
- <bean id="osgiCommandRegistry" class="org.apache.felix.karaf.gshell.core.OsgiCommandRegistry">
- <argument ref="commandRegistry"/>
- </bean>
-
- <bean id="osgiAliasRegistry" class="org.apache.felix.karaf.gshell.core.OsgiAliasRegistry">
- <argument ref="aliasRegistry"/>
- </bean>
-
- <reference-list id="osgiCommands" interface="org.apache.geronimo.gshell.command.Command">
- <reference-listener ref="osgiCommandRegistry" bind-method="register" unbind-method="unregister"/>
- </reference-list>
-
- <reference-list id="osgiLinkCommands" interface="org.apache.geronimo.gshell.command.Link">
- <reference-listener ref="osgiCommandRegistry" bind-method="register" unbind-method="unregister"/>
- </reference-list>
-
- <reference-list id="osgiAliases" interface="org.apache.geronimo.gshell.command.Alias">
- <reference-listener ref="osgiAliasRegistry" bind-method="register" unbind-method="unregister"/>
- </reference-list>
-
- <service ref="localShell" interface="org.apache.geronimo.gshell.shell.Shell"/>
-
- <service ref="commandLineExecutor" interface="org.apache.geronimo.gshell.commandline.CommandLineExecutor"/>
-
-</blueprint>
diff --git a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-remote.xml b/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-remote.xml
deleted file mode 100644
index 87c3100..0000000
--- a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-remote.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<?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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:ext="http://geronimo.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
-
- <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
-
- <bean id="sshClient" class="org.apache.sshd.SshClient" factory-method="setUpDefaultClient" init-method="start" destroy-method="stop">
- </bean>
-
- <bean id="sshServer" class="org.apache.sshd.SshServer" factory-method="setUpDefaultServer" scope="prototype">
- <property name="port" value="${sshPort}" />
- <property name="shellFactory">
- <bean class="org.apache.geronimo.gshell.commands.ssh.ShellFactoryImpl">
- <property name="application" ref="application" />
- <property name="completers">
- <list>
- <ref component-id="commandsCompleter"/>
- <ref component-id="aliasNameCompleter"/>
- </list>
- </property>
- <property name="executor" ref="commandLineExecutor" />
- <property name="prompter">
- <bean class="org.apache.geronimo.gshell.wisdom.shell.ConsolePrompterImpl">
- <argument ref="application"/>
- </bean>
- </property>
- <property name="errorHandler">
- <bean class="org.apache.geronimo.gshell.wisdom.shell.ConsoleErrorHandlerImpl" />
- </property>
- <property name="history">
- <bean class="org.apache.geronimo.gshell.wisdom.shell.HistoryImpl">
- <argument ref="application"/>
- </bean>
- </property>
- </bean>
- </property>
- <property name="commandFactory">
- <bean class="org.apache.felix.karaf.gshell.core.sshd.ShellCommandFactory">
- <property name="executor" ref="commandLineExecutor" />
- </bean>
- </property>
- <property name="keyPairProvider" ref="keyPairProvider" />
- <property name="passwordAuthenticator" ref="passwordAuthenticator" />
- </bean>
-
- <bean id="keyPairProvider" class="org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider">
- <property name="path" value="${hostKey}" />
- </bean>
- <bean id="passwordAuthenticator" class="org.apache.sshd.server.jaas.JaasPasswordAuthenticator">
- <property name="domain" value="${sshRealm}" />
- </bean>
-
- <bean id="sshServerFactory" class="org.apache.felix.karaf.gshell.core.sshd.SshServerFactory" init-method="start" destroy-method="stop">
- <argument ref="sshServer" />
- <property name="start" value="$[karaf.startRemoteShell]" />
- </bean>
-
-</blueprint>
\ No newline at end of file
diff --git a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-vfs.xml b/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-vfs.xml
deleted file mode 100644
index 354eab0..0000000
--- a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell-vfs.xml
+++ /dev/null
@@ -1,116 +0,0 @@
-<?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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <type-converters>
- <bean class="org.apache.geronimo.gshell.vfs.config.CacheStrategyConverter"/>
- </type-converters>
-
- <bean id="fileSystemAccess" class="org.apache.geronimo.gshell.vfs.FileSystemAccessImpl">
- <argument ref="fileSystemManager"/>
- </bean>
-
- <bean id="fileObjectNameCompleter" class="org.apache.geronimo.gshell.vfs.FileObjectNameCompleter">
- <argument ref="fileSystemAccess"/>
- </bean>
-
- <!--
- TODO: Set tempDir File arg in constructor to set the temporary location, may need 2 replicators?
- -->
- <bean id="defaultFileReplicator" class="org.apache.commons.vfs.impl.DefaultFileReplicator" init-method="init"/>
-
- <bean id="fileSystemManagerFactory" class="org.apache.geronimo.gshell.vfs.config.FileSystemManagerFactory" init-method="init">
- <property name="filesCache">
- <bean class="org.apache.commons.vfs.cache.SoftRefFilesCache"/>
- </property>
-
- <property name="cacheStrategy" value="ON_RESOLVE"/>
-
- <property name="fileReplicator">
- <bean class="org.apache.commons.vfs.impl.PrivilegedFileReplicator">
- <argument ref="defaultFileReplicator"/>
- </bean>
- </property>
-
- <!--
- TODO: Try and root the temporary store under ${gshell.home}/tmp or something
- -->
- <property name="temporaryFileStore">
- <ref component-id="defaultFileReplicator"/>
- </property>
-
- <property name="fileContentInfoFactory">
- <bean class="org.apache.commons.vfs.impl.FileContentInfoFilenameFactory"/>
- </property>
-
- <property name="defaultProvider">
- <bean class="org.apache.commons.vfs.provider.url.UrlFileProvider"/>
- </property>
- </bean>
-
- <bean id="fileSystemManager" factory-ref="fileSystemManagerFactory" factory-method="getFileSystemManager"/>
-
- <bean class="org.apache.geronimo.gshell.vfs.config.FileProviderConfigurer" init-method="init">
- <property name="fileSystemManager" ref="fileSystemManager"/>
- <property name="scheme" value="tmp"/>
- <property name="provider">
- <bean class="org.apache.commons.vfs.provider.temp.TemporaryFileProvider"/>
- </property>
- </bean>
-
- <bean class="org.apache.geronimo.gshell.vfs.config.FileProviderConfigurer" init-method="init">
- <property name="fileSystemManager" ref="fileSystemManager"/>
- <property name="scheme" value="ram"/>
- <property name="provider">
- <bean class="org.apache.commons.vfs.provider.ram.RamFileProvider"/>
- </property>
- </bean>
-
- <bean class="org.apache.geronimo.gshell.vfs.config.FileProviderConfigurer" init-method="init">
- <property name="fileSystemManager" ref="fileSystemManager"/>
- <property name="scheme" value="file"/>
- <property name="provider">
- <bean class="org.apache.commons.vfs.provider.local.DefaultLocalFileProvider"/>
- </property>
- </bean>
-
- <bean class="org.apache.geronimo.gshell.vfs.config.FileProviderConfigurer" init-method="init">
- <property name="fileSystemManager" ref="fileSystemManager"/>
- <property name="scheme" value="mvn"/>
- <property name="provider">
- <bean class="org.apache.felix.karaf.gshell.core.vfs.mvn.MvnFileProvider"/>
- </property>
- </bean>
-
- <bean id="metaDataRegistry" class="org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistryImpl" init-method="init">
- <argument ref="eventManager" />
- </bean>
-
- <bean id="metaFileProviderConfigurer" class="org.apache.geronimo.gshell.vfs.config.FileProviderConfigurer" init-method="init">
- <property name="fileSystemManager" ref="fileSystemManager"/>
- <property name="scheme" value="meta"/>
- <property name="provider">
- <bean class="org.apache.geronimo.gshell.vfs.provider.meta.MetaFileProvider">
- <argument ref="metaDataRegistry"/>
- </bean>
- </property>
- </bean>
-
-</blueprint>
\ No newline at end of file
diff --git a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell.xml b/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell.xml
deleted file mode 100644
index e85c82c..0000000
--- a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/blueprint/gshell.xml
+++ /dev/null
@@ -1,191 +0,0 @@
-<?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.
-
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <bean id="io"
- class="org.apache.geronimo.gshell.io.IO">
- <property name="verbosity" value="DEBUG"/>
- </bean>
-
- <bean id="branding"
- class="org.apache.felix.karaf.gshell.core.DefaultBranding">
- <property name="prompt" value="@|bold %{gshell.username}|@%{application.id}:@|bold %{gshell.group}|> " />
- </bean>
-
- <bean id="application"
- class="org.apache.felix.karaf.gshell.core.ApplicationImpl"
- init-method="init">
- <property name="id" value="$[karaf.name]"/>
- <property name="io" ref="io"/>
- <property name="model">
- <bean class="org.apache.geronimo.gshell.application.model.ApplicationModel">
- <property name="branding" ref="branding"/>
- </bean>
- </property>
- <property name="variables">
- <bean class="org.apache.geronimo.gshell.command.Variables"/>
- </property>
- </bean>
-
- <bean id="beanContainer"
- class="org.apache.felix.karaf.gshell.core.BeanContainerWrapper">
- <argument ref="blueprintContainer"/>
- </bean>
-
- <bean id="eventManager"
- class="org.apache.geronimo.gshell.event.EventManagerImpl"/>
-
- <bean id="applicationManager"
- class="org.apache.felix.karaf.gshell.core.ApplicationManagerImpl"
- init-method="init"
- destroy-method="destroy">
- <argument ref="eventManager" />
- <argument ref="application" />
- <argument ref="blueprintContainer"/>
- </bean>
-
- <bean id="commandLineParser"
- class="org.apache.geronimo.gshell.parser.CommandLineParser"/>
-
- <bean id="aliasRegistry"
- class="org.apache.geronimo.gshell.wisdom.registry.AliasRegistryImpl">
- <argument ref="eventManager"/>
- </bean>
-
- <bean id="aliasMetaMapper"
- class="org.apache.geronimo.gshell.wisdom.registry.AliasMetaMapper"
- init-method="init">
- <argument ref="eventManager"/>
- <argument ref="metaDataRegistry"/>
- <argument ref="aliasRegistry"/>
- </bean>
-
- <bean id="commandRegistry"
- class="org.apache.geronimo.gshell.wisdom.registry.CommandRegistryImpl">
- <argument ref="eventManager"/>
- </bean>
-
- <bean id="commandMetaMapper"
- class="org.apache.geronimo.gshell.wisdom.registry.CommandMetaMapper"
- init-method="init">
- <argument ref="eventManager"/>
- <argument ref="metaDataRegistry"/>
- <argument ref="commandRegistry"/>
- </bean>
-
- <bean id="groupDirResolver"
- class="org.apache.geronimo.gshell.wisdom.registry.GroupDirectoryResolver">
- <argument ref="fileSystemAccess"/>
- </bean>
-
- <bean id="commandResolver"
- class="org.apache.felix.karaf.gshell.core.CommandResolverImpl">
- <argument ref="fileSystemAccess"/>
- <argument ref="groupDirResolver"/>
- <property name="beanContainer" ref="beanContainer"/>
- <property name="aliasCommandBeanId">
- <idref component-id="aliasCommandPrototype"/>
- </property>
- <property name="groupCommandBeanId">
- <idref component-id="groupCommandPrototype"/>
- </property>
- </bean>
-
- <bean id="aliasCommandPrototype"
- class="org.apache.felix.karaf.gshell.core.WorkAroundAliasCommand"
- scope="prototype">
- <argument ref="commandLineExecutor"/>
- <property name="beanContainer" ref="beanContainer"/>
- </bean>
-
- <bean id="groupCommandPrototype"
- class="org.apache.geronimo.gshell.wisdom.command.GroupCommand"
- scope="prototype">
- <property name="beanContainer" ref="beanContainer"/>
- </bean>
-
- <bean id="commandLineBuilder" class="org.apache.geronimo.gshell.wisdom.shell.CommandLineBuilderImpl">
- <argument ref="commandLineParser"/>
- </bean>
-
- <bean id="commandLineExecutor"
- class="org.apache.geronimo.gshell.wisdom.shell.CommandLineExecutorImpl">
- <argument ref="commandResolver"/>
- <argument ref="commandLineBuilder"/>
- </bean>
-
- <bean id="shell"
- class="org.apache.geronimo.gshell.wisdom.shell.ShellImpl"
- scope="prototype"
- init-method="init">
- <argument ref="application"/>
- <argument ref="commandLineExecutor"/>
-
- <property name="completers">
- <list>
- <ref component-id="commandsCompleter"/>
- <ref component-id="aliasNameCompleter"/>
- </list>
- </property>
- <property name="prompter">
- <bean class="org.apache.geronimo.gshell.wisdom.shell.ConsolePrompterImpl">
- <argument ref="application"/>
- </bean>
- </property>
- <property name="errorHandler">
- <bean class="org.apache.geronimo.gshell.wisdom.shell.ConsoleErrorHandlerImpl" />
- </property>
- <property name="history">
- <bean class="org.apache.geronimo.gshell.wisdom.shell.HistoryImpl">
- <argument ref="application"/>
- </bean>
- </property>
- </bean>
-
- <bean id="commandNameCompleter"
- class="org.apache.geronimo.gshell.wisdom.completer.CommandNameCompleter"
- activation="lazy"
- init-method="init">
- <argument ref="eventManager"/>
- <argument ref="commandRegistry"/>
- </bean>
-
- <bean id="aliasNameCompleter"
- class="org.apache.geronimo.gshell.wisdom.completer.AliasNameCompleter"
- activation="lazy"
- init-method="init">
- <argument ref="eventManager"/>
- <argument ref="aliasRegistry"/>
- </bean>
-
- <bean id="commandsCompleter"
- class="org.apache.geronimo.gshell.wisdom.completer.CommandsCompleter"
- activation="lazy"
- init-method="init">
- <argument ref="eventManager"/>
- <argument ref="commandRegistry"/>
- </bean>
-
- <bean id="variableNameCompleter"
- class="org.apache.geronimo.gshell.wisdom.completer.VariableNameCompleter"
- activation="lazy">
- </bean>
-
-</blueprint>
\ No newline at end of file
diff --git a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/metatype/metatype.properties b/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/metatype/metatype.properties
deleted file mode 100644
index 880f228..0000000
--- a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/metatype/metatype.properties
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# 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.
-#
-
-#
-# This file contains localization strings for configuration labels and
-# descriptions as used in the metatype.xml descriptor
-
-shell.name = Apache Felix Karaf Shell
-shell.description = Configuration of Apache Felix Karaf Shell
-
-sshPort.name = SSH Port
-sshPort.description = port of the SSH server
-
-sshRealm.name = SSH Realm
-sshRealm.description = name of the JAAS realm used for authentication
-
-hostKey.name = Host keys
-hostKey.description = Path to the host key file
diff --git a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/metatype/metatype.xml b/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/metatype/metatype.xml
deleted file mode 100644
index 5c851f9..0000000
--- a/karaf/gshell/gshell-run/src/main/resources/OSGI-INF/metatype/metatype.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?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.
-
--->
-<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0" localization="OSGI-INF/metatype/metatype">
- <OCD id="org.apache.felix.karaf.shell" name="%shell.name" description="%shell.description">
- <AD id="sshPort" type="Integer" default="8101" name="%sshPort.name"
- description="%sshPort.description"/>
- <AD id="sshRealm" type="String" default="karaf" name="%sshRealm.name"
- description="%sshRealm.description"/>
- <AD id="hostKey" type="String" default="${karaf.base}/etc/host.key" name="%hostKey.name"
- description="%hostKey.description"/>
- </OCD>
- <Designate pid="org.apache.felix.karaf.shell">
- <Object ocdref="org.apache.felix.karaf.shell"/>
- </Designate>
-</metatype:MetaData>
diff --git a/karaf/gshell/gshell-ssh/pom.xml b/karaf/gshell/gshell-ssh/pom.xml
new file mode 100644
index 0000000..3f72ef3
--- /dev/null
+++ b/karaf/gshell/gshell-ssh/pom.xml
@@ -0,0 +1,102 @@
+<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.felix.karaf.gshell</groupId>
+ <artifactId>gshell</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.felix.karaf.gshell</groupId>
+ <artifactId>org.apache.felix.karaf.gshell.ssh</artifactId>
+ <packaging>bundle</packaging>
+ <version>1.2.0-SNAPSHOT</version>
+ <name>Apache Felix Karaf :: GShell SSH</name>
+
+ <description>
+ Provides SSH support to the console
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix.karaf.gshell</groupId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>${pom.basedir}/src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
+ <Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
+ <Import-Package>
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.felix.karaf.gshell.console,
+ org.apache.sshd.server.keyprovider,
+ org.apache.sshd.server.jaas,
+ *
+ </Import-Package>
+ <Private-Package>org.apache.felix.karaf.jpm.*</Private-Package>
+ <_versionpolicy>${bnd.version.policy}</_versionpolicy>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellCommandFactory.java b/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellCommandFactory.java
new file mode 100644
index 0000000..87a542f
--- /dev/null
+++ b/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellCommandFactory.java
@@ -0,0 +1,94 @@
+/*
+ * 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.felix.karaf.gshell.ssh;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import org.apache.sshd.server.CommandFactory;
+import org.osgi.service.command.CommandProcessor;
+import org.osgi.service.command.CommandSession;
+
+public class ShellCommandFactory implements CommandFactory {
+
+ private CommandProcessor commandProcessor;
+
+ public void setCommandProcessor(CommandProcessor commandProcessor) {
+ this.commandProcessor = commandProcessor;
+ }
+
+ public Command createCommand(String command) {
+ return new ShellCommand(command);
+ }
+
+ public class ShellCommand implements Command {
+
+ private String command;
+ private InputStream in;
+ private OutputStream out;
+ private OutputStream err;
+ private ExitCallback callback;
+
+ public ShellCommand(String command) {
+ this.command = command;
+ }
+
+ public void setInputStream(InputStream in) {
+ this.in = in;
+ }
+
+ public void setOutputStream(OutputStream out) {
+ this.out = out;
+ }
+
+ public void setErrorStream(OutputStream err) {
+ this.err = err;
+ }
+
+ public void setExitCallback(ExitCallback callback) {
+ this.callback = callback;
+ }
+
+ public void start() throws IOException {
+ try {
+ CommandSession session = commandProcessor.createSession(in, new PrintStream(out), new PrintStream(err));
+ session.execute(command);
+ } catch (Exception e) {
+ throw (IOException) new IOException("Unable to start shell").initCause(e);
+ } finally {
+ close(in, out, err);
+ callback.onExit(0);
+ }
+ }
+
+ }
+
+ private static void close(Closeable... closeables) {
+ for (Closeable c : closeables) {
+ try {
+ c.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+}
diff --git a/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellFactoryImpl.java b/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellFactoryImpl.java
new file mode 100644
index 0000000..5c4ff98
--- /dev/null
+++ b/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellFactoryImpl.java
@@ -0,0 +1,128 @@
+/*
+ * 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.felix.karaf.gshell.ssh;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.karaf.gshell.console.Completer;
+import org.apache.felix.karaf.gshell.console.completer.AggregateCompleter;
+import org.apache.felix.karaf.gshell.console.jline.Console;
+import org.apache.sshd.server.ShellFactory;
+import org.osgi.service.command.CommandProcessor;
+import org.osgi.service.command.CommandSession;
+
+/**
+ * SSHD {@link org.apache.sshd.server.ShellFactory} which provides access to GShell.
+ *
+ * @version $Rev: 731517 $ $Date: 2009-01-05 11:25:19 +0100 (Mon, 05 Jan 2009) $
+ */
+public class ShellFactoryImpl implements ShellFactory
+{
+ private CommandProcessor commandProcessor;
+ private List<Completer> completers;
+
+ public void setCommandProcessor(CommandProcessor commandProcessor) {
+ this.commandProcessor = commandProcessor;
+ }
+
+ public void setCompleters(List<Completer> completers) {
+ this.completers = completers;
+ }
+
+ public Shell createShell() {
+ return new ShellImpl();
+ }
+
+ public class ShellImpl implements Shell
+ {
+ private InputStream in;
+
+ private OutputStream out;
+
+ private OutputStream err;
+
+ private ExitCallback callback;
+
+ private boolean closed;
+
+ public void setInputStream(final InputStream in) {
+ this.in = in;
+ }
+
+ public void setOutputStream(final OutputStream out) {
+ this.out = out;
+ }
+
+ public void setErrorStream(final OutputStream err) {
+ this.err = err;
+ }
+
+ public void setExitCallback(ExitCallback callback) {
+ this.callback = callback;
+ }
+
+ public void start(final Environment env) throws IOException {
+ try {
+ CommandSession session = commandProcessor.createSession(in, new PrintStream(out), new PrintStream(err));
+ session.put("APPLICATION", System.getProperty("karaf.name", "root"));
+ for (Map.Entry<String,String> e : env.getEnv().entrySet()) {
+ session.put(e.getKey(), e.getValue());
+ }
+ Console console = new Console(session,
+ new SshTerminal(env),
+ new AggregateCompleter(completers),
+ new Runnable() {
+ public void run() {
+ destroy();
+ }
+ });
+ new Thread(console).start();
+ } catch (Exception e) {
+ throw (IOException) new IOException("Unable to start shell").initCause(e);
+ }
+ }
+
+ public void destroy() {
+ if (!closed) {
+ closed = true;
+ ShellFactoryImpl.close(in, out, err);
+ callback.onExit(0);
+ }
+ }
+
+ }
+
+ private static void close(Closeable... closeables) {
+ for (Closeable c : closeables) {
+ try {
+ c.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+
+}
diff --git a/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshAction.java b/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshAction.java
new file mode 100644
index 0000000..4627a03
--- /dev/null
+++ b/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshAction.java
@@ -0,0 +1,156 @@
+///*
+// * 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.felix.karaf.gshell.ssh;
+//
+//import org.apache.sshd.ClientChannel;
+//import org.apache.sshd.ClientSession;
+//import org.apache.sshd.SshClient;
+//import org.apache.sshd.client.future.ConnectFuture;
+//import org.apache.sshd.common.util.NoCloseInputStream;
+//import org.apache.sshd.common.util.NoCloseOutputStream;
+//import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+//import org.apache.felix.karaf.gshell.console.BlueprintContainerAware;
+//import org.apache.felix.gogo.commands.Option;
+//import org.apache.felix.gogo.commands.Argument;
+//import org.slf4j.Logger;
+//import org.slf4j.LoggerFactory;
+//import org.osgi.service.blueprint.container.BlueprintContainer;
+//
+///**
+// * Connect to a SSH server.
+// *
+// * @version $Rev: 721244 $ $Date: 2008-11-27 18:19:56 +0100 (Thu, 27 Nov 2008) $
+// */
+//public class SshAction
+// extends OsgiCommandSupport implements BlueprintContainerAware
+//{
+// private final Logger log = LoggerFactory.getLogger(getClass());
+//
+// @Option(name="-l", aliases={"--username"}, description = "Username")
+// private String username;
+//
+// @Option(name="-P", aliases={"--password"}, description = "Password")
+// private String password;
+//
+// @Argument(required=true, description = "Host")
+// private String hostname;
+//
+// @Option(name="-p", aliases={"--port"}, description = "Port")
+// private int port = 22;
+//
+// private BlueprintContainer container;
+//
+// private ClientSession session;
+//
+// public void setBlueprintContainer(final BlueprintContainer container) {
+// assert container != null;
+// this.container = container;
+// }
+//
+// /**
+// * Helper to validate that prompted username or password is not null or empty.
+// */
+// private class UsernamePasswordValidator
+// implements PromptReader.Validator
+// {
+// private String type;
+//
+// private int count = 0;
+//
+// private int max = 3;
+//
+// public UsernamePasswordValidator(final String type) {
+// assert type != null;
+//
+// this.type = type;
+// }
+//
+// public boolean isValid(final String value) {
+// count++;
+//
+// if (value != null && value.trim().length() > 0) {
+// return true;
+// }
+//
+// if (count >= max) {
+// throw new RuntimeException("Too many attempts; failed to prompt user for " + type + " after " + max + " tries");
+// }
+//
+// return false;
+// }
+// }
+//
+// @Override
+// protected Object doExecute() throws Exception {
+//
+// //
+// // TODO: Parse hostname for <username>@<hostname>
+// //
+//
+// System.out.println("Connecting to host " + hostname + " on port " + port);
+//
+// // If the username/password was not configured via cli, then prompt the user for the values
+// if (username == null || password == null) {
+// PromptReader prompter = new PromptReader(io);
+// log.debug("Prompting user for credentials");
+// if (username == null) {
+// username = prompter.readLine("Login: ", new UsernamePasswordValidator("login"));
+// }
+// if (password == null) {
+// text = messages.getMessage("prompt.password");
+// password = prompter.readPassword("Password: ", new UsernamePasswordValidator("password"));
+// }
+// }
+//
+// // Create the client from prototype
+// SshClient client = (SshClient) container.getComponentInstance(SshClient.class.getName());
+// log.debug("Created client: {}", client);
+// client.start();;
+//
+// try {
+// ConnectFuture future = client.connect(hostname, port);
+// future.await();
+// session = future.getSession();
+// try {
+// System.out.println("Connected");
+//
+// session.authPassword(username, password);
+// int ret = session.waitFor(ClientSession.WAIT_AUTH | ClientSession.CLOSED | ClientSession.AUTHED, 0);
+// if ((ret & ClientSession.AUTHED) == 0) {
+// System.err.println("Authentication failed");
+// return null;
+// }
+//
+// ClientChannel channel = session.createChannel("shell");
+// channel.setIn(new NoCloseInputStream(System.in));
+// channel.setOut(new NoCloseOutputStream(System.out));
+// channel.setErr(new NoCloseOutputStream(System.err));
+// channel.open();
+// channel.waitFor(ClientChannel.CLOSED, 0);
+// } finally {
+// session.close(false);
+// }
+// } finally {
+// client.stop();
+// }
+//
+// return null;
+// }
+//}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshServerAction.java b/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerAction.java
similarity index 62%
rename from karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshServerAction.java
rename to karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerAction.java
index 1166858..69cef2b 100644
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshServerAction.java
+++ b/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerAction.java
@@ -17,49 +17,46 @@
* under the License.
*/
-package org.apache.geronimo.gshell.commands.ssh;
+package org.apache.felix.karaf.gshell.ssh;
import org.apache.sshd.SshServer;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.CommandAction;
-import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.i18n.MessageSource;
-import org.apache.geronimo.gshell.io.IO;
-import org.apache.geronimo.gshell.spring.BeanContainer;
-import org.apache.geronimo.gshell.spring.BeanContainerAware;
+import org.apache.felix.karaf.gshell.console.BlueprintContainerAware;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Option;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.osgi.service.blueprint.container.BlueprintContainer;
/**
* Start a SSH server.
*
* @version $Rev: 720411 $ $Date: 2008-11-25 05:32:43 +0100 (Tue, 25 Nov 2008) $
*/
-public class SshServerAction
- implements CommandAction, BeanContainerAware
+public class SshServerAction extends OsgiCommandSupport implements BlueprintContainerAware
{
private final Logger log = LoggerFactory.getLogger(getClass());
@Option(name="-p", aliases={ "--port" }, description = "Port")
- private int port=8101;
+ private int port = 8101;
@Option(name="-b", aliases={ "--background"}, description = "Background")
private boolean background = true;
- private BeanContainer container;
+ private BlueprintContainer container;
- public void setBeanContainer(final BeanContainer container) {
+ private String sshServerId;
+
+ public void setBlueprintContainer(final BlueprintContainer container) {
assert container != null;
-
this.container = container;
}
- public Object execute(final CommandContext context) throws Exception {
- assert context != null;
- IO io = context.getIo();
- MessageSource messages = context.getCommand().getMessages();
+ public void setSshServerId(String sshServerId) {
+ this.sshServerId = sshServerId;
+ }
- SshServer server = container.getBean("sshServer", SshServer.class);
+ protected Object doExecute() throws Exception {
+ SshServer server = (SshServer) container.getComponentInstance(sshServerId);
log.debug("Created server: {}", server);
@@ -67,7 +64,7 @@
server.start();
- io.info(messages.format("info.listening", port));
+ System.out.println("SSH server listening on port " + port);
if (!background) {
synchronized (this) {
@@ -79,6 +76,6 @@
server.stop();
}
- return Result.SUCCESS;
+ return null;
}
}
diff --git a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/SshServerFactory.java b/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerFactory.java
similarity index 96%
rename from karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/SshServerFactory.java
rename to karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerFactory.java
index 1e8a946..56efe3e 100644
--- a/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/SshServerFactory.java
+++ b/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerFactory.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.felix.karaf.gshell.core.sshd;
+package org.apache.felix.karaf.gshell.ssh;
import org.apache.sshd.SshServer;
diff --git a/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshTerminal.java b/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshTerminal.java
new file mode 100644
index 0000000..819f205
--- /dev/null
+++ b/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshTerminal.java
@@ -0,0 +1,65 @@
+/*
+ * 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.felix.karaf.gshell.ssh;
+
+import jline.Terminal;
+import org.apache.sshd.server.ShellFactory;
+
+public class SshTerminal extends Terminal implements ShellFactory.SignalListener {
+
+ private ShellFactory.Environment environment;
+
+ public SshTerminal(ShellFactory.Environment environment) {
+ this.environment = environment;
+ this.environment.addSignalListener(this);
+ }
+
+ public void initializeTerminal() throws Exception {
+ }
+
+ public int getTerminalWidth() {
+ return Integer.valueOf(this.environment.getEnv().get("COLUMNS"));
+ }
+
+ public int getTerminalHeight() {
+ return Integer.valueOf(this.environment.getEnv().get("LINES"));
+ }
+
+ public boolean isSupported() {
+ return true;
+ }
+
+ public boolean getEcho() {
+ return false;
+ }
+
+ public boolean isEchoEnabled() {
+ return false;
+ }
+
+ public void enableEcho() {
+ }
+
+ public void disableEcho() {
+ }
+
+ public void signal(int signal) {
+
+ }
+}
diff --git a/karaf/gshell/gshell-ssh/src/main/resources/OSGI-INF/blueprint/gshell-ssh.xml b/karaf/gshell/gshell-ssh/src/main/resources/OSGI-INF/blueprint/gshell-ssh.xml
new file mode 100644
index 0000000..0af6137
--- /dev/null
+++ b/karaf/gshell/gshell-ssh/src/main/resources/OSGI-INF/blueprint/gshell-ssh.xml
@@ -0,0 +1,102 @@
+<?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.
+
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:cm="http://www.osgi.org/xmlns/blueprint-cm/v1.0.0"
+ xmlns:ext="http://geronimo.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
+
+ <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
+
+ <cm:property-placeholder persistent-id="org.apache.felix.karaf.shell">
+ <cm:default-properties>
+ <cm:property name="sshPort" value="8101"/>
+ <cm:property name="sshRealm" value="karaf"/>
+ <cm:property name="hostKey" value="${karaf.base}/etc/host.key"/>
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
+ <!--
+ <command name="ssh/ssh">
+ <action class="org.apache.felix.karaf.gshell.ssh.SshAction">
+ </action>
+ </command>
+ -->
+ <command name="ssh/sshd">
+ <action class="org.apache.felix.karaf.gshell.ssh.SshServerAction">
+ <property name="sshServerId">
+ <bp:idref component-id="sshServer"/>
+ </property>
+ </action>
+ </command>
+ </command-bundle>
+
+ <bean id="sshClient" class="org.apache.sshd.SshClient" factory-method="setUpDefaultClient" init-method="start"
+ destroy-method="stop">
+ </bean>
+
+ <bean id="sshServer" class="org.apache.sshd.SshServer" factory-method="setUpDefaultServer" scope="prototype">
+ <property name="port" value="${sshPort}"/>
+ <property name="shellFactory">
+ <bean class="org.apache.felix.karaf.gshell.ssh.ShellFactoryImpl">
+ <property name="completers">
+ <list>
+ <ref component-id="commandCompleter"/>
+ </list>
+ </property>
+ <property name="commandProcessor" ref="commandProcessor"/>
+ </bean>
+ </property>
+ <property name="commandFactory">
+ <bean class="org.apache.felix.karaf.gshell.ssh.ShellCommandFactory">
+ <property name="commandProcessor" ref="commandProcessor"/>
+ </bean>
+ </property>
+ <property name="keyPairProvider" ref="keyPairProvider"/>
+ <property name="passwordAuthenticator" ref="passwordAuthenticator"/>
+ </bean>
+
+ <bean id="keyPairProvider" class="org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider">
+ <property name="path" value="${hostKey}"/>
+ </bean>
+ <bean id="passwordAuthenticator" class="org.apache.sshd.server.jaas.JaasPasswordAuthenticator">
+ <property name="domain" value="${sshRealm}"/>
+ </bean>
+
+ <bean id="sshServerFactory" class="org.apache.felix.karaf.gshell.ssh.SshServerFactory" init-method="start"
+ destroy-method="stop">
+ <argument ref="sshServer"/>
+ <property name="start" value="$[karaf.startRemoteShell]"/>
+ </bean>
+
+ <reference id="commandProcessor" interface="org.osgi.service.command.CommandProcessor">
+ </reference>
+
+ <reference-list id="functions" filter="(&(osgi.command.scope=*)(osgi.command.function=*))" availability="optional">
+ <reference-listener ref="commandCompleter"
+ bind-method="register"
+ unbind-method="unregister"/>
+ </reference-list>
+
+ <bean id="commandCompleter" class="org.apache.felix.karaf.gshell.console.completer.CommandsCompleter">
+ <property name="bundleContext" ref="blueprintBundleContext" />
+ </bean>
+
+</blueprint>
diff --git a/karaf/gshell/gshell-wrapper/pom.xml b/karaf/gshell/gshell-wrapper/pom.xml
index 3645ed5..72e12b6 100644
--- a/karaf/gshell/gshell-wrapper/pom.xml
+++ b/karaf/gshell/gshell-wrapper/pom.xml
@@ -37,22 +37,10 @@
Provides the Service Wrapper GShell integration
</description>
- <properties>
- <gshell.osgi.import>
- org.apache.felix.karaf.main.spi.*;resolution:=optional,
- org.apache.geronimo.gshell*,
- </gshell.osgi.import>
- <gshell.osgi.export>
- </gshell.osgi.export>
- <gshell.osgi.private>
- org.apache.felix.karaf.gshell.wrapper.*,
- </gshell.osgi.private>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.core</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
</dependency>
<dependency>
@@ -60,11 +48,6 @@
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
- </dependency>
</dependencies>
<build>
@@ -99,10 +82,9 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Export-Package>${pom.artifactId}*;version=${project.version}</Export-Package>
<Import-Package>
- org.apache.geronimo.gshell.command,
- org.apache.geronimo.gshell.wisdom.command,
- org.apache.geronimo.gshell.wisdom.registry,
- org.apache.felix.karaf.gshell.core,
+ org.osgi.service.command,
+ org.apache.felix.gogo.commands,
+ org.apache.felix.karaf.gshell.console,
*
</Import-Package>
<Private-Package>!*</Private-Package>
diff --git a/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/InstallCommand.java b/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/InstallCommand.java
index 6f3a7e1..5af0922 100644
--- a/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/InstallCommand.java
+++ b/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/InstallCommand.java
@@ -26,9 +26,8 @@
import java.util.Map;
import java.util.Scanner;
-import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.io.PumpStreamHandler;
-import org.apache.felix.karaf.gshell.core.OsgiCommandSupport;
+import org.apache.felix.karaf.gshell.console.OsgiCommandSupport;
+import org.apache.felix.gogo.commands.Option;
/**
* Installs this Karaf instance as a service in your operating systems.
@@ -106,7 +105,7 @@
// TODO: figure out how to hook in the service that it starts up
// when the machine boots up.
} else {
- io.out.println("Your operating system '"+os+"' is not currently supported.");
+ System.out.println("Your operating system '"+os+"' is not currently supported.");
return 1;
}
@@ -117,83 +116,83 @@
File wrapperConf = new File(etc,name+"-wrapper.conf");
copyFilteredResourceTo(wrapperConf, "all/karaf-wrapper.conf", props);
- io.out.println("");
- io.out.println("Setup complete. You may want to tweak the JVM properties in the wrapper configuration file: "+wrapperConf.getPath());
- io.out.println("before installing and starting the service.");
- io.out.println("");
+ System.out.println("");
+ System.out.println("Setup complete. You may want to tweak the JVM properties in the wrapper configuration file: "+wrapperConf.getPath());
+ System.out.println("before installing and starting the service.");
+ System.out.println("");
if( os.startsWith("Win") ) {
- io.out.println("");
- io.out.println("To install the service, run: ");
- io.out.println(" C:> "+serviceFile.getPath()+" install");
- io.out.println("");
- io.out.println("Once installed, to start the service run: ");
- io.out.println(" C:> net start \""+name+"\"");
- io.out.println("");
- io.out.println("Once running, to stop the service run: ");
- io.out.println(" C:> net stop \""+name+"\"");
- io.out.println("");
- io.out.println("Once stopped, to remove the installed the service run: ");
- io.out.println(" C:> "+serviceFile.getPath()+" remove");
- io.out.println("");
+ System.out.println("");
+ System.out.println("To install the service, run: ");
+ System.out.println(" C:> "+serviceFile.getPath()+" install");
+ System.out.println("");
+ System.out.println("Once installed, to start the service run: ");
+ System.out.println(" C:> net start \""+name+"\"");
+ System.out.println("");
+ System.out.println("Once running, to stop the service run: ");
+ System.out.println(" C:> net stop \""+name+"\"");
+ System.out.println("");
+ System.out.println("Once stopped, to remove the installed the service run: ");
+ System.out.println(" C:> "+serviceFile.getPath()+" remove");
+ System.out.println("");
} else if( os.startsWith("Mac OS X") ) {
- io.out.println("");
- io.out.println("At this time it is not known how to get this service to start when the machine is rebooted.");
- io.out.println("If you know how to install the following service script so that it gets started");
- io.out.println("when OS X starts, please email dev@felix.apache.org and let us know how so");
- io.out.println("we can update this message.");
- io.out.println(" ");
- io.out.println(" To start the service:");
- io.out.println(" $ "+serviceFile.getPath()+" start");
- io.out.println("");
- io.out.println(" To stop the service:");
- io.out.println(" $ "+serviceFile.getPath()+" stop");
- io.out.println("");
+ System.out.println("");
+ System.out.println("At this time it is not known how to get this service to start when the machine is rebooted.");
+ System.out.println("If you know how to install the following service script so that it gets started");
+ System.out.println("when OS X starts, please email dev@felix.apache.org and let us know how so");
+ System.out.println("we can update this message.");
+ System.out.println(" ");
+ System.out.println(" To start the service:");
+ System.out.println(" $ "+serviceFile.getPath()+" start");
+ System.out.println("");
+ System.out.println(" To stop the service:");
+ System.out.println(" $ "+serviceFile.getPath()+" stop");
+ System.out.println("");
} else if( os.startsWith("Linux") ) {
- io.out.println("The way the service is installed depends upon your flavor of Linux.");
+ System.out.println("The way the service is installed depends upon your flavor of Linux.");
// TODO: figure out if we can detect the Linux flavor
- io.out.println("");
- io.out.println("@|cyan On Redhat/Fedora/CentOS Systems:|");
- io.out.println(" To install the service:");
- io.out.println(" $ ln -s "+serviceFile.getPath()+" /etc/init.d/");
- io.out.println(" $ chkconfig "+serviceFile.getName()+" --add");
- io.out.println("");
- io.out.println(" To start the service when the machine is rebooted:");
- io.out.println(" $ chkconfig "+serviceFile.getName()+" on");
- io.out.println("");
- io.out.println(" To disable starting the service when the machine is rebooted:");
- io.out.println(" $ chkconfig "+serviceFile.getName()+" off");
- io.out.println("");
- io.out.println(" To start the service:");
- io.out.println(" $ service "+serviceFile.getName()+" start");
- io.out.println("");
- io.out.println(" To stop the service:");
- io.out.println(" $ service "+serviceFile.getName()+" stop");
- io.out.println("");
- io.out.println(" To uninstall the service :");
- io.out.println(" $ chkconfig "+serviceFile.getName()+" --del");
- io.out.println(" $ rm /etc/init.d/"+serviceFile.getName());
+ System.out.println("");
+ System.out.println("@|cyan On Redhat/Fedora/CentOS Systems:|");
+ System.out.println(" To install the service:");
+ System.out.println(" $ ln -s "+serviceFile.getPath()+" /etc/init.d/");
+ System.out.println(" $ chkconfig "+serviceFile.getName()+" --add");
+ System.out.println("");
+ System.out.println(" To start the service when the machine is rebooted:");
+ System.out.println(" $ chkconfig "+serviceFile.getName()+" on");
+ System.out.println("");
+ System.out.println(" To disable starting the service when the machine is rebooted:");
+ System.out.println(" $ chkconfig "+serviceFile.getName()+" off");
+ System.out.println("");
+ System.out.println(" To start the service:");
+ System.out.println(" $ service "+serviceFile.getName()+" start");
+ System.out.println("");
+ System.out.println(" To stop the service:");
+ System.out.println(" $ service "+serviceFile.getName()+" stop");
+ System.out.println("");
+ System.out.println(" To uninstall the service :");
+ System.out.println(" $ chkconfig "+serviceFile.getName()+" --del");
+ System.out.println(" $ rm /etc/init.d/"+serviceFile.getName());
- io.out.println("");
- io.out.println("@|cyan On Ubuntu/Debian Systems:|");
- io.out.println(" To install the service:");
- io.out.println(" $ ln -s "+serviceFile.getPath()+" /etc/init.d/");
- io.out.println("");
- io.out.println(" To start the service when the machine is rebooted:");
- io.out.println(" $ update-rc.d "+serviceFile.getName()+" defaults");
- io.out.println("");
- io.out.println(" To disable starting the service when the machine is rebooted:");
- io.out.println(" $ update-rc.d -f "+serviceFile.getName()+" remove");
- io.out.println("");
- io.out.println(" To start the service:");
- io.out.println(" $ /etc/init.d/"+serviceFile.getName()+" start");
- io.out.println("");
- io.out.println(" To stop the service:");
- io.out.println(" $ /etc/init.d/"+serviceFile.getName()+" stop");
- io.out.println("");
- io.out.println(" To uninstall the service :");
- io.out.println(" $ rm /etc/init.d/"+serviceFile.getName());
+ System.out.println("");
+ System.out.println("@|cyan On Ubuntu/Debian Systems:|");
+ System.out.println(" To install the service:");
+ System.out.println(" $ ln -s "+serviceFile.getPath()+" /etc/init.d/");
+ System.out.println("");
+ System.out.println(" To start the service when the machine is rebooted:");
+ System.out.println(" $ update-rc.d "+serviceFile.getName()+" defaults");
+ System.out.println("");
+ System.out.println(" To disable starting the service when the machine is rebooted:");
+ System.out.println(" $ update-rc.d -f "+serviceFile.getName()+" remove");
+ System.out.println("");
+ System.out.println(" To start the service:");
+ System.out.println(" $ /etc/init.d/"+serviceFile.getName()+" start");
+ System.out.println("");
+ System.out.println(" To stop the service:");
+ System.out.println(" $ /etc/init.d/"+serviceFile.getName()+" stop");
+ System.out.println("");
+ System.out.println(" To uninstall the service :");
+ System.out.println(" $ rm /etc/init.d/"+serviceFile.getName());
}
@@ -211,7 +210,7 @@
builder.command("chmod", mode, serviceFile.getCanonicalPath());
Process p = builder.start();
- PumpStreamHandler handler = new PumpStreamHandler(io.inputStream, io.outputStream, io.errorStream);
+ PumpStreamHandler handler = new PumpStreamHandler(System.in, System.out, System.err);
handler.attach(p);
handler.start();
int status = p.waitFor();
@@ -221,7 +220,7 @@
private void copyResourceTo(File outFile, String resource, boolean text) throws Exception {
if( !outFile.exists() ) {
- io.out.println("Creating file: @|green "+outFile.getPath()+"|");
+ System.out.println("Creating file: @|green "+outFile.getPath()+"|");
InputStream is = InstallCommand.class.getResourceAsStream(resource);
try {
if( text ) {
@@ -231,7 +230,7 @@
Scanner scanner = new Scanner(is);
while (scanner.hasNextLine() ) {
String line = scanner.nextLine();
- io.out.println("writing: "+line);
+ System.out.println("writing: "+line);
out.println(line);
}
} finally {
@@ -253,13 +252,13 @@
safeClose(is);
}
} else {
- io.out.println("@|red File allready exists|. Move it out of the way if you want it re-created: "+outFile.getPath()+"");
+ System.out.println("@|red File allready exists|. Move it out of the way if you want it re-created: "+outFile.getPath()+"");
}
}
private void copyFilteredResourceTo(File outFile, String resource, HashMap<String, String> props) throws Exception {
if( !outFile.exists() ) {
- io.out.println("Creating file: @|green "+outFile.getPath()+"|");
+ System.out.println("Creating file: @|green "+outFile.getPath()+"|");
InputStream is = InstallCommand.class.getResourceAsStream(resource);
try {
// Read it line at a time so that we can use the platform line ending when we write it out.
@@ -278,7 +277,7 @@
safeClose(is);
}
} else {
- io.out.println("@|red File allready exists|. Move it out of the way if you want it re-created: "+outFile.getPath()+"");
+ System.out.println("@|red File allready exists|. Move it out of the way if you want it re-created: "+outFile.getPath()+"");
}
}
@@ -314,7 +313,7 @@
private void mkdir(File file) {
if( !file.exists() ) {
- io.out.println("Creating missing directory: @|green "+file.getPath()+"|");
+ System.out.println("Creating missing directory: @|green "+file.getPath()+"|");
file.mkdirs();
}
}
diff --git a/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/PumpStreamHandler.java b/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/PumpStreamHandler.java
new file mode 100644
index 0000000..37c5769
--- /dev/null
+++ b/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/PumpStreamHandler.java
@@ -0,0 +1,232 @@
+/*
+ * 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.felix.karaf.gshell.wrapper;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
+//
+// Based on Apache Ant 1.6.5
+//
+
+/**
+ * Copies standard output and error of children streams to standard output and error of the parent.
+ *
+ * @version $Rev: 705608 $ $Date: 2008-10-17 15:28:45 +0200 (Fri, 17 Oct 2008) $
+ */
+public class PumpStreamHandler
+{
+ private InputStream in;
+
+ private OutputStream out;
+
+ private OutputStream err;
+
+ private Thread outputThread;
+
+ private Thread errorThread;
+
+ private StreamPumper inputPump;
+
+ //
+ // NOTE: May want to use a ThreadPool here, 3 threads per/pair seems kinda expensive :-(
+ //
+
+ public PumpStreamHandler(final InputStream in, final OutputStream out, final OutputStream err) {
+ assert in != null;
+ assert out != null;
+ assert err != null;
+
+ this.in = in;
+ this.out = out;
+ this.err = err;
+ }
+
+ public PumpStreamHandler(final OutputStream out, final OutputStream err) {
+ this(null, out, err);
+ }
+
+ public PumpStreamHandler(final OutputStream outAndErr) {
+ this(outAndErr, outAndErr);
+ }
+
+ /**
+ * Set the input stream from which to read the standard output of the child.
+ */
+ public void setChildOutputStream(final InputStream in) {
+ assert in != null;
+
+ createChildOutputPump(in, out);
+ }
+
+ /**
+ * Set the input stream from which to read the standard error of the child.
+ */
+ public void setChildErrorStream(final InputStream in) {
+ assert in != null;
+
+ if (err != null) {
+ createChildErrorPump(in, err);
+ }
+ }
+
+ /**
+ * Set the output stream by means of which input can be sent to the child.
+ */
+ public void setChildInputStream(final OutputStream out) {
+ assert out != null;
+
+ if (in != null) {
+ inputPump = createInputPump(in, out, true);
+ }
+ else {
+ try {
+ out.close();
+ } catch (IOException e) { }
+ }
+ }
+
+ /**
+ * Attach to a child streams from the given process.
+ *
+ * @param p The process to attach to.
+ */
+ public void attach(final Process p) {
+ assert p != null;
+
+ setChildInputStream(p.getOutputStream());
+ setChildOutputStream(p.getInputStream());
+ setChildErrorStream(p.getErrorStream());
+ }
+ /**
+ * Start pumping the streams.
+ */
+ public void start() {
+ if (outputThread != null) {
+ outputThread.start();
+ }
+
+ if (errorThread != null) {
+ errorThread.start();
+ }
+
+ if (inputPump != null) {
+ Thread inputThread = new Thread(inputPump);
+ inputThread.setDaemon(true);
+ inputThread.start();
+ }
+ }
+
+ /**
+ * Stop pumping the streams.
+ */
+ public void stop() {
+ if (outputThread != null) {
+ try {
+ outputThread.join();
+ }
+ catch (InterruptedException e) {
+ // ignore
+ }
+ }
+
+ if (errorThread != null) {
+ try {
+ errorThread.join();
+ }
+ catch (InterruptedException e) {
+ // ignore
+ }
+ }
+
+ if (inputPump != null) {
+ inputPump.stop();
+ }
+
+ try {
+ err.flush();
+ } catch (IOException e) { }
+ try {
+ out.flush();
+ } catch (IOException e) { }
+ }
+
+ /**
+ * Create the pump to handle child output.
+ */
+ protected void createChildOutputPump(final InputStream in, final OutputStream out) {
+ assert in != null;
+ assert out != null;
+
+ outputThread = createPump(in, out);
+ }
+
+ /**
+ * Create the pump to handle error output.
+ */
+ protected void createChildErrorPump(final InputStream in, final OutputStream out) {
+ assert in != null;
+ assert out != null;
+
+ errorThread = createPump(in, out);
+ }
+
+ /**
+ * Creates a stream pumper to copy the given input stream to the given output stream.
+ */
+ protected Thread createPump(final InputStream in, final OutputStream out) {
+ assert in != null;
+ assert out != null;
+
+ return createPump(in, out, false);
+ }
+
+ /**
+ * Creates a stream pumper to copy the given input stream to the
+ * given output stream.
+ *
+ * @param in The input stream to copy from.
+ * @param out The output stream to copy to.
+ * @param closeWhenExhausted If true close the inputstream.
+ * @return A thread object that does the pumping.
+ */
+ protected Thread createPump(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
+ assert in != null;
+ assert out != null;
+
+ final Thread result = new Thread(new StreamPumper(in, out, closeWhenExhausted));
+ result.setDaemon(true);
+ return result;
+ }
+
+ /**
+ * Creates a stream pumper to copy the given input stream to the
+ * given output stream. Used for standard input.
+ */
+ protected StreamPumper createInputPump(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
+ assert in != null;
+ assert out != null;
+
+ StreamPumper pumper = new StreamPumper(in, out, closeWhenExhausted);
+ pumper.setAutoflush(true);
+ return pumper;
+ }
+}
\ No newline at end of file
diff --git a/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/StreamPumper.java b/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/StreamPumper.java
new file mode 100644
index 0000000..58aa8e5
--- /dev/null
+++ b/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/StreamPumper.java
@@ -0,0 +1,199 @@
+/*
+ * 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.felix.karaf.gshell.wrapper;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
+//
+// Based on Apache Ant 1.6.5
+//
+
+/**
+ * Copies all data from an input stream to an output stream.
+ *
+ * @version $Rev: 705608 $ $Date: 2008-10-17 15:28:45 +0200 (Fri, 17 Oct 2008) $
+ */
+public class StreamPumper
+ implements Runnable
+{
+ private InputStream in;
+
+ private OutputStream out;
+
+ private volatile boolean finish;
+
+ private volatile boolean finished;
+
+ private boolean closeWhenExhausted;
+
+ private boolean autoflush;
+
+ private Exception exception;
+
+ private int bufferSize = 128;
+
+ private boolean started;
+
+ /**
+ * Create a new stream pumper.
+ *
+ * @param in Input stream to read data from
+ * @param out Output stream to write data to.
+ * @param closeWhenExhausted If true, the output stream will be closed when
+ * the input is exhausted.
+ */
+ public StreamPumper(final InputStream in, final OutputStream out, final boolean closeWhenExhausted) {
+ assert in != null;
+ assert out != null;
+
+ this.in = in;
+ this.out = out;
+ this.closeWhenExhausted = closeWhenExhausted;
+ }
+
+ /**
+ * Create a new stream pumper.
+ *
+ * @param in Input stream to read data from
+ * @param out Output stream to write data to.
+ */
+ public StreamPumper(final InputStream in, final OutputStream out) {
+ this(in, out, false);
+ }
+
+ /**
+ * Set whether data should be flushed through to the output stream.
+ *
+ * @param autoflush If true, push through data; if false, let it be buffered
+ */
+ public void setAutoflush(boolean autoflush) {
+ this.autoflush = autoflush;
+ }
+
+ /**
+ * Copies data from the input stream to the output stream.
+ *
+ * Terminates as soon as the input stream is closed or an error occurs.
+ */
+ public void run() {
+ synchronized (this) {
+ started = true;
+ }
+ finished = false;
+ finish = false;
+
+ final byte[] buf = new byte[bufferSize];
+
+ int length;
+ try {
+ while ((length = in.read(buf)) > 0 && !finish) {
+ out.write(buf, 0, length);
+ if (autoflush) {
+ out.flush();
+ }
+ }
+ out.flush();
+ }
+ catch (Exception e) {
+ synchronized (this) {
+ exception = e;
+ }
+ }
+ finally {
+ if (closeWhenExhausted) {
+ try {
+ out.close();
+ } catch (IOException e) { }
+ }
+ finished = true;
+
+ synchronized (this) {
+ notifyAll();
+ }
+ }
+ }
+
+ /**
+ * Tells whether the end of the stream has been reached.
+ *
+ * @return true If the stream has been exhausted.
+ */
+ public boolean isFinished() {
+ return finished;
+ }
+
+ /**
+ * This method blocks until the stream pumper finishes.
+ *
+ * @see #isFinished()
+ */
+ public synchronized void waitFor() throws InterruptedException {
+ while (!isFinished()) {
+ wait();
+ }
+ }
+
+ /**
+ * Set the size in bytes of the read buffer.
+ *
+ * @param bufferSize the buffer size to use.
+ * @throws IllegalStateException if the StreamPumper is already running.
+ */
+ public synchronized void setBufferSize(final int bufferSize) {
+ if (started) {
+ throw new IllegalStateException("Cannot set buffer size on a running StreamPumper");
+ }
+
+ this.bufferSize = bufferSize;
+ }
+
+ /**
+ * Get the size in bytes of the read buffer.
+ *
+ * @return The size of the read buffer.
+ */
+ public synchronized int getBufferSize() {
+ return bufferSize;
+ }
+
+ /**
+ * Get the exception encountered, if any.
+ *
+ * @return The Exception encountered; or null if there was none.
+ */
+ public synchronized Exception getException() {
+ return exception;
+ }
+
+ /**
+ * Stop the pumper as soon as possible.
+ *
+ * Note that it may continue to block on the input stream
+ * but it will really stop the thread as soon as it gets EOF
+ * or any byte, and it will be marked as finished.
+ */
+ public synchronized void stop() {
+ finish = true;
+
+ notifyAll();
+ }
+}
\ No newline at end of file
diff --git a/karaf/gshell/gshell-wrapper/src/main/resources/OSGI-INF/blueprint/gshell-wrapper.xml b/karaf/gshell/gshell-wrapper/src/main/resources/OSGI-INF/blueprint/gshell-wrapper.xml
index fddc211..91e4a14 100644
--- a/karaf/gshell/gshell-wrapper/src/main/resources/OSGI-INF/blueprint/gshell-wrapper.xml
+++ b/karaf/gshell/gshell-wrapper/src/main/resources/OSGI-INF/blueprint/gshell-wrapper.xml
@@ -21,9 +21,7 @@
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
<command name="wrapper/install">
- <action class="org.apache.felix.karaf.gshell.wrapper.InstallCommand">
- <property name="bundleContext" ref="bundleContext"/>
- </action>
+ <action class="org.apache.felix.karaf.gshell.wrapper.InstallCommand"/>
</command>
</command-bundle>
diff --git a/karaf/gshell/pom.xml b/karaf/gshell/pom.xml
index 503fc53..bebd1eb 100644
--- a/karaf/gshell/pom.xml
+++ b/karaf/gshell/pom.xml
@@ -34,8 +34,7 @@
<name>Apache Felix Karaf :: GShell</name>
<modules>
- <module>gshell-core</module>
- <module>gshell-run</module>
+ <module>gshell-console</module>
<module>gshell-osgi</module>
<module>gshell-admin</module>
<module>gshell-features</module>
@@ -44,6 +43,8 @@
<module>gshell-log</module>
<module>gshell-config</module>
<module>gshell-packages</module>
+ <module>gshell-ssh</module>
+ <module>gshell-commands</module>
</modules>
</project>
diff --git a/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Config.java b/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Config.java
index a8eb3ff..c0e4e5c 100644
--- a/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Config.java
+++ b/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Config.java
@@ -75,9 +75,11 @@
Module[] modules = this.modules;
AppConfigurationEntry[] entries = new AppConfigurationEntry[modules.length];
for (int i = 0; i < modules.length; i++) {
- Map<String,String> options = new HashMap<String,String>();
+ Map<String,Object> options = new HashMap<String,Object>();
if (modules[i].getOptions() != null) {
- options.putAll(modules[i].getOptions());
+ for (Map.Entry e : modules[i].getOptions().entrySet()) {
+ options.put(e.getKey().toString(), e.getValue());
+ }
}
options.put(ProxyLoginModule.PROPERTY_MODULE, modules[i].getClassName());
options.put(ProxyLoginModule.PROPERTY_BUNDLE, Long.toString(bundleContext.getBundle().getBundleId()));
diff --git a/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Module.java b/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Module.java
index baaa352..ae74205 100644
--- a/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Module.java
+++ b/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/Module.java
@@ -16,7 +16,7 @@
*/
package org.apache.felix.karaf.jaas.config.impl;
-import java.util.Map;
+import java.util.Properties;
/**
* POJO for a login module.
@@ -26,7 +26,7 @@
private String className;
private String flags;
- private Map<String,String> options;
+ private Properties options;
public String getClassName() {
return className;
@@ -44,11 +44,11 @@
this.flags = flags;
}
- public Map<String, String> getOptions() {
+ public Properties getOptions() {
return options;
}
- public void setOptions(Map<String, String> options) {
+ public void setOptions(Properties options) {
this.options = options;
}
diff --git a/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/NamespaceHandler.java b/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/NamespaceHandler.java
index 1b3dcc0..68f73e2 100644
--- a/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/NamespaceHandler.java
+++ b/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/NamespaceHandler.java
@@ -70,7 +70,7 @@
if (rank != null && rank.length() > 0) {
bean.addProperty("rank", createValue(context, rank));
}
- NodeList childElements = element.getElementsByTagName("module");
+ NodeList childElements = element.getElementsByTagNameNS("http://felix.apache.org/karaf/xmlns/jaas/v1.0.0", "module");
if (childElements != null && childElements.getLength() > 0) {
MutableCollectionMetadata children = context.createMetadata(MutableCollectionMetadata.class);
for (int i = 0; i < childElements.getLength(); ++i) {
diff --git a/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/OsgiConfiguration.java b/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/OsgiConfiguration.java
index a5489d8..405161a 100644
--- a/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/OsgiConfiguration.java
+++ b/karaf/jaas/jaas-config/src/main/java/org/apache/felix/karaf/jaas/config/impl/OsgiConfiguration.java
@@ -27,16 +27,14 @@
public class OsgiConfiguration extends Configuration {
- private List<JaasRealm> realms;
+ private final List<JaasRealm> realms = new CopyOnWriteArrayList<JaasRealm>();
public void init() {
- realms = new CopyOnWriteArrayList<JaasRealm>();
Configuration.setConfiguration(this);
}
public void close() {
realms.clear();
- realms = null;
Configuration.setConfiguration(null);
}
@@ -45,9 +43,7 @@
}
public void unregister(JaasRealm realm, Map<String,?> properties) {
- if (realms != null) {
- realms.remove(realm);
- }
+ realms.remove(realm);
}
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
diff --git a/karaf/pom.xml b/karaf/pom.xml
index 4fc97f2..f78369a 100644
--- a/karaf/pom.xml
+++ b/karaf/pom.xml
@@ -18,7 +18,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-
+ ƒ
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -66,35 +66,25 @@
</prerequisites>
<properties>
- <config.location>etc</config.location>
- <ant.version>1.7.0_1</ant.version>
<aopalliance.version>1.0_1</aopalliance.version>
<asm.version>2.2.3_1</asm.version>
<cglib.version>2.1_3_2-SNAPSHOT</cglib.version>
- <commons.codec.version>1.2_1</commons.codec.version>
- <commons.httpclient.version>3.1_1</commons.httpclient.version>
- <commons.io.version>1.3.2_1</commons.io.version>
- <commons.jexl.version>1.1_1</commons.jexl.version>
<commons.logging.version>1.1.1</commons.logging.version>
- <commons.vfs.version>1.0_1</commons.vfs.version>
<depends.maven.plugin.version>1.0</depends.maven.plugin.version>
<easymock.version>2.4</easymock.version>
- <equinox.version> 3.5.0.v20090429-1630</equinox.version>
+ <equinox.version> 3.5.0.v20090520</equinox.version>
<felix.bundlerepository.version>1.4.0</felix.bundlerepository.version>
<felix.compendium.version>1.2.0</felix.compendium.version>
<felix.configadmin.version>1.0.4</felix.configadmin.version>
<felix.framework.version>1.9.0-SNAPSHOT</felix.framework.version>
- <felix.http.version>1.0.0</felix.http.version>
+ <felix.gogo.version>0.9.0-SNAPSHOT</felix.gogo.version>
<felix.osgi.version>1.3.0-SNAPSHOT</felix.osgi.version>
<felix.plugin.version>2.0.0</felix.plugin.version>
<felix.prefs.version>1.0.2</felix.prefs.version>
<felix.webconsole.version>1.2.11-SNAPSHOT</felix.webconsole.version>
<felix.metatype.version>1.0.2</felix.metatype.version>
- <geronimo.annotation.version>1.1.1</geronimo.annotation.version>
<geronimo.blueprint.version>1.0.0-SNAPSHOT</geronimo.blueprint.version>
<geronimo.servlet.version>1.1.2</geronimo.servlet.version>
- <gshell.version>1.0-alpha-2</gshell.version>
- <jaxp.ri.version>1.4.2_2</jaxp.ri.version>
<jetty.bundle.version>6.1.14_1</jetty.bundle.version>
<junit.version>3.8.2_1</junit.version>
<jline.version>0.9.94_1</jline.version>
@@ -113,7 +103,7 @@
<spring.version>2.5.6.SEC01</spring.version>
<sshd.version>0.1.0</sshd.version>
<woodstox.version>3.2.7_1</woodstox.version>
- <osgi.jmx.version>1.0-r6125-patched</osgi.jmx.version>
+ <osgi.jmx.version>4.2.0.200907080519</osgi.jmx.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -243,6 +233,11 @@
</dependency>
<dependency>
<groupId>org.apache.felix.karaf.gshell</groupId>
+ <artifactId>org.apache.felix.karaf.gshell.console</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix.karaf.gshell</groupId>
<artifactId>org.apache.felix.karaf.gshell.run</artifactId>
<version>${pom.version}</version>
</dependency>
@@ -282,6 +277,16 @@
<version>${pom.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.felix.karaf.gshell</groupId>
+ <artifactId>org.apache.felix.karaf.gshell.ssh</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix.karaf.gshell</groupId>
+ <artifactId>org.apache.felix.karaf.gshell.commands</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.felix.karaf.jaas</groupId>
<artifactId>org.apache.felix.karaf.jaas.boot</artifactId>
<version>${pom.version}</version>
@@ -571,140 +576,16 @@
<version>${mina.version}</version>
<exclusions>
<exclusion>
- <groupId>net.gleamynode</groupId>
- <artifactId>netty2</artifactId>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
</exclusion>
<exclusion>
- <groupId>com.jcraft</groupId>
- <artifactId>jzlib</artifactId>
- </exclusion>
- <exclusion>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>logkit</groupId>
- <artifactId>logkit</artifactId>
- </exclusion>
- <exclusion>
- <groupId>avalon-framework</groupId>
- <artifactId>avalon-framework</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
- <groupId>org.apache.geronimo.gshell.support</groupId>
- <artifactId>gshell-terminal</artifactId>
- <version>${gshell.version}</version>
- <exclusions>
- <exclusion>
- <groupId>jline</groupId>
- <artifactId>jline</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.support</groupId>
- <artifactId>gshell-spring</artifactId>
- <version>${gshell.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.support</groupId>
- <artifactId>gshell-interpolation</artifactId>
- <version>${gshell.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.commands</groupId>
- <artifactId>gshell-builtin</artifactId>
- <version>${gshell.version}</version>
- <exclusions>
- <exclusion>
- <groupId>oro</groupId>
- <artifactId>oro</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-vfs</groupId>
- <artifactId>commons-vfs</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.commands</groupId>
- <artifactId>gshell-file</artifactId>
- <version>${gshell.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.commands</groupId>
- <artifactId>gshell-network</artifactId>
- <version>${gshell.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.commands</groupId>
- <artifactId>gshell-shell</artifactId>
- <version>${gshell.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.commands</groupId>
- <artifactId>gshell-ssh</artifactId>
- <version>${gshell.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.geronimo.gshell.support</groupId>
- <artifactId>gshell-security</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.commands</groupId>
- <artifactId>gshell-text</artifactId>
- <version>${gshell.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.gshell.wisdom</groupId>
- <artifactId>gshell-wisdom-core</artifactId>
- <version>${gshell.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.geronimo.gshell.support</groupId>
- <artifactId>gshell-ivy</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.geronimo.gshell.support</groupId>
- <artifactId>gshell-xstore</artifactId>
- </exclusion>
- <exclusion>
- <groupId>commons-jexl</groupId>
- <artifactId>commons-jexl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-api</artifactId>
- <version>1.0-alpha-32</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>1.5.5</version>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.4.3</version>
@@ -720,19 +601,6 @@
<version>1.4.3</version>
</dependency>
<dependency>
- <groupId>com.thoughtworks.xstream</groupId>
- <artifactId>xstream</artifactId>
- <version>1.3</version>
- <exclusions>
- <exclusion>
- <!-- xom is an optional dependency of xstream. Its also
- LGPL, so its really not ASF compatible. -->
- <groupId>xom</groupId>
- <artifactId>xom</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
<version>${pax.logging.version}</version>
@@ -769,21 +637,6 @@
<version>${geronimo.annotation.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.servicemix.specs</groupId>
- <artifactId>org.apache.servicemix.specs.jaxp-api-1.4</artifactId>
- <version>${servicemix.specs.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.jaxp-ri</artifactId>
- <version>${jaxp.ri.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.woodstox</artifactId>
- <version>${woodstox.version}</version>
- </dependency>
- <dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>${easymock.version}</version>
@@ -792,58 +645,11 @@
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>${sshd.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.mina</groupId>
- <artifactId>mina-core</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>jmx</artifactId>
+ <artifactId>org.osgi.impl.bundle.jmx</artifactId>
<version>${osgi.jmx.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.osgi</groupId>
- <artifactId>osgi_R4_core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.osgi</groupId>
- <artifactId>osgi_R4_compendium</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl104-over-slf4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>com.oracle.osgi</groupId>
- <artifactId>jmx-impl</artifactId>
- <version>${osgi.jmx.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.osgi</groupId>
- <artifactId>osgi_R4_core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.osgi</groupId>
- <artifactId>osgi_R4_compendium</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl104-over-slf4j</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
@@ -880,6 +686,16 @@
<artifactId>blueprint-bundle</artifactId>
<version>${geronimo.blueprint.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.felix.gogo</groupId>
+ <artifactId>org.apache.felix.gogo.runtime</artifactId>
+ <version>${felix.gogo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix.gogo</groupId>
+ <artifactId>org.apache.felix.gogo.commands</artifactId>
+ <version>${felix.gogo.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>