You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2018/12/03 16:31:15 UTC

[1/2] incubator-unomi git commit: UNOMI-215 New rule monitoring commands & other new commands - Refactor commands to use new style - Remove blueprint - Rename commands to remove "Command" at the end of the name

Repository: incubator-unomi
Updated Branches:
  refs/heads/master ac1ce5791 -> e5075636d


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleList.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleList.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleList.java
new file mode 100644
index 0000000..de5a4d8
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleList.java
@@ -0,0 +1,108 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.Metadata;
+import org.apache.unomi.api.PartialList;
+import org.apache.unomi.api.conditions.Condition;
+import org.apache.unomi.api.query.Query;
+import org.apache.unomi.api.rules.RuleStatistics;
+import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.api.services.RulesService;
+import org.apache.unomi.common.DataTable;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+@Command(scope = "unomi", name = "rule-list", description = "This will list all the rules deployed in the Apache Unomi Context Server")
+@Service
+public class RuleList extends ListCommandSupport {
+
+    @Reference
+    RulesService rulesService;
+
+    @Reference
+    DefinitionsService definitionsService;
+
+    @Argument(index = 0, name = "maxEntries", description = "The maximum number of entries to retrieve (defaults to 100)", required = false, multiValued = false)
+    int maxEntries = 100;
+
+    @Override
+    protected String[] getHeaders() {
+        return new String[] {
+                "Activated",
+                "Hidden",
+                "Read-only",
+                "Identifier",
+                "Scope",
+                "Name",
+                "Tags",
+                "System tags",
+                "Executions",
+                "Conditions [ms]",
+                "Actions [ms]"
+        };
+    }
+
+    @Override
+    protected DataTable buildDataTable() {
+        Query query = new Query();
+        Condition matchAllCondition = new Condition(definitionsService.getConditionType("matchAllCondition"));
+        query.setCondition(matchAllCondition);
+        query.setLimit(maxEntries);
+        PartialList<Metadata> ruleMetadatas = rulesService.getRuleMetadatas(query);
+        if (ruleMetadatas.getList().size() != ruleMetadatas.getTotalSize()) {
+            System.out.println("WARNING : Only the first " + ruleMetadatas.getPageSize() + " rules have been retrieved, there are " + ruleMetadatas.getTotalSize() + " rules registered in total. Use the maxEntries parameter to retrieve more rules");
+        }
+        Map<String,RuleStatistics> allRuleStatistics = rulesService.getAllRuleStatistics();
+
+        DataTable dataTable = new DataTable();
+        for (Metadata ruleMetadata : ruleMetadatas.getList()) {
+            ArrayList<Comparable> rowData = new ArrayList<>();
+            String ruleId = ruleMetadata.getId();
+            rowData.add(ruleMetadata.isEnabled() ? "x" : "");
+            rowData.add(ruleMetadata.isHidden() ? "x" : "");
+            rowData.add(ruleMetadata.isReadOnly() ? "x" : "");
+            rowData.add(ruleId);
+            rowData.add(ruleMetadata.getScope());
+            rowData.add(ruleMetadata.getName());
+            rowData.add(StringUtils.join(ruleMetadata.getTags(), ","));
+            rowData.add(StringUtils.join(ruleMetadata.getSystemTags(), ","));
+            RuleStatistics ruleStatistics = allRuleStatistics.get(ruleId);
+            if (ruleStatistics != null) {
+                rowData.add(ruleStatistics.getExecutionCount());
+                rowData.add(ruleStatistics.getConditionsTime());
+                rowData.add(ruleStatistics.getActionsTime());
+            } else {
+                rowData.add(0L);
+                rowData.add(0L);
+                rowData.add(0L);
+            }
+            dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
+        }
+        dataTable.sort(new DataTable.SortCriteria(9, DataTable.SortOrder.DESCENDING),
+                new DataTable.SortCriteria(10, DataTable.SortOrder.DESCENDING),
+                new DataTable.SortCriteria(5, DataTable.SortOrder.ASCENDING));
+        return dataTable;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleListCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleListCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleListCommand.java
deleted file mode 100644
index 3d70d72..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleListCommand.java
+++ /dev/null
@@ -1,110 +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.unomi.shell.commands;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.unomi.api.Metadata;
-import org.apache.unomi.api.PartialList;
-import org.apache.unomi.api.conditions.Condition;
-import org.apache.unomi.api.query.Query;
-import org.apache.unomi.api.rules.RuleStatistics;
-import org.apache.unomi.api.services.DefinitionsService;
-import org.apache.unomi.api.services.RulesService;
-import org.apache.unomi.common.DataTable;
-
-import java.util.ArrayList;
-import java.util.Map;
-
-@Command(scope = "unomi", name = "rule-list", description = "This will list all the rules deployed in the Apache Unomi Context Server")
-public class RuleListCommand extends ListCommandSupport {
-
-    private RulesService rulesService;
-    private DefinitionsService definitionsService;
-
-    public void setRulesService(RulesService rulesService) {
-        this.rulesService = rulesService;
-    }
-
-    public void setDefinitionsService(DefinitionsService definitionsService) {
-        this.definitionsService = definitionsService;
-    }
-
-    @Argument(index = 0, name = "maxEntries", description = "The maximum number of entries to retrieve (defaults to 100)", required = false, multiValued = false)
-    int maxEntries = 100;
-
-    @Override
-    protected String[] getHeaders() {
-        return new String[] {
-                "Activated",
-                "Hidden",
-                "Read-only",
-                "Identifier",
-                "Scope",
-                "Name",
-                "Tags",
-                "System tags",
-                "Executions",
-                "Conditions [ms]",
-                "Actions [ms]"
-        };
-    }
-
-    @Override
-    protected DataTable buildDataTable() {
-        Query query = new Query();
-        Condition matchAllCondition = new Condition(definitionsService.getConditionType("matchAllCondition"));
-        query.setCondition(matchAllCondition);
-        query.setLimit(maxEntries);
-        PartialList<Metadata> ruleMetadatas = rulesService.getRuleMetadatas(query);
-        if (ruleMetadatas.getList().size() != ruleMetadatas.getTotalSize()) {
-            System.out.println("WARNING : Only the first " + ruleMetadatas.getPageSize() + " rules have been retrieved, there are " + ruleMetadatas.getTotalSize() + " rules registered in total. Use the maxEntries parameter to retrieve more rules");
-        }
-        Map<String,RuleStatistics> allRuleStatistics = rulesService.getAllRuleStatistics();
-
-        DataTable dataTable = new DataTable();
-        for (Metadata ruleMetadata : ruleMetadatas.getList()) {
-            ArrayList<Comparable> rowData = new ArrayList<>();
-            String ruleId = ruleMetadata.getId();
-            rowData.add(ruleMetadata.isEnabled() ? "x" : "");
-            rowData.add(ruleMetadata.isHidden() ? "x" : "");
-            rowData.add(ruleMetadata.isReadOnly() ? "x" : "");
-            rowData.add(ruleId);
-            rowData.add(ruleMetadata.getScope());
-            rowData.add(ruleMetadata.getName());
-            rowData.add(StringUtils.join(ruleMetadata.getTags(), ","));
-            rowData.add(StringUtils.join(ruleMetadata.getSystemTags(), ","));
-            RuleStatistics ruleStatistics = allRuleStatistics.get(ruleId);
-            if (ruleStatistics != null) {
-                rowData.add(ruleStatistics.getExecutionCount());
-                rowData.add(ruleStatistics.getConditionsTime());
-                rowData.add(ruleStatistics.getActionsTime());
-            } else {
-                rowData.add(0L);
-                rowData.add(0L);
-                rowData.add(0L);
-            }
-            dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
-        }
-        dataTable.sort(new DataTable.SortCriteria(9, DataTable.SortOrder.DESCENDING),
-                new DataTable.SortCriteria(10, DataTable.SortOrder.DESCENDING),
-                new DataTable.SortCriteria(5, DataTable.SortOrder.ASCENDING));
-        return dataTable;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleResetStats.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleResetStats.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleResetStats.java
new file mode 100644
index 0000000..7a228be
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleResetStats.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.unomi.shell.commands;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.services.RulesService;
+
+@Command(scope = "unomi", name = "rule-reset-stats", description = "This command will reset the rule statistics")
+@Service
+public class RuleResetStats implements Action {
+
+    @Reference
+    RulesService rulesService;
+
+    @Override
+    public Object execute() throws Exception {
+        rulesService.resetAllRuleStatistics();
+        System.out.println("Rule statistics successfully reset.");
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleResetStatsCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleResetStatsCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleResetStatsCommand.java
deleted file mode 100644
index 3ab0b66..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleResetStatsCommand.java
+++ /dev/null
@@ -1,38 +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.unomi.shell.commands;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.unomi.api.services.RulesService;
-
-@Command(scope = "unomi", name = "rule-reset-stats", description = "This command will reset the rule statistics")
-public class RuleResetStatsCommand extends OsgiCommandSupport {
-
-    private RulesService rulesService;
-
-    public void setRulesService(RulesService rulesService) {
-        this.rulesService = rulesService;
-    }
-
-    @Override
-    protected Object doExecute() throws Exception {
-        rulesService.resetAllRuleStatistics();
-        System.out.println("Rule statistics successfully reset.");
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleTail.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleTail.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleTail.java
new file mode 100644
index 0000000..6cf66b2
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleTail.java
@@ -0,0 +1,93 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.Event;
+import org.apache.unomi.api.rules.Rule;
+import org.apache.unomi.api.services.RuleListenerService;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This command will list all the rules executions in the shell console.
+ */
+@Command(scope = "unomi", name = "rule-tail", description = "This will tail all the rules executed in the Apache Unomi Context Server")
+@Service
+public class RuleTail extends TailCommandSupport {
+
+    int[] columnSizes = new int[] { 36, 36, 14, 36, 29, 15, 5 };
+    String[] columnHeaders = new String[] {
+            "Rule ID",
+            "Rule Name",
+            "Event Type",
+            "Session",
+            "Profile",
+            "Timestamp",
+            "Scope",
+    };
+
+    @Override
+    public int[] getColumnSizes() {
+        return columnSizes;
+    }
+
+    @Override
+    public String[] getColumnHeaders() {
+        return columnHeaders;
+    }
+
+    @Override
+    public Object getListener() {
+        return new TailRuleListener(session.getConsole());
+    }
+
+    class TailRuleListener implements RuleListenerService {
+
+        PrintStream out;
+
+        public TailRuleListener(PrintStream out) {
+            this.out = out;
+        }
+
+        @Override
+        public void onEvaluate(Rule rule, Event event) {
+            // this method is not used by this command
+        }
+
+        @Override
+        public void onAlreadyRaised(AlreadyRaisedFor alreadyRaisedFor, Rule rule, Event event) {
+            // not displayed using this command, see the rule watch command instead.
+        }
+
+        @Override
+        public void onExecuteActions(Rule rule, Event event) {
+            List<String> ruleExecutionInfo = new ArrayList<>();
+            ruleExecutionInfo.add(rule.getItemId());
+            ruleExecutionInfo.add(rule.getMetadata().getName());
+            ruleExecutionInfo.add(event.getEventType());
+            ruleExecutionInfo.add(event.getSessionId());
+            ruleExecutionInfo.add(event.getProfileId());
+            ruleExecutionInfo.add(event.getTimeStamp().toString());
+            ruleExecutionInfo.add(event.getScope());
+            outputLine(out, ruleExecutionInfo);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleTailCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleTailCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleTailCommand.java
deleted file mode 100644
index 910c1e2..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleTailCommand.java
+++ /dev/null
@@ -1,91 +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.unomi.shell.commands;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.unomi.api.Event;
-import org.apache.unomi.api.rules.Rule;
-import org.apache.unomi.api.services.RuleListenerService;
-
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This command will list all the rules executions in the shell console.
- */
-@Command(scope = "unomi", name = "rule-tail", description = "This will tail all the rules executed in the Apache Unomi Context Server")
-public class RuleTailCommand extends TailCommandSupport {
-
-    int[] columnSizes = new int[] { 36, 36, 14, 36, 29, 15, 5 };
-    String[] columnHeaders = new String[] {
-            "Rule ID",
-            "Rule Name",
-            "Event Type",
-            "Session",
-            "Profile",
-            "Timestamp",
-            "Scope",
-    };
-
-    @Override
-    public int[] getColumnSizes() {
-        return columnSizes;
-    }
-
-    @Override
-    public String[] getColumnHeaders() {
-        return columnHeaders;
-    }
-
-    @Override
-    public Object getListener() {
-        return new TailRuleListener(session.getConsole());
-    }
-
-    class TailRuleListener implements RuleListenerService {
-
-        PrintStream out;
-
-        public TailRuleListener(PrintStream out) {
-            this.out = out;
-        }
-
-        @Override
-        public void onEvaluate(Rule rule, Event event) {
-            // this method is not used by this command
-        }
-
-        @Override
-        public void onAlreadyRaised(AlreadyRaisedFor alreadyRaisedFor, Rule rule, Event event) {
-            // not displayed using this command, see the rule watch command instead.
-        }
-
-        @Override
-        public void onExecuteActions(Rule rule, Event event) {
-            List<String> ruleExecutionInfo = new ArrayList<>();
-            ruleExecutionInfo.add(rule.getItemId());
-            ruleExecutionInfo.add(rule.getMetadata().getName());
-            ruleExecutionInfo.add(event.getEventType());
-            ruleExecutionInfo.add(event.getSessionId());
-            ruleExecutionInfo.add(event.getProfileId());
-            ruleExecutionInfo.add(event.getTimeStamp().toString());
-            ruleExecutionInfo.add(event.getScope());
-            outputLine(out, ruleExecutionInfo);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleView.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleView.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleView.java
new file mode 100644
index 0000000..7e431f7
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleView.java
@@ -0,0 +1,48 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.rules.Rule;
+import org.apache.unomi.api.services.RulesService;
+import org.apache.unomi.persistence.spi.CustomObjectMapper;
+
+@Command(scope = "unomi", name = "rule-view", description = "This will allows to view a rule in the Apache Unomi Context Server")
+@Service
+public class RuleView implements Action {
+
+    @Reference
+    RulesService rulesService;
+
+    @Argument(index = 0, name = "rule", description = "The identifier for the rule", required = true, multiValued = false)
+    String ruleIdentifier;
+
+    public Object execute() throws Exception {
+        Rule rule = rulesService.getRule(ruleIdentifier);
+        if (rule == null) {
+            System.out.println("Couldn't find a rule with id=" + ruleIdentifier);
+            return null;
+        }
+        String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(rule);
+        System.out.println(jsonRule);
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleViewcommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleViewcommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleViewcommand.java
deleted file mode 100644
index c37a107..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleViewcommand.java
+++ /dev/null
@@ -1,49 +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.unomi.shell.commands;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.unomi.api.rules.Rule;
-import org.apache.unomi.api.services.RulesService;
-import org.apache.unomi.persistence.spi.CustomObjectMapper;
-
-@Command(scope = "unomi", name = "rule-view", description = "This will allows to view a rule in the Apache Unomi Context Server")
-public class RuleViewcommand extends OsgiCommandSupport {
-
-    private RulesService rulesService;
-
-    @Argument(index = 0, name = "rule", description = "The identifier for the rule", required = true, multiValued = false)
-    String ruleIdentifier;
-
-    public void setRulesService(RulesService rulesService) {
-        this.rulesService = rulesService;
-    }
-
-    @Override
-    protected Object doExecute() throws Exception {
-        Rule rule = rulesService.getRule(ruleIdentifier);
-        if (rule == null) {
-            System.out.println("Couldn't find a rule with id=" + ruleIdentifier);
-            return null;
-        }
-        String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(rule);
-        System.out.println(jsonRule);
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleWatch.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleWatch.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleWatch.java
new file mode 100644
index 0000000..c943944
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleWatch.java
@@ -0,0 +1,110 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.Event;
+import org.apache.unomi.api.rules.Rule;
+import org.apache.unomi.api.services.RuleListenerService;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This command can watch the evaluations of the conditions as well as the executions of a specified number of rules.
+ */
+@Command(scope = "unomi", name = "rule-watch", description = "This will watch the specified rules evaluating and executing in the Apache Unomi Context Server")
+@Service
+public class RuleWatch extends TailCommandSupport {
+
+    @Argument(index = 0, name = "ruleIds", description = "Identifier(s) of rule(s) to watch", required = true, multiValued = true)
+    String[] ruleIds;
+
+    int[] columnSizes = new int[] { 10, 36, 36, 14, 36, 29, 15, 5 };
+    String[] columnHeaders = new String[] {
+            "Status",
+            "Rule ID",
+            "Rule Name",
+            "Event Type",
+            "Session",
+            "Profile",
+            "Timestamp",
+            "Scope",
+    };
+
+    @Override
+    public int[] getColumnSizes() {
+        return columnSizes;
+    }
+
+    @Override
+    public String[] getColumnHeaders() {
+        return columnHeaders;
+    }
+
+    @Override
+    public Object getListener() {
+        return new RuleWatchListener(session.getConsole());
+    }
+
+    class RuleWatchListener implements RuleListenerService {
+
+        PrintStream out;
+
+        public RuleWatchListener(PrintStream out) {
+            this.out = out;
+        }
+
+        @Override
+        public void onEvaluate(Rule rule, Event event) {
+            populateRuleInfo(rule, event, "EVALUATE");
+        }
+
+
+        @Override
+        public void onAlreadyRaised(AlreadyRaisedFor alreadyRaisedFor, Rule rule, Event event) {
+            populateRuleInfo(rule, event, "AR " + alreadyRaisedFor.toString());
+        }
+
+        @Override
+        public void onExecuteActions(Rule rule, Event event) {
+            populateRuleInfo(rule, event, "EXECUTE");
+        }
+
+        public void populateRuleInfo(Rule rule, Event event, String status) {
+            if (!ArrayUtils.contains(ruleIds, rule.getItemId())) {
+                return;
+            }
+            List<String> ruleExecutionInfo = new ArrayList<>();
+            ruleExecutionInfo.add(status);
+            ruleExecutionInfo.add(rule.getItemId());
+            ruleExecutionInfo.add(rule.getMetadata().getName());
+            ruleExecutionInfo.add(event.getEventType());
+            ruleExecutionInfo.add(event.getSessionId());
+            ruleExecutionInfo.add(event.getProfileId());
+            ruleExecutionInfo.add(event.getTimeStamp().toString());
+            ruleExecutionInfo.add(event.getScope());
+            outputLine(out, ruleExecutionInfo);
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleWatchCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleWatchCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleWatchCommand.java
deleted file mode 100644
index 1012c14..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/RuleWatchCommand.java
+++ /dev/null
@@ -1,108 +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.unomi.shell.commands;
-
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.unomi.api.Event;
-import org.apache.unomi.api.rules.Rule;
-import org.apache.unomi.api.services.RuleListenerService;
-
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This command can watch the evaluations of the conditions as well as the executions of a specified number of rules.
- */
-@Command(scope = "unomi", name = "rule-watch", description = "This will watch the specified rules evaluating and executing in the Apache Unomi Context Server")
-public class RuleWatchCommand extends TailCommandSupport {
-
-    @Argument(index = 0, name = "ruleIds", description = "Identifier(s) of rule(s) to watch", required = true, multiValued = true)
-    String[] ruleIds;
-
-    int[] columnSizes = new int[] { 10, 36, 36, 14, 36, 29, 15, 5 };
-    String[] columnHeaders = new String[] {
-            "Status",
-            "Rule ID",
-            "Rule Name",
-            "Event Type",
-            "Session",
-            "Profile",
-            "Timestamp",
-            "Scope",
-    };
-
-    @Override
-    public int[] getColumnSizes() {
-        return columnSizes;
-    }
-
-    @Override
-    public String[] getColumnHeaders() {
-        return columnHeaders;
-    }
-
-    @Override
-    public Object getListener() {
-        return new RuleWatchListener(session.getConsole());
-    }
-
-    class RuleWatchListener implements RuleListenerService {
-
-        PrintStream out;
-
-        public RuleWatchListener(PrintStream out) {
-            this.out = out;
-        }
-
-        @Override
-        public void onEvaluate(Rule rule, Event event) {
-            populateRuleInfo(rule, event, "EVALUATE");
-        }
-
-
-        @Override
-        public void onAlreadyRaised(AlreadyRaisedFor alreadyRaisedFor, Rule rule, Event event) {
-            populateRuleInfo(rule, event, "AR " + alreadyRaisedFor.toString());
-        }
-
-        @Override
-        public void onExecuteActions(Rule rule, Event event) {
-            populateRuleInfo(rule, event, "EXECUTE");
-        }
-
-        public void populateRuleInfo(Rule rule, Event event, String status) {
-            if (!ArrayUtils.contains(ruleIds, rule.getItemId())) {
-                return;
-            }
-            List<String> ruleExecutionInfo = new ArrayList<>();
-            ruleExecutionInfo.add(status);
-            ruleExecutionInfo.add(rule.getItemId());
-            ruleExecutionInfo.add(rule.getMetadata().getName());
-            ruleExecutionInfo.add(event.getEventType());
-            ruleExecutionInfo.add(event.getSessionId());
-            ruleExecutionInfo.add(event.getProfileId());
-            ruleExecutionInfo.add(event.getTimeStamp().toString());
-            ruleExecutionInfo.add(event.getScope());
-            outputLine(out, ruleExecutionInfo);
-        }
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentList.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentList.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentList.java
new file mode 100644
index 0000000..5f83951
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentList.java
@@ -0,0 +1,73 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.Metadata;
+import org.apache.unomi.api.PartialList;
+import org.apache.unomi.api.services.SegmentService;
+import org.apache.unomi.common.DataTable;
+
+import java.util.ArrayList;
+
+@Command(scope = "unomi", name = "segment-list", description = "This will list all the segments present in the Apache Unomi Context Server")
+@Service
+public class SegmentList extends ListCommandSupport {
+
+    @Reference
+    SegmentService segmentService;
+
+    @Argument(index = 0, name = "maxEntries", description = "The maximum number of entries to retrieve (defaults to 100)", required = false, multiValued = false)
+    int maxEntries = 100;
+
+    @Override
+    protected String[] getHeaders() {
+        return new String[] {
+                "Enabled",
+                "Hidden",
+                "Id",
+                "Scope",
+                "Name",
+                "System tags"
+        };
+    }
+
+    @Override
+    protected DataTable buildDataTable() {
+        PartialList<Metadata> segmentMetadatas = segmentService.getSegmentMetadatas(0, maxEntries, null);
+
+        DataTable dataTable = new DataTable();
+        for (Metadata metadata : segmentMetadatas.getList()) {
+            ArrayList<Comparable> rowData = new ArrayList<>();
+            rowData.add(metadata.isEnabled() ? "x" : "");
+            rowData.add(metadata.isHidden() ? "x" : "");
+            rowData.add(metadata.getId());
+            rowData.add(metadata.getScope());
+            rowData.add(metadata.getName());
+            rowData.add(StringUtils.join(metadata.getSystemTags(), ","));
+            dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
+        }
+
+        dataTable.sort(new DataTable.SortCriteria(4, DataTable.SortOrder.ASCENDING));
+        return dataTable;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentListCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentListCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentListCommand.java
deleted file mode 100644
index 2c50403..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentListCommand.java
+++ /dev/null
@@ -1,73 +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.unomi.shell.commands;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.unomi.api.Metadata;
-import org.apache.unomi.api.PartialList;
-import org.apache.unomi.api.services.SegmentService;
-import org.apache.unomi.common.DataTable;
-
-import java.util.ArrayList;
-
-@Command(scope = "unomi", name = "segment-list", description = "This will list all the segments present in the Apache Unomi Context Server")
-public class SegmentListCommand extends ListCommandSupport {
-
-    private SegmentService segmentService;
-
-    public void setSegmentService(SegmentService segmentService) {
-        this.segmentService = segmentService;
-    }
-
-    @Argument(index = 0, name = "maxEntries", description = "The maximum number of entries to retrieve (defaults to 100)", required = false, multiValued = false)
-    int maxEntries = 100;
-
-    @Override
-    protected String[] getHeaders() {
-        return new String[] {
-                "Enabled",
-                "Hidden",
-                "Id",
-                "Scope",
-                "Name",
-                "System tags"
-        };
-    }
-
-    @Override
-    protected DataTable buildDataTable() {
-        PartialList<Metadata> segmentMetadatas = segmentService.getSegmentMetadatas(0, maxEntries, null);
-
-        DataTable dataTable = new DataTable();
-        for (Metadata metadata : segmentMetadatas.getList()) {
-            ArrayList<Comparable> rowData = new ArrayList<>();
-            rowData.add(metadata.isEnabled() ? "x" : "");
-            rowData.add(metadata.isHidden() ? "x" : "");
-            rowData.add(metadata.getId());
-            rowData.add(metadata.getScope());
-            rowData.add(metadata.getName());
-            rowData.add(StringUtils.join(metadata.getSystemTags(), ","));
-            dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
-        }
-
-        dataTable.sort(new DataTable.SortCriteria(4, DataTable.SortOrder.ASCENDING));
-        return dataTable;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentView.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentView.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentView.java
new file mode 100644
index 0000000..d502148
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentView.java
@@ -0,0 +1,48 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.segments.Segment;
+import org.apache.unomi.api.services.SegmentService;
+import org.apache.unomi.persistence.spi.CustomObjectMapper;
+
+@Command(scope = "unomi", name = "segment-view", description = "This will allows to view a segment in the Apache Unomi Context Server")
+@Service
+public class SegmentView implements Action {
+
+    @Reference
+    SegmentService segmentService;
+
+    @Argument(index = 0, name = "segmentId", description = "The identifier for the segment", required = true, multiValued = false)
+    String segmentIdentifier;
+
+    public Object execute() throws Exception {
+        Segment segment = segmentService.getSegmentDefinition(segmentIdentifier);
+        if (segment == null) {
+            System.out.println("Couldn't find an action with id=" + segmentIdentifier);
+            return null;
+        }
+        String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(segment);
+        System.out.println(jsonRule);
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentViewCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentViewCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentViewCommand.java
deleted file mode 100644
index 3869e60..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SegmentViewCommand.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.unomi.shell.commands;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.unomi.api.segments.Segment;
-import org.apache.unomi.api.services.SegmentService;
-import org.apache.unomi.persistence.spi.CustomObjectMapper;
-
-@Command(scope = "unomi", name = "segment-view", description = "This will allows to view a segment in the Apache Unomi Context Server")
-public class SegmentViewCommand extends OsgiCommandSupport {
-
-    private SegmentService segmentService;
-
-    @Argument(index = 0, name = "segmentId", description = "The identifier for the segment", required = true, multiValued = false)
-    String segmentIdentifier;
-
-
-    public void setSegmentService(SegmentService segmentService) {
-        this.segmentService = segmentService;
-    }
-
-    @Override
-    protected Object doExecute() throws Exception {
-        Segment segment = segmentService.getSegmentDefinition(segmentIdentifier);
-        if (segment == null) {
-            System.out.println("Couldn't find an action with id=" + segmentIdentifier);
-            return null;
-        }
-        String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(segment);
-        System.out.println(jsonRule);
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionList.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionList.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionList.java
new file mode 100644
index 0000000..a3d0fda
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionList.java
@@ -0,0 +1,79 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.PartialList;
+import org.apache.unomi.api.Session;
+import org.apache.unomi.api.conditions.Condition;
+import org.apache.unomi.api.query.Query;
+import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.api.services.ProfileService;
+import org.apache.unomi.common.DataTable;
+
+import java.util.ArrayList;
+
+@Command(scope = "unomi", name = "session-list", description = "This commands lists the latest sessions updated in the Apache Unomi Context Server")
+@Service
+public class SessionList extends ListCommandSupport {
+
+    @Reference
+    ProfileService profileService;
+
+    @Reference
+    DefinitionsService definitionsService;
+
+    @Argument(index = 0, name = "maxEntries", description = "The maximum number of entries to retrieve (defaults to 100)", required = false, multiValued = false)
+    int maxEntries = 100;
+
+    @java.lang.Override
+    protected String[] getHeaders() {
+        return new String[] {
+                "ID",
+                "Scope",
+                "Last event",
+                "Duration",
+                "Profile",
+                "Timestamp"
+        };
+    }
+
+    @java.lang.Override
+    protected DataTable buildDataTable() {
+        Query query = new Query();
+        query.setSortby("lastEventDate:desc");
+        query.setLimit(maxEntries);
+        Condition matchAllCondition = new Condition(definitionsService.getConditionType("matchAllCondition"));
+        query.setCondition(matchAllCondition);
+        PartialList<Session> lastModifiedProfiles = profileService.searchSessions(query);
+        DataTable dataTable = new DataTable();
+        for (Session session : lastModifiedProfiles.getList()) {
+            ArrayList<Comparable> rowData = new ArrayList<>();
+            rowData.add(session.getItemId());
+            rowData.add(session.getScope());
+            rowData.add(session.getLastEventDate());
+            rowData.add(session.getDuration());
+            rowData.add(session.getProfileId());
+            rowData.add(session.getTimeStamp());
+            dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
+        }
+        return dataTable;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionListCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionListCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionListCommand.java
deleted file mode 100644
index 1fc91c4..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionListCommand.java
+++ /dev/null
@@ -1,80 +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.unomi.shell.commands;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.unomi.api.PartialList;
-import org.apache.unomi.api.Session;
-import org.apache.unomi.api.conditions.Condition;
-import org.apache.unomi.api.query.Query;
-import org.apache.unomi.api.services.DefinitionsService;
-import org.apache.unomi.api.services.ProfileService;
-import org.apache.unomi.common.DataTable;
-
-import java.util.ArrayList;
-
-@Command(scope = "unomi", name = "session-list", description = "This commands lists the latest sessions updated in the Apache Unomi Context Server")
-public class SessionListCommand extends ListCommandSupport {
-    private ProfileService profileService;
-    private DefinitionsService definitionsService;
-
-    public void setProfileService(ProfileService profileService) {
-        this.profileService = profileService;
-    }
-
-    public void setDefinitionsService(DefinitionsService definitionsService) {
-        this.definitionsService = definitionsService;
-    }
-
-    @Argument(index = 0, name = "maxEntries", description = "The maximum number of entries to retrieve (defaults to 100)", required = false, multiValued = false)
-    int maxEntries = 100;
-
-    @java.lang.Override
-    protected String[] getHeaders() {
-        return new String[] {
-                "ID",
-                "Scope",
-                "Last event",
-                "Duration",
-                "Profile",
-                "Timestamp"
-        };
-    }
-
-    @java.lang.Override
-    protected DataTable buildDataTable() {
-        Query query = new Query();
-        query.setSortby("lastEventDate:desc");
-        query.setLimit(maxEntries);
-        Condition matchAllCondition = new Condition(definitionsService.getConditionType("matchAllCondition"));
-        query.setCondition(matchAllCondition);
-        PartialList<Session> lastModifiedProfiles = profileService.searchSessions(query);
-        DataTable dataTable = new DataTable();
-        for (Session session : lastModifiedProfiles.getList()) {
-            ArrayList<Comparable> rowData = new ArrayList<>();
-            rowData.add(session.getItemId());
-            rowData.add(session.getScope());
-            rowData.add(session.getLastEventDate());
-            rowData.add(session.getDuration());
-            rowData.add(session.getProfileId());
-            rowData.add(session.getTimeStamp());
-            dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
-        }
-        return dataTable;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionView.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionView.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionView.java
new file mode 100644
index 0000000..d8d96ad
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionView.java
@@ -0,0 +1,48 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.Session;
+import org.apache.unomi.api.services.ProfileService;
+import org.apache.unomi.persistence.spi.CustomObjectMapper;
+
+@Command(scope = "unomi", name = "session-view", description = "This command will dump a session as a JSON string")
+@Service
+public class SessionView implements Action {
+
+    @Reference
+    ProfileService profileService;
+
+    @Argument(index = 0, name = "session", description = "The identifier for the session", required = true, multiValued = false)
+    String sessionIdentifier;
+
+    public Object execute() throws Exception {
+        Session session = profileService.loadSession(sessionIdentifier, null);
+        if (session == null) {
+            System.out.println("Couldn't find a session with id=" + sessionIdentifier);
+            return null;
+        }
+        String jsonSession = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(session);
+        System.out.println(jsonSession);
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionViewCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionViewCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionViewCommand.java
deleted file mode 100644
index 53725d0..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/SessionViewCommand.java
+++ /dev/null
@@ -1,48 +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.unomi.shell.commands;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.unomi.api.Session;
-import org.apache.unomi.api.services.ProfileService;
-import org.apache.unomi.persistence.spi.CustomObjectMapper;
-
-@Command(scope = "unomi", name = "session-view", description = "This command will dump a session as a JSON string")
-public class SessionViewCommand extends OsgiCommandSupport {
-    private ProfileService profileService;
-
-    public void setProfileService(ProfileService profileService) {
-        this.profileService = profileService;
-    }
-
-    @Argument(index = 0, name = "session", description = "The identifier for the session", required = true, multiValued = false)
-    String sessionIdentifier;
-
-    @Override
-    protected Object doExecute() throws Exception {
-        Session session = profileService.loadSession(sessionIdentifier, null);
-        if (session == null) {
-            System.out.println("Couldn't find a session with id=" + sessionIdentifier);
-            return null;
-        }
-        String jsonSession = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(session);
-        System.out.println(jsonSession);
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/TailCommandSupport.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/TailCommandSupport.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/TailCommandSupport.java
index ba0a0ad..f6af032 100644
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/TailCommandSupport.java
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/TailCommandSupport.java
@@ -17,7 +17,10 @@
 package org.apache.unomi.shell.commands;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.console.Session;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 
 import java.io.PrintStream;
@@ -25,12 +28,18 @@ import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.List;
 
-public abstract class TailCommandSupport extends OsgiCommandSupport {
+public abstract class TailCommandSupport implements Action {
 
     public abstract int[] getColumnSizes();
 
     public abstract String[] getColumnHeaders();
 
+    @Reference
+    Session session;
+
+    @Reference
+    BundleContext bundleContext;
+
     public void outputHeaders(PrintStream out) {
         StringBuilder headerLine = new StringBuilder();
         int[] columnSizes = getColumnSizes();
@@ -68,9 +77,7 @@ public abstract class TailCommandSupport extends OsgiCommandSupport {
     
     public abstract Object getListener();
 
-
-    @Override
-    protected Object doExecute() throws Exception {
+    public Object execute() throws Exception {
         // Do not use System.out as it may write to the wrong console depending on the thread that calls our log handler
         PrintStream out = session.getConsole();
         out.flush();

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/tools/shell-dev-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml
deleted file mode 100644
index 16f60fb..0000000
--- a/tools/shell-dev-commands/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ /dev/null
@@ -1,134 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~ Licensed to the Apache Software Foundation (ASF) under one or more
-  ~ contributor license agreements.  See the NOTICE file distributed with
-  ~ this work for additional information regarding copyright ownership.
-  ~ The ASF licenses this file to You under the Apache License, Version 2.0
-  ~ (the "License"); you may not use this file except in compliance with
-  ~ the License.  You may obtain a copy of the License at
-  ~
-  ~      http://www.apache.org/licenses/LICENSE-2.0
-  ~
-  ~ Unless required by applicable law or agreed to in writing, software
-  ~ distributed under the License is distributed on an "AS IS" BASIS,
-  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  ~ See the License for the specific language governing permissions and
-  ~ limitations under the License.
-  -->
-
-<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-           xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-           xmlns:shell="http://karaf.apache.org/xmlns/shell/v1.1.0"
-           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
-
-    <reference id="segmentService" interface="org.apache.unomi.api.services.SegmentService"/>
-    <reference id="userListService" interface="org.apache.unomi.api.services.UserListService"/>
-    <reference id="definitionsService" interface="org.apache.unomi.api.services.DefinitionsService"/>
-    <reference id="goalsService" interface="org.apache.unomi.api.services.GoalsService"/>
-    <reference id="rulesService" interface="org.apache.unomi.api.services.RulesService"/>
-    <reference id="profileService" interface="org.apache.unomi.api.services.ProfileService"/>
-    <reference id="clusterService" interface="org.apache.unomi.api.services.ClusterService"/>
-    <reference id="queryService" interface="org.apache.unomi.api.services.QueryService"/>
-    <reference id="eventService" interface="org.apache.unomi.api.services.EventService"/>
-    <reference id="patchService" interface="org.apache.unomi.api.services.PatchService"/>
-
-    <shell:command-bundle>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.RuleListCommand">
-                <shell:property name="rulesService" ref="rulesService" />
-                <shell:property name="definitionsService" ref="definitionsService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.RuleViewcommand">
-                <shell:property name="rulesService" ref="rulesService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.RuleResetStatsCommand">
-                <shell:property name="rulesService" ref="rulesService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.RuleTailCommand">
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.RuleWatchCommand">
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.ActionListCommand">
-                <shell:property name="definitionsService" ref="definitionsService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.ActionViewCommand">
-                <shell:property name="definitionsService" ref="definitionsService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.ConditionListCommand">
-                <shell:property name="definitionsService" ref="definitionsService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.ConditionViewCommand">
-                <shell:property name="definitionsService" ref="definitionsService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.SegmentListCommand">
-                <shell:property name="segmentService" ref="segmentService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.SegmentViewCommand">
-                <shell:property name="segmentService" ref="segmentService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.DeployDefinitionCommand">
-                <shell:property name="definitionsService" ref="definitionsService" />
-                <shell:property name="goalsService" ref="goalsService" />
-                <shell:property name="profileService" ref="profileService" />
-                <shell:property name="rulesService" ref="rulesService" />
-                <shell:property name="segmentService" ref="segmentService" />
-                <shell:property name="patchService" ref="patchService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.ProfileListCommand">
-                <shell:property name="definitionsService" ref="definitionsService" />
-                <shell:property name="profileService" ref="profileService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.ProfileViewCommand">
-                <shell:property name="profileService" ref="profileService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.EventTailCommand">
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.EventViewCommand">
-                <shell:property name="definitionsService" ref="definitionsService" />
-                <shell:property name="eventService" ref="eventService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.SessionViewCommand">
-                <shell:property name="profileService" ref="profileService" />
-            </shell:action>
-        </shell:command>
-        <shell:command>
-            <shell:action class="org.apache.unomi.shell.commands.SessionListCommand">
-                <shell:property name="definitionsService" ref="definitionsService" />
-                <shell:property name="profileService" ref="profileService" />
-            </shell:action>
-        </shell:command>
-    </shell:command-bundle>
-
-</blueprint>


[2/2] incubator-unomi git commit: UNOMI-215 New rule monitoring commands & other new commands - Refactor commands to use new style - Remove blueprint - Rename commands to remove "Command" at the end of the name

Posted by sh...@apache.org.
UNOMI-215 New rule monitoring commands & other new commands
- Refactor commands to use new style
- Remove blueprint
- Rename commands to remove "Command" at the end of the name

Signed-off-by: Serge Huber <sh...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/e5075636
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/e5075636
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/e5075636

Branch: refs/heads/master
Commit: e5075636dac6672bbae66d33ccccc5e6b4e7379e
Parents: ac1ce57
Author: Serge Huber <sh...@apache.org>
Authored: Mon Dec 3 17:31:09 2018 +0100
Committer: Serge Huber <sh...@apache.org>
Committed: Mon Dec 3 17:31:09 2018 +0100

----------------------------------------------------------------------
 tools/shell-dev-commands/pom.xml                |  14 +
 .../apache/unomi/shell/commands/ActionList.java |  64 ++++
 .../unomi/shell/commands/ActionListCommand.java |  64 ----
 .../apache/unomi/shell/commands/ActionView.java |  48 +++
 .../unomi/shell/commands/ActionViewCommand.java |  50 ----
 .../unomi/shell/commands/ConditionList.java     |  64 ++++
 .../shell/commands/ConditionListCommand.java    |  64 ----
 .../unomi/shell/commands/ConditionView.java     |  50 ++++
 .../shell/commands/ConditionViewCommand.java    |  51 ----
 .../unomi/shell/commands/DeployDefinition.java  | 292 ++++++++++++++++++
 .../shell/commands/DeployDefinitionCommand.java | 293 -------------------
 .../apache/unomi/shell/commands/EventTail.java  |  94 ++++++
 .../unomi/shell/commands/EventTailCommand.java  |  92 ------
 .../apache/unomi/shell/commands/EventView.java  |  60 ++++
 .../unomi/shell/commands/EventViewCommand.java  |  63 ----
 .../shell/commands/ListCommandSupport.java      |   9 +-
 .../unomi/shell/commands/ProfileList.java       |  78 +++++
 .../shell/commands/ProfileListCommand.java      |  80 -----
 .../unomi/shell/commands/ProfileView.java       |  48 +++
 .../shell/commands/ProfileViewCommand.java      |  49 ----
 .../apache/unomi/shell/commands/RuleList.java   | 108 +++++++
 .../unomi/shell/commands/RuleListCommand.java   | 110 -------
 .../unomi/shell/commands/RuleResetStats.java    |  38 +++
 .../shell/commands/RuleResetStatsCommand.java   |  38 ---
 .../apache/unomi/shell/commands/RuleTail.java   |  93 ++++++
 .../unomi/shell/commands/RuleTailCommand.java   |  91 ------
 .../apache/unomi/shell/commands/RuleView.java   |  48 +++
 .../unomi/shell/commands/RuleViewcommand.java   |  49 ----
 .../apache/unomi/shell/commands/RuleWatch.java  | 110 +++++++
 .../unomi/shell/commands/RuleWatchCommand.java  | 108 -------
 .../unomi/shell/commands/SegmentList.java       |  73 +++++
 .../shell/commands/SegmentListCommand.java      |  73 -----
 .../unomi/shell/commands/SegmentView.java       |  48 +++
 .../shell/commands/SegmentViewCommand.java      |  50 ----
 .../unomi/shell/commands/SessionList.java       |  79 +++++
 .../shell/commands/SessionListCommand.java      |  80 -----
 .../unomi/shell/commands/SessionView.java       |  48 +++
 .../shell/commands/SessionViewCommand.java      |  48 ---
 .../shell/commands/TailCommandSupport.java      |  17 +-
 .../resources/OSGI-INF/blueprint/blueprint.xml  | 134 ---------
 40 files changed, 1473 insertions(+), 1597 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/pom.xml
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/pom.xml b/tools/shell-dev-commands/pom.xml
index a89f86f..abc79e9 100644
--- a/tools/shell-dev-commands/pom.xml
+++ b/tools/shell-dev-commands/pom.xml
@@ -114,4 +114,18 @@
         </dependency>
     </dependencies>
 
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Karaf-Commands>*</Karaf-Commands>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionList.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionList.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionList.java
new file mode 100644
index 0000000..7839cb7
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionList.java
@@ -0,0 +1,64 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.actions.ActionType;
+import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.common.DataTable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@Command(scope = "unomi", name = "action-list", description = "This will list all the actions deployed in the Apache Unomi Context Server")
+@Service
+public class ActionList extends ListCommandSupport {
+
+    @Reference
+    DefinitionsService definitionsService;
+
+    @Override
+    protected String[] getHeaders() {
+        return new String[] {
+                "Id",
+                "Name",
+                "System tags"
+        };
+    }
+
+    @Override
+    protected DataTable buildDataTable() {
+        Collection<ActionType> allActions = definitionsService.getAllActionTypes();
+
+        DataTable dataTable = new DataTable();
+
+        for (ActionType actionType : allActions) {
+            ArrayList<Comparable> rowData = new ArrayList<>();
+            rowData.add(actionType.getItemId());
+            rowData.add(actionType.getMetadata().getName());
+            rowData.add(StringUtils.join(actionType.getMetadata().getSystemTags(), ","));
+            dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
+        }
+
+        dataTable.sort(new DataTable.SortCriteria(1, DataTable.SortOrder.ASCENDING));
+        return dataTable;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionListCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionListCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionListCommand.java
deleted file mode 100644
index d6525ec..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionListCommand.java
+++ /dev/null
@@ -1,64 +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.unomi.shell.commands;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.unomi.api.actions.ActionType;
-import org.apache.unomi.api.services.DefinitionsService;
-import org.apache.unomi.common.DataTable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@Command(scope = "unomi", name = "action-list", description = "This will list all the actions deployed in the Apache Unomi Context Server")
-public class ActionListCommand extends ListCommandSupport {
-
-    private DefinitionsService definitionsService;
-
-    public void setDefinitionsService(DefinitionsService definitionsService) {
-        this.definitionsService = definitionsService;
-    }
-
-    @Override
-    protected String[] getHeaders() {
-        return new String[] {
-                "Id",
-                "Name",
-                "System tags"
-        };
-    }
-
-    @Override
-    protected DataTable buildDataTable() {
-        Collection<ActionType> allActions = definitionsService.getAllActionTypes();
-
-        DataTable dataTable = new DataTable();
-
-        for (ActionType actionType : allActions) {
-            ArrayList<Comparable> rowData = new ArrayList<>();
-            rowData.add(actionType.getItemId());
-            rowData.add(actionType.getMetadata().getName());
-            rowData.add(StringUtils.join(actionType.getMetadata().getSystemTags(), ","));
-            dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
-        }
-
-        dataTable.sort(new DataTable.SortCriteria(1, DataTable.SortOrder.ASCENDING));
-        return dataTable;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionView.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionView.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionView.java
new file mode 100644
index 0000000..939e7f9
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionView.java
@@ -0,0 +1,48 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.actions.ActionType;
+import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.persistence.spi.CustomObjectMapper;
+
+@Command(scope = "unomi", name = "action-view", description = "This will display a single action deployed in the Apache Unomi Context Server")
+@Service
+public class ActionView implements Action {
+
+    @Reference
+    DefinitionsService definitionsService;
+
+    @Argument(index = 0, name = "actionId", description = "The identifier for the action", required = true, multiValued = false)
+    String actionTypeIdentifier;
+
+    public Object execute() throws Exception {
+        ActionType actionType = definitionsService.getActionType(actionTypeIdentifier);
+        if (actionType == null) {
+            System.out.println("Couldn't find an action with id=" + actionTypeIdentifier);
+            return null;
+        }
+        String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(actionType);
+        System.out.println(jsonRule);
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionViewCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionViewCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionViewCommand.java
deleted file mode 100644
index 9d1b820..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ActionViewCommand.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.unomi.shell.commands;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.unomi.api.actions.ActionType;
-import org.apache.unomi.api.services.DefinitionsService;
-import org.apache.unomi.persistence.spi.CustomObjectMapper;
-
-@Command(scope = "unomi", name = "action-view", description = "This will display a single action deployed in the Apache Unomi Context Server")
-public class ActionViewCommand extends OsgiCommandSupport {
-
-    private DefinitionsService definitionsService;
-
-    @Argument(index = 0, name = "actionId", description = "The identifier for the action", required = true, multiValued = false)
-    String actionTypeIdentifier;
-
-
-    public void setDefinitionsService(DefinitionsService definitionsService) {
-        this.definitionsService = definitionsService;
-    }
-
-    @Override
-    protected Object doExecute() throws Exception {
-        ActionType actionType = definitionsService.getActionType(actionTypeIdentifier);
-        if (actionType == null) {
-            System.out.println("Couldn't find an action with id=" + actionTypeIdentifier);
-            return null;
-        }
-        String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(actionType);
-        System.out.println(jsonRule);
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionList.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionList.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionList.java
new file mode 100644
index 0000000..83f6deb
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionList.java
@@ -0,0 +1,64 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.conditions.ConditionType;
+import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.common.DataTable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@Command(scope = "unomi", name = "condition-list", description = "This will list all the conditions deployed in the Apache Unomi Context Server")
+@Service
+public class ConditionList extends ListCommandSupport {
+
+    @Reference
+    DefinitionsService definitionsService;
+
+    @Override
+    protected String[] getHeaders() {
+        return new String[] {
+                "Id",
+                "Name",
+                "System tags"
+        };
+    }
+
+    @Override
+    protected DataTable buildDataTable() {
+        Collection<ConditionType> allConditionTypes = definitionsService.getAllConditionTypes();
+
+        DataTable dataTable = new DataTable();
+
+        for (ConditionType conditionType : allConditionTypes) {
+            ArrayList<Comparable> rowData = new ArrayList<>();
+            rowData.add(conditionType.getItemId());
+            rowData.add(conditionType.getMetadata().getName());
+            rowData.add(StringUtils.join(conditionType.getMetadata().getSystemTags(), ","));
+            dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
+        }
+
+        dataTable.sort(new DataTable.SortCriteria(1, DataTable.SortOrder.ASCENDING));
+        return dataTable;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionListCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionListCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionListCommand.java
deleted file mode 100644
index 4cf5be0..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionListCommand.java
+++ /dev/null
@@ -1,64 +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.unomi.shell.commands;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.unomi.api.conditions.ConditionType;
-import org.apache.unomi.api.services.DefinitionsService;
-import org.apache.unomi.common.DataTable;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@Command(scope = "unomi", name = "condition-list", description = "This will list all the conditions deployed in the Apache Unomi Context Server")
-public class ConditionListCommand extends ListCommandSupport {
-
-    private DefinitionsService definitionsService;
-
-    public void setDefinitionsService(DefinitionsService definitionsService) {
-        this.definitionsService = definitionsService;
-    }
-
-    @Override
-    protected String[] getHeaders() {
-        return new String[] {
-                "Id",
-                "Name",
-                "System tags"
-        };
-    }
-
-    @Override
-    protected DataTable buildDataTable() {
-        Collection<ConditionType> allConditionTypes = definitionsService.getAllConditionTypes();
-
-        DataTable dataTable = new DataTable();
-
-        for (ConditionType conditionType : allConditionTypes) {
-            ArrayList<Comparable> rowData = new ArrayList<>();
-            rowData.add(conditionType.getItemId());
-            rowData.add(conditionType.getMetadata().getName());
-            rowData.add(StringUtils.join(conditionType.getMetadata().getSystemTags(), ","));
-            dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
-        }
-
-        dataTable.sort(new DataTable.SortCriteria(1, DataTable.SortOrder.ASCENDING));
-        return dataTable;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionView.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionView.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionView.java
new file mode 100644
index 0000000..03efe9d
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionView.java
@@ -0,0 +1,50 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.conditions.ConditionType;
+import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.persistence.spi.CustomObjectMapper;
+
+@Command(scope = "unomi", name = "condition-view", description = "This will display a single condition deployed in the Apache Unomi Context Server")
+@Service
+public class ConditionView implements Action {
+
+    @Reference
+    DefinitionsService definitionsService;
+
+    @Argument(index = 0, name = "conditionId", description = "The identifier for the condition", required = true, multiValued = false)
+    String conditionTypeIdentifier;
+
+    public Object execute() throws Exception {
+        ConditionType conditionType = definitionsService.getConditionType(conditionTypeIdentifier);
+        if (conditionType == null) {
+            System.out.println("Couldn't find an action with id=" + conditionTypeIdentifier);
+            return null;
+        }
+        String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(conditionType);
+        System.out.println(jsonRule);
+        return null;
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionViewCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionViewCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionViewCommand.java
deleted file mode 100644
index 0c96b17..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ConditionViewCommand.java
+++ /dev/null
@@ -1,51 +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.unomi.shell.commands;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.unomi.api.conditions.ConditionType;
-import org.apache.unomi.api.services.DefinitionsService;
-import org.apache.unomi.persistence.spi.CustomObjectMapper;
-
-@Command(scope = "unomi", name = "condition-view", description = "This will display a single condition deployed in the Apache Unomi Context Server")
-public class ConditionViewCommand extends OsgiCommandSupport {
-
-    private DefinitionsService definitionsService;
-
-    @Argument(index = 0, name = "conditionId", description = "The identifier for the condition", required = true, multiValued = false)
-    String conditionTypeIdentifier;
-
-    public void setDefinitionsService(DefinitionsService definitionsService) {
-        this.definitionsService = definitionsService;
-    }
-
-    @Override
-    protected Object doExecute() throws Exception {
-        ConditionType conditionType = definitionsService.getConditionType(conditionTypeIdentifier);
-        if (conditionType == null) {
-            System.out.println("Couldn't find an action with id=" + conditionTypeIdentifier);
-            return null;
-        }
-        String jsonRule = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(conditionType);
-        System.out.println(jsonRule);
-        return null;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinition.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinition.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinition.java
new file mode 100644
index 0000000..d0baae9
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinition.java
@@ -0,0 +1,292 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.unomi.api.Patch;
+import org.apache.unomi.api.PersonaWithSessions;
+import org.apache.unomi.api.PropertyType;
+import org.apache.unomi.api.actions.ActionType;
+import org.apache.unomi.api.campaigns.Campaign;
+import org.apache.unomi.api.conditions.ConditionType;
+import org.apache.unomi.api.goals.Goal;
+import org.apache.unomi.api.rules.Rule;
+import org.apache.unomi.api.segments.Scoring;
+import org.apache.unomi.api.segments.Segment;
+import org.apache.unomi.api.services.*;
+import org.apache.unomi.persistence.spi.CustomObjectMapper;
+import org.jline.reader.LineReader;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+
+@Command(scope = "unomi", name = "deploy-definition", description = "This will deploy a specific definition")
+@Service
+public class DeployDefinition implements Action {
+
+    @Reference
+    DefinitionsService definitionsService;
+
+    @Reference
+    GoalsService goalsService;
+
+    @Reference
+    ProfileService profileService;
+
+    @Reference
+    RulesService rulesService;
+
+    @Reference
+    SegmentService segmentService;
+
+    @Reference
+    PatchService patchService;
+
+    @Reference
+    BundleContext bundleContext;
+
+    @Reference
+    Session session;
+
+    private final static List<String> definitionTypes = Arrays.asList("condition", "action", "goal", "campaign", "persona", "property", "rule", "segment", "scoring", "patch");
+
+    @Argument(index = 0, name = "bundleId", description = "The bundle identifier where to find the definition", multiValued = false)
+    Long bundleIdentifier;
+
+    @Argument(index = 1, name = "type", description = "The kind of definitions you want to load (e.g.: condition, action, ..)", required = false, multiValued = false)
+    String definitionType;
+
+    @Argument(index = 2, name = "fileName", description = "The name of the file which contains the definition, without its extension (e.g: firstName)", required = false, multiValued = false)
+    String fileName;
+
+    public Object execute() throws Exception {
+        List<Bundle> bundlesToUpdate;
+        if (bundleIdentifier == null) {
+            List<Bundle> bundles = new ArrayList<>();
+            for (Bundle bundle : bundleContext.getBundles()) {
+                if (bundle.findEntries("META-INF/cxs/", "*.json", true) != null) {
+                    bundles.add(bundle);
+                }
+            }
+
+            bundles = bundles.stream()
+                    .filter(b -> definitionTypes.stream().anyMatch((t) -> b.findEntries(getDefinitionTypePath(t), "*.json", true) != null))
+                    .collect(Collectors.toList());
+
+            List<String> stringList = bundles.stream().map(Bundle::getSymbolicName).collect(Collectors.toList());
+            stringList.add(0, "* (All)");
+
+            String bundleAnswer = askUserWithAuthorizedAnswer(session, "Which bundle ?" + getValuesWithNumber(stringList) + "\n",
+                    IntStream.range(1,bundles.size()+1).mapToObj(Integer::toString).collect(Collectors.toList()));
+            if (bundleAnswer.equals("1")) {
+                bundlesToUpdate = bundles;
+            } else {
+                bundlesToUpdate = Collections.singletonList(bundles.get(new Integer(bundleAnswer) - 2));
+            }
+        } else {
+            Bundle bundle = bundleContext.getBundle(bundleIdentifier);
+
+            if (bundle == null) {
+                System.out.println("Couldn't find a bundle with id: " + bundleIdentifier);
+                return null;
+            }
+
+            bundlesToUpdate = Collections.singletonList(bundle);
+        }
+
+        if (definitionType == null) {
+            List<String> values = definitionTypes.stream().filter((t) -> bundlesToUpdate.stream().anyMatch(b->b.findEntries(getDefinitionTypePath(t), "*.json", true) != null)).collect(Collectors.toList());
+
+            if (values.isEmpty()) {
+                System.out.println("Couldn't find definitions in bundle : " + bundlesToUpdate);
+                return null;
+            }
+
+            String definitionTypeAnswer = askUserWithAuthorizedAnswer(session, "Which kind of definition do you want to load?" + getValuesWithNumber(values) + "\n",
+                    IntStream.range(1,values.size()+1).mapToObj(Integer::toString).collect(Collectors.toList()));
+            definitionType = values.get(new Integer(definitionTypeAnswer)-1);
+        }
+
+        if (!definitionTypes.contains(definitionType)) {
+            System.out.println("Invalid type '" + definitionType + "' , allowed values : " +definitionTypes);
+            return null;
+        }
+
+        String path = getDefinitionTypePath(definitionType);
+        List<URL> values = bundlesToUpdate.stream().flatMap(b->b.findEntries(path, "*.json", true) != null ? Collections.list(b.findEntries(path, "*.json", true)).stream() : Stream.empty()).collect(Collectors.toList());
+        if (values.isEmpty()) {
+            System.out.println("Couldn't find definitions in bundle with id: " + bundleIdentifier + " and definition path: " + path);
+            return null;
+        }
+
+        if (fileName == null) {
+            List<String> stringList = values.stream().map(u -> StringUtils.substringAfterLast(u.getFile(), "/")).sorted().collect(Collectors.toList());
+            stringList.add(0, "* (All)");
+            String fileNameAnswer = askUserWithAuthorizedAnswer(session, "Which file do you want to load ?" + getValuesWithNumber(stringList) + "\n",
+                    IntStream.range(1,stringList.size()+1).mapToObj(Integer::toString).collect(Collectors.toList()));
+            fileName = stringList.get(new Integer(fileNameAnswer)-1);
+        }
+        if (fileName.startsWith("*")) {
+            for (URL url : values) {
+                updateDefinition(definitionType, url);
+            }
+        } else {
+            if (!fileName.contains("/")) {
+                fileName = "/" + fileName;
+            }
+            if (!fileName.endsWith(".json")) {
+                fileName += ".json";
+            }
+
+            Optional<URL> optionalURL = values.stream().filter(u -> u.getFile().endsWith(fileName)).findFirst();
+            if (optionalURL.isPresent()) {
+                URL url = optionalURL.get();
+                updateDefinition(definitionType, url);
+            } else {
+                System.out.println("Couldn't find file " + fileName);
+                return null;
+            }
+        }
+
+        return null;
+    }
+
+    private String askUserWithAuthorizedAnswer(Session session, String msg, List<String> authorizedAnswer) throws IOException {
+        String answer;
+        do {
+            answer = promptMessageToUser(session,msg);
+        } while (!authorizedAnswer.contains(answer.toLowerCase()));
+        return answer;
+    }
+
+    private String promptMessageToUser(Session session, String msg) throws IOException {
+        LineReader reader = (LineReader) session.get(".jline.reader");
+        return reader.readLine(msg, null);
+    }
+
+    private String getValuesWithNumber(List<String> values) {
+        StringBuilder definitionTypesWithNumber = new StringBuilder();
+        for (int i = 0; i < values.size(); i++) {
+            definitionTypesWithNumber.append("\n").append(i+1).append(". ").append(values.get(i));
+        }
+        return definitionTypesWithNumber.toString();
+    }
+
+    private void updateDefinition(String definitionType, URL definitionURL) {
+        try {
+                    
+            switch (definitionType) {
+                case "condition":
+                    ConditionType conditionType = CustomObjectMapper.getObjectMapper().readValue(definitionURL, ConditionType.class);
+                    definitionsService.setConditionType(conditionType);
+                    break;
+                case "action":
+                    ActionType actionType = CustomObjectMapper.getObjectMapper().readValue(definitionURL, ActionType.class);
+                    definitionsService.setActionType(actionType);
+                    break;
+                case "goal":
+                    Goal goal = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Goal.class);
+                    goalsService.setGoal(goal);
+                    break;
+                case "campaign":
+                    Campaign campaign = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Campaign.class);
+                    goalsService.setCampaign(campaign);
+                    break;
+                case "persona":
+                    PersonaWithSessions persona = CustomObjectMapper.getObjectMapper().readValue(definitionURL, PersonaWithSessions.class);
+                    profileService.savePersonaWithSessions(persona);
+                    break;
+                case "property":
+                    PropertyType propertyType = CustomObjectMapper.getObjectMapper().readValue(definitionURL, PropertyType.class);
+                    profileService.setPropertyTypeTarget(definitionURL, propertyType);
+                    profileService.setPropertyType(propertyType);
+                    break;
+                case "rule":
+                    Rule rule = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Rule.class);
+                    rulesService.setRule(rule);
+                    break;
+                case "segment":
+                    Segment segment = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Segment.class);
+                    segmentService.setSegmentDefinition(segment);
+                    break;
+                case "scoring":
+                    Scoring scoring = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Scoring.class);
+                    segmentService.setScoringDefinition(scoring);
+                    break;
+                case "patch":
+                    Patch patch = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Patch.class);
+                    patchService.patch(patch);
+                    break;
+            }
+            System.out.println("Predefined definition registered : "+definitionURL.getFile());
+        } catch (IOException e) {
+            System.out.println("Error while saving definition " + definitionURL);
+            System.out.println(e.getMessage());
+        }
+    }
+
+    private String getDefinitionTypePath(String definitionType) {
+        StringBuilder path = new StringBuilder("META-INF/cxs/");
+        switch (definitionType) {
+            case "condition":
+                path.append("conditions");
+                break;
+            case "action":
+                path.append("actions");
+                break;
+            case "goal":
+                path.append("goals");
+                break;
+            case "campaign":
+                path.append("campaigns");
+                break;
+            case "persona":
+                path.append("personas");
+                break;
+            case "property":
+                path.append("properties");
+                break;
+            case "rule":
+                path.append("rules");
+                break;
+            case "segment":
+                path.append("segments");
+                break;
+            case "scoring":
+                path.append("scoring");
+                break;
+            case "patch":
+                path.append("patches");
+                break;
+        }
+
+        return path.toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinitionCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinitionCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinitionCommand.java
deleted file mode 100644
index 826b15f..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/DeployDefinitionCommand.java
+++ /dev/null
@@ -1,293 +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.unomi.shell.commands;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.felix.service.command.CommandSession;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.unomi.api.*;
-import org.apache.unomi.api.actions.ActionType;
-import org.apache.unomi.api.campaigns.Campaign;
-import org.apache.unomi.api.conditions.ConditionType;
-import org.apache.unomi.api.goals.Goal;
-import org.apache.unomi.api.rules.Rule;
-import org.apache.unomi.api.segments.Scoring;
-import org.apache.unomi.api.segments.Segment;
-import org.apache.unomi.api.services.*;
-import org.apache.unomi.persistence.spi.CustomObjectMapper;
-import org.jline.reader.LineReader;
-import org.osgi.framework.Bundle;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
-
-@Command(scope = "unomi", name = "deploy-definition", description = "This will deploy a specific definition")
-public class DeployDefinitionCommand extends OsgiCommandSupport {
-
-    private DefinitionsService definitionsService;
-    private GoalsService goalsService;
-    private ProfileService profileService;
-    private RulesService rulesService;
-    private SegmentService segmentService;
-    private PatchService patchService;
-
-    private final static List<String> definitionTypes = Arrays.asList("condition", "action", "goal", "campaign", "persona", "property", "rule", "segment", "scoring", "patch");
-
-
-    @Argument(index = 0, name = "bundleId", description = "The bundle identifier where to find the definition", multiValued = false)
-    Long bundleIdentifier;
-
-    @Argument(index = 1, name = "type", description = "The kind of definitions you want to load (e.g.: condition, action, ..)", required = false, multiValued = false)
-    String definitionType;
-
-    @Argument(index = 2, name = "fileName", description = "The name of the file which contains the definition, without its extension (e.g: firstName)", required = false, multiValued = false)
-    String fileName;
-
-    protected Object doExecute() throws Exception {
-        List<Bundle> bundlesToUpdate;
-        if (bundleIdentifier == null) {
-            List<Bundle> bundles = new ArrayList<>();
-            for (Bundle bundle : bundleContext.getBundles()) {
-                if (bundle.findEntries("META-INF/cxs/", "*.json", true) != null) {
-                    bundles.add(bundle);
-                }
-            }
-
-            bundles = bundles.stream()
-                    .filter(b -> definitionTypes.stream().anyMatch((t) -> b.findEntries(getDefinitionTypePath(t), "*.json", true) != null))
-                    .collect(Collectors.toList());
-
-            List<String> stringList = bundles.stream().map(Bundle::getSymbolicName).collect(Collectors.toList());
-            stringList.add(0, "* (All)");
-
-            String bundleAnswer = askUserWithAuthorizedAnswer(session, "Which bundle ?" + getValuesWithNumber(stringList) + "\n",
-                    IntStream.range(1,bundles.size()+1).mapToObj(Integer::toString).collect(Collectors.toList()));
-            if (bundleAnswer.equals("1")) {
-                bundlesToUpdate = bundles;
-            } else {
-                bundlesToUpdate = Collections.singletonList(bundles.get(new Integer(bundleAnswer) - 2));
-            }
-        } else {
-            Bundle bundle = bundleContext.getBundle(bundleIdentifier);
-
-            if (bundle == null) {
-                System.out.println("Couldn't find a bundle with id: " + bundleIdentifier);
-                return null;
-            }
-
-            bundlesToUpdate = Collections.singletonList(bundle);
-        }
-
-        if (definitionType == null) {
-            List<String> values = definitionTypes.stream().filter((t) -> bundlesToUpdate.stream().anyMatch(b->b.findEntries(getDefinitionTypePath(t), "*.json", true) != null)).collect(Collectors.toList());
-
-            if (values.isEmpty()) {
-                System.out.println("Couldn't find definitions in bundle : " + bundlesToUpdate);
-                return null;
-            }
-
-            String definitionTypeAnswer = askUserWithAuthorizedAnswer(session, "Which kind of definition do you want to load?" + getValuesWithNumber(values) + "\n",
-                    IntStream.range(1,values.size()+1).mapToObj(Integer::toString).collect(Collectors.toList()));
-            definitionType = values.get(new Integer(definitionTypeAnswer)-1);
-        }
-
-        if (!definitionTypes.contains(definitionType)) {
-            System.out.println("Invalid type '" + definitionType + "' , allowed values : " +definitionTypes);
-            return null;
-        }
-
-        String path = getDefinitionTypePath(definitionType);
-        List<URL> values = bundlesToUpdate.stream().flatMap(b->b.findEntries(path, "*.json", true) != null ? Collections.list(b.findEntries(path, "*.json", true)).stream() : Stream.empty()).collect(Collectors.toList());
-        if (values.isEmpty()) {
-            System.out.println("Couldn't find definitions in bundle with id: " + bundleIdentifier + " and definition path: " + path);
-            return null;
-        }
-
-        if (fileName == null) {
-            List<String> stringList = values.stream().map(u -> StringUtils.substringAfterLast(u.getFile(), "/")).sorted().collect(Collectors.toList());
-            stringList.add(0, "* (All)");
-            String fileNameAnswer = askUserWithAuthorizedAnswer(session, "Which file do you want to load ?" + getValuesWithNumber(stringList) + "\n",
-                    IntStream.range(1,stringList.size()+1).mapToObj(Integer::toString).collect(Collectors.toList()));
-            fileName = stringList.get(new Integer(fileNameAnswer)-1);
-        }
-        if (fileName.startsWith("*")) {
-            for (URL url : values) {
-                updateDefinition(definitionType, url);
-            }
-        } else {
-            if (!fileName.contains("/")) {
-                fileName = "/" + fileName;
-            }
-            if (!fileName.endsWith(".json")) {
-                fileName += ".json";
-            }
-
-            Optional<URL> optionalURL = values.stream().filter(u -> u.getFile().endsWith(fileName)).findFirst();
-            if (optionalURL.isPresent()) {
-                URL url = optionalURL.get();
-                updateDefinition(definitionType, url);
-            } else {
-                System.out.println("Couldn't find file " + fileName);
-                return null;
-            }
-        }
-
-        return null;
-    }
-
-    private String askUserWithAuthorizedAnswer(CommandSession session, String msg, List<String> authorizedAnswer) throws IOException {
-        String answer;
-        do {
-            answer = promptMessageToUser(session,msg);
-        } while (!authorizedAnswer.contains(answer.toLowerCase()));
-        return answer;
-    }
-
-    private String promptMessageToUser(CommandSession session, String msg) throws IOException {
-        LineReader reader = (LineReader) session.get(".jline.reader");
-        return reader.readLine(msg, null);
-    }
-
-    private String getValuesWithNumber(List<String> values) {
-        StringBuilder definitionTypesWithNumber = new StringBuilder();
-        for (int i = 0; i < values.size(); i++) {
-            definitionTypesWithNumber.append("\n").append(i+1).append(". ").append(values.get(i));
-        }
-        return definitionTypesWithNumber.toString();
-    }
-
-    private void updateDefinition(String definitionType, URL definitionURL) {
-        try {
-                    
-            switch (definitionType) {
-                case "condition":
-                    ConditionType conditionType = CustomObjectMapper.getObjectMapper().readValue(definitionURL, ConditionType.class);
-                    definitionsService.setConditionType(conditionType);
-                    break;
-                case "action":
-                    ActionType actionType = CustomObjectMapper.getObjectMapper().readValue(definitionURL, ActionType.class);
-                    definitionsService.setActionType(actionType);
-                    break;
-                case "goal":
-                    Goal goal = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Goal.class);
-                    goalsService.setGoal(goal);
-                    break;
-                case "campaign":
-                    Campaign campaign = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Campaign.class);
-                    goalsService.setCampaign(campaign);
-                    break;
-                case "persona":
-                    PersonaWithSessions persona = CustomObjectMapper.getObjectMapper().readValue(definitionURL, PersonaWithSessions.class);
-                    profileService.savePersonaWithSessions(persona);
-                    break;
-                case "property":
-                    PropertyType propertyType = CustomObjectMapper.getObjectMapper().readValue(definitionURL, PropertyType.class);
-                    profileService.setPropertyTypeTarget(definitionURL, propertyType);
-                    profileService.setPropertyType(propertyType);
-                    break;
-                case "rule":
-                    Rule rule = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Rule.class);
-                    rulesService.setRule(rule);
-                    break;
-                case "segment":
-                    Segment segment = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Segment.class);
-                    segmentService.setSegmentDefinition(segment);
-                    break;
-                case "scoring":
-                    Scoring scoring = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Scoring.class);
-                    segmentService.setScoringDefinition(scoring);
-                    break;
-                case "patch":
-                    Patch patch = CustomObjectMapper.getObjectMapper().readValue(definitionURL, Patch.class);
-                    patchService.patch(patch);
-                    break;
-            }
-            System.out.println("Predefined definition registered : "+definitionURL.getFile());
-        } catch (IOException e) {
-            System.out.println("Error while saving definition " + definitionURL);
-            System.out.println(e.getMessage());
-        }
-    }
-
-    private String getDefinitionTypePath(String definitionType) {
-        StringBuilder path = new StringBuilder("META-INF/cxs/");
-        switch (definitionType) {
-            case "condition":
-                path.append("conditions");
-                break;
-            case "action":
-                path.append("actions");
-                break;
-            case "goal":
-                path.append("goals");
-                break;
-            case "campaign":
-                path.append("campaigns");
-                break;
-            case "persona":
-                path.append("personas");
-                break;
-            case "property":
-                path.append("properties");
-                break;
-            case "rule":
-                path.append("rules");
-                break;
-            case "segment":
-                path.append("segments");
-                break;
-            case "scoring":
-                path.append("scoring");
-                break;
-            case "patch":
-                path.append("patches");
-                break;
-        }
-
-        return path.toString();
-    }
-
-    public void setDefinitionsService(DefinitionsService definitionsService) {
-        this.definitionsService = definitionsService;
-    }
-
-    public void setGoalsService(GoalsService goalsService) {
-        this.goalsService = goalsService;
-    }
-
-    public void setProfileService(ProfileService profileService) {
-        this.profileService = profileService;
-    }
-
-    public void setRulesService(RulesService rulesService) {
-        this.rulesService = rulesService;
-    }
-
-    public void setSegmentService(SegmentService segmentService) {
-        this.segmentService = segmentService;
-    }
-
-    public void setPatchService(PatchService patchService) {
-        this.patchService = patchService;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventTail.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventTail.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventTail.java
new file mode 100644
index 0000000..36ecdec
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventTail.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.unomi.shell.commands;
+
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.Event;
+import org.apache.unomi.api.services.EventListenerService;
+import org.apache.unomi.api.services.EventService;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+@Command(scope = "unomi", name = "event-tail", description = "This will tail all the events coming into the Apache Unomi Context Server")
+@Service
+public class EventTail extends TailCommandSupport  {
+
+    @Argument(index = 0, name = "withInternal", description = "Whether to also monitor internal events (such as profileUpdated)", required = false, multiValued = false)
+    boolean withInternal = false;
+
+    int[] columnSizes = new int[] { 36, 14, 36, 36, 29, 15, 5 };
+    String[] columnHeaders = new String[] {
+            "ID",
+            "Type",
+            "Session",
+            "Profile",
+            "Timestamp",
+            "Scope",
+            "Persistent"
+    };
+
+    @Override
+    public int[] getColumnSizes() {
+        return columnSizes;
+    }
+
+    @Override
+    public String[] getColumnHeaders() {
+        return columnHeaders;
+    }
+
+    @Override
+    public Object getListener() {
+        return new TailEventListener(session.getConsole());
+    }
+
+    class TailEventListener implements EventListenerService {
+
+        PrintStream out;
+
+        public TailEventListener(PrintStream out) {
+            this.out = out;
+        }
+
+        @Override
+        public boolean canHandle(Event event) {
+            return true;
+        }
+
+        @Override
+        public int onEvent(Event event) {
+            if (!event.isPersistent() && !withInternal) {
+                return EventService.NO_CHANGE;
+            }
+            List<String> eventInfo = new ArrayList<>();
+            eventInfo.add(event.getItemId());
+            eventInfo.add(event.getEventType());
+            eventInfo.add(event.getSessionId());
+            eventInfo.add(event.getProfileId());
+            eventInfo.add(event.getTimeStamp().toString());
+            eventInfo.add(event.getScope());
+            eventInfo.add(Boolean.toString(event.isPersistent()));
+            outputLine(out, eventInfo);
+            return EventService.NO_CHANGE;
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventTailCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventTailCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventTailCommand.java
deleted file mode 100644
index 51f4ece..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventTailCommand.java
+++ /dev/null
@@ -1,92 +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.unomi.shell.commands;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.unomi.api.Event;
-import org.apache.unomi.api.services.EventListenerService;
-import org.apache.unomi.api.services.EventService;
-
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-
-@Command(scope = "unomi", name = "event-tail", description = "This will tail all the events coming into the Apache Unomi Context Server")
-public class EventTailCommand extends TailCommandSupport  {
-
-    @Argument(index = 0, name = "withInternal", description = "Whether to also monitor internal events (such as profileUpdated)", required = false, multiValued = false)
-    boolean withInternal = false;
-
-    int[] columnSizes = new int[] { 36, 14, 36, 36, 29, 15, 5 };
-    String[] columnHeaders = new String[] {
-            "ID",
-            "Type",
-            "Session",
-            "Profile",
-            "Timestamp",
-            "Scope",
-            "Persistent"
-    };
-
-    @Override
-    public int[] getColumnSizes() {
-        return columnSizes;
-    }
-
-    @Override
-    public String[] getColumnHeaders() {
-        return columnHeaders;
-    }
-
-    @Override
-    public Object getListener() {
-        return new TailEventListener(session.getConsole());
-    }
-
-    class TailEventListener implements EventListenerService {
-
-        PrintStream out;
-
-        public TailEventListener(PrintStream out) {
-            this.out = out;
-        }
-
-        @Override
-        public boolean canHandle(Event event) {
-            return true;
-        }
-
-        @Override
-        public int onEvent(Event event) {
-            if (!event.isPersistent() && !withInternal) {
-                return EventService.NO_CHANGE;
-            }
-            List<String> eventInfo = new ArrayList<>();
-            eventInfo.add(event.getItemId());
-            eventInfo.add(event.getEventType());
-            eventInfo.add(event.getSessionId());
-            eventInfo.add(event.getProfileId());
-            eventInfo.add(event.getTimeStamp().toString());
-            eventInfo.add(event.getScope());
-            eventInfo.add(Boolean.toString(event.isPersistent()));
-            outputLine(out, eventInfo);
-            return EventService.NO_CHANGE;
-        }
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventView.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventView.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventView.java
new file mode 100644
index 0000000..10054dd
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventView.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.unomi.shell.commands;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.Event;
+import org.apache.unomi.api.PartialList;
+import org.apache.unomi.api.conditions.Condition;
+import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.api.services.EventService;
+import org.apache.unomi.persistence.spi.CustomObjectMapper;
+
+@Command(scope = "unomi", name = "event-view", description = "This command will dump an Event as a JSON object")
+@Service
+public class EventView implements Action {
+
+    @Reference
+    EventService eventService;
+
+    @Reference
+    DefinitionsService definitionsService;
+
+    @Argument(index = 0, name = "event", description = "The identifier for the event", required = true, multiValued = false)
+    String eventIdentifier;
+
+    public Object execute() throws Exception {
+
+        Condition eventCondition = new Condition(definitionsService.getConditionType("eventPropertyCondition"));
+        eventCondition.setParameter("propertyName", "itemId");
+        eventCondition.setParameter("comparisonOperator", "equals");
+        eventCondition.setParameter("propertyValue", eventIdentifier);
+
+        PartialList<Event> matchingEvents = eventService.searchEvents(eventCondition, 0, 10);
+        if (matchingEvents == null || matchingEvents.getTotalSize() != 1) {
+            System.out.println("Couldn't find a single event with id=" + eventIdentifier + ". Maybe it wasn't a persistent event ?");
+            return null;
+        }
+        String jsonEvent = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(matchingEvents.get(0));
+        System.out.println(jsonEvent);
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventViewCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventViewCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventViewCommand.java
deleted file mode 100644
index 9be10d5..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/EventViewCommand.java
+++ /dev/null
@@ -1,63 +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.unomi.shell.commands;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.unomi.api.Event;
-import org.apache.unomi.api.PartialList;
-import org.apache.unomi.api.conditions.Condition;
-import org.apache.unomi.api.services.DefinitionsService;
-import org.apache.unomi.api.services.EventService;
-import org.apache.unomi.persistence.spi.CustomObjectMapper;
-
-@Command(scope = "unomi", name = "event-view", description = "This command will dump an Event as a JSON object")
-public class EventViewCommand extends OsgiCommandSupport {
-
-    private EventService eventService;
-    private DefinitionsService definitionsService;
-
-    public void setEventService(EventService eventService) {
-        this.eventService = eventService;
-    }
-
-    public void setDefinitionsService(DefinitionsService definitionsService) {
-        this.definitionsService = definitionsService;
-    }
-
-    @Argument(index = 0, name = "event", description = "The identifier for the event", required = true, multiValued = false)
-    String eventIdentifier;
-
-    @Override
-    protected Object doExecute() throws Exception {
-
-        Condition eventCondition = new Condition(definitionsService.getConditionType("eventPropertyCondition"));
-        eventCondition.setParameter("propertyName", "itemId");
-        eventCondition.setParameter("comparisonOperator", "equals");
-        eventCondition.setParameter("propertyValue", eventIdentifier);
-
-        PartialList<Event> matchingEvents = eventService.searchEvents(eventCondition, 0, 10);
-        if (matchingEvents == null || matchingEvents.getTotalSize() != 1) {
-            System.out.println("Couldn't find a single event with id=" + eventIdentifier + ". Maybe it wasn't a persistent event ?");
-            return null;
-        }
-        String jsonEvent = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(matchingEvents.get(0));
-        System.out.println(jsonEvent);
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ListCommandSupport.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ListCommandSupport.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ListCommandSupport.java
index 20dde1f..dad45f1 100644
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ListCommandSupport.java
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ListCommandSupport.java
@@ -16,8 +16,8 @@
  */
 package org.apache.unomi.shell.commands;
 
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Option;
 import org.apache.karaf.shell.support.table.Row;
 import org.apache.karaf.shell.support.table.ShellTable;
 import org.apache.unomi.common.DataTable;
@@ -27,7 +27,7 @@ import java.util.ArrayList;
 /**
  * A utility class to make it easier to build tables for listing Apache Unomi objects.
  */
-public abstract class ListCommandSupport extends OsgiCommandSupport {
+public abstract class ListCommandSupport implements Action {
 
     @Option(name = "--csv", description = "Output table in CSV format", required = false, multiValued = false)
     boolean csv;
@@ -46,8 +46,7 @@ public abstract class ListCommandSupport extends OsgiCommandSupport {
      */
     protected abstract DataTable buildDataTable();
 
-    @Override
-    protected Object doExecute() throws Exception {
+    public Object execute() throws Exception {
 
         DataTable dataTable = buildDataTable();
 

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileList.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileList.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileList.java
new file mode 100644
index 0000000..14f16a9
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileList.java
@@ -0,0 +1,78 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.PartialList;
+import org.apache.unomi.api.Profile;
+import org.apache.unomi.api.conditions.Condition;
+import org.apache.unomi.api.query.Query;
+import org.apache.unomi.api.services.DefinitionsService;
+import org.apache.unomi.api.services.ProfileService;
+import org.apache.unomi.common.DataTable;
+
+import java.util.ArrayList;
+
+@Command(scope = "unomi", name = "profile-list", description = "This commands lists the latest profiles updated in the Apache Unomi Context Server")
+@Service
+public class ProfileList extends ListCommandSupport {
+
+    @Reference
+    ProfileService profileService;
+
+    @Reference
+    DefinitionsService definitionsService;
+
+    @Argument(index = 0, name = "maxEntries", description = "The maximum number of entries to retrieve (defaults to 100)", required = false, multiValued = false)
+    int maxEntries = 100;
+
+    @java.lang.Override
+    protected String[] getHeaders() {
+        return new String[] {
+                "ID",
+                "Scope",
+                "Segments",
+                "Consents",
+                "Last modification",
+        };
+    }
+
+    @java.lang.Override
+    protected DataTable buildDataTable() {
+        Query query = new Query();
+        query.setSortby("properties.lastVisit:desc");
+        query.setLimit(maxEntries);
+        Condition matchAllCondition = new Condition(definitionsService.getConditionType("matchAllCondition"));
+        query.setCondition(matchAllCondition);
+        PartialList<Profile> lastModifiedProfiles = profileService.search(query, Profile.class);
+        DataTable dataTable = new DataTable();
+        for (Profile profile : lastModifiedProfiles.getList()) {
+            ArrayList<Comparable> rowData = new ArrayList<>();
+            rowData.add(profile.getItemId());
+            rowData.add(profile.getScope());
+            rowData.add(StringUtils.join(profile.getSegments(), ","));
+            rowData.add(StringUtils.join(profile.getConsents().keySet(), ","));
+            rowData.add((String) profile.getProperty("lastVisit"));
+            dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
+        }
+        return dataTable;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileListCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileListCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileListCommand.java
deleted file mode 100644
index fe244c4..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileListCommand.java
+++ /dev/null
@@ -1,80 +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.unomi.shell.commands;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.unomi.api.PartialList;
-import org.apache.unomi.api.Profile;
-import org.apache.unomi.api.conditions.Condition;
-import org.apache.unomi.api.query.Query;
-import org.apache.unomi.api.services.DefinitionsService;
-import org.apache.unomi.api.services.ProfileService;
-import org.apache.unomi.common.DataTable;
-
-import java.util.ArrayList;
-
-@Command(scope = "unomi", name = "profile-list", description = "This commands lists the latest profiles updated in the Apache Unomi Context Server")
-public class ProfileListCommand extends ListCommandSupport {
-
-    private ProfileService profileService;
-    private DefinitionsService definitionsService;
-
-    public void setProfileService(ProfileService profileService) {
-        this.profileService = profileService;
-    }
-
-    public void setDefinitionsService(DefinitionsService definitionsService) {
-        this.definitionsService = definitionsService;
-    }
-
-    @Argument(index = 0, name = "maxEntries", description = "The maximum number of entries to retrieve (defaults to 100)", required = false, multiValued = false)
-    int maxEntries = 100;
-
-    @java.lang.Override
-    protected String[] getHeaders() {
-        return new String[] {
-                "ID",
-                "Scope",
-                "Segments",
-                "Consents",
-                "Last modification",
-        };
-    }
-
-    @java.lang.Override
-    protected DataTable buildDataTable() {
-        Query query = new Query();
-        query.setSortby("properties.lastVisit:desc");
-        query.setLimit(maxEntries);
-        Condition matchAllCondition = new Condition(definitionsService.getConditionType("matchAllCondition"));
-        query.setCondition(matchAllCondition);
-        PartialList<Profile> lastModifiedProfiles = profileService.search(query, Profile.class);
-        DataTable dataTable = new DataTable();
-        for (Profile profile : lastModifiedProfiles.getList()) {
-            ArrayList<Comparable> rowData = new ArrayList<>();
-            rowData.add(profile.getItemId());
-            rowData.add(profile.getScope());
-            rowData.add(StringUtils.join(profile.getSegments(), ","));
-            rowData.add(StringUtils.join(profile.getConsents().keySet(), ","));
-            rowData.add((String) profile.getProperty("lastVisit"));
-            dataTable.addRow(rowData.toArray(new Comparable[rowData.size()]));
-        }
-        return dataTable;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileView.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileView.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileView.java
new file mode 100644
index 0000000..8970579
--- /dev/null
+++ b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileView.java
@@ -0,0 +1,48 @@
+/*
+ * 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.unomi.shell.commands;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.unomi.api.Profile;
+import org.apache.unomi.api.services.ProfileService;
+import org.apache.unomi.persistence.spi.CustomObjectMapper;
+
+@Command(scope = "unomi", name = "profile-view", description = "This command will dump a profile as a JSON string")
+@Service
+public class ProfileView implements Action {
+
+    @Reference
+    ProfileService profileService;
+
+    @Argument(index = 0, name = "profile", description = "The identifier for the profile", required = true, multiValued = false)
+    String profileIdentifier;
+
+    public Object execute() throws Exception {
+        Profile profile = profileService.load(profileIdentifier);
+        if (profile == null) {
+            System.out.println("Couldn't find a profile with id=" + profileIdentifier);
+            return null;
+        }
+        String jsonProfile = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(profile);
+        System.out.println(jsonProfile);
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/e5075636/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileViewCommand.java
----------------------------------------------------------------------
diff --git a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileViewCommand.java b/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileViewCommand.java
deleted file mode 100644
index 34b77e3..0000000
--- a/tools/shell-dev-commands/src/main/java/org/apache/unomi/shell/commands/ProfileViewCommand.java
+++ /dev/null
@@ -1,49 +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.unomi.shell.commands;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.unomi.api.Profile;
-import org.apache.unomi.api.services.ProfileService;
-import org.apache.unomi.persistence.spi.CustomObjectMapper;
-
-@Command(scope = "unomi", name = "profile-view", description = "This command will dump a profile as a JSON string")
-public class ProfileViewCommand extends OsgiCommandSupport {
-
-    private ProfileService profileService;
-
-    public void setProfileService(ProfileService profileService) {
-        this.profileService = profileService;
-    }
-
-    @Argument(index = 0, name = "profile", description = "The identifier for the profile", required = true, multiValued = false)
-    String profileIdentifier;
-
-    @Override
-    protected Object doExecute() throws Exception {
-        Profile profile = profileService.load(profileIdentifier);
-        if (profile == null) {
-            System.out.println("Couldn't find a profile with id=" + profileIdentifier);
-            return null;
-        }
-        String jsonProfile = CustomObjectMapper.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(profile);
-        System.out.println(jsonProfile);
-        return null;
-    }
-}