You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/09/27 14:03:55 UTC
svn commit: r699621 - in
/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom:
plugin/activation/ plugin/bundle/ shell/
Author: jdillon
Date: Sat Sep 27 05:03:55 2008
New Revision: 699621
URL: http://svn.apache.org/viewvc?rev=699621&view=rev
Log:
Added enable/disable/isEnabled to Bundle, implement enable/disable for CommandBundle, moved bits from activation rule
Modified:
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultCommandBundleActivationRule.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/Bundle.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/CommandBundle.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultCommandBundleActivationRule.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultCommandBundleActivationRule.java?rev=699621&r1=699620&r2=699621&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultCommandBundleActivationRule.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/activation/DefaultCommandBundleActivationRule.java Sat Sep 27 05:03:55 2008
@@ -19,15 +19,11 @@
package org.apache.geronimo.gshell.wisdom.plugin.activation;
-import org.apache.geronimo.gshell.command.Command;
-import org.apache.geronimo.gshell.registry.CommandRegistry;
-import org.apache.geronimo.gshell.registry.AliasRegistry;
import org.apache.geronimo.gshell.spring.BeanContainer;
import org.apache.geronimo.gshell.spring.BeanContainerAware;
import org.apache.geronimo.gshell.wisdom.plugin.bundle.CommandBundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import java.util.Map;
@@ -41,12 +37,6 @@
{
private final Logger log = LoggerFactory.getLogger(getClass());
- @Autowired
- private CommandRegistry commandRegistry;
-
- @Autowired
- private AliasRegistry aliasRegistry;
-
private BeanContainer container;
private String bundleName;
@@ -97,17 +87,7 @@
log.debug("Processing command bundle: {}", bundle);
- Map<String,Command> commands = bundle.getCommands();
-
- for (String name : commands.keySet()) {
- commandRegistry.registerCommand(name, commands.get(name));
- }
-
- Map<String,String> aliases = bundle.getAliases();
-
- for (String name : aliases.keySet()) {
- aliasRegistry.registerAlias(name, aliases.get(name));
- }
+ bundle.enable();
}
};
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/Bundle.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/Bundle.java?rev=699621&r1=699620&r2=699621&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/Bundle.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/Bundle.java Sat Sep 27 05:03:55 2008
@@ -28,5 +28,9 @@
{
String getName();
- // TODO: start/stop enable/disable close/destroy
+ boolean isEnabled();
+
+ void enable() throws Exception;
+
+ void disable() throws Exception;
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/CommandBundle.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/CommandBundle.java?rev=699621&r1=699620&r2=699621&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/CommandBundle.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/bundle/CommandBundle.java Sat Sep 27 05:03:55 2008
@@ -20,6 +20,11 @@
package org.apache.geronimo.gshell.wisdom.plugin.bundle;
import org.apache.geronimo.gshell.command.Command;
+import org.apache.geronimo.gshell.registry.CommandRegistry;
+import org.apache.geronimo.gshell.registry.AliasRegistry;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import java.util.Map;
@@ -31,6 +36,16 @@
public class CommandBundle
implements Bundle
{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Autowired
+ private CommandRegistry commandRegistry;
+
+ @Autowired
+ private AliasRegistry aliasRegistry;
+
+ private boolean enabled = false;
+
private String name;
private Map<String,Command> commands;
@@ -66,4 +81,44 @@
this.aliases = aliases;
}
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void enable() throws Exception {
+ if (enabled) {
+ throw new IllegalStateException("Already enabled");
+ }
+
+ log.debug("Enabling");
+
+ for (String name : commands.keySet()) {
+ commandRegistry.registerCommand(name, commands.get(name));
+ }
+
+ for (String name : aliases.keySet()) {
+ aliasRegistry.registerAlias(name, aliases.get(name));
+ }
+
+ enabled = true;
+ }
+
+ public void disable() throws Exception {
+ if (!enabled) {
+ throw new IllegalStateException("Not enabled");
+ }
+
+ log.debug("Disabling");
+
+ for (String name : commands.keySet()) {
+ commandRegistry.removeCommand(name);
+ }
+
+ for (String name : aliases.keySet()) {
+ aliasRegistry.removeAlias(name);
+ }
+
+ enabled = false;
+ }
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java?rev=699621&r1=699620&r2=699621&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java Sat Sep 27 05:03:55 2008
@@ -184,6 +184,10 @@
// Ya, bust out the sexy JLine console baby!
JLineConsole console = new JLineConsole(executor, io);
+ //
+ // TODO: Hook up completer bits here
+ //
+
// Setup the prompt
console.setPrompter(getPrompter());