You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2014/02/14 17:26:20 UTC

[2/2] git commit: [KARAF-2761] Use the Java DSL for scr:* commands

[KARAF-2761] Use the Java DSL for scr:* commands

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/40140e4f
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/40140e4f
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/40140e4f

Branch: refs/heads/master
Commit: 40140e4f0c0745a41c1a4579f529f07e5819d785
Parents: c159f2e
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Fri Feb 14 17:26:03 2014 +0100
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Fri Feb 14 17:26:03 2014 +0100

----------------------------------------------------------------------
 .../scr/command/ActivateCommandComponent.java   |  81 -------------
 .../org/apache/karaf/scr/command/Commands.java  |  84 +++++++++++++
 .../scr/command/DeactivateCommandComponent.java |  81 -------------
 .../scr/command/DetailsCommandComponent.java    |  82 -------------
 .../karaf/scr/command/ListCommandComponent.java |  76 ------------
 .../karaf/scr/command/ScrCommandConstants.java  |   4 -
 .../karaf/scr/command/ScrCommandSupport.java    | 118 -------------------
 .../scr/command/action/ActivateAction.java      |   3 +
 .../scr/command/action/DeactivateAction.java    |   3 +
 .../karaf/scr/command/action/DetailsAction.java |   5 +-
 .../karaf/scr/command/action/ListAction.java    |   2 +-
 .../scr/command/action/ScrActionSupport.java    |   3 +-
 12 files changed, 96 insertions(+), 446 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/40140e4f/scr/command/src/main/java/org/apache/karaf/scr/command/ActivateCommandComponent.java
----------------------------------------------------------------------
diff --git a/scr/command/src/main/java/org/apache/karaf/scr/command/ActivateCommandComponent.java b/scr/command/src/main/java/org/apache/karaf/scr/command/ActivateCommandComponent.java
deleted file mode 100644
index d3b2607..0000000
--- a/scr/command/src/main/java/org/apache/karaf/scr/command/ActivateCommandComponent.java
+++ /dev/null
@@ -1,81 +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.karaf.scr.command;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.karaf.shell.commands.Action;
-import org.apache.felix.scr.ScrService;
-import org.apache.karaf.scr.command.action.ActivateAction;
-import org.apache.karaf.scr.command.completer.ActivateCompleter;
-import org.apache.karaf.shell.console.CompletableFunction;
-import org.apache.karaf.shell.console.Completer;
-
-import aQute.bnd.annotation.component.Activate;
-import aQute.bnd.annotation.component.Component;
-import aQute.bnd.annotation.component.Deactivate;
-import aQute.bnd.annotation.component.Reference;
-
-/**
- * Shell Command used to activate a Declarative Service Component.
- */
-@Component(
-        provide=CompletableFunction.class,
-        name = ActivateCommandComponent.COMPONENT_NAME,
-        enabled = true,
-        immediate = true,
-        properties={
-                ScrCommandConstants.OSGI_COMMAND_SCOPE_KEY + "=" + ScrCommandConstants.SCR_COMMAND,
-                ScrCommandConstants.OSGI_COMMAND_FUNCTION_KEY + "=" + ScrCommandConstants.ACTIVATE_FUNCTION,
-                ScrCommandConstants.HIDDEN_COMPONENT_KEY + "=true"
-        })
-public class ActivateCommandComponent extends ScrCommandSupport {
-
-    public static final String COMPONENT_NAME = "ActivateCommand";
-
-    public static final String COMPONENT_LABEL = "Apache Karaf SCR Activate Command";
-
-    @Override
-    public Class<? extends Action> getActionClass() {
-        return ActivateAction.class;
-    }
-
-    @Override
-    public List<Class<? extends Completer>> getCompleterClasses() {
-        List<Class<? extends Completer>> completers = new ArrayList<Class<? extends Completer>>();
-        completers.add(ActivateCompleter.class);
-        return completers;
-    }
-
-    @Activate
-    public void activate(){
-        logger.info("Activating the " + COMPONENT_LABEL);
-    }
-    
-    @Deactivate
-    public void deactivate(){
-        logger.info("Deactivating the " + COMPONENT_LABEL);
-    }
-    
-    @Reference
-    @Override
-    public void setScrService(ScrService scrService) {
-    	super.setScrService(scrService);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/40140e4f/scr/command/src/main/java/org/apache/karaf/scr/command/Commands.java
----------------------------------------------------------------------
diff --git a/scr/command/src/main/java/org/apache/karaf/scr/command/Commands.java b/scr/command/src/main/java/org/apache/karaf/scr/command/Commands.java
new file mode 100644
index 0000000..70533e5
--- /dev/null
+++ b/scr/command/src/main/java/org/apache/karaf/scr/command/Commands.java
@@ -0,0 +1,84 @@
+/*
+ * 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.karaf.scr.command;
+
+import aQute.bnd.annotation.component.Activate;
+import aQute.bnd.annotation.component.Component;
+import aQute.bnd.annotation.component.Deactivate;
+import aQute.bnd.annotation.component.Reference;
+import org.apache.felix.scr.ScrService;
+import org.apache.karaf.scr.command.action.ActivateAction;
+import org.apache.karaf.scr.command.action.DeactivateAction;
+import org.apache.karaf.scr.command.action.DetailsAction;
+import org.apache.karaf.scr.command.action.ListAction;
+import org.apache.karaf.scr.command.completer.ActivateCompleter;
+import org.apache.karaf.scr.command.completer.DeactivateCompleter;
+import org.apache.karaf.scr.command.completer.DetailsCompleter;
+import org.apache.karaf.scr.command.completer.ScrCompleterSupport;
+import org.apache.karaf.shell.commands.Action;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ */
+@Component
+public class Commands extends org.apache.karaf.shell.commands.Commands {
+
+    protected final Logger logger = LoggerFactory.getLogger(getClass().getName());
+    protected ScrService scrService;
+
+    @Activate
+    public void activate() {
+        logger.info("Activating SCR commands");
+        completer(ActivateCompleter.class);
+        completer(DeactivateCompleter.class);
+        completer(DetailsCompleter.class);
+        command(ActivateAction.class);
+        command(DeactivateAction.class);
+        command(DetailsAction.class);
+        command(ListAction.class);
+        register();
+    }
+
+    @Deactivate
+    public void deactivate() {
+        logger.info("Deactivating SCR commands");
+        unregister();
+    }
+
+    @Reference
+    public void setScrService(ScrService scrService) {
+        this.scrService = scrService;
+    }
+
+    public CompleterBuilder completer(Class<? extends ScrCompleterSupport> completerClass) {
+        try {
+            ScrCompleterSupport completer = completerClass.newInstance();
+            completer.setScrService(scrService);
+            return completer(completer);
+        } catch (Exception e) {
+            throw new RuntimeException("Unable to create completer", e);
+        }
+    }
+
+    public CommandBuilder command(Class<? extends Action> actionClass) {
+        return super.command(actionClass)
+                .properties(scrService)
+                .serviceProp(ScrCommandConstants.HIDDEN_COMPONENT_KEY, "true");
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/40140e4f/scr/command/src/main/java/org/apache/karaf/scr/command/DeactivateCommandComponent.java
----------------------------------------------------------------------
diff --git a/scr/command/src/main/java/org/apache/karaf/scr/command/DeactivateCommandComponent.java b/scr/command/src/main/java/org/apache/karaf/scr/command/DeactivateCommandComponent.java
deleted file mode 100644
index ae2bf9f..0000000
--- a/scr/command/src/main/java/org/apache/karaf/scr/command/DeactivateCommandComponent.java
+++ /dev/null
@@ -1,81 +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.karaf.scr.command;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.karaf.shell.commands.Action;
-import org.apache.felix.scr.ScrService;
-import org.apache.karaf.scr.command.action.DeactivateAction;
-import org.apache.karaf.scr.command.completer.DeactivateCompleter;
-import org.apache.karaf.shell.console.CompletableFunction;
-import org.apache.karaf.shell.console.Completer;
-
-import aQute.bnd.annotation.component.Activate;
-import aQute.bnd.annotation.component.Component;
-import aQute.bnd.annotation.component.Deactivate;
-import aQute.bnd.annotation.component.Reference;
-
-/**
- * Shell Command used to deactivate a Declarative Service Component.
- */
-@Component(
-        provide=CompletableFunction.class,
-        name = DeactivateCommandComponent.COMPONENT_NAME,
-        enabled = true,
-        immediate = true,
-        properties={
-                ScrCommandConstants.OSGI_COMMAND_SCOPE_KEY + "=" + ScrCommandConstants.SCR_COMMAND,
-                ScrCommandConstants.OSGI_COMMAND_FUNCTION_KEY + "=" + ScrCommandConstants.DEACTIVATE_FUNCTION,
-                ScrCommandConstants.HIDDEN_COMPONENT_KEY + "=true"
-        })
-public class DeactivateCommandComponent extends ScrCommandSupport {
-
-    public static final String COMPONENT_NAME = "DeactivateCommand";
-
-    public static final String COMPONENT_LABEL = "Apache Karaf SCR Deactivate Command";
-
-    @Override
-    public Class<? extends Action> getActionClass() {
-        return DeactivateAction.class;
-    }
-
-    @Override
-    public List<Class<? extends Completer>> getCompleterClasses() {
-        List<Class<? extends Completer>> completers = new ArrayList<Class<? extends Completer>>();
-        completers.add(DeactivateCompleter.class);
-        return completers;
-    }
-
-    @Activate
-    public void activate(){
-        logger.info("Activating the " + COMPONENT_LABEL);
-    }
-    
-    @Deactivate
-    public void deactivate(){
-        logger.info("Deactivating the " + COMPONENT_LABEL);
-    }
-    
-    @Reference
-    @Override
-    public void setScrService(ScrService scrService) {
-    	super.setScrService(scrService);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/40140e4f/scr/command/src/main/java/org/apache/karaf/scr/command/DetailsCommandComponent.java
----------------------------------------------------------------------
diff --git a/scr/command/src/main/java/org/apache/karaf/scr/command/DetailsCommandComponent.java b/scr/command/src/main/java/org/apache/karaf/scr/command/DetailsCommandComponent.java
deleted file mode 100644
index 51407b0..0000000
--- a/scr/command/src/main/java/org/apache/karaf/scr/command/DetailsCommandComponent.java
+++ /dev/null
@@ -1,82 +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.karaf.scr.command;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.karaf.shell.commands.Action;
-import org.apache.felix.scr.ScrService;
-import org.apache.karaf.scr.command.action.DetailsAction;
-import org.apache.karaf.scr.command.completer.DetailsCompleter;
-import org.apache.karaf.shell.console.CompletableFunction;
-import org.apache.karaf.shell.console.Completer;
-
-import aQute.bnd.annotation.component.Activate;
-import aQute.bnd.annotation.component.Component;
-import aQute.bnd.annotation.component.Deactivate;
-import aQute.bnd.annotation.component.Reference;
-
-/**
- * Shell Command that prints the current state details of a given
- * Declarative Service Component.
- */
-@Component(
-        provide=CompletableFunction.class,
-        name = DetailsCommandComponent.COMPONENT_NAME,
-        enabled = true,
-        immediate = true,
-        properties={
-                ScrCommandConstants.OSGI_COMMAND_SCOPE_KEY + "=" + ScrCommandConstants.SCR_COMMAND,
-                ScrCommandConstants.OSGI_COMMAND_FUNCTION_KEY + "=" + ScrCommandConstants.DETAILS_FUNCTION,
-                ScrCommandConstants.HIDDEN_COMPONENT_KEY + "=true"
-        })
-public class DetailsCommandComponent extends ScrCommandSupport {
-
-    public static final String COMPONENT_NAME = "DetailsCommand";
-
-    public static final String COMPONENT_LABEL = "Apache Karaf SCR Details Command";
-
-    @Override
-    public Class<? extends Action> getActionClass() {
-        return DetailsAction.class;
-    }
-
-    @Override
-    public List<Class<? extends Completer>> getCompleterClasses() {
-        List<Class<? extends Completer>> completers = new ArrayList<Class<? extends Completer>>();
-        completers.add(DetailsCompleter.class);
-        return completers;
-    }
-
-    @Activate
-    public void activate(){
-        logger.info("Activating the " + COMPONENT_LABEL);
-    }
-    
-    @Deactivate
-    public void deactivate(){
-        logger.info("Deactivating the " + COMPONENT_LABEL);
-    }
-    
-    @Reference
-    @Override
-    public void setScrService(ScrService scrService) {
-    	super.setScrService(scrService);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/40140e4f/scr/command/src/main/java/org/apache/karaf/scr/command/ListCommandComponent.java
----------------------------------------------------------------------
diff --git a/scr/command/src/main/java/org/apache/karaf/scr/command/ListCommandComponent.java b/scr/command/src/main/java/org/apache/karaf/scr/command/ListCommandComponent.java
deleted file mode 100644
index 23d82f3..0000000
--- a/scr/command/src/main/java/org/apache/karaf/scr/command/ListCommandComponent.java
+++ /dev/null
@@ -1,76 +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.karaf.scr.command;
-
-import java.util.List;
-
-import org.apache.karaf.shell.commands.Action;
-import org.apache.felix.scr.ScrService;
-import org.apache.karaf.scr.command.action.ListAction;
-import org.apache.karaf.shell.console.CompletableFunction;
-import org.apache.karaf.shell.console.Completer;
-
-import aQute.bnd.annotation.component.Activate;
-import aQute.bnd.annotation.component.Component;
-import aQute.bnd.annotation.component.Deactivate;
-import aQute.bnd.annotation.component.Reference;
-
-/**
- * Shell Command that lists the available Declarative Service Components.
- */
-@Component(
-        provide=CompletableFunction.class,
-        name = ListCommandComponent.COMPONENT_NAME,
-        enabled = true,
-        immediate = true,
-        properties={
-                ScrCommandConstants.OSGI_COMMAND_SCOPE_KEY + "=" + ScrCommandConstants.SCR_COMMAND,
-                ScrCommandConstants.OSGI_COMMAND_FUNCTION_KEY + "=" + ScrCommandConstants.LIST_FUNCTION,
-                ScrCommandConstants.HIDDEN_COMPONENT_KEY + "=true"
-        })
-public class ListCommandComponent extends ScrCommandSupport {
-
-    public static final String COMPONENT_NAME = "ListCommand";
-    public static final String COMPONENT_LABEL = "Apache Karaf SCR List Command";
-
-    @Override
-    public Class<? extends Action> getActionClass() {
-        return ListAction.class;
-    }
-
-    @Override
-    public List<Class<? extends Completer>> getCompleterClasses() {
-        return null;
-    }
-
-    @Activate
-    public void activate(){
-        logger.info("Activating the " + COMPONENT_LABEL);
-    }
-    
-    @Deactivate
-    public void deactivate(){
-        logger.info("Deactivating the " + COMPONENT_LABEL);
-    }
-    
-    @Reference
-    @Override
-    public void setScrService(ScrService scrService) {
-    	super.setScrService(scrService);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/40140e4f/scr/command/src/main/java/org/apache/karaf/scr/command/ScrCommandConstants.java
----------------------------------------------------------------------
diff --git a/scr/command/src/main/java/org/apache/karaf/scr/command/ScrCommandConstants.java b/scr/command/src/main/java/org/apache/karaf/scr/command/ScrCommandConstants.java
index d7f0d10..9faf449 100644
--- a/scr/command/src/main/java/org/apache/karaf/scr/command/ScrCommandConstants.java
+++ b/scr/command/src/main/java/org/apache/karaf/scr/command/ScrCommandConstants.java
@@ -18,10 +18,6 @@ package org.apache.karaf.scr.command;
 
 public class ScrCommandConstants {
 
-    public static final String OSGI_COMMAND_SCOPE_KEY = "osgi.command.scope";
-
-    public static final String OSGI_COMMAND_FUNCTION_KEY = "osgi.command.function";
-
     public static final String HIDDEN_COMPONENT_KEY = "hidden.component";
 
     public static final String SCR_COMMAND = "scr";

http://git-wip-us.apache.org/repos/asf/karaf/blob/40140e4f/scr/command/src/main/java/org/apache/karaf/scr/command/ScrCommandSupport.java
----------------------------------------------------------------------
diff --git a/scr/command/src/main/java/org/apache/karaf/scr/command/ScrCommandSupport.java b/scr/command/src/main/java/org/apache/karaf/scr/command/ScrCommandSupport.java
deleted file mode 100644
index 34c4c7e..0000000
--- a/scr/command/src/main/java/org/apache/karaf/scr/command/ScrCommandSupport.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.karaf.scr.command;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import org.apache.karaf.shell.commands.Action;
-import org.apache.karaf.shell.commands.basic.AbstractCommand;
-import org.apache.felix.scr.ScrService;
-import org.apache.karaf.scr.command.action.ScrActionSupport;
-import org.apache.karaf.scr.command.completer.ScrCompleterSupport;
-import org.apache.karaf.shell.console.CompletableFunction;
-import org.apache.karaf.shell.console.Completer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class ScrCommandSupport extends AbstractCommand implements CompletableFunction {
-    
-    protected final Logger logger = LoggerFactory.getLogger(getClass().getName());
-
-    private ScrService scrService;
-    private ReadWriteLock lock = new ReentrantReadWriteLock();
-
-    @Override
-    public abstract Class<? extends Action> getActionClass();
-
-    public abstract List<Class<? extends Completer>> getCompleterClasses();
-
-    @Override
-    public Action createNewAction() {
-        try {
-            lock.readLock().lock();
-            ScrActionSupport action = (ScrActionSupport) getActionClass().newInstance();
-            action.setScrService(getScrService());
-            return action;
-        } catch (InstantiationException e) {
-            throw new RuntimeException(e);
-        } catch (IllegalAccessException e) {
-            throw new RuntimeException(e);
-        } finally {
-            lock.readLock().unlock();
-        }
-    }
-
-    public List<Completer> getCompleters() {
-        List<Completer> completers = null;
-
-        if (getCompleterClasses() != null) {
-            try {
-                lock.readLock().lock();
-                completers = new ArrayList<Completer>();
-                for (Class<? extends Completer> completerClass : getCompleterClasses()) {
-                    ScrCompleterSupport ccs = (ScrCompleterSupport) completerClass.newInstance();
-                    ccs.setScrService(scrService);
-                    completers.add(ccs);
-                }
-
-            } catch (InstantiationException e) {
-                throw new RuntimeException(e);
-            } catch (IllegalAccessException e) {
-                throw new RuntimeException(e);
-            } finally {
-                lock.readLock().unlock();
-            }
-        }
-        return completers;
-    }
-    
-    public Map<String, Completer> getOptionalCompleters() {
-    	return null;
-    }
-    
-    /**
-     * Returns the instance of ScrService for this instance of ScrCommandSupport.
-     *
-     * @return the ScrCommandSupport or null
-     */
-    public ScrService getScrService() {
-        return scrService;
-    }
-
-	public void setScrService(ScrService scrService) {
-        try {
-            lock.writeLock().lock();
-    		this.scrService = scrService;
-        } finally {
-            lock.writeLock().unlock();
-        }
-	}
-
-	public void unsetScrService(ScrService scrService) {
-        try {
-            lock.writeLock().lock();
-    		this.scrService = null;
-        } finally {
-            lock.writeLock().unlock();
-        }
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/karaf/blob/40140e4f/scr/command/src/main/java/org/apache/karaf/scr/command/action/ActivateAction.java
----------------------------------------------------------------------
diff --git a/scr/command/src/main/java/org/apache/karaf/scr/command/action/ActivateAction.java b/scr/command/src/main/java/org/apache/karaf/scr/command/action/ActivateAction.java
index eac8175..5e435d4 100755
--- a/scr/command/src/main/java/org/apache/karaf/scr/command/action/ActivateAction.java
+++ b/scr/command/src/main/java/org/apache/karaf/scr/command/action/ActivateAction.java
@@ -16,12 +16,14 @@
  */
 package org.apache.karaf.scr.command.action;
 
+import org.apache.karaf.scr.command.completer.ActivateCompleter;
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.felix.scr.Component;
 import org.apache.felix.scr.ScrService;
 import org.apache.karaf.scr.command.ScrCommandConstants;
 import org.apache.karaf.scr.command.ScrUtils;
+import org.apache.karaf.shell.commands.Completer;
 
 /**
  * Activates the given component by supplying its component name.
@@ -30,6 +32,7 @@ import org.apache.karaf.scr.command.ScrUtils;
 public class ActivateAction extends ScrActionSupport {
 
     @Argument(index = 0, name = "name", description = "The name of the Component to activate ", required = true, multiValued = false)
+    @Completer(ActivateCompleter.class)
     String name;
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf/blob/40140e4f/scr/command/src/main/java/org/apache/karaf/scr/command/action/DeactivateAction.java
----------------------------------------------------------------------
diff --git a/scr/command/src/main/java/org/apache/karaf/scr/command/action/DeactivateAction.java b/scr/command/src/main/java/org/apache/karaf/scr/command/action/DeactivateAction.java
index e6eba5f..e417459 100755
--- a/scr/command/src/main/java/org/apache/karaf/scr/command/action/DeactivateAction.java
+++ b/scr/command/src/main/java/org/apache/karaf/scr/command/action/DeactivateAction.java
@@ -16,11 +16,13 @@
  */
 package org.apache.karaf.scr.command.action;
 
+import org.apache.karaf.scr.command.completer.DeactivateCompleter;
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
 import org.apache.felix.scr.Component;
 import org.apache.felix.scr.ScrService;
 import org.apache.karaf.scr.command.ScrCommandConstants;
+import org.apache.karaf.shell.commands.Completer;
 
 /**
  * Deactivates the given component by supplying its component name.
@@ -29,6 +31,7 @@ import org.apache.karaf.scr.command.ScrCommandConstants;
 public class DeactivateAction extends ScrActionSupport {
 
     @Argument(index = 0, name = "name", description = "The name of the Component to deactivate ", required = true, multiValued = false)
+    @Completer(DeactivateCompleter.class)
     String name;
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf/blob/40140e4f/scr/command/src/main/java/org/apache/karaf/scr/command/action/DetailsAction.java
----------------------------------------------------------------------
diff --git a/scr/command/src/main/java/org/apache/karaf/scr/command/action/DetailsAction.java b/scr/command/src/main/java/org/apache/karaf/scr/command/action/DetailsAction.java
index ccd92d5..39b462c 100644
--- a/scr/command/src/main/java/org/apache/karaf/scr/command/action/DetailsAction.java
+++ b/scr/command/src/main/java/org/apache/karaf/scr/command/action/DetailsAction.java
@@ -21,8 +21,10 @@ import org.apache.felix.scr.Reference;
 import org.apache.felix.scr.ScrService;
 import org.apache.karaf.scr.command.ScrCommandConstants;
 import org.apache.karaf.scr.command.ScrUtils;
+import org.apache.karaf.scr.command.completer.DetailsCompleter;
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Completer;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.component.ComponentConstants;
@@ -35,7 +37,8 @@ import java.util.Hashtable;
 @Command(scope = ScrCommandConstants.SCR_COMMAND, name = ScrCommandConstants.DETAILS_FUNCTION, description = "Displays a list of available components")
 public class DetailsAction extends ScrActionSupport {
 
-    @Argument(index = 0, name = "name", description = "The name of the Component to display the detials of", required = true, multiValued = false)
+    @Argument(index = 0, name = "name", description = "The name of the Component to display the details of", required = true, multiValued = false)
+    @Completer(DetailsCompleter.class)
     String name;
 
     @SuppressWarnings("rawtypes")

http://git-wip-us.apache.org/repos/asf/karaf/blob/40140e4f/scr/command/src/main/java/org/apache/karaf/scr/command/action/ListAction.java
----------------------------------------------------------------------
diff --git a/scr/command/src/main/java/org/apache/karaf/scr/command/action/ListAction.java b/scr/command/src/main/java/org/apache/karaf/scr/command/action/ListAction.java
index 25686a1..da6b16e 100755
--- a/scr/command/src/main/java/org/apache/karaf/scr/command/action/ListAction.java
+++ b/scr/command/src/main/java/org/apache/karaf/scr/command/action/ListAction.java
@@ -31,8 +31,8 @@ import java.util.Arrays;
 @Command(scope = ScrCommandConstants.SCR_COMMAND, name = ScrCommandConstants.LIST_FUNCTION, description = "Displays a list of available components")
 public class ListAction extends ScrActionSupport {
 
-
     private final IdComparator idComparator = new IdComparator();
+
     @Override
     protected Object doScrAction(ScrService scrService) throws Exception {
         if (logger.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/40140e4f/scr/command/src/main/java/org/apache/karaf/scr/command/action/ScrActionSupport.java
----------------------------------------------------------------------
diff --git a/scr/command/src/main/java/org/apache/karaf/scr/command/action/ScrActionSupport.java b/scr/command/src/main/java/org/apache/karaf/scr/command/action/ScrActionSupport.java
index 0cf5e5a..0580dae 100755
--- a/scr/command/src/main/java/org/apache/karaf/scr/command/action/ScrActionSupport.java
+++ b/scr/command/src/main/java/org/apache/karaf/scr/command/action/ScrActionSupport.java
@@ -35,7 +35,7 @@ import java.util.Arrays;
 import java.util.Hashtable;
 import java.util.List;
 
-public abstract class ScrActionSupport extends SubShellAction {
+public abstract class ScrActionSupport extends AbstractAction {
 
     @Option(name = ScrActionSupport.SHOW_ALL_OPTION, aliases = {ScrActionSupport.SHOW_ALL_ALIAS}, description = "Show all Components including the System Components (hidden by default)", required = false, multiValued = false)
     boolean showHidden = false;
@@ -48,7 +48,6 @@ public abstract class ScrActionSupport extends SubShellAction {
     private ScrService scrService;
 
     public ScrActionSupport() {
-        setSubShell("scr");
     }
 
     @Override