[KARAF-3503] Complete refactoring to remove blueprint dependency and full support of Karaf 4, upgrade to Hazelcast 3.5.1
Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/3e5e7c33 Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/3e5e7c33 Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/3e5e7c33 Branch: refs/heads/master Commit: 3e5e7c339fd433be392127bb1cbeaa73f82369d5 Parents: cdfa9b8 Author: Jean-Baptiste Onofré <[email protected]> Authored: Wed Aug 26 07:39:53 2015 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Wed Aug 26 07:39:53 2015 +0200 ---------------------------------------------------------------------- NOTICE | 2 +- assembly/pom.xml | 87 +++-- assembly/src/main/resources/features.xml | 112 +++--- bundle/NOTICE | 2 +- bundle/pom.xml | 41 +- .../cellar/bundle/internal/osgi/Activator.java | 134 +++++++ .../karaf/cellar/bundle/shell/BlockCommand.java | 6 +- .../bundle/shell/BundleCommandSupport.java | 10 +- .../bundle/shell/InstallBundleCommand.java | 13 +- .../cellar/bundle/shell/ListBundleCommand.java | 8 +- .../cellar/bundle/shell/StartBundleCommand.java | 6 +- .../cellar/bundle/shell/StopBundleCommand.java | 7 +- .../bundle/shell/UninstallBundleCommand.java | 6 +- .../completers/AllBundlesNameCompleter.java | 14 +- .../completers/AllBundlesVersionCompleter.java | 14 +- .../resources/OSGI-INF/blueprint/blueprint.xml | 67 ---- .../resources/OSGI-INF/blueprint/management.xml | 36 -- .../OSGI-INF/blueprint/shell-bundle.xml | 104 ----- cloud/NOTICE | 2 +- cloud/pom.xml | 23 +- .../apache/karaf/cellar/cloud/Activator.java | 46 --- .../cellar/cloud/internal/osgi/Activator.java | 47 +++ config/NOTICE | 2 +- config/pom.xml | 34 +- .../cellar/config/internal/osgi/Activator.java | 135 +++++++ .../karaf/cellar/config/shell/BlockCommand.java | 13 +- .../cellar/config/shell/DeleteCommand.java | 13 +- .../karaf/cellar/config/shell/ListCommand.java | 11 +- .../cellar/config/shell/PropAppendCommand.java | 13 +- .../cellar/config/shell/PropDelCommand.java | 13 +- .../config/shell/PropExcludedCommand.java | 9 +- .../cellar/config/shell/PropListCommand.java | 11 +- .../cellar/config/shell/PropSetCommand.java | 13 +- .../completers/ClusterConfigCompleter.java | 16 +- .../resources/OSGI-INF/blueprint/blueprint.xml | 81 ---- .../resources/OSGI-INF/blueprint/management.xml | 31 -- .../OSGI-INF/blueprint/shell-config.xml | 115 ------ core/NOTICE | 2 +- core/pom.xml | 25 +- .../cellar/core/internal/osgi/Activator.java | 76 ++++ .../cellar/core/shell/CellarCommandSupport.java | 17 +- .../shell/completer/AllGroupsCompleter.java | 2 + .../core/shell/completer/AllNodeCompleter.java | 2 + .../shell/completer/GroupCompleterSupport.java | 12 +- .../shell/completer/LocalGroupsCompleter.java | 2 + .../shell/completer/NodeCompleterSupport.java | 12 +- .../shell/completer/OtherGroupsCompleter.java | 2 + .../resources/OSGI-INF/blueprint/blueprint.xml | 27 -- dosgi/NOTICE | 2 +- dosgi/pom.xml | 31 +- .../cellar/dosgi/internal/osgi/Activator.java | 117 ++++++ .../shell/ListDistributedServicesCommand.java | 6 +- .../resources/OSGI-INF/blueprint/blueprint.xml | 58 --- .../resources/OSGI-INF/blueprint/management.xml | 32 -- .../OSGI-INF/blueprint/shell-dosgi.xml | 25 -- event/NOTICE | 2 +- event/pom.xml | 25 +- .../cellar/event/internal/osgi/Activator.java | 97 +++++ .../resources/OSGI-INF/blueprint/blueprint.xml | 60 --- features/NOTICE | 2 +- features/pom.xml | 37 +- .../features/internal/osgi/Activator.java | 150 ++++++++ .../cellar/features/shell/BlockCommand.java | 11 +- .../features/shell/InstallFeatureCommand.java | 15 +- .../features/shell/ListFeaturesCommand.java | 17 +- .../cellar/features/shell/RepoAddCommand.java | 15 +- .../cellar/features/shell/RepoListCommand.java | 15 +- .../features/shell/RepoRemoveCommand.java | 15 +- .../features/shell/UninstallFeatureCommand.java | 13 +- .../resources/OSGI-INF/blueprint/blueprint.xml | 75 ---- .../resources/OSGI-INF/blueprint/management.xml | 36 -- .../OSGI-INF/blueprint/shell-features.xml | 110 ------ hazelcast/NOTICE | 2 +- hazelcast/pom.xml | 32 +- .../hazelcast/internal/osgi/Activator.java | 380 +++++++++++++++++++ .../resources/OSGI-INF/blueprint/blueprint.xml | 197 ---------- .../resources/OSGI-INF/blueprint/management.xml | 59 --- itests/pom.xml | 20 +- .../karaf/cellar/itests/CellarTestSupport.java | 167 ++++---- kubernetes/NOTICE | 2 +- kubernetes/pom.xml | 22 +- .../karaf/cellar/kubernetes/Activator.java | 46 --- .../kubernetes/KubernetesDiscoveryService.java | 12 +- .../kubernetes/internal/osgi/Activator.java | 45 +++ manual/NOTICE | 2 +- obr/NOTICE | 2 +- obr/pom.xml | 33 +- .../cellar/obr/internal/osgi/Activator.java | 130 +++++++ .../cellar/obr/shell/ObrAddUrlCommand.java | 11 +- .../cellar/obr/shell/ObrCommandSupport.java | 3 +- .../cellar/obr/shell/ObrDeployCommand.java | 13 +- .../karaf/cellar/obr/shell/ObrListCommand.java | 13 +- .../cellar/obr/shell/ObrListUrlCommand.java | 9 +- .../cellar/obr/shell/ObrRemoveUrlCommand.java | 11 +- .../resources/OSGI-INF/blueprint/blueprint.xml | 65 ---- .../resources/OSGI-INF/blueprint/management.xml | 30 -- .../OSGI-INF/blueprint/shell-commands.xml | 82 ---- pom.xml | 71 ++-- samples/camel-hazelcast-app/NOTICE | 2 +- samples/dosgi-greeter/NOTICE | 2 +- samples/dosgi-greeter/client/pom.xml | 17 +- .../dosgi/greeter/client/GreetCommand.java | 11 +- .../OSGI-INF/blueprint/shell-greeter.xml | 29 -- samples/dosgi-greeter/service/pom.xml | 24 +- .../dosgi/greeter/service/Activator.java | 48 +++ .../resources/OSGI-INF/blueprint/blueprint.xml | 39 -- samples/hazelcast-app/NOTICE | 2 +- samples/hazelcast-app/pom.xml | 2 +- shell/NOTICE | 2 +- shell/pom.xml | 33 +- .../cellar/shell/ClusterCommandSupport.java | 2 + .../karaf/cellar/shell/NodePingCommand.java | 9 +- .../karaf/cellar/shell/NodesListCommand.java | 7 +- .../apache/karaf/cellar/shell/SyncCommand.java | 14 +- .../shell/consumer/ConsumerStartCommand.java | 9 +- .../shell/consumer/ConsumerStatusCommand.java | 9 +- .../shell/consumer/ConsumerStopCommand.java | 9 +- .../cellar/shell/consumer/ConsumerSupport.java | 2 +- .../cellar/shell/group/GroupCreateCommand.java | 6 +- .../cellar/shell/group/GroupDeleteCommand.java | 9 +- .../cellar/shell/group/GroupJoinCommand.java | 11 +- .../cellar/shell/group/GroupListCommand.java | 9 +- .../cellar/shell/group/GroupPickCommand.java | 11 +- .../cellar/shell/group/GroupQuitCommand.java | 11 +- .../cellar/shell/group/GroupSetCommand.java | 11 +- .../karaf/cellar/shell/group/GroupSupport.java | 2 +- .../shell/handler/HandlersStartCommand.java | 9 +- .../shell/handler/HandlersStatusCommand.java | 9 +- .../shell/handler/HandlersStopCommand.java | 9 +- .../cellar/shell/handler/HandlersSupport.java | 2 +- .../shell/producer/ProducerStartCommand.java | 9 +- .../shell/producer/ProducerStatusCommand.java | 9 +- .../shell/producer/ProducerStopCommand.java | 9 +- .../cellar/shell/producer/ProducerSupport.java | 2 +- .../OSGI-INF/blueprint/shell-cluster.xml | 208 ---------- utils/NOTICE | 2 +- utils/pom.xml | 25 +- .../utils/ping/internal/osgi/Activator.java | 55 +++ .../resources/OSGI-INF/blueprint/blueprint.xml | 35 -- webconsole/NOTICE | 2 +- webconsole/pom.xml | 24 +- .../webconsole/internal/osgi/Activator.java | 70 ++++ .../OSGI-INF/blueprint/webconsole-cellar.xml | 37 -- 143 files changed, 2508 insertions(+), 2251 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/NOTICE ---------------------------------------------------------------------- diff --git a/NOTICE b/NOTICE index addb35c..64cb235 100644 --- a/NOTICE +++ b/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/assembly/pom.xml ---------------------------------------------------------------------- diff --git a/assembly/pom.xml b/assembly/pom.xml index 703c3c8..13f1e6a 100644 --- a/assembly/pom.xml +++ b/assembly/pom.xml @@ -33,6 +33,25 @@ <packaging>pom</packaging> <name>Apache Karaf :: Cellar :: Assembly</name> + <dependencies> + <dependency> + <groupId>org.apache.karaf.features</groupId> + <artifactId>framework</artifactId> + <version>${karaf.version}</version> + <type>kar</type> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.karaf.features</groupId> + <artifactId>standard</artifactId> + <version>${karaf.version}</version> + <classifier>features</classifier> + <type>xml</type> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> <resources> <resource> @@ -45,6 +64,45 @@ </resources> <plugins> <plugin> + <groupId>org.apache.karaf.tooling</groupId> + <artifactId>karaf-maven-plugin</artifactId> + <executions> + <execution> + <id>verify</id> + <phase>process-resources</phase> + <goals> + <goal>verify</goal> + </goals> + <configuration> + <descriptors> + <descriptor>mvn:org.apache.karaf.features/framework/${karaf.version}/xml/features</descriptor> + <descriptor>mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features</descriptor> + <descriptor>file:${project.build.directory}/classes/features.xml</descriptor> + </descriptors> + <distribution>org.apache.karaf.features:framework</distribution> + <javase>1.7</javase> + <framework> + <feature>framework</feature> + </framework> + <features> + <feature>hazelcast</feature> + <feature>cellar-core</feature> + <feature>cellar-hazelcast</feature> + <feature>cellar-shell</feature> + <feature>cellar</feature> + <feature>cellar-dosgi</feature> + <feature>cellar-obr</feature> + <feature>cellar-eventadmin</feature> + <feature>cellar-cloud</feature> + <!-- <feature>cellar-kubernetes</feature> --> + <feature>cellar-webconsole</feature> + </features> + <verifyTransitive>false</verifyTransitive> + </configuration> + </execution> + </executions> + </plugin> + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> @@ -136,35 +194,6 @@ </execution> </executions> </plugin> - <!-- - <plugin> - <groupId>org.apache.karaf.tooling</groupId> - <artifactId>karaf-maven-plugin</artifactId> - <version>${karaf.version}</version> - <executions> - <execution> - <id>features-generate-descriptor</id> - <phase>compile</phase> - <goals> - <goal>features-generate-descriptor</goal> - </goals> - <configuration> - <addBundlesToPrimaryFeature>false</addBundlesToPrimaryFeature> - </configuration> - </execution> - <execution> - <id>features-create-kar</id> - <phase>package</phase> - <goals> - <goal>features-create-kar</goal> - </goals> - <configuration> - <featuresFile>target/classes/features.xml</featuresFile> - </configuration> - </execution> - </executions> - </plugin> - --> </plugins> </build> http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/assembly/src/main/resources/features.xml ---------------------------------------------------------------------- diff --git a/assembly/src/main/resources/features.xml b/assembly/src/main/resources/features.xml index 076f306..df9fcc7 100644 --- a/assembly/src/main/resources/features.xml +++ b/assembly/src/main/resources/features.xml @@ -13,78 +13,95 @@ See the License for the specific language governing permissions and limitations under the License. --> -<features name="karaf-cellar-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> +<features name="karaf-cellar-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.3.0 http://karaf.apache.org/xmlns/features/v1.3.0"> <repository>mvn:org.apache.jclouds.karaf/jclouds-karaf/${jclouds.version}/xml/features</repository> <repository>mvn:io.fabric8/karaf-features/${fabric8.version}/xml/features</repository> - <feature name="cellar-core" description="Karaf clustering core" version="${project.version}" resolver="(obr)"> + <feature name="cellar-core" description="Karaf clustering core" version="${project.version}"> + <feature dependency="true">aries-proxy</feature> <configfile finalname="/etc/org.apache.karaf.cellar.groups.cfg">mvn:org.apache.karaf.cellar/apache-karaf-cellar/${project.version}/cfg/groups</configfile> <configfile finalname="/etc/org.apache.karaf.cellar.node.cfg">mvn:org.apache.karaf.cellar/apache-karaf-cellar/${project.version}/cfg/node</configfile> - <bundle start-level="30">mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.core/${project.version}</bundle> - <bundle start-level="31">mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.utils/${project.version}</bundle> + <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.core/${project.version}</bundle> </feature> - <feature name="hazelcast" description="In memory data grid" version="${hazelcast.version}" resolver="(obr)"> + <feature name="hazelcast" description="In memory data grid" version="${hazelcast.version}"> <configfile finalname="/etc/hazelcast.xml">mvn:org.apache.karaf.cellar/apache-karaf-cellar/${project.version}/xml/hazelcast</configfile> - <bundle start-level="30" dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle> - <bundle start-level="30" dependency="true">mvn:com.eclipsesource.minimal-json/minimal-json/0.9.2</bundle> - <bundle start-level="70">mvn:com.hazelcast/hazelcast-all/${hazelcast.version}</bundle> + <bundle>mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle> + <bundle>mvn:com.eclipsesource.minimal-json/minimal-json/0.9.2</bundle> + <bundle>mvn:com.hazelcast/hazelcast-all/${hazelcast.version}</bundle> </feature> - <feature name="cellar-hazelcast" description="Cellar implementation based on Hazelcast" version="${project.version}" resolver="(obr)"> + <feature name="cellar-hazelcast" description="Cellar implementation based on Hazelcast" version="${project.version}"> <feature version="${hazelcast.version}">hazelcast</feature> <feature version="${project.version}">cellar-core</feature> - <bundle start-level="70">mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast/${project.version}</bundle> + <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.hazelcast/${project.version}</bundle> + <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.utils/${project.version}</bundle> </feature> - <feature name="cellar-config" description="ConfigAdmin cluster support" version="${project.version}" resolver="(obr)"> - <feature version="${project.version}">cellar-core</feature> - <bundle start-level="40">mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.config/${project.version}</bundle> + <feature name="cellar-config" description="ConfigAdmin cluster support" version="${project.version}"> + <conditional> + <condition>config</condition> + <feature>cellar-hazelcast</feature> + <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.config/${project.version}</bundle> + </conditional> </feature> - <feature name="cellar-features" description="Karaf features cluster support" version="${project.version}" resolver="(obr)"> - <feature version="${project.version}">cellar-core</feature> - <bundle start-level="40">mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.features/${project.version}</bundle> + <feature name="cellar-features" description="Karaf features cluster support" version="${project.version}"> + <conditional> + <condition>feature</condition> + <feature>cellar-hazelcast</feature> + <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.features/${project.version}</bundle> + </conditional> </feature> - <feature name="cellar-bundle" description="Bundle cluster support" version="${project.version}" resolver="(obr)"> - <feature version="${project.version}">cellar-core</feature> - <bundle start-level="40">mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.bundle/${project.version}</bundle> + <feature name="cellar-bundle" description="Bundle cluster support" version="${project.version}"> + <conditional> + <condition>bundle</condition> + <feature>cellar-hazelcast</feature> + <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.bundle/${project.version}</bundle> + </conditional> </feature> - <feature name="cellar-shell" description="Cellar shell support" version="${project.version}" resolver="(obr)"> - <feature version="${project.version}">cellar-core</feature> - <bundle start-level="40">mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.shell/${project.version}</bundle> + <feature name="cellar-shell" description="Cellar shell support" version="${project.version}"> + <conditional> + <condition>shell</condition> + <feature>cellar-hazelcast</feature> + <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.shell/${project.version}</bundle> + </conditional> </feature> - <feature name="cellar" description="Karaf clustering" version="${project.version}" resolver="(obr)"> - <feature version="${project.version}">cellar-hazelcast</feature> - <feature version="${project.version}">cellar-shell</feature> - <feature version="${project.version}">cellar-config</feature> - <feature version="${project.version}">cellar-bundle</feature> - <feature version="${project.version}">cellar-features</feature> + <feature name="cellar" description="Karaf clustering" version="${project.version}"> + <feature>cellar-hazelcast</feature> + <feature>cellar-shell</feature> + <feature>cellar-config</feature> + <feature>cellar-bundle</feature> + <feature>cellar-features</feature> </feature> - <feature name="cellar-dosgi" description="DOSGi support" version="${project.version}" resolver="(obr)"> - <feature version="${project.version}">cellar-core</feature> + <feature name="cellar-dosgi" description="DOSGi support" version="${project.version}"> + <feature>cellar-hazelcast</feature> <bundle start-level="40">mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.dosgi/${project.version}</bundle> </feature> - <feature name="cellar-obr" description="OBR cluster support" version="${project.version}" resolver="(obr)"> - <feature>obr</feature> - <feature version="${project.version}">cellar-core</feature> - <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.obr/${project.version}</bundle> + <feature name="cellar-obr" description="OBR cluster support" version="${project.version}"> + <conditional> + <condition>obr</condition> + <feature>cellar-hazelcast</feature> + <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.obr/${project.version}</bundle> + </conditional> </feature> - <feature name="cellar-eventadmin" description="OSGi events broadcasting in clusters" version="${project.version}" resolver="(obr)"> - <feature>eventadmin</feature> - <feature version="${project.version}">cellar-core</feature> - <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.event/${project.version}</bundle> + <feature name="cellar-eventadmin" description="OSGi events broadcasting in clusters" version="${project.version}"> + <conditional> + <condition>eventadmin</condition> + <feature>cellar-hazelcast</feature> + <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.event/${project.version}</bundle> + </conditional> </feature> - <feature name="cellar-cloud" description="Cloud blobstore support in clusters" version="${project.version}" resolver="(obr)"> - <feature version="${project.version}">cellar-core</feature> + <feature name="cellar-cloud" description="Cloud blobstore support in clusters" version="${project.version}"> + <feature>cellar-hazelcast</feature> <feature version="${jclouds.version}">jclouds</feature> <!-- Adding S3 as the default Blobstore --> <feature>jclouds-aws-s3</feature> @@ -92,16 +109,17 @@ <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.cloud/${project.version}</bundle> </feature> - <feature name="cellar-kubernetes" description="Cellar kubernetes support in clusters" version="${project.version}" resolver="(obr)"> - <feature version="${project.version}">cellar-core</feature> + <feature name="cellar-kubernetes" description="Cellar kubernetes support in clusters" version="${project.version}"> <feature>fabric8-kubernetes-api</feature> - <bundle start-level="40">mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.kubernetes/${project.version}</bundle> + <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.kubernetes/${project.version}</bundle> </feature> - <feature name="cellar-webconsole" description="Cellar plugin for Karaf WebConsole" version="${project.version}" resolver="(obr)"> - <feature version="${project.version}">cellar</feature> - <feature>webconsole</feature> - <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.webconsole/${project.version}</bundle> + <feature name="cellar-webconsole" description="Cellar plugin for Karaf WebConsole" version="${project.version}"> + <conditional> + <condition>webconsole</condition> + <feature>cellar-hazelcast</feature> + <bundle>mvn:org.apache.karaf.cellar/org.apache.karaf.cellar.webconsole/${project.version}</bundle> + </conditional> </feature> </features> http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/NOTICE ---------------------------------------------------------------------- diff --git a/bundle/NOTICE b/bundle/NOTICE index addb35c..64cb235 100644 --- a/bundle/NOTICE +++ b/bundle/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/bundle/pom.xml ---------------------------------------------------------------------- diff --git a/bundle/pom.xml b/bundle/pom.xml index 0889b88..893578a 100644 --- a/bundle/pom.xml +++ b/bundle/pom.xml @@ -41,6 +41,14 @@ <scope>provided</scope> </dependency> <dependency> + <groupId>org.apache.karaf</groupId> + <artifactId>org.apache.karaf.util</artifactId> + </dependency> + <dependency> + <groupId>org.apache.karaf.shell</groupId> + <artifactId>org.apache.karaf.shell.core</artifactId> + </dependency> + <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> <scope>provided</scope> @@ -58,12 +66,6 @@ <scope>provided</scope> </dependency> - <!-- Shell table --> - <dependency> - <groupId>org.apache.karaf.shell</groupId> - <artifactId>org.apache.karaf.shell.table</artifactId> - </dependency> - <!-- Logging Dependencies --> <dependency> <groupId>org.slf4j</groupId> @@ -75,29 +77,28 @@ <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.bundle*;version="${project.version}" + !org.apache.karaf.cellar.bundle.management.internal, + !org.apache.karaf.cellar.bundle.internal.osgi, + org.apache.karaf.cellar.bundle* </Export-Package> <Import-Package> - javax.management*, - org.apache.karaf.cellar.core*;version="${project.version}", - org.apache.felix.service.command, - org.apache.felix.gogo.commands, - org.apache.karaf.shell.console;version="[3,5)", - org.apache.karaf.shell.console.commands;version="[3,5)", - org.apache.karaf.shell.console.completer;version="[3,5)", - org.apache.karaf.shell.commands;version="[3,5)", - org.apache.karaf.shell.table;version="[3,5)", - org.apache.karaf.features;version="[3,5)", - org.osgi*, - org.slf4j;version="[1.6,2)";resolution:=optional + org.slf4j;version="[1.6,2)";resolution:=optional, + org.apache.karaf.shell*;resolution:=optional, + * </Import-Package> <Private-Package> - org.apache.karaf.cellar.bundle.management.internal + org.apache.karaf.cellar.bundle.management.internal, + org.apache.karaf.cellar.bundle.internal.osgi, + org.apache.karaf.util.tracker;-split-package:=merge-first </Private-Package> </instructions> </configuration> http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java new file mode 100644 index 0000000..0dbb724 --- /dev/null +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/internal/osgi/Activator.java @@ -0,0 +1,134 @@ +/* + * 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.bundle.internal.osgi; + +import org.apache.karaf.cellar.bundle.BundleEventHandler; +import org.apache.karaf.cellar.bundle.BundleSynchronizer; +import org.apache.karaf.cellar.bundle.LocalBundleListener; +import org.apache.karaf.cellar.bundle.management.internal.CellarBundleMBeanImpl; +import org.apache.karaf.cellar.core.ClusterManager; +import org.apache.karaf.cellar.core.GroupManager; +import org.apache.karaf.cellar.core.Synchronizer; +import org.apache.karaf.cellar.core.event.EventHandler; +import org.apache.karaf.cellar.core.event.EventProducer; +import org.apache.karaf.features.FeaturesService; +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.framework.ServiceRegistration; +import org.osgi.service.cm.ConfigurationAdmin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Hashtable; + +@Services( + provides = { + @ProvideService(EventHandler.class), + @ProvideService(Synchronizer.class) + }, + requires = { + @RequireService(ClusterManager.class), + @RequireService(GroupManager.class), + @RequireService(ConfigurationAdmin.class), + @RequireService(EventProducer.class), + @RequireService(FeaturesService.class) + } +) +public class Activator extends BaseActivator { + + private final static Logger LOGGER = LoggerFactory.getLogger(Activator.class); + + private LocalBundleListener localBundleListener; + private BundleSynchronizer synchronizer; + private BundleEventHandler eventHandler; + private ServiceRegistration mbeanRegistration; + + @Override + public void doStart() throws Exception { + + ClusterManager clusterManager = getTrackedService(ClusterManager.class); + GroupManager groupManager = getTrackedService(GroupManager.class); + ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class); + EventProducer eventProducer = getTrackedService(EventProducer.class); + FeaturesService featuresService = getTrackedService(FeaturesService.class); + + LOGGER.debug("[CELLAR BUNDLE] Init even handler"); + eventHandler = new BundleEventHandler(); + eventHandler.setConfigurationAdmin(configurationAdmin); + eventHandler.setClusterManager(clusterManager); + eventHandler.setGroupManager(groupManager); + eventHandler.setBundleContext(bundleContext); + eventHandler.setFeaturesService(featuresService); + eventHandler.init(); + Hashtable props = new Hashtable(); + props.put("managed", "true"); + register(EventHandler.class, eventHandler, props); + + LOGGER.debug("[CELLAR BUNDLE] Init local listener"); + localBundleListener = new LocalBundleListener(); + localBundleListener.setClusterManager(clusterManager); + localBundleListener.setGroupManager(groupManager); + localBundleListener.setConfigurationAdmin(configurationAdmin); + localBundleListener.setEventProducer(eventProducer); + localBundleListener.setFeaturesService(featuresService); + localBundleListener.setBundleContext(bundleContext); + localBundleListener.init(); + + LOGGER.debug("[CELLAR BUNDLE] Init synchronizer"); + synchronizer = new BundleSynchronizer(); + synchronizer.setConfigurationAdmin(configurationAdmin); + synchronizer.setGroupManager(groupManager); + synchronizer.setClusterManager(clusterManager); + synchronizer.setBundleContext(bundleContext); + synchronizer.init(); + props = new Hashtable(); + props.put("resource", "bundle"); + register(Synchronizer.class, synchronizer, props); + + LOGGER.debug("[CELLAR BUNDLE] Register MBean"); + CellarBundleMBeanImpl mbean = new CellarBundleMBeanImpl(); + mbean.setClusterManager(clusterManager); + mbean.setConfigurationAdmin(configurationAdmin); + mbean.setGroupManager(groupManager); + mbean.setEventProducer(eventProducer); + mbean.setBundleContext(bundleContext); + props = new Hashtable(); + props.put("jmx.objectname", "org.apache.karaf.cellar:type=bundle,name=" + System.getProperty("karaf.name")); + mbeanRegistration = bundleContext.registerService(getInterfaceNames(mbean), mbean, props); + + } + + @Override + public void doStop() { + if (mbeanRegistration != null) { + mbeanRegistration.unregister(); + mbeanRegistration = null; + } + if (synchronizer != null) { + synchronizer.destroy(); + synchronizer = null; + } + if (localBundleListener != null) { + localBundleListener.destroy(); + localBundleListener = null; + } + if (eventHandler != null) { + eventHandler.destroy(); + eventHandler = null; + } + } + +} http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BlockCommand.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BlockCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BlockCommand.java index 7ad11eb..199a13c 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BlockCommand.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BlockCommand.java @@ -18,12 +18,14 @@ import org.apache.karaf.cellar.core.CellarSupport; import org.apache.karaf.cellar.core.Configurations; import org.apache.karaf.cellar.core.Group; import org.apache.karaf.cellar.core.event.EventType; -import org.apache.karaf.shell.commands.Command; -import org.apache.karaf.shell.commands.Option; +import org.apache.karaf.shell.api.action.Command; +import org.apache.karaf.shell.api.action.Option; +import org.apache.karaf.shell.api.action.lifecycle.Service; import java.util.*; @Command(scope = "cluster", name = "bundle-block", description = "Change the blocking policy for a bundle") +@Service public class BlockCommand extends BundleCommandSupport { @Option(name = "-in", description = "Update the inbound direction", required = false, multiValued = false) http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java index 66a73e5..6937307 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java @@ -17,8 +17,12 @@ import org.apache.karaf.cellar.bundle.BundleState; import org.apache.karaf.cellar.bundle.Constants; import org.apache.karaf.cellar.core.Configurations; import org.apache.karaf.cellar.core.shell.CellarCommandSupport; -import org.apache.karaf.shell.commands.Argument; +import org.apache.karaf.cellar.core.shell.completer.AllGroupsCompleter; +import org.apache.karaf.shell.api.action.Argument; +import org.apache.karaf.shell.api.action.Completion; +import org.apache.karaf.shell.api.action.lifecycle.Reference; import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; import org.osgi.framework.BundleEvent; import java.util.ArrayList; @@ -31,11 +35,15 @@ import java.util.regex.Pattern; public abstract class BundleCommandSupport extends CellarCommandSupport { @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false) + @Completion(AllGroupsCompleter.class) String groupName; @Argument(index = 1, name = "ids", description = "The list of bundle (identified by IDs or name or name/version) separated by whitespaces", required = false, multiValued = true) List<String> ids; + @Reference + protected BundleContext bundleContext; + protected abstract Object doExecute() throws Exception; /** http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java index 3f86aac..eee3cf9 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/InstallBundleCommand.java @@ -23,9 +23,13 @@ import org.apache.karaf.cellar.core.control.SwitchStatus; import org.apache.karaf.cellar.core.event.EventProducer; import org.apache.karaf.cellar.core.event.EventType; import org.apache.karaf.cellar.core.shell.CellarCommandSupport; -import org.apache.karaf.shell.commands.Argument; -import org.apache.karaf.shell.commands.Command; -import org.apache.karaf.shell.commands.Option; +import org.apache.karaf.cellar.core.shell.completer.AllGroupsCompleter; +import org.apache.karaf.shell.api.action.Argument; +import org.apache.karaf.shell.api.action.Command; +import org.apache.karaf.shell.api.action.Completion; +import org.apache.karaf.shell.api.action.Option; +import org.apache.karaf.shell.api.action.lifecycle.Reference; +import org.apache.karaf.shell.api.action.lifecycle.Service; import org.osgi.framework.BundleEvent; import java.net.URL; @@ -35,9 +39,11 @@ import java.util.jar.JarInputStream; import java.util.jar.Manifest; @Command(scope = "cluster", name = "bundle-install", description = "Install bundles in a cluster group") +@Service public class InstallBundleCommand extends CellarCommandSupport { @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false) + @Completion(AllGroupsCompleter.class) String groupName; @Argument(index = 1, name = "urls", description = "Bundle URLs separated by whitespace", required = true, multiValued = true) @@ -46,6 +52,7 @@ public class InstallBundleCommand extends CellarCommandSupport { @Option(name = "-s", aliases = {"--start"}, description = "Start the bundle after installation", required = false, multiValued = false) boolean start; + @Reference private EventProducer eventProducer; @Override http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java index 165d5de..b935dd1 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/ListBundleCommand.java @@ -18,14 +18,16 @@ import org.apache.karaf.cellar.bundle.Constants; import org.apache.karaf.cellar.core.CellarSupport; import org.apache.karaf.cellar.core.Group; import org.apache.karaf.cellar.core.event.EventType; -import org.apache.karaf.shell.commands.Command; -import org.apache.karaf.shell.commands.Option; -import org.apache.karaf.shell.table.ShellTable; +import org.apache.karaf.shell.api.action.Command; +import org.apache.karaf.shell.api.action.Option; +import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.karaf.shell.support.table.ShellTable; import org.osgi.framework.BundleEvent; import java.util.*; @Command(scope = "cluster", name = "bundle-list", description = "List the bundles in a cluster group") +@Service public class ListBundleCommand extends BundleCommandSupport { @Option(name = "-s", aliases = {}, description = "Shows the symbolic name", required = false, multiValued = false) http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java index 552d753..c1e773f 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StartBundleCommand.java @@ -22,15 +22,19 @@ import org.apache.karaf.cellar.core.Group; import org.apache.karaf.cellar.core.control.SwitchStatus; import org.apache.karaf.cellar.core.event.EventProducer; import org.apache.karaf.cellar.core.event.EventType; -import org.apache.karaf.shell.commands.Command; +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.osgi.framework.BundleEvent; import java.util.List; import java.util.Map; @Command(scope = "cluster", name = "bundle-start", description = "Start bundles in a cluster group") +@Service public class StartBundleCommand extends BundleCommandSupport { + @Reference private EventProducer eventProducer; @Override http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java index d91aa9a..6f5968c 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/StopBundleCommand.java @@ -22,14 +22,19 @@ import org.apache.karaf.cellar.core.Group; import org.apache.karaf.cellar.core.control.SwitchStatus; import org.apache.karaf.cellar.core.event.EventProducer; import org.apache.karaf.cellar.core.event.EventType; -import org.apache.karaf.shell.commands.Command; +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.osgi.framework.BundleEvent; import java.util.List; import java.util.Map; @Command(scope = "cluster", name = "bundle-stop", description = "Stop a bundle in a cluster group") +@Service public class StopBundleCommand extends BundleCommandSupport { + + @Reference private EventProducer eventProducer; @Override http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java index 760a58a..fd9f8d5 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UninstallBundleCommand.java @@ -22,15 +22,19 @@ import org.apache.karaf.cellar.core.Group; import org.apache.karaf.cellar.core.control.SwitchStatus; import org.apache.karaf.cellar.core.event.EventProducer; import org.apache.karaf.cellar.core.event.EventType; -import org.apache.karaf.shell.commands.Command; +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.osgi.framework.BundleEvent; import java.util.List; import java.util.Map; @Command(scope = "cluster", name = "bundle-uninstall", description = "Uninstall a bundle from a cluster group") +@Service public class UninstallBundleCommand extends BundleCommandSupport { + @Reference private EventProducer eventProducer; @Override http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/completers/AllBundlesNameCompleter.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/completers/AllBundlesNameCompleter.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/completers/AllBundlesNameCompleter.java index 2da8af3..1719299 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/completers/AllBundlesNameCompleter.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/completers/AllBundlesNameCompleter.java @@ -13,8 +13,12 @@ */ package org.apache.karaf.cellar.bundle.shell.completers; -import org.apache.karaf.shell.console.Completer; -import org.apache.karaf.shell.console.completer.StringsCompleter; +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.CommandLine; +import org.apache.karaf.shell.api.console.Completer; +import org.apache.karaf.shell.api.console.Session; +import org.apache.karaf.shell.support.completers.StringsCompleter; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; @@ -23,16 +27,18 @@ import java.util.List; /** * Completer on all bundle symbolic name. */ +@Service public class AllBundlesNameCompleter implements Completer { + @Reference private BundleContext bundleContext; - public int complete(String buffer, int cursor, List<String> candidates) { + public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); for (Bundle bundle : bundleContext.getBundles()) { delegate.getStrings().add(bundle.getSymbolicName()); } - return delegate.complete(buffer, cursor, candidates); + return delegate.complete(session, commandLine, candidates); } public BundleContext getBundleContext() { http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/completers/AllBundlesVersionCompleter.java ---------------------------------------------------------------------- diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/completers/AllBundlesVersionCompleter.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/completers/AllBundlesVersionCompleter.java index a547e5e..4c6a00c 100644 --- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/completers/AllBundlesVersionCompleter.java +++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/completers/AllBundlesVersionCompleter.java @@ -13,8 +13,12 @@ */ package org.apache.karaf.cellar.bundle.shell.completers; -import org.apache.karaf.shell.console.Completer; -import org.apache.karaf.shell.console.completer.StringsCompleter; +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.CommandLine; +import org.apache.karaf.shell.api.console.Completer; +import org.apache.karaf.shell.api.console.Session; +import org.apache.karaf.shell.support.completers.StringsCompleter; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; @@ -23,16 +27,18 @@ import java.util.List; /** * Completer on all bundle version.. */ +@Service public class AllBundlesVersionCompleter implements Completer { + @Reference private BundleContext bundleContext; - public int complete(String buffer, int cursor, List<String> candidates) { + public int complete(Session session, CommandLine commandLine, List<String> candidates) { StringsCompleter delegate = new StringsCompleter(); for (Bundle bundle : bundleContext.getBundles()) { delegate.getStrings().add(bundle.getHeaders().get("Bundle-Version").toString()); } - return delegate.complete(buffer, cursor, candidates); + return delegate.complete(session, commandLine, candidates); } public BundleContext getBundleContext() { http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml ---------------------------------------------------------------------- diff --git a/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml deleted file mode 100644 index ec986e7..0000000 --- a/bundle/src/main/resources/OSGI-INF/blueprint/blueprint.xml +++ /dev/null @@ -1,67 +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 default-availability="mandatory" - xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 - http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"> - - <!-- Local Bundle Listener --> - <bean id="localListener" class="org.apache.karaf.cellar.bundle.LocalBundleListener" init-method="init" - destroy-method="destroy"> - <property name="clusterManager" ref="clusterManager"/> - <property name="groupManager" ref="groupManager"/> - <property name="configurationAdmin" ref="configurationAdmin"/> - <property name="bundleContext" ref="blueprintBundleContext"/> - <property name="eventProducer" ref="eventProducer"/> - <property name="featuresService" ref="featuresService"/> - </bean> - - <!-- Bundle Synchronizer --> - <bean id="synchronizer" class="org.apache.karaf.cellar.bundle.BundleSynchronizer" - init-method="init" destroy-method="destroy" depends-on="eventHandler"> - <property name="configurationAdmin" ref="configurationAdmin"/> - <property name="groupManager" ref="groupManager"/> - <property name="clusterManager" ref="clusterManager"/> - <property name="bundleContext" ref="blueprintBundleContext"/> - </bean> - <service ref="synchronizer" interface="org.apache.karaf.cellar.core.Synchronizer"> - <service-properties> - <entry key="resource" value="bundle"/> - </service-properties> - </service> - - <!-- Cluster Bundle Event Handler --> - <bean id="eventHandler" class="org.apache.karaf.cellar.bundle.BundleEventHandler" - init-method="init" destroy-method="destroy"> - <property name="configurationAdmin" ref="configurationAdmin"/> - <property name="clusterManager" ref="clusterManager"/> - <property name="bundleContext" ref="blueprintBundleContext"/> - <property name="groupManager" ref="groupManager"/> - <property name="featuresService" ref="featuresService"/> - </bean> - <service ref="eventHandler" interface="org.apache.karaf.cellar.core.event.EventHandler"> - <service-properties> - <entry key="managed" value="true"/> - </service-properties> - </service> - - <!-- Cluster Core Services --> - <reference id="clusterManager" interface="org.apache.karaf.cellar.core.ClusterManager"/> - <reference id="groupManager" interface="org.apache.karaf.cellar.core.GroupManager" /> - <reference id="configurationAdmin" interface="org.osgi.service.cm.ConfigurationAdmin"/> - <reference id="eventProducer" interface="org.apache.karaf.cellar.core.event.EventProducer"/> - <reference id="featuresService" interface="org.apache.karaf.features.FeaturesService"/> - -</blueprint> http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/resources/OSGI-INF/blueprint/management.xml ---------------------------------------------------------------------- diff --git a/bundle/src/main/resources/OSGI-INF/blueprint/management.xml b/bundle/src/main/resources/OSGI-INF/blueprint/management.xml deleted file mode 100644 index 02ceeb7..0000000 --- a/bundle/src/main/resources/OSGI-INF/blueprint/management.xml +++ /dev/null @@ -1,36 +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 default-availability="mandatory" - xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" - xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"> - - <!-- system properties --> - <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]" /> - - <!-- Cellar Bundle MBean --> - <bean id="cellarBundleMBean" class="org.apache.karaf.cellar.bundle.management.internal.CellarBundleMBeanImpl"> - <property name="clusterManager" ref="clusterManager"/> - <property name="groupManager" ref="groupManager"/> - <property name="eventProducer" ref="eventProducer"/> - <property name="configurationAdmin" ref="configurationAdmin"/> - <property name="bundleContext" ref="blueprintBundleContext"/> - </bean> - <service ref="cellarBundleMBean" auto-export="interfaces"> - <service-properties> - <entry key="jmx.objectname" value="org.apache.karaf.cellar:type=bundle,name=$[karaf.name]"/> - </service-properties> - </service> - -</blueprint> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml ---------------------------------------------------------------------- diff --git a/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml b/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml deleted file mode 100644 index f8862e8..0000000 --- a/bundle/src/main/resources/OSGI-INF/blueprint/shell-bundle.xml +++ /dev/null @@ -1,104 +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.bundle.shell.ListBundleCommand"> - <property name="clusterManager" ref="clusterManager"/> - <property name="groupManager" ref="groupManager"/> - <property name="configurationAdmin" ref="configurationAdmin"/> - </action> - <completers> - <ref component-id="allGroupsCompleter"/> - </completers> - </command> - <command> - <action class="org.apache.karaf.cellar.bundle.shell.InstallBundleCommand"> - <property name="clusterManager" ref="clusterManager"/> - <property name="groupManager" ref="groupManager"/> - <property name="eventProducer" ref="eventProducer"/> - <property name="configurationAdmin" ref="configurationAdmin"/> - </action> - <completers> - <ref component-id="allGroupsCompleter"/> - </completers> - </command> - <command> - <action class="org.apache.karaf.cellar.bundle.shell.UninstallBundleCommand"> - <property name="clusterManager" ref="clusterManager"/> - <property name="groupManager" ref="groupManager"/> - <property name="eventProducer" ref="eventProducer"/> - <property name="configurationAdmin" ref="configurationAdmin"/> - </action> - <completers> - <ref component-id="allGroupsCompleter"/> - <ref component-id="allBundlesNameCompleter"/> - <ref component-id="allBundlesVersionCompleter"/> - </completers> - </command> - <command> - <action class="org.apache.karaf.cellar.bundle.shell.StartBundleCommand"> - <property name="clusterManager" ref="clusterManager"/> - <property name="groupManager" ref="groupManager"/> - <property name="eventProducer" ref="eventProducer"/> - <property name="configurationAdmin" ref="configurationAdmin"/> - </action> - <completers> - <ref component-id="allGroupsCompleter"/> - <ref component-id="allBundlesNameCompleter"/> - <ref component-id="allBundlesVersionCompleter"/> - </completers> - </command> - <command> - <action class="org.apache.karaf.cellar.bundle.shell.StopBundleCommand"> - <property name="clusterManager" ref="clusterManager"/> - <property name="groupManager" ref="groupManager"/> - <property name="eventProducer" ref="eventProducer"/> - <property name="configurationAdmin" ref="configurationAdmin"/> - </action> - <completers> - <ref component-id="allGroupsCompleter"/> - <ref component-id="allBundlesNameCompleter"/> - <ref component-id="allBundlesVersionCompleter"/> - </completers> - </command> - <command> - <action class="org.apache.karaf.cellar.bundle.shell.BlockCommand"> - <property name="clusterManager" ref="clusterManager"/> - <property name="groupManager" ref="groupManager"/> - <property name="configurationAdmin" ref="configurationAdmin"/> - </action> - <completers> - <ref component-id="allGroupsCompleter"/> - <ref component-id="allBundlesNameCompleter"/> - <ref component-id="allBundlesVersionCompleter"/> - </completers> - </command> - </command-bundle> - - <bean id="allGroupsCompleter" class="org.apache.karaf.cellar.core.shell.completer.AllGroupsCompleter"> - <property name="groupManager" ref="groupManager"/> - </bean> - - <bean id="allBundlesNameCompleter" class="org.apache.karaf.cellar.bundle.shell.completers.AllBundlesNameCompleter"> - <property name="bundleContext" ref="blueprintBundleContext"/> - </bean> - - <bean id="allBundlesVersionCompleter" class="org.apache.karaf.cellar.bundle.shell.completers.AllBundlesVersionCompleter"> - <property name="bundleContext" ref="blueprintBundleContext"/> - </bean> - -</blueprint> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/cloud/NOTICE ---------------------------------------------------------------------- diff --git a/cloud/NOTICE b/cloud/NOTICE index addb35c..64cb235 100644 --- a/cloud/NOTICE +++ b/cloud/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/cloud/pom.xml ---------------------------------------------------------------------- diff --git a/cloud/pom.xml b/cloud/pom.xml index b47c5d0..3ad433e 100644 --- a/cloud/pom.xml +++ b/cloud/pom.xml @@ -40,6 +40,10 @@ <groupId>org.apache.karaf.cellar</groupId> <artifactId>org.apache.karaf.cellar.core</artifactId> </dependency> + <dependency> + <groupId>org.apache.karaf</groupId> + <artifactId>org.apache.karaf.util</artifactId> + </dependency> <!-- JClouds Dependencies --> <dependency> @@ -89,22 +93,27 @@ <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.cloud*;version="${project.version}" + !org.apache.karaf.cellar.cloud.internal.osgi, + org.apache.karaf.cellar.cloud* </Export-Package> <Import-Package> - org.joda.time;version="${joda-time.version}", - org.joda.time.chrono;version="${joda-time.version}", - org.apache.karaf.cellar.core*;version="${project.version}", - org.osgi*, - org.slf4j;version="[1.6,2)";resolution:=optional + org.slf4j;version="[1.6,2)";resolution:=optional, + * </Import-Package> + <Private-Package> + org.apache.karaf.cellar.cloud.internal.osgi, + org.apache.karaf.util.tracker;-split-package:=merge-first + </Private-Package> <DynamicImport-Package>org.jclouds.*</DynamicImport-Package> - <Bundle-Activator>org.apache.karaf.cellar.cloud.Activator</Bundle-Activator> </instructions> </configuration> </plugin> http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java ---------------------------------------------------------------------- diff --git a/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java b/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java deleted file mode 100644 index b8f253a..0000000 --- a/cloud/src/main/java/org/apache/karaf/cellar/cloud/Activator.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.cloud; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.Constants; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.cm.ManagedServiceFactory; - -import java.util.Hashtable; - -/** - * Cloud bundle activator. - */ -public class Activator implements BundleActivator { - - private ServiceRegistration serviceRegistration; - - @Override - public void start(BundleContext context) throws Exception { - Hashtable<String, Object> properties = new Hashtable<String, Object>(); - properties.put(Constants.SERVICE_PID, "org.apache.karaf.cellar.cloud"); - BlobStoreDiscoveryServiceFactory blobStoreDiscoveryServiceFactory = new BlobStoreDiscoveryServiceFactory(context); - serviceRegistration = context.registerService(ManagedServiceFactory.class.getName(), blobStoreDiscoveryServiceFactory, properties); - } - - @Override - public void stop(BundleContext context) throws Exception { - if (serviceRegistration != null) { - serviceRegistration.unregister(); - } - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/cloud/src/main/java/org/apache/karaf/cellar/cloud/internal/osgi/Activator.java ---------------------------------------------------------------------- diff --git a/cloud/src/main/java/org/apache/karaf/cellar/cloud/internal/osgi/Activator.java b/cloud/src/main/java/org/apache/karaf/cellar/cloud/internal/osgi/Activator.java new file mode 100644 index 0000000..1c240b3 --- /dev/null +++ b/cloud/src/main/java/org/apache/karaf/cellar/cloud/internal/osgi/Activator.java @@ -0,0 +1,47 @@ +/* + * 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.cloud.internal.osgi; + +import org.apache.karaf.cellar.cloud.BlobStoreDiscoveryServiceFactory; +import org.apache.karaf.util.tracker.BaseActivator; +import org.apache.karaf.util.tracker.annotation.ProvideService; +import org.apache.karaf.util.tracker.annotation.Services; +import org.osgi.framework.Constants; +import org.osgi.service.cm.ManagedServiceFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Hashtable; + +/** + * Cloud bundle activator. + */ +@Services( + provides = { + @ProvideService(ManagedServiceFactory.class) + } +) +public class Activator extends BaseActivator { + + private final static Logger LOGGER = LoggerFactory.getLogger(Activator.class); + + public void doStart() throws Exception { + LOGGER.debug("[CELLAR CLOUD] Init discovery service factory"); + Hashtable<String, Object> properties = new Hashtable<String, Object>(); + properties.put(Constants.SERVICE_PID, "org.apache.karaf.cellar.cloud"); + BlobStoreDiscoveryServiceFactory blobStoreDiscoveryServiceFactory = new BlobStoreDiscoveryServiceFactory(bundleContext); + register(ManagedServiceFactory.class, blobStoreDiscoveryServiceFactory, properties); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/config/NOTICE ---------------------------------------------------------------------- diff --git a/config/NOTICE b/config/NOTICE index addb35c..64cb235 100644 --- a/config/NOTICE +++ b/config/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/config/pom.xml ---------------------------------------------------------------------- diff --git a/config/pom.xml b/config/pom.xml index ec925c8..0b90d17 100644 --- a/config/pom.xml +++ b/config/pom.xml @@ -42,6 +42,14 @@ <scope>provided</scope> </dependency> <dependency> + <groupId>org.apache.karaf</groupId> + <artifactId>org.apache.karaf.util</artifactId> + </dependency> + <dependency> + <groupId>org.apache.karaf.shell</groupId> + <artifactId>org.apache.karaf.shell.core</artifactId> + </dependency> + <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.utils</artifactId> </dependency> @@ -67,29 +75,29 @@ <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.config*;version="${project.version}" + !org.apache.karaf.cellar.config.internal.osgi, + !org.apache.karaf.cellar.config.management.internal, + org.apache.karaf.cellar.config* </Export-Package> <Import-Package> - javax.management*, - org.apache.karaf.cellar.core*;version="${project.version}", - org.apache.felix.service.command, - org.apache.felix.gogo.commands, - org.apache.karaf.shell.console;version="[3,5)", - org.apache.karaf.shell.console.completer;version="[3,5)", - org.apache.karaf.shell.console.commands;version="[3,5)", - org.apache.karaf.shell.commands;version="[3,5)", - org.apache.karaf.shell.table;version="[3,5)", - org.osgi*, - org.slf4j;version="[1.6,2)";resolution:=optional + org.slf4j;version="[1.6,2)";resolution:=optional, + org.apache.karaf.shell*;resolution:=optional, + * </Import-Package> <Private-Package> + org.apache.karaf.cellar.config.internal.osgi, org.apache.karaf.cellar.config.management.internal, - org.apache.felix.utils*;-split-package:=merge-first + org.apache.felix.utils*;-split-package:=merge-first, + org.apache.karaf.util.tracker;-split-package:=merge-first </Private-Package> </instructions> </configuration> http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/config/src/main/java/org/apache/karaf/cellar/config/internal/osgi/Activator.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/karaf/cellar/config/internal/osgi/Activator.java b/config/src/main/java/org/apache/karaf/cellar/config/internal/osgi/Activator.java new file mode 100644 index 0000000..2bf5bfd --- /dev/null +++ b/config/src/main/java/org/apache/karaf/cellar/config/internal/osgi/Activator.java @@ -0,0 +1,135 @@ +/* + * 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.config.internal.osgi; + +import org.apache.karaf.cellar.config.ConfigurationEventHandler; +import org.apache.karaf.cellar.config.ConfigurationSynchronizer; +import org.apache.karaf.cellar.config.LocalConfigurationListener; +import org.apache.karaf.cellar.config.management.internal.CellarConfigMBeanImpl; +import org.apache.karaf.cellar.core.ClusterManager; +import org.apache.karaf.cellar.core.GroupManager; +import org.apache.karaf.cellar.core.Synchronizer; +import org.apache.karaf.cellar.core.event.EventHandler; +import org.apache.karaf.cellar.core.event.EventProducer; +import org.apache.karaf.util.tracker.BaseActivator; +import org.apache.karaf.util.tracker.annotation.Managed; +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.framework.ServiceRegistration; +import org.osgi.service.cm.ConfigurationAdmin; +import org.osgi.service.cm.ConfigurationListener; +import org.osgi.service.cm.ManagedService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.Hashtable; + +@Services( + requires = { + @RequireService(ClusterManager.class), + @RequireService(GroupManager.class), + @RequireService(ConfigurationAdmin.class), + @RequireService(EventProducer.class) + }, + provides = { + @ProvideService(ConfigurationListener.class), + @ProvideService(Synchronizer.class), + @ProvideService(EventHandler.class) + } +) +@Managed("org.apache.karaf.shell.config") +public class Activator extends BaseActivator implements ManagedService { + + private final static Logger LOGGER = LoggerFactory.getLogger(Activator.class); + + private LocalConfigurationListener localConfigurationListener; + private ConfigurationSynchronizer configurationSynchronizer; + private ConfigurationEventHandler configurationEventHandler; + private ServiceRegistration cellarConfigMBeanRegistration; + + @Override + public void doStart() throws Exception { + + ClusterManager clusterManager = getTrackedService(ClusterManager.class); + GroupManager groupManager = getTrackedService(GroupManager.class); + ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class); + EventProducer eventProducer = getTrackedService(EventProducer.class); + + File storage = new File(getString("storage", System.getProperty("karaf.etc"))); + + LOGGER.debug("[CELLAR CONFIG] Init event handler"); + configurationEventHandler = new ConfigurationEventHandler(); + configurationEventHandler.setConfigurationAdmin(configurationAdmin); + configurationEventHandler.setGroupManager(groupManager); + configurationEventHandler.setClusterManager(clusterManager); + configurationEventHandler.setStorage(storage); + configurationEventHandler.init(); + Hashtable props = new Hashtable(); + props.put("managed", "true"); + register(EventHandler.class, configurationEventHandler); + + LOGGER.debug("[CELLAR CONFIG] Init local listener"); + localConfigurationListener = new LocalConfigurationListener(); + localConfigurationListener.setClusterManager(clusterManager); + localConfigurationListener.setGroupManager(groupManager); + localConfigurationListener.setConfigurationAdmin(configurationAdmin); + localConfigurationListener.setEventProducer(eventProducer); + localConfigurationListener.init(); + register(ConfigurationListener.class, localConfigurationListener); + + LOGGER.debug("[CELLAR CONFIG] Init synchronizer"); + configurationSynchronizer = new ConfigurationSynchronizer(); + configurationSynchronizer.setConfigurationAdmin(configurationAdmin); + configurationSynchronizer.setGroupManager(groupManager); + configurationSynchronizer.setClusterManager(clusterManager); + configurationSynchronizer.setStorage(storage); + configurationSynchronizer.init(); + props = new Hashtable(); + props.put("resource", "config"); + register(Synchronizer.class, configurationSynchronizer, props); + + LOGGER.debug("[CELLAR CONFIG] Register MBean"); + CellarConfigMBeanImpl cellarConfigMBean = new CellarConfigMBeanImpl(); + cellarConfigMBean.setClusterManager(clusterManager); + cellarConfigMBean.setGroupManager(groupManager); + cellarConfigMBean.setConfigurationAdmin(configurationAdmin); + cellarConfigMBean.setEventProducer(eventProducer); + props = new Hashtable(); + props.put("jmx.objectname", "org.apache.karaf.cellar:type=config,name=" + System.getProperty("karaf.name")); + cellarConfigMBeanRegistration = bundleContext.registerService(getInterfaceNames(cellarConfigMBean), cellarConfigMBean, props); + } + + @Override + public void doStop() { + if (cellarConfigMBeanRegistration != null) { + cellarConfigMBeanRegistration.unregister(); + cellarConfigMBeanRegistration = null; + } + if (configurationSynchronizer != null) { + configurationSynchronizer.destroy(); + configurationSynchronizer = null; + } + if (localConfigurationListener != null) { + localConfigurationListener.destroy(); + localConfigurationListener = null; + } + if (configurationEventHandler != null) { + configurationEventHandler.destroy(); + configurationEventHandler = null; + } + } + +} http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/config/src/main/java/org/apache/karaf/cellar/config/shell/BlockCommand.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/karaf/cellar/config/shell/BlockCommand.java b/config/src/main/java/org/apache/karaf/cellar/config/shell/BlockCommand.java index 977025e..4877d10 100644 --- a/config/src/main/java/org/apache/karaf/cellar/config/shell/BlockCommand.java +++ b/config/src/main/java/org/apache/karaf/cellar/config/shell/BlockCommand.java @@ -14,24 +14,31 @@ package org.apache.karaf.cellar.config.shell; import org.apache.karaf.cellar.config.Constants; +import org.apache.karaf.cellar.config.shell.completers.ClusterConfigCompleter; import org.apache.karaf.cellar.core.CellarSupport; import org.apache.karaf.cellar.core.Configurations; import org.apache.karaf.cellar.core.Group; import org.apache.karaf.cellar.core.event.EventType; import org.apache.karaf.cellar.core.shell.CellarCommandSupport; -import org.apache.karaf.shell.commands.Argument; -import org.apache.karaf.shell.commands.Command; -import org.apache.karaf.shell.commands.Option; +import org.apache.karaf.cellar.core.shell.completer.AllGroupsCompleter; +import org.apache.karaf.shell.api.action.Argument; +import org.apache.karaf.shell.api.action.Command; +import org.apache.karaf.shell.api.action.Completion; +import org.apache.karaf.shell.api.action.Option; +import org.apache.karaf.shell.api.action.lifecycle.Service; import java.util.Set; @Command(scope = "cluster", name = "config-block", description = "Change the blocking policy for a bundle") +@Service public class BlockCommand extends CellarCommandSupport { @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false) + @Completion(AllGroupsCompleter.class) String groupName; @Argument(index = 1, name = "pidPattern", description = "The configuration PID pattern", required = false, multiValued = false) + @Completion(ClusterConfigCompleter.class) String pid; @Option(name = "-in", description = "Update the inbound direction", required = false, multiValued = false) http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/config/src/main/java/org/apache/karaf/cellar/config/shell/DeleteCommand.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/karaf/cellar/config/shell/DeleteCommand.java b/config/src/main/java/org/apache/karaf/cellar/config/shell/DeleteCommand.java index de66aa0..0ce9994 100644 --- a/config/src/main/java/org/apache/karaf/cellar/config/shell/DeleteCommand.java +++ b/config/src/main/java/org/apache/karaf/cellar/config/shell/DeleteCommand.java @@ -15,27 +15,36 @@ package org.apache.karaf.cellar.config.shell; import org.apache.karaf.cellar.config.ClusterConfigurationEvent; import org.apache.karaf.cellar.config.Constants; +import org.apache.karaf.cellar.config.shell.completers.ClusterConfigCompleter; import org.apache.karaf.cellar.core.Configurations; import org.apache.karaf.cellar.core.Group; import org.apache.karaf.cellar.core.control.SwitchStatus; import org.apache.karaf.cellar.core.event.EventProducer; -import org.apache.karaf.shell.commands.Argument; -import org.apache.karaf.shell.commands.Command; import org.apache.karaf.cellar.core.event.EventType; +import org.apache.karaf.cellar.core.shell.completer.AllGroupsCompleter; +import org.apache.karaf.shell.api.action.Argument; +import org.apache.karaf.shell.api.action.Command; +import org.apache.karaf.shell.api.action.Completion; +import org.apache.karaf.shell.api.action.lifecycle.Reference; +import org.apache.karaf.shell.api.action.lifecycle.Service; import org.osgi.service.cm.ConfigurationEvent; import java.util.Map; import java.util.Properties; @Command(scope = "cluster", name = "config-delete", description = "Delete a configuration from a cluster group") +@Service public class DeleteCommand extends ConfigCommandSupport { @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false) + @Completion(AllGroupsCompleter.class) String groupName; @Argument(index = 1, name = "pid", description = "The configuration PID", required = true, multiValued = false) + @Completion(ClusterConfigCompleter.class) String pid; + @Reference private EventProducer eventProducer; @Override http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/3e5e7c33/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java ---------------------------------------------------------------------- diff --git a/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java b/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java index 41ba78a..11740cb 100644 --- a/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java +++ b/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java @@ -18,9 +18,12 @@ import org.apache.karaf.cellar.config.Constants; import org.apache.karaf.cellar.core.Configurations; import org.apache.karaf.cellar.core.Group; import org.apache.karaf.cellar.core.event.EventType; -import org.apache.karaf.shell.commands.Argument; -import org.apache.karaf.shell.commands.Command; -import org.apache.karaf.shell.commands.Option; +import org.apache.karaf.cellar.core.shell.completer.AllGroupsCompleter; +import org.apache.karaf.shell.api.action.Argument; +import org.apache.karaf.shell.api.action.Command; +import org.apache.karaf.shell.api.action.Completion; +import org.apache.karaf.shell.api.action.Option; +import org.apache.karaf.shell.api.action.lifecycle.Service; import org.osgi.service.cm.Configuration; import java.util.Enumeration; @@ -29,9 +32,11 @@ import java.util.Map; import java.util.Properties; @Command(scope = "cluster", name = "config-list", description = "List the configurations in a cluster group") +@Service public class ListCommand extends ConfigCommandSupport { @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false) + @Completion(AllGroupsCompleter.class) String groupName; @Argument(index = 1, name = "pid", description = "The configuration PID to look for", required = false, multiValued = false)
