Make things as lazy as possible
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@793044 13f79535-47bb-0310-9956-ffa450edef68
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 e82b4c1..74cad8b 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
@@ -17,7 +17,8 @@
limitations under the License.
-->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ default-activation="lazy">
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
<command name="admin/create">
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 673ec3e..da7e2bf 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
@@ -17,7 +17,8 @@
limitations under the License.
-->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ default-activation="lazy">
<command-bundle xmlns="http://felix.apache.org/karaf/xmlns/gshell/v1.0.0">
<command name="config/cancel">
diff --git a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/NamespaceHandler.java b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/NamespaceHandler.java
index d3c1fdf..1e4e1c7 100644
--- a/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/NamespaceHandler.java
+++ b/karaf/gshell/gshell-console/src/main/java/org/apache/felix/karaf/gshell/console/commands/NamespaceHandler.java
@@ -159,6 +159,7 @@
}
MutableServiceMetadata commandService = context.createMetadata(MutableServiceMetadata.class);
+ commandService.setActivation(MutableServiceMetadata.ACTIVATION_LAZY);
commandService.setId(getName());
commandService.addInterface(Function.class.getName());
commandService.addInterface(CompletableFunction.class.getName());
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 7c784c0..344ddf4 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
@@ -18,7 +18,8 @@
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:ext="http://geronimo.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0">
+ xmlns:ext="http://geronimo.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
+ default-activation="lazy">
<ext:property-placeholder placeholder-prefix="$(" placeholder-suffix=")"/>
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
index a93a16e..e34f12d 100644
--- 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
@@ -60,12 +60,17 @@
private BlueprintContainer container;
private ClientSession session;
+ private String sshClientId;
public void setBlueprintContainer(final BlueprintContainer container) {
assert container != null;
this.container = container;
}
+ public void setSshClientId(String sshClientId) {
+ this.sshClientId = sshClientId;
+ }
+
@Override
protected Object doExecute() throws Exception {
@@ -87,9 +92,9 @@
}
// Create the client from prototype
- SshClient client = (SshClient) container.getComponentInstance(SshClient.class.getName());
+ SshClient client = (SshClient) container.getComponentInstance(sshClientId);
log.debug("Created client: {}", client);
- client.start();;
+ client.start();
try {
ConnectFuture future = client.connect(hostname, port);
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
index e0147a5..e393a00 100644
--- 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
@@ -20,7 +20,8 @@
<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">
+ xmlns:ext="http://geronimo.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
+ default-activation="lazy">
<ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
@@ -35,6 +36,9 @@
<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">
+ <property name="sshClientId">
+ <bp:idref component-id="sshClient"/>
+ </property>
</action>
</command>
<command name="ssh/sshd">
@@ -46,8 +50,7 @@
</command>
</command-bundle>
- <bean id="sshClient" class="org.apache.sshd.SshClient" factory-method="setUpDefaultClient" init-method="start"
- destroy-method="stop">
+ <bean id="sshClient" class="org.apache.sshd.SshClient" factory-method="setUpDefaultClient" scope="prototype">
</bean>
<bean id="sshServer" class="org.apache.sshd.SshServer" factory-method="setUpDefaultServer" scope="prototype">
@@ -79,7 +82,7 @@
</bean>
<bean id="sshServerFactory" class="org.apache.felix.karaf.gshell.ssh.SshServerFactory" init-method="start"
- destroy-method="stop">
+ destroy-method="stop" activation="eager">
<argument ref="sshServer"/>
<property name="start" value="$[karaf.startRemoteShell]"/>
</bean>