You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by gn...@apache.org on 2009/07/09 10:29:22 UTC
svn commit: r792445 [5/6] - in /felix/trunk/karaf: ./ assembly/
assembly/src/main/descriptors/ assembly/src/main/filtered-resources/
assembly/src/main/filtered-resources/etc/ client/
deployer/features/src/main/resources/OSGI-INF/blueprint/ deployer/fil...
Modified: felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListBundles.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListBundles.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListBundles.java (original)
+++ felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListBundles.java Thu Jul 9 08:29:14 2009
@@ -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)
Modified: felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListServices.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListServices.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListServices.java (original)
+++ felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ListServices.java Thu Jul 9 08:29:14 2009
@@ -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;
}
}
Modified: felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/RefreshBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/RefreshBundle.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/RefreshBundle.java (original)
+++ felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/RefreshBundle.java Thu Jul 9 08:29:14 2009
@@ -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;
}
}
Modified: felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ResolveBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ResolveBundle.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ResolveBundle.java (original)
+++ felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/ResolveBundle.java Thu Jul 9 08:29:14 2009
@@ -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 });
Modified: felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Shutdown.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Shutdown.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Shutdown.java (original)
+++ felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Shutdown.java Thu Jul 9 08:29:14 2009
@@ -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;
}
}
Modified: felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartBundle.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartBundle.java (original)
+++ felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartBundle.java Thu Jul 9 08:29:14 2009
@@ -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 {
Modified: felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartLevel.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartLevel.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartLevel.java (original)
+++ felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StartLevel.java Thu Jul 9 08:29:14 2009
@@ -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;
}
}
Modified: felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java (original)
+++ felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/StopBundle.java Thu Jul 9 08:29:14 2009
@@ -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 {
Modified: felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/UpdateBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/UpdateBundle.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/UpdateBundle.java (original)
+++ felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/UpdateBundle.java Thu Jul 9 08:29:14 2009
@@ -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 {
Modified: felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Util.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Util.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Util.java (original)
+++ felix/trunk/karaf/gshell/gshell-osgi/src/main/java/org/apache/felix/karaf/gshell/osgi/Util.java Thu Jul 9 08:29:14 2009
@@ -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;
}
Modified: felix/trunk/karaf/gshell/gshell-osgi/src/main/resources/OSGI-INF/blueprint/gshell-osgi.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-osgi/src/main/resources/OSGI-INF/blueprint/gshell-osgi.xml?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-osgi/src/main/resources/OSGI-INF/blueprint/gshell-osgi.xml (original)
+++ felix/trunk/karaf/gshell/gshell-osgi/src/main/resources/OSGI-INF/blueprint/gshell-osgi.xml Thu Jul 9 08:29:14 2009
@@ -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>
Modified: felix/trunk/karaf/gshell/gshell-packages/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-packages/pom.xml?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-packages/pom.xml (original)
+++ felix/trunk/karaf/gshell/gshell-packages/pom.xml Thu Jul 9 08:29:14 2009
@@ -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>
Modified: felix/trunk/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ExportsCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ExportsCommand.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ExportsCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ExportsCommand.java Thu Jul 9 08:29:14 2009
@@ -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();
Modified: felix/trunk/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ImportsCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ImportsCommand.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ImportsCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/ImportsCommand.java Thu Jul 9 08:29:14 2009
@@ -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();
Modified: felix/trunk/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/PackageCommandSupport.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/PackageCommandSupport.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/PackageCommandSupport.java (original)
+++ felix/trunk/karaf/gshell/gshell-packages/src/main/java/org/apache/felix/karaf/gshell/packages/PackageCommandSupport.java Thu Jul 9 08:29:14 2009
@@ -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;
}
Modified: felix/trunk/karaf/gshell/gshell-packages/src/main/resources/OSGI-INF/blueprint/gshell-packages.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-packages/src/main/resources/OSGI-INF/blueprint/gshell-packages.xml?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-packages/src/main/resources/OSGI-INF/blueprint/gshell-packages.xml (original)
+++ felix/trunk/karaf/gshell/gshell-packages/src/main/resources/OSGI-INF/blueprint/gshell-packages.xml Thu Jul 9 08:29:14 2009
@@ -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>
Copied: felix/trunk/karaf/gshell/gshell-ssh/pom.xml (from r792359, felix/trunk/karaf/gshell/gshell-config/pom.xml)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-ssh/pom.xml?p2=felix/trunk/karaf/gshell/gshell-ssh/pom.xml&p1=felix/trunk/karaf/gshell/gshell-config/pom.xml&r1=792359&r2=792445&rev=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/pom.xml (original)
+++ felix/trunk/karaf/gshell/gshell-ssh/pom.xml Thu Jul 9 08:29:14 2009
@@ -28,19 +28,19 @@
</parent>
<groupId>org.apache.felix.karaf.gshell</groupId>
- <artifactId>org.apache.felix.karaf.gshell.config</artifactId>
+ <artifactId>org.apache.felix.karaf.gshell.ssh</artifactId>
<packaging>bundle</packaging>
<version>1.2.0-SNAPSHOT</version>
- <name>Apache Felix Karaf :: GShell ConfigAdmin Commands</name>
+ <name>Apache Felix Karaf :: GShell SSH</name>
<description>
- Provides the ConfigAdmin GShell commands
+ Provides SSH support to the console
</description>
<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,17 +56,26 @@
</dependency>
<dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-core</artifactId>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.junit</artifactId>
+ <scope>test</scope>
</dependency>
<dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-annotation_1.0_spec</artifactId>
+ <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>
@@ -76,13 +85,14 @@
<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,
+ org.apache.sshd.server.keyprovider,
+ org.apache.sshd.server.jaas,
*
</Import-Package>
- <Private-Package>!*</Private-Package>
+ <Private-Package>org.apache.felix.karaf.jpm.*</Private-Package>
<_versionpolicy>${bnd.version.policy}</_versionpolicy>
</instructions>
</configuration>
Added: felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellCommandFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellCommandFactory.java?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellCommandFactory.java (added)
+++ felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellCommandFactory.java Thu Jul 9 08:29:14 2009
@@ -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
+ }
+ }
+ }
+}
Added: felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellFactoryImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellFactoryImpl.java?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellFactoryImpl.java (added)
+++ felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/ShellFactoryImpl.java Thu Jul 9 08:29:14 2009
@@ -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
+ }
+ }
+ }
+
+}
Added: felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshAction.java?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshAction.java (added)
+++ felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshAction.java Thu Jul 9 08:29:14 2009
@@ -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;
+// }
+//}
Copied: felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerAction.java (from r792359, felix/trunk/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshServerAction.java)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerAction.java?p2=felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerAction.java&p1=felix/trunk/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshServerAction.java&r1=792359&r2=792445&rev=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/commands/ssh/SshServerAction.java (original)
+++ felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerAction.java Thu Jul 9 08:29:14 2009
@@ -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) {
- assert container != null;
+ 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;
}
}
Copied: felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerFactory.java (from r792359, felix/trunk/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/SshServerFactory.java)
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerFactory.java?p2=felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerFactory.java&p1=felix/trunk/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/SshServerFactory.java&r1=792359&r2=792445&rev=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-core/src/main/java/org/apache/felix/karaf/gshell/core/sshd/SshServerFactory.java (original)
+++ felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshServerFactory.java Thu Jul 9 08:29:14 2009
@@ -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;
Added: felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshTerminal.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshTerminal.java?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshTerminal.java (added)
+++ felix/trunk/karaf/gshell/gshell-ssh/src/main/java/org/apache/felix/karaf/gshell/ssh/SshTerminal.java Thu Jul 9 08:29:14 2009
@@ -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) {
+
+ }
+}
Added: felix/trunk/karaf/gshell/gshell-ssh/src/main/resources/OSGI-INF/blueprint/gshell-ssh.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-ssh/src/main/resources/OSGI-INF/blueprint/gshell-ssh.xml?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-ssh/src/main/resources/OSGI-INF/blueprint/gshell-ssh.xml (added)
+++ felix/trunk/karaf/gshell/gshell-ssh/src/main/resources/OSGI-INF/blueprint/gshell-ssh.xml Thu Jul 9 08:29:14 2009
@@ -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>
Modified: felix/trunk/karaf/gshell/gshell-wrapper/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-wrapper/pom.xml?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-wrapper/pom.xml (original)
+++ felix/trunk/karaf/gshell/gshell-wrapper/pom.xml Thu Jul 9 08:29:14 2009
@@ -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>
Modified: felix/trunk/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/InstallCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/InstallCommand.java?rev=792445&r1=792444&r2=792445&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/InstallCommand.java (original)
+++ felix/trunk/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/InstallCommand.java Thu Jul 9 08:29:14 2009
@@ -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());
-
- 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 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());
+
+ 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();
}
}
Added: felix/trunk/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/PumpStreamHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/PumpStreamHandler.java?rev=792445&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/PumpStreamHandler.java (added)
+++ felix/trunk/karaf/gshell/gshell-wrapper/src/main/java/org/apache/felix/karaf/gshell/wrapper/PumpStreamHandler.java Thu Jul 9 08:29:14 2009
@@ -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