You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by io...@apache.org on 2011/05/06 19:55:42 UTC

svn commit: r1100302 [5/5] - in /karaf/cellar: ./ branches/ tags/ trunk/ trunk/config/ trunk/config/src/ trunk/config/src/main/ trunk/config/src/main/java/ trunk/config/src/main/java/org/ trunk/config/src/main/java/org/apache/ trunk/config/src/main/jav...

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupDeleteCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupDeleteCommand.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupDeleteCommand.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupDeleteCommand.java Fri May  6 17:55:35 2011
@@ -0,0 +1,63 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.group;
+
+import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.Node;
+import org.apache.karaf.cellar.core.control.ManageGroupAction;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author iocanel
+ */
+@Command(scope = "cluster", name = "group-delete", description = "Deletes a group")
+public class GroupDeleteCommand extends GroupSupport {
+
+
+    @Argument(index = 0, name = "group", description = "The name of the group to delete", required = false, multiValued = false)
+    String group;
+
+    /**
+     * Execute the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected Object doExecute() throws Exception {
+        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+            Group g = groupManager.findGroupByName(group);
+            List<String> nodes = new LinkedList<String>();
+
+            if (g.getMembers() != null && !g.getMembers().isEmpty()) {
+                for (Node n : g.getMembers()) {
+                    nodes.add(n.getId());
+                }
+                doExecute(ManageGroupAction.QUIT, group, nodes);
+            }
+
+            groupManager.deleteGroup(group);
+        } finally {
+            Thread.currentThread().setContextClassLoader(originalClassLoader);
+        }
+        return null;
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupJoinCommand.java Fri May  6 17:55:35 2011
@@ -0,0 +1,46 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.group;
+
+import org.apache.karaf.cellar.core.control.ManageGroupAction;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+
+/**
+ * @author iocanel
+ */
+@Command(scope = "cluster", name = "group-join", description = "Manages nodes and groups")
+public class GroupJoinCommand extends GroupSupport {
+
+
+    @Argument(index = 0, name = "group", description = "The name of the group to join", required = false, multiValued = false)
+    String group;
+
+    @Argument(index = 1, name = "node", description = "The id of the node(s) to turn on/off event producer. If none specified current is assumed", required = false, multiValued = true)
+    List<String> nodes;
+
+    /**
+     * Execute the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected Object doExecute() throws Exception {
+        return doExecute(ManageGroupAction.JOIN, group, nodes);
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupListCommand.java Fri May  6 17:55:35 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.group;
+
+import org.apache.karaf.cellar.core.control.ManageGroupAction;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+
+/**
+ * @author iocanel
+ */
+@Command(scope = "cluster", name = "group-list", description = "Manages nodes and groups")
+public class GroupListCommand extends GroupSupport {
+
+    @Argument(index = 0, name = "node", description = "The id of the node(s) to turn on/off event producer", required = false, multiValued = true)
+    List<String> nodes;
+
+    /**
+     * Execute the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected Object doExecute() throws Exception {
+        return doExecute(ManageGroupAction.LIST, null, nodes);
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupQuitCommand.java Fri May  6 17:55:35 2011
@@ -0,0 +1,46 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.group;
+
+import org.apache.karaf.cellar.core.control.ManageGroupAction;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+
+/**
+ * @author iocanel
+ */
+@Command(scope = "cluster", name = "group-quit", description = "Manages nodes and groups")
+public class GroupQuitCommand extends GroupSupport {
+
+
+    @Argument(index = 0, name = "group", description = "The name of the group to join", required = false, multiValued = false)
+    String group;
+
+    @Argument(index = 1, name = "node", description = "The id of the node(s) to turn on/off event producer", required = false, multiValued = true)
+    List<String> nodes;
+
+    /**
+     * Execute the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected Object doExecute() throws Exception {
+        return doExecute(ManageGroupAction.QUIT, group, nodes);
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSetCommand.java Fri May  6 17:55:35 2011
@@ -0,0 +1,46 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.group;
+
+import org.apache.karaf.cellar.core.control.ManageGroupAction;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+
+/**
+ * @author: iocanel
+ */
+@Command(scope = "cluster", name = "group-set", description = "Set the target nodes to a specific group")
+public class GroupSetCommand extends GroupSupport {
+
+
+    @Argument(index = 0, name = "group", description = "The name of the group to join", required = false, multiValued = false)
+    String group;
+
+    @Argument(index = 1, name = "node", description = "The id of the node(s) to turn on/off event producer. If none specified current is assumed", required = false, multiValued = true)
+    List<String> nodes;
+
+    /**
+     * Execute the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected Object doExecute() throws Exception {
+        return doExecute(ManageGroupAction.SET, group, nodes);
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/group/GroupSupport.java Fri May  6 17:55:35 2011
@@ -0,0 +1,86 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.group;
+
+import org.apache.karaf.cellar.core.Group;
+import org.apache.karaf.cellar.core.Node;
+import org.apache.karaf.cellar.core.control.ManageGroupAction;
+import org.apache.karaf.cellar.core.control.ManageGroupCommand;
+import org.apache.karaf.cellar.core.control.ManageGroupResult;
+import org.apache.karaf.cellar.shell.ClusterCommandSuppot;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author iocanel
+ */
+public abstract class GroupSupport extends ClusterCommandSuppot {
+
+    protected static final String OUTPUT_FORMAT = "%1s %-20s %s";
+
+    /**
+     * Execut the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    protected Object doExecute(ManageGroupAction action, String group, Collection<String> nodes) throws Exception {
+        ManageGroupCommand command = new ManageGroupCommand(clusterManager.generateId());
+        Set<Node> recipientList = clusterManager.listNodes(nodes);
+
+        //Set the recipient list
+        if (recipientList != null && !recipientList.isEmpty()) {
+            command.setDestination(recipientList);
+        } else {
+            Set<Node> recipients = new HashSet<Node>();
+            recipients.add(clusterManager.getNode());
+            command.setDestination(recipients);
+        }
+
+        command.setAction(action);
+
+
+        if (group != null) {
+            command.setGroupName(group);
+        }
+
+        Map<Node, ManageGroupResult> results = executionContext.execute(command);
+        if (results == null || results.isEmpty()) {
+            System.out.println("No result received within given timeout");
+        } else {
+            System.out.println(String.format(OUTPUT_FORMAT, " ", "Node", "Group"));
+            for (Node node : results.keySet()) {
+                ManageGroupResult result = results.get(node);
+                if (result != null && result.getGroups() != null) {
+                    for (Group g : result.getGroups()) {
+                        if (g.getMembers() != null && !g.getMembers().isEmpty()) {
+                            for (Node memeber : g.getMembers()) {
+                                String name = g.getName();
+                                String mark = " ";
+                                if (memeber.equals(clusterManager.getNode()))
+                                    mark = "*";
+                                System.out.println(String.format(OUTPUT_FORMAT, mark, memeber.getId(), name));
+                            }
+                        } else System.out.println(String.format(OUTPUT_FORMAT, "", "", g.getName()));
+                    }
+                }
+            }
+        }
+        return null;
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStartCommand.java Fri May  6 17:55:35 2011
@@ -0,0 +1,68 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.handler;
+
+import org.apache.karaf.cellar.core.ClusterManager;
+import org.apache.karaf.cellar.core.command.ExecutionContext;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+
+/**
+ * @author iocanel
+ */
+@Command(scope = "cluster", name = "handlers", description = "Starts the handler of the specified nodes.")
+public class HandlersStartCommand extends HandlersSupport {
+
+    private static final String OUTPUT_FORMAT = "%-20s %-7s %s";
+
+    private ClusterManager clusterManager;
+    private ExecutionContext executionContext;
+
+    @Argument(index = 0, name = "handler-start", description = "The id of the event handler", required = false, multiValued = false)
+    String handler;
+
+    @Argument(index = 1, name = "node", description = "The id of the node(s)", required = false, multiValued = true)
+    List<String> nodes;
+
+
+    /**
+     * Execute the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected Object doExecute() throws Exception {
+        return doExecute(handler, nodes, Boolean.TRUE);
+    }
+
+    public ExecutionContext getExecutionContext() {
+        return executionContext;
+    }
+
+    public void setExecutionContext(ExecutionContext executionContext) {
+        this.executionContext = executionContext;
+    }
+
+    public ClusterManager getClusterManager() {
+        return clusterManager;
+    }
+
+    public void setClusterManager(ClusterManager clusterManager) {
+        this.clusterManager = clusterManager;
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStatusCommand.java Fri May  6 17:55:35 2011
@@ -0,0 +1,68 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.handler;
+
+import org.apache.karaf.cellar.core.ClusterManager;
+import org.apache.karaf.cellar.core.command.ExecutionContext;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+
+/**
+ * @author iocanel
+ */
+@Command(scope = "cluster", name = "handler-status", description = "Lists the handlers of the specified nodes.")
+public class HandlersStatusCommand extends HandlersSupport {
+
+    private static final String OUTPUT_FORMAT = "%-20s %-7s %s";
+
+    private ClusterManager clusterManager;
+    private ExecutionContext executionContext;
+
+    @Argument(index = 0, name = "handler-start", description = "The id of the event handler", required = false, multiValued = false)
+    String handler;
+
+    @Argument(index = 1, name = "node", description = "The id of the node(s)", required = false, multiValued = true)
+    List<String> nodes;
+
+
+    /**
+     * Execute the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected Object doExecute() throws Exception {
+        return doExecute(handler, nodes, null);
+    }
+
+    public ExecutionContext getExecutionContext() {
+        return executionContext;
+    }
+
+    public void setExecutionContext(ExecutionContext executionContext) {
+        this.executionContext = executionContext;
+    }
+
+    public ClusterManager getClusterManager() {
+        return clusterManager;
+    }
+
+    public void setClusterManager(ClusterManager clusterManager) {
+        this.clusterManager = clusterManager;
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersStopCommand.java Fri May  6 17:55:35 2011
@@ -0,0 +1,68 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.handler;
+
+import org.apache.karaf.cellar.core.ClusterManager;
+import org.apache.karaf.cellar.core.command.ExecutionContext;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+
+/**
+ * @author iocanel
+ */
+@Command(scope = "cluster", name = "handler-stop", description = "Stops the handler of the specified nodes.")
+public class HandlersStopCommand extends HandlersSupport {
+
+    private static final String OUTPUT_FORMAT = "%-20s %-7s %s";
+
+    private ClusterManager clusterManager;
+    private ExecutionContext executionContext;
+
+    @Argument(index = 0, name = "handler", description = "The id of the event handler", required = false, multiValued = false)
+    String handler;
+
+    @Argument(index = 1, name = "node", description = "The id of the node(s)", required = false, multiValued = true)
+    List<String> nodes;
+
+
+    /**
+     * Execute the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected Object doExecute() throws Exception {
+        return doExecute(handler, nodes, Boolean.FALSE);
+    }
+
+    public ExecutionContext getExecutionContext() {
+        return executionContext;
+    }
+
+    public void setExecutionContext(ExecutionContext executionContext) {
+        this.executionContext = executionContext;
+    }
+
+    public ClusterManager getClusterManager() {
+        return clusterManager;
+    }
+
+    public void setClusterManager(ClusterManager clusterManager) {
+        this.clusterManager = clusterManager;
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/handler/HandlersSupport.java Fri May  6 17:55:35 2011
@@ -0,0 +1,75 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.handler;
+
+import org.apache.karaf.cellar.core.Node;
+import org.apache.karaf.cellar.core.control.ManageHandlersCommand;
+import org.apache.karaf.cellar.core.control.ManageHandlersResult;
+import org.apache.karaf.cellar.shell.ClusterCommandSuppot;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author iocanel
+ */
+public abstract class HandlersSupport extends ClusterCommandSuppot {
+
+    protected static final String OUTPUT_FORMAT = "%-20s %-7s %s";
+
+    /**
+     * Execute the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    protected Object doExecute(String handler, List<String> nodes, Boolean status) throws Exception {
+        ManageHandlersCommand command = new ManageHandlersCommand(clusterManager.generateId());
+        Set<Node> recipientList = clusterManager.listNodes(nodes);
+
+        //Set the recipient list
+        if (recipientList != null && !recipientList.isEmpty()) {
+            command.setDestination(recipientList);
+        }
+
+        //Set the name of the handler.
+        if (handler != null && handler.length() > 2) {
+            handler = handler.substring(1);
+            handler = handler.substring(0, handler.length() - 1);
+            command.setHandlesName(handler);
+        }
+
+        command.setStatus(status);
+
+
+        Map<Node, ManageHandlersResult> results = executionContext.execute(command);
+        if (results == null || results.isEmpty()) {
+            System.out.println("No result received within given timeout");
+        } else {
+            System.out.println(String.format(OUTPUT_FORMAT, "Node", "Status", "Event Handler"));
+            for (Node node : results.keySet()) {
+                ManageHandlersResult result = results.get(node);
+                if (result != null && result.getHandlers() != null) {
+                    for (String h : result.getHandlers().keySet()) {
+                        String s = result.getHandlers().get(h);
+                        System.out.println(String.format(OUTPUT_FORMAT, node.getId(), s, handler));
+                    }
+                }
+            }
+        }
+        return null;
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStartCommand.java Fri May  6 17:55:35 2011
@@ -0,0 +1,43 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.producer;
+
+import org.apache.karaf.cellar.core.control.SwitchStatus;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+
+/**
+ * @author iocanel
+ */
+@Command(scope = "cluster", name = "producer-start", description = "Turns on the producer capabilities of a node.")
+public class ProducerStartCommand extends ProducerSupport {
+
+    @Argument(index = 0, name = "node", description = "The id of the node(s) to turn on/off event producer", required = false, multiValued = true)
+    List<String> nodes;
+
+
+    /**
+     * Execute the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected Object doExecute() throws Exception {
+        return doExecute(nodes, SwitchStatus.ON);
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStatusCommand.java Fri May  6 17:55:35 2011
@@ -0,0 +1,42 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.producer;
+
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+
+/**
+ * @author iocanel
+ */
+@Command(scope = "cluster", name = "producer-start", description = "Displays the producer capabilities of a node.")
+public class ProducerStatusCommand extends ProducerSupport {
+
+    @Argument(index = 0, name = "node", description = "The id of the node(s) to turn on/off event producer", required = false, multiValued = true)
+    List<String> nodes;
+
+
+    /**
+     * Execute the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected Object doExecute() throws Exception {
+        return doExecute(nodes, null);
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerStopCommand.java Fri May  6 17:55:35 2011
@@ -0,0 +1,43 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.producer;
+
+import org.apache.karaf.cellar.core.control.SwitchStatus;
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
+
+import java.util.List;
+
+/**
+ * @author iocanel
+ */
+@Command(scope = "cluster", name = "producer-stop", description = "Turns off the producer capabilities of a node.")
+public class ProducerStopCommand extends ProducerSupport {
+
+    @Argument(index = 0, name = "node", description = "The id of the node(s) to turn on/off event producer", required = false, multiValued = true)
+    List<String> nodes;
+
+
+    /**
+     * Execute the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    @Override
+    protected Object doExecute() throws Exception {
+        return doExecute(nodes, SwitchStatus.OFF);
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java (added)
+++ karaf/cellar/trunk/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java Fri May  6 17:55:35 2011
@@ -0,0 +1,65 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.shell.producer;
+
+import org.apache.karaf.cellar.core.Node;
+import org.apache.karaf.cellar.core.control.ProducerSwitchCommand;
+import org.apache.karaf.cellar.core.control.ProducerSwitchResult;
+import org.apache.karaf.cellar.core.control.SwitchStatus;
+import org.apache.karaf.cellar.shell.ClusterCommandSuppot;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author iocanel
+ */
+
+public abstract class ProducerSupport extends ClusterCommandSuppot {
+
+    protected static final String OUTPUT_FORMAT = "%-20s %s";
+
+    /**
+     * Execut the command.
+     *
+     * @return
+     * @throws Exception
+     */
+    protected Object doExecute(List<String> nodes, SwitchStatus status) throws Exception {
+        ProducerSwitchCommand command = new ProducerSwitchCommand(clusterManager.generateId());
+        Set<Node> recipientList = clusterManager.listNodes(nodes);
+
+        //Set the recipient list
+        if (recipientList != null && !recipientList.isEmpty()) {
+            command.setDestination(recipientList);
+        }
+
+        command.setStatus(status);
+
+
+        Map<Node, ProducerSwitchResult> results = executionContext.execute(command);
+        if (results == null || results.isEmpty()) {
+            System.out.println("No result received within given timeout");
+        } else {
+            System.out.println(String.format(OUTPUT_FORMAT, "Node", "Status"));
+            for (Node node : results.keySet()) {
+                ProducerSwitchResult result = results.get(node);
+                System.out.println(String.format(OUTPUT_FORMAT, node.getId(), result.getStatus()));
+            }
+        }
+        return null;
+    }
+}

Added: karaf/cellar/trunk/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml (added)
+++ karaf/cellar/trunk/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml Fri May  6 17:55:35 2011
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   Licensed 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="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
+
+    <!-- Command Bundle -->
+    <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.0.0">
+        <command name="cluster/list-nodes">
+            <action class="org.apache.karaf.cellar.shell.ListNodesCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+            </action>
+        </command>
+
+        <command name="cluster/ping">
+            <action class="org.apache.karaf.cellar.shell.PingCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+        </command>
+
+        <command name="cluster/consumer-start">
+            <action class="org.apache.karaf.cellar.shell.consumer.ConsumerStartCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="allNodesCompleter"/>
+            </completers>
+        </command>
+
+        <command name="cluster/consumer-stop">
+            <action class="org.apache.karaf.cellar.shell.consumer.ConsumerStopCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="allNodesCompleter"/>
+            </completers>
+        </command>
+
+        <command name="cluster/consumer-status">
+            <action class="org.apache.karaf.cellar.shell.consumer.ConsumerStatusCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="allNodesCompleter"/>
+            </completers>
+        </command>
+
+        <command name="cluster/producer-start">
+            <action class="org.apache.karaf.cellar.shell.producer.ProducerStartCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="allNodesCompleter"/>
+            </completers>
+        </command>
+
+        <command name="cluster/producer-stop">
+            <action class="org.apache.karaf.cellar.shell.producer.ProducerStopCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="allNodesCompleter"/>
+            </completers>
+        </command>
+
+        <command name="cluster/producer-status">
+            <action class="org.apache.karaf.cellar.shell.producer.ProducerStatusCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="allNodesCompleter"/>
+            </completers>
+        </command>
+
+        <command name="cluster/handler-start">
+            <action class="org.apache.karaf.cellar.shell.handler.HandlersStartCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="allNodesCompleter"/>
+            </completers>
+        </command>
+
+        <command name="cluster/handler-stop">
+            <action class="org.apache.karaf.cellar.shell.handler.HandlersStopCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="allNodesCompleter"/>
+            </completers>
+        </command>
+
+
+        <command name="cluster/handler-status">
+            <action class="org.apache.karaf.cellar.shell.handler.HandlersStatusCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="allNodesCompleter"/>
+            </completers>
+        </command>
+
+        <command name="cluster/group-join">
+            <action class="org.apache.karaf.cellar.shell.group.GroupJoinCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="groupManager" ref="groupManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="otherGroupCompleter"/>
+            </completers>
+        </command>
+
+        <command name="cluster/group-quit">
+            <action class="org.apache.karaf.cellar.shell.group.GroupQuitCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="groupManager" ref="groupManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="localGroupCompleter"/>
+            </completers>
+        </command>
+
+        <command name="cluster/group-set">
+            <action class="org.apache.karaf.cellar.shell.group.GroupSetCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="groupManager" ref="groupManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="allGroupCompleter"/>
+            </completers>
+        </command>
+
+        <command name="cluster/group-list">
+            <action class="org.apache.karaf.cellar.shell.group.GroupListCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="groupManager" ref="groupManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+        </command>
+
+        <command name="cluster/group-create">
+            <action class="org.apache.karaf.cellar.shell.group.GroupCreateCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="groupManager" ref="groupManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+        </command>
+
+        <command name="cluster/group-delete">
+            <action class="org.apache.karaf.cellar.shell.group.GroupDeleteCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="groupManager" ref="groupManager"/>
+                <property name="executionContext" ref="executionContext"/>
+            </action>
+            <completers>
+                <ref component-id="allGroupCompleter"/>
+            </completers>
+        </command>
+
+    </command-bundle>
+
+    <!-- Reference to the Cluster Manager -->
+    <reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
+    <reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/>
+    <reference id="executionContext" interface="org.apache.karaf.cellar.core.command.ExecutionContext"/>
+
+    <!-- Completers -->
+    <bean id="allNodesCompleter" class="org.apache.karaf.cellar.core.completers.AllNodeCompleter">
+        <property name="clusterManager" ref="clusterManager"/>
+    </bean>
+
+    <bean id="allGroupCompleter" class="org.apache.karaf.cellar.core.shell.completers.AllGroupsCompleter">
+        <property name="groupManager" ref="groupManager"/>
+    </bean>
+
+    <bean id="localGroupCompleter" class="org.apache.karaf.cellar.core.shell.completers.LocalGroupsCompleter">
+        <property name="groupManager" ref="groupManager"/>
+    </bean>
+
+    <bean id="otherGroupCompleter" class="org.apache.karaf.cellar.core.shell.completers.OtherGroupsCompleter">
+        <property name="groupManager" ref="groupManager"/>
+    </bean>
+
+</blueprint>

Added: karaf/cellar/trunk/src/main/resources/feature.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/src/main/resources/feature.xml?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/src/main/resources/feature.xml (added)
+++ karaf/cellar/trunk/src/main/resources/feature.xml Fri May  6 17:55:35 2011
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed 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.
+  -->
+
+<features>
+    <repository>mvn:org.apache.karaf.assemblies.features/standard/${karaf.version}/xml/features</repository>
+
+    <feature name='hazelcast' description='In memory data grid' version='${hazelcast.version}' resolver='(obr)'>
+        <bundle>mvn:com.hazelcast/hazelcast/${hazelcast.version}</bundle>
+    </feature>
+
+    <feature name='hazelcast-monitor' description='Hazelcast console' version='${hazelcast.version}' resolver='(obr)'>
+        <feature version='${hazelcast.version}'>hazelcast</feature>
+        <feature version='${karaf.version}'>war</feature>
+        <bundle>mvn:com.hazelcast/hazelcast-monitor/${hazelcast.version}/war</bundle>
+    </feature>
+
+    <feature name='cellar' description='Karaf clustering' version='${project.version}' resolver='(obr)'>
+        <feature version='${hazelcast.version}'>hazelcast</feature>
+        <feature version='${springdm.version}'>spring-dm</feature>
+        <bundle>mvn:org.apache.karaf.cellar/core/${project.version}</bundle>
+        <bundle>mvn:org.apache.karaf.cellar/config/${project.version}</bundle>
+        <bundle>mvn:org.apache.karaf.cellar/features/${project.version}</bundle>
+        <bundle>mvn:org.apache.karaf.cellar/utils/${project.version}</bundle>
+        <bundle>mvn:org.apache.karaf.cellar/shell/${project.version}</bundle>
+        <bundle>mvn:org.apache.karaf.cellar/hazelcast/${project.version}</bundle>
+        <configfile finalname="/etc/org.apache.karaf.cellar.groups.cfg">mvn:org.apache.karaf.cellar/cellar/${project.version}/cfg/groups
+        </configfile>
+        <configfile finalname="/etc/org.apache.karaf.cellar.node.cfg">mvn:org.apache.karaf.cellar/cellar/${project.version}/cfg/node</configfile>
+    </feature>
+
+</features>
\ No newline at end of file

Added: karaf/cellar/trunk/src/main/resources/groups.cfg
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/src/main/resources/groups.cfg?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/src/main/resources/groups.cfg (added)
+++ karaf/cellar/trunk/src/main/resources/groups.cfg Fri May  6 17:55:35 2011
@@ -0,0 +1,11 @@
+default.config.whitelist.inbound=*
+default.config.whitelist.outbound=*
+default.config.blacklist.inbound=org.apache.karaf.cellar.node,org.apache.karaf.management
+default.config.blacklist.outbound=org.apache.karaf.cellar.node,org.apache.karaf.management
+default.config.sync=true
+default.features.whitelist.inbound=*
+default.features.whitelist.outbound=*
+default.features.blacklist.inbound=cellar
+default.features.blacklist.outbound=cellar
+default.features.sync=true
+default.repositories.sync=true
\ No newline at end of file

Added: karaf/cellar/trunk/src/main/resources/node.cfg
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/src/main/resources/node.cfg?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/src/main/resources/node.cfg (added)
+++ karaf/cellar/trunk/src/main/resources/node.cfg Fri May  6 17:55:35 2011
@@ -0,0 +1 @@
+groups=default
\ No newline at end of file

Added: karaf/cellar/trunk/utils/pom.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/utils/pom.xml?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/utils/pom.xml (added)
+++ karaf/cellar/trunk/utils/pom.xml Fri May  6 17:55:35 2011
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.apache.karaf.cellar</groupId>
+        <artifactId>karaf-cellar</artifactId>
+        <version>1.0.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.karaf.cellar</groupId>
+    <artifactId>utils</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Karaf :: Cellar :: Utils</name>
+
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <osgi.import>
+            !org.apache.karaf.cellar.utils*;version=${project.version},
+            org.apache.karaf.cellar.core*;version=${project.version},
+            *
+        </osgi.import>
+        <osgi.dynamic.import>javax.*,org.w3c.*,org.xml.*</osgi.dynamic.import>
+        <osgi.export>
+            org.apache.karaf.cellar.utils*;version=${project.version}
+        </osgi.export>
+    </properties>
+
+    <dependencies>
+        <!-- Internal Dependencies -->
+        <dependency>
+            <groupId>org.apache.karaf.cellar</groupId>
+            <artifactId>core</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <!-- Configuration Admin -->
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.configadmin</artifactId>
+        </dependency>
+        <!-- Logging Dependencies -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>
\ No newline at end of file

Added: karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Ping.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Ping.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Ping.java (added)
+++ karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Ping.java Fri May  6 17:55:35 2011
@@ -0,0 +1,28 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.utils.ping;
+
+import org.apache.karaf.cellar.core.command.Command;
+
+/**
+ * @author iocanel
+ */
+public class Ping extends Command<Pong> {
+
+    public Ping(String id) {
+        super(id);
+    }
+
+}

Added: karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PingHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PingHandler.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PingHandler.java (added)
+++ karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PingHandler.java Fri May  6 17:55:35 2011
@@ -0,0 +1,44 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.utils.ping;
+
+import org.apache.karaf.cellar.core.command.CommandHandler;
+import org.apache.karaf.cellar.core.control.BasicSwitch;
+import org.apache.karaf.cellar.core.control.Switch;
+
+/**
+ * @author iocanel
+ */
+public class PingHandler extends CommandHandler<Ping, Pong> {
+
+    public static final String SWITCH_ID = "org.apache.karaf.cellar.command.ping.switch";
+
+    private final Switch commandSwitch = new BasicSwitch(SWITCH_ID);
+
+    @Override
+    public Pong execute(Ping command) {
+        return new Pong(command.getId());
+    }
+
+    @Override
+    public Class<Ping> getType() {
+        return Ping.class;
+    }
+
+    @Override
+    public Switch getSwitch() {
+        return commandSwitch;
+    }
+}

Added: karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Pong.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Pong.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Pong.java (added)
+++ karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/Pong.java Fri May  6 17:55:35 2011
@@ -0,0 +1,27 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.utils.ping;
+
+import org.apache.karaf.cellar.core.command.Result;
+
+/**
+ * @author iocanel
+ */
+public class Pong extends Result {
+
+    public Pong(String id) {
+        super(id);
+    }
+}

Added: karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PongHandler.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PongHandler.java?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PongHandler.java (added)
+++ karaf/cellar/trunk/utils/src/main/java/org/apache/karaf/cellar/utils/ping/PongHandler.java Fri May  6 17:55:35 2011
@@ -0,0 +1,28 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.karaf.cellar.utils.ping;
+
+import org.apache.karaf.cellar.core.command.ResultHandler;
+
+/**
+ * @author iocanel
+ */
+public class PongHandler extends ResultHandler<Pong> {
+
+    @Override
+    public Class<Pong> getType() {
+        return Pong.class;
+    }
+}

Added: karaf/cellar/trunk/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml?rev=1100302&view=auto
==============================================================================
--- karaf/cellar/trunk/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml (added)
+++ karaf/cellar/trunk/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml Fri May  6 17:55:35 2011
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Licensed 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="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="pingHandler" class="org.apache.karaf.cellar.utils.ping.PingHandler">
+        <property name="producer" ref="producer"/>
+
+    </bean>
+
+    <bean id="pongHandler" class="org.apache.karaf.cellar.utils.ping.PongHandler">
+        <property name="commandStore" ref="commandStore"/>
+    </bean>
+
+    <!-- OSGi Services  & References -->
+    <service ref="pingHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
+    <service ref="pongHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/>
+    <reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/>
+    <reference id="eventProducer" interface="org.apache.karaf.cellar.core.event.EventProducer"/>
+    <reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/>
+    <reference id="commandStore" interface="org.apache.karaf.cellar.core.command.CommandStore"/>
+    <reference id="producer" interface="org.apache.karaf.cellar.core.event.EventProducer"/>
+</blueprint>