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 <shu...@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 <shu...@apache.org>
Authored: Mon Dec 3 17:31:09 2018 +0100
Committer: Serge Huber <shu...@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;
-    }
-}

Reply via email to