Repository: karaf-cellar Updated Branches: refs/heads/master cdfa9b827 -> 3e5e7c339
http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java ---------------------------------------------------------------------- diff --git a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java index a37bf96..89d2a30 100644 --- a/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java +++ b/shell/src/main/java/org/apache/karaf/cellar/shell/producer/ProducerSupport.java @@ -18,7 +18,7 @@ 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.ClusterCommandSupport; -import org.apache.karaf.shell.table.ShellTable; +import org.apache.karaf.shell.support.table.ShellTable; import java.util.HashSet; import java.util.List; http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml ---------------------------------------------------------------------- diff --git a/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml b/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml deleted file mode 100644 index b5b2991..0000000 --- a/shell/src/main/resources/OSGI-INF/blueprint/shell-cluster.xml +++ /dev/null @@ -1,208 +0,0 @@ -<?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 xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> - <command> - <action class="org.apache.karaf.cellar.shell.NodesListCommand"> - <property name="clusterManager" ref="clusterManager"/> - </action> - </command> - <command> - <action class="org.apache.karaf.cellar.shell.NodePingCommand"> - <property name="clusterManager" ref="clusterManager"/> - <property name="executionContext" ref="executionContext"/> - </action> - <completers> - <ref component-id="allNodesCompleter"/> - </completers> - </command> - <command> - <action class="org.apache.karaf.cellar.shell.SyncCommand"> - <property name="clusterManager" ref="clusterManager"/> - <property name="groupManager" ref="groupManager"/> - <property name="configurationAdmin" ref="configurationAdmin"/> - </action> - </command> - <command> - <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> - <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> - <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> - <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> - <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> - <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> - <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> - <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> - <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> - <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="allGroupsCompleter"/> - <ref component-id="allNodesCompleter"/> - </completers> - </command> - <command> - <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"/> - <ref component-id="allNodesCompleter"/> - </completers> - </command> - <command> - <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="allGroupsCompleter"/> - <ref component-id="allNodesCompleter"/> - </completers> - </command> - <command> - <action class="org.apache.karaf.cellar.shell.group.GroupPickCommand"> - <property name="clusterManager" ref="clusterManager"/> - <property name="groupManager" ref="groupManager"/> - <property name="executionContext" ref="executionContext"/> - </action> - <completers> - <ref component-id="allGroupsCompleter"/> - </completers> - </command> - <command> - <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> - <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> - <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="allGroupsCompleter"/> - </completers> - </command> - </command-bundle> - - <reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager" availability="optional"/> - <reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager" availability="optional"/> - <reference id="executionContext" interface="org.apache.karaf.cellar.core.command.ExecutionContext" availability="optional"/> - <reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/> - - <bean id="allNodesCompleter" class="org.apache.karaf.cellar.core.shell.completer.AllNodeCompleter"> - <property name="clusterManager" ref="clusterManager"/> - </bean> - <bean id="allGroupsCompleter" class="org.apache.karaf.cellar.core.shell.completer.AllGroupsCompleter"> - <property name="groupManager" ref="groupManager"/> - </bean> - <bean id="localGroupCompleter" class="org.apache.karaf.cellar.core.shell.completer.LocalGroupsCompleter"> - <property name="groupManager" ref="groupManager"/> - </bean> - <bean id="otherGroupCompleter" class="org.apache.karaf.cellar.core.shell.completer.OtherGroupsCompleter"> - <property name="groupManager" ref="groupManager"/> - </bean> - -</blueprint> http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/utils/NOTICE ---------------------------------------------------------------------- diff --git a/utils/NOTICE b/utils/NOTICE index addb35c..64cb235 100644 --- a/utils/NOTICE +++ b/utils/NOTICE @@ -1,5 +1,5 @@ Apache Karaf Cellar -Copyright 2011-2014 The Apache Software Foundation +Copyright 2011-2015 The Apache Software Foundation I. Used Software http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/utils/pom.xml ---------------------------------------------------------------------- diff --git a/utils/pom.xml b/utils/pom.xml index 3c861bb..28d1d64 100644 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -38,12 +38,22 @@ <dependency> <groupId>org.apache.karaf.cellar</groupId> <artifactId>org.apache.karaf.cellar.core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.osgi</groupId> + <artifactId>org.osgi.core</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.compendium</artifactId> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.apache.karaf</groupId> + <artifactId>org.apache.karaf.util</artifactId> + </dependency> <!-- Logging Dependencies --> <dependency> @@ -56,17 +66,26 @@ <build> <plugins> <plugin> + <groupId>org.apache.karaf.tooling</groupId> + <artifactId>karaf-services-maven-plugin</artifactId> + </plugin> + <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <configuration> <instructions> <Export-Package> - org.apache.karaf.cellar.utils*;version="${project.version}" + !org.apache.karaf.cellar.utils.ping.internal, + org.apache.karaf.cellar.utils* </Export-Package> <Import-Package> - org.apache.karaf.cellar.core*;version="${project.version}", - org.osgi* + org.slf4j;version="[1.6,2)";resolution:=optional, + * </Import-Package> + <Private-Package> + org.apache.karaf.cellar.utils.ping.internal, + org.apache.karaf.util.tracker;-split-package:=merge-first + </Private-Package> </instructions> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/utils/src/main/java/org/apache/karaf/cellar/utils/ping/internal/osgi/Activator.java ---------------------------------------------------------------------- diff --git a/utils/src/main/java/org/apache/karaf/cellar/utils/ping/internal/osgi/Activator.java b/utils/src/main/java/org/apache/karaf/cellar/utils/ping/internal/osgi/Activator.java new file mode 100644 index 0000000..a82dbc5 --- /dev/null +++ b/utils/src/main/java/org/apache/karaf/cellar/utils/ping/internal/osgi/Activator.java @@ -0,0 +1,55 @@ +/* + * 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.internal.osgi; + +import org.apache.karaf.cellar.core.ClusterManager; +import org.apache.karaf.cellar.core.command.CommandStore; +import org.apache.karaf.cellar.core.event.EventHandler; +import org.apache.karaf.cellar.core.event.EventProducer; +import org.apache.karaf.cellar.utils.ping.PingHandler; +import org.apache.karaf.cellar.utils.ping.PongHandler; +import org.apache.karaf.util.tracker.BaseActivator; +import org.apache.karaf.util.tracker.annotation.ProvideService; +import org.apache.karaf.util.tracker.annotation.RequireService; +import org.apache.karaf.util.tracker.annotation.Services; +import org.osgi.service.cm.ConfigurationAdmin; + +@Services( + requires = { @RequireService(ClusterManager.class), @RequireService(CommandStore.class), @RequireService(EventProducer.class), @RequireService(ConfigurationAdmin.class)}, + provides = { @ProvideService(EventHandler.class)} +) +public class Activator extends BaseActivator { + + @Override + public void doStart() throws Exception { + // retrieving services + ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class); + ClusterManager clusterManager = getTrackedService(ClusterManager.class); + EventProducer eventProducer = getTrackedService(EventProducer.class); + CommandStore commandStore = getTrackedService(CommandStore.class); + + // registering ping event handler + PingHandler pingHandler = new PingHandler(); + pingHandler.setClusterManager(clusterManager); + pingHandler.setConfigurationAdmin(configurationAdmin); + pingHandler.setProducer(eventProducer); + register(EventHandler.class, pingHandler); + + // registering pong event handler + PongHandler pongHandler = new PongHandler(); + pongHandler.setCommandStore(commandStore); + register(EventHandler.class, pongHandler); + } + +} http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml deleted file mode 100644 index 85cfb16..0000000 --- a/utils/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ /dev/null @@ -1,35 +0,0 @@ -<?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"> - - <!-- Handler for the cluster ping event --> - <bean id="pingHandler" class="org.apache.karaf.cellar.utils.ping.PingHandler"> - <property name="producer" ref="producer"/> - </bean> - <service ref="pingHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/> - - <!-- Handler for the cluster pong event --> - <bean id="pongHandler" class="org.apache.karaf.cellar.utils.ping.PongHandler"> - <property name="commandStore" ref="commandStore"/> - </bean> - <service ref="pongHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"/> - - <reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager" availability="optional"/> - <reference id="commandStore" interface="org.apache.karaf.cellar.core.command.CommandStore" availability="optional"/> - <reference id="producer" interface="org.apache.karaf.cellar.core.event.EventProducer" filter="(!(type = group))" availability="optional"/> - <reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/> - -</blueprint> http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/webconsole/NOTICE ---------------------------------------------------------------------- diff --git a/webconsole/NOTICE b/webconsole/NOTICE index addb35c..64cb235 100644 --- a/webconsole/NOTICE +++ b/webconsole/NOTICE @@ -1,5 +1,5 @@ Apache Karaf Cellar -Copyright 2011-2014 The Apache Software Foundation +Copyright 2011-2015 The Apache Software Foundation I. Used Software http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/webconsole/pom.xml ---------------------------------------------------------------------- diff --git a/webconsole/pom.xml b/webconsole/pom.xml index 6073a33..02a229d 100644 --- a/webconsole/pom.xml +++ b/webconsole/pom.xml @@ -40,6 +40,10 @@ </dependency> <dependency> + <groupId>org.apache.karaf</groupId> + <artifactId>org.apache.karaf.util</artifactId> + </dependency> + <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> <scope>provided</scope> @@ -96,21 +100,29 @@ </resources> <plugins> <plugin> + <groupId>org.apache.karaf.tooling</groupId> + <artifactId>karaf-services-maven-plugin</artifactId> + </plugin> + <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <configuration> <instructions> <Export-Package> - org.apache.karaf.cellar.webconsole*;version="${project.version}" + !org.apache.karaf.cellar.webconsole.internal.osgi, + org.apache.karaf.cellar.webconsole* </Export-Package> <Import-Package> - org.apache.karaf.cellar.core*;version="${project.version}", - org.apache.felix.webconsole;version="[3,5)", - org.osgi.framework, - org.osgi.service.blueprint, - org.slf4j;version="[1.6,2)";resolution:=optional + org.slf4j;version="[1.6,2)";resolution:=optional, + javax.servlet*;version="[3,4)", + org.apache.felix.webconsole*;version="[3,5)", + * </Import-Package> <Embed-Dependency>json</Embed-Dependency> + <Private-Package> + org.apache.karaf.cellar.webconsole.internal.osgi, + org.apache.karaf.util.tracker;-split-package:=merge-first + </Private-Package> </instructions> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/internal/osgi/Activator.java ---------------------------------------------------------------------- diff --git a/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/internal/osgi/Activator.java b/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/internal/osgi/Activator.java new file mode 100644 index 0000000..43c2d48 --- /dev/null +++ b/webconsole/src/main/java/org/apache/karaf/cellar/webconsole/internal/osgi/Activator.java @@ -0,0 +1,70 @@ +/* + * 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.webconsole.internal.osgi; + +import org.apache.karaf.cellar.core.ClusterManager; +import org.apache.karaf.cellar.core.GroupManager; +import org.apache.karaf.cellar.webconsole.CellarPlugin; +import org.apache.karaf.util.tracker.BaseActivator; +import org.apache.karaf.util.tracker.annotation.ProvideService; +import org.apache.karaf.util.tracker.annotation.RequireService; +import org.apache.karaf.util.tracker.annotation.Services; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.Servlet; +import java.util.Hashtable; + +@Services( + provides = { + @ProvideService(Servlet.class) + }, + requires = { + @RequireService(ClusterManager.class), + @RequireService(GroupManager.class) + } +) +public class Activator extends BaseActivator { + + private final static Logger LOGGER = LoggerFactory.getLogger(Activator.class); + + private CellarPlugin plugin; + + @Override + public void doStart() throws Exception { + + ClusterManager clusterManager = getTrackedService(ClusterManager.class); + GroupManager groupManager = getTrackedService(GroupManager.class); + + LOGGER.debug("[CELLAR WEBCONSOLE] Init plugin"); + plugin = new CellarPlugin(); + plugin.setClusterManager(clusterManager); + plugin.setGroupManager(groupManager); + plugin.setBundleContext(bundleContext); + plugin.start(); + Hashtable props = new Hashtable(); + props.put("felix.webconsole.label", "cellar"); + register(Servlet.class, plugin, props); + + } + + @Override + public void doStop() { + if (plugin != null) { + plugin.stop(); + plugin = null; + } + } + +} http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml ---------------------------------------------------------------------- diff --git a/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml b/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml deleted file mode 100644 index 6c60241..0000000 --- a/webconsole/src/main/resources/OSGI-INF/blueprint/webconsole-cellar.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ---> -<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy"> - - <reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager"/> - <reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/> - - <bean id="cellarPlugin" class="org.apache.karaf.cellar.webconsole.CellarPlugin" init-method="start" - destroy-method="stop"> - <property name="bundleContext" ref="blueprintBundleContext"/> - <property name="groupManager" ref="groupManager"/> - <property name="clusterManager" ref="clusterManager"/> - </bean> - <service ref="cellarPlugin" interface="javax.servlet.Servlet"> - <service-properties> - <entry key="felix.webconsole.label" value="cellar"/> - </service-properties> - </service> - -</blueprint>
