You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2015/05/05 16:32:15 UTC
[6/9] karaf-cave git commit: Remove blueprint,
upgrade to karaf 4 commands
Remove blueprint, upgrade to karaf 4 commands
Project: http://git-wip-us.apache.org/repos/asf/karaf-cave/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cave/commit/d36371b2
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cave/tree/d36371b2
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cave/diff/d36371b2
Branch: refs/heads/master
Commit: d36371b2b199c9123203e929dadab935d7bad1c4
Parents: a59c7a8
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Tue May 5 11:06:48 2015 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Tue May 5 11:06:48 2015 +0200
----------------------------------------------------------------------
assembly/src/main/resources/features.xml | 4 +-
pom.xml | 18 +++-
server/command/pom.xml | 13 +--
.../command/CaveRepositoryCommandSupport.java | 13 ++-
.../server/command/RepositoriesListCommand.java | 4 +-
.../server/command/RepositoryCreateCommand.java | 8 +-
.../command/RepositoryDestroyCommand.java | 9 +-
.../command/RepositoryInstallCommand.java | 9 +-
.../command/RepositoryPopulateCommand.java | 15 ++-
.../server/command/RepositoryProxyCommand.java | 15 ++-
.../command/RepositoryUninstallCommand.java | 9 +-
.../server/command/RepositoryUpdateCommand.java | 9 +-
.../RepositoryUploadArtifactCommand.java | 15 ++-
.../command/completers/RepositoryCompleter.java | 18 ++--
.../OSGI-INF/blueprint/cave-server-commands.xml | 104 -------------------
server/management/pom.xml | 24 +++--
.../server/management/internal/Activator.java | 51 +++++++++
.../OSGI-INF/blueprint/cave-management.xml | 21 ----
server/storage/pom.xml | 17 ++-
.../karaf/cave/server/storage/Activator.java | 45 ++++++++
.../OSGI-INF/blueprint/cave-storage.xml | 38 -------
21 files changed, 236 insertions(+), 223 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/assembly/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/assembly/src/main/resources/features.xml b/assembly/src/main/resources/features.xml
index 47ff868..abce0f1 100644
--- a/assembly/src/main/resources/features.xml
+++ b/assembly/src/main/resources/features.xml
@@ -30,7 +30,6 @@
<configfile finalname="/etc/org.apache.karaf.cave.server.storage.cfg">
mvn:org.apache.karaf.cave/apache-karaf-cave/${project.version}/cfg/filesystem
</configfile>
- <feature>shell-compat</feature>
<bundle dependency="true">mvn:javax.annotation/javax.annotation-api/1.2</bundle>
<bundle dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.jsr339-api-2.0/2.4.0</bundle>
<bundle>mvn:org.jsoup/jsoup/${jsoup.version}</bundle>
@@ -57,7 +56,8 @@
mvn:org.apache.karaf.cave/apache-karaf-cave/${project.version}/cfg/cxf
</configfile>
<feature version="[3,4)">cxf</feature>
- <feature>cave-server</feature>
+ <feature>aries-blueprint</feature>
+ <feature>cave-storage</feature>
<bundle>mvn:org.apache.karaf.cave.server/org.apache.karaf.cave.server.rest/${project.version}</bundle>
</feature>
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2dc9634..0b5f608 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,7 +75,7 @@
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
<version>${karaf.version}</version>
</dependency>
<dependency>
@@ -136,9 +136,23 @@
<pluginManagement>
<plugins>
<plugin>
+ <groupId>org.apache.karaf.tooling</groupId>
+ <artifactId>karaf-services-maven-plugin</artifactId>
+ <version>${karaf.version}</version>
+ <executions>
+ <execution>
+ <id>service-metadata-generate</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>service-metadata-generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
- <version>2.4.0</version>
+ <version>2.5.3</version>
<extensions>true</extensions>
</plugin>
<plugin>
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/pom.xml
----------------------------------------------------------------------
diff --git a/server/command/pom.xml b/server/command/pom.xml
index 0e023e0..c185ea5 100644
--- a/server/command/pom.xml
+++ b/server/command/pom.xml
@@ -36,7 +36,7 @@
<dependencies>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
@@ -52,18 +52,15 @@
<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>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Import-Package>
- org.apache.felix.service.command,
- org.apache.felix.gogo.commands,
- org.apache.karaf.shell*;version="[3,5)",
- org.apache.karaf.cave.server.api;version="${project.version}",
- *
- </Import-Package>
</instructions>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/src/main/java/org/apache/karaf/cave/server/command/CaveRepositoryCommandSupport.java
----------------------------------------------------------------------
diff --git a/server/command/src/main/java/org/apache/karaf/cave/server/command/CaveRepositoryCommandSupport.java b/server/command/src/main/java/org/apache/karaf/cave/server/command/CaveRepositoryCommandSupport.java
index 2920c97..acc0ef8 100644
--- a/server/command/src/main/java/org/apache/karaf/cave/server/command/CaveRepositoryCommandSupport.java
+++ b/server/command/src/main/java/org/apache/karaf/cave/server/command/CaveRepositoryCommandSupport.java
@@ -17,21 +17,26 @@
package org.apache.karaf.cave.server.command;
import org.apache.karaf.cave.server.api.CaveRepositoryService;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
/**
* Abstract command describing the default behavior of Karaf Cave commands.
*/
-public abstract class CaveRepositoryCommandSupport extends OsgiCommandSupport {
+public abstract class CaveRepositoryCommandSupport implements Action {
+ @Reference
private CaveRepositoryService caveRepositoryService;
public CaveRepositoryService getCaveRepositoryService() {
return this.caveRepositoryService;
}
- public void setCaveRepositoryService(CaveRepositoryService caveRepositoryService) {
- this.caveRepositoryService = caveRepositoryService;
+ @Override
+ public Object execute() throws Exception {
+ return doExecute();
}
+ protected abstract Object doExecute() throws Exception;
+
}
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoriesListCommand.java
----------------------------------------------------------------------
diff --git a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoriesListCommand.java b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoriesListCommand.java
index 49aca41..c1f6693 100644
--- a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoriesListCommand.java
+++ b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoriesListCommand.java
@@ -17,13 +17,15 @@
package org.apache.karaf.cave.server.command;
import org.apache.karaf.cave.server.api.CaveRepository;
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.apache.karaf.shell.table.ShellTable;
/**
* Command to list all Cave repositories
*/
@Command(scope = "cave", name = "repositories", description = "List all Cave repositories")
+@Service
public class RepositoriesListCommand extends CaveRepositoryCommandSupport {
protected Object doExecute() throws Exception {
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryCreateCommand.java
----------------------------------------------------------------------
diff --git a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryCreateCommand.java b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryCreateCommand.java
index dfda227..1eff436 100644
--- a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryCreateCommand.java
+++ b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryCreateCommand.java
@@ -17,14 +17,16 @@
package org.apache.karaf.cave.server.command;
import org.apache.karaf.cave.server.api.CaveRepository;
-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.shell.api.action.Argument;
+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;
/**
* Create a Cave repository.
*/
@Command(scope = "cave", name = "repository-create", description = "Create a Cave repository")
+@Service
public class RepositoryCreateCommand extends CaveRepositoryCommandSupport {
@Option(name = "-l", aliases = {"--location"}, description = "Location of the repository on the file system", required = false, multiValued = false)
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryDestroyCommand.java
----------------------------------------------------------------------
diff --git a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryDestroyCommand.java b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryDestroyCommand.java
index 8298f4d..0ae3ca5 100644
--- a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryDestroyCommand.java
+++ b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryDestroyCommand.java
@@ -16,16 +16,21 @@
*/
package org.apache.karaf.cave.server.command;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.cave.server.command.completers.RepositoryCompleter;
+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.Service;
/**
* Destroy a Cave repository
*/
@Command(scope = "cave", name = "repository-destroy", description = "Destroy a Cave repository from the registry, including delete of storage")
+@Service
public class RepositoryDestroyCommand extends CaveRepositoryCommandSupport {
@Argument(index = 0, name = "name", description = "The name of the repository", required = true, multiValued = false)
+ @Completion(RepositoryCompleter.class)
String name = null;
protected Object doExecute() throws Exception {
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryInstallCommand.java
----------------------------------------------------------------------
diff --git a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryInstallCommand.java b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryInstallCommand.java
index e7025e0..0677ae9 100644
--- a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryInstallCommand.java
+++ b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryInstallCommand.java
@@ -16,16 +16,21 @@
*/
package org.apache.karaf.cave.server.command;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.cave.server.command.completers.RepositoryCompleter;
+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.Service;
/**
* Command to install a Cave repository into the OBR service.
*/
@Command(scope = "cave", name = "repository-install", description = "Install a Cave repository in the OBR service")
+@Service
public class RepositoryInstallCommand extends CaveRepositoryCommandSupport {
@Argument(index = 0, name = "name", description = "The name of the repository", required = true, multiValued = false)
+ @Completion(RepositoryCompleter.class)
String name = null;
protected Object doExecute() throws Exception {
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryPopulateCommand.java
----------------------------------------------------------------------
diff --git a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryPopulateCommand.java b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryPopulateCommand.java
index 76582c7..aa29d17 100644
--- a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryPopulateCommand.java
+++ b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryPopulateCommand.java
@@ -16,17 +16,21 @@
*/
package org.apache.karaf.cave.server.command;
-import org.apache.karaf.cave.server.api.CaveRepository;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-
import java.net.URL;
+import org.apache.karaf.cave.server.api.CaveRepository;
+import org.apache.karaf.cave.server.command.completers.RepositoryCompleter;
+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;
+
/**
* Populate a Cave repository from a given URL
*/
@Command(scope = "cave", name = "repository-populate", description = "Populate a Cave repository with the artifacts available at a given URL")
+@Service
public class RepositoryPopulateCommand extends CaveRepositoryCommandSupport {
@Option(name = "-no", aliases = { "--no-obr-generate" }, description = "Do not generate the OBR metadata", required = false, multiValued = false)
@@ -36,6 +40,7 @@ public class RepositoryPopulateCommand extends CaveRepositoryCommandSupport {
String filter;
@Argument(index = 0, name = "name", description = "The name of the repository", required = true, multiValued = false)
+ @Completion(RepositoryCompleter.class)
String name = null;
@Argument(index = 1, name = "url", description = "The source URL to use", required = true, multiValued = false)
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryProxyCommand.java
----------------------------------------------------------------------
diff --git a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryProxyCommand.java b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryProxyCommand.java
index 610c397..c33496b 100644
--- a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryProxyCommand.java
+++ b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryProxyCommand.java
@@ -16,20 +16,25 @@
*/
package org.apache.karaf.cave.server.command;
-import org.apache.karaf.cave.server.api.CaveRepository;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-
import java.net.URL;
+import org.apache.karaf.cave.server.api.CaveRepository;
+import org.apache.karaf.cave.server.command.completers.RepositoryCompleter;
+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;
+
/**
* Add an URL to proxy in the Cave repository.
*/
@Command(scope = "cave", name = "repository-proxy", description = "Proxy a given URL in the Karaf Cave repository")
+@Service
public class RepositoryProxyCommand extends CaveRepositoryCommandSupport {
@Argument(index = 0, name = "name", description = "The name of the repository", required = true, multiValued = false)
+ @Completion(RepositoryCompleter.class)
String name = null;
@Argument(index = 1, name = "URL", description = "The URL to proxy", required = true, multiValued = false)
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUninstallCommand.java
----------------------------------------------------------------------
diff --git a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUninstallCommand.java b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUninstallCommand.java
index 1a60138..a0aab37 100644
--- a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUninstallCommand.java
+++ b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUninstallCommand.java
@@ -16,16 +16,21 @@
*/
package org.apache.karaf.cave.server.command;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.cave.server.command.completers.RepositoryCompleter;
+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.Service;
/**
* Uninstall a Cave repository from the repositories registry
*/
@Command(scope = "cave", name = "repository-uninstall", description = "Uninstall a Cave repository from the repositories registry")
+@Service
public class RepositoryUninstallCommand extends CaveRepositoryCommandSupport {
@Argument(index = 0, name = "name", description = "The name of the repository", required = true, multiValued = false)
+ @Completion(RepositoryCompleter.class)
String name = null;
protected Object doExecute() throws Exception {
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUpdateCommand.java
----------------------------------------------------------------------
diff --git a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUpdateCommand.java b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUpdateCommand.java
index 29d5334..c4329f9 100644
--- a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUpdateCommand.java
+++ b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUpdateCommand.java
@@ -17,16 +17,21 @@
package org.apache.karaf.cave.server.command;
import org.apache.karaf.cave.server.api.CaveRepository;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.cave.server.command.completers.RepositoryCompleter;
+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.Service;
/**
* Update the OBR metadata of a Cave repository
*/
@Command(scope = "cave", name = "repository-update", description = "Update OBR metadata of a Cave repository")
+@Service
public class RepositoryUpdateCommand extends CaveRepositoryCommandSupport {
@Argument(index = 0, name = "name", description = "The name of the repository", required = true, multiValued = false)
+ @Completion(RepositoryCompleter.class)
String name = null;
protected Object doExecute() throws Exception {
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUploadArtifactCommand.java
----------------------------------------------------------------------
diff --git a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUploadArtifactCommand.java b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUploadArtifactCommand.java
index 3b68eb0..40988d4 100644
--- a/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUploadArtifactCommand.java
+++ b/server/command/src/main/java/org/apache/karaf/cave/server/command/RepositoryUploadArtifactCommand.java
@@ -16,20 +16,25 @@
*/
package org.apache.karaf.cave.server.command;
-import org.apache.karaf.cave.server.api.CaveRepository;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-
import java.net.URL;
+import org.apache.karaf.cave.server.api.CaveRepository;
+import org.apache.karaf.cave.server.command.completers.RepositoryCompleter;
+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;
+
/**
* Upload an artifact into a Cave repository
*/
@Command(scope = "cave", name = "repository-upload", description = "Upload an artifact in a Cave repository")
+@Service
public class RepositoryUploadArtifactCommand extends CaveRepositoryCommandSupport {
@Argument(index = 0, name = "repository", description = "The name of the repository", required = true, multiValued = false)
+ @Completion(RepositoryCompleter.class)
String name = null;
@Argument(index = 1, name = "artifact", description = "The URL of the artifact to upload", required = true, multiValued = false)
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/src/main/java/org/apache/karaf/cave/server/command/completers/RepositoryCompleter.java
----------------------------------------------------------------------
diff --git a/server/command/src/main/java/org/apache/karaf/cave/server/command/completers/RepositoryCompleter.java b/server/command/src/main/java/org/apache/karaf/cave/server/command/completers/RepositoryCompleter.java
index da9a34a..202d298 100644
--- a/server/command/src/main/java/org/apache/karaf/cave/server/command/completers/RepositoryCompleter.java
+++ b/server/command/src/main/java/org/apache/karaf/cave/server/command/completers/RepositoryCompleter.java
@@ -16,16 +16,20 @@
*/
package org.apache.karaf.cave.server.command.completers;
+import java.util.List;
+
import org.apache.karaf.cave.server.api.CaveRepository;
import org.apache.karaf.cave.server.api.CaveRepositoryService;
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-
-import java.util.List;
+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;
/**
* Completer of the Karaf Cave repositories.
*/
+@Service
public class RepositoryCompleter implements Completer {
private CaveRepositoryService caveRepositoryService;
@@ -38,11 +42,13 @@ public class RepositoryCompleter implements Completer {
return this.caveRepositoryService;
}
- public int complete(String buffer, int cursor, List candidates) {
+ @Override
+ public int complete(Session session, CommandLine commandLine, List<String> list) {
StringsCompleter delegate = new StringsCompleter();
for (CaveRepository caveRepository : caveRepositoryService.getRepositories()) {
delegate.getStrings().add(caveRepository.getName());
}
- return delegate.complete(buffer, cursor, candidates);
+ return delegate.complete(session, commandLine, list);
}
+
}
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/command/src/main/resources/OSGI-INF/blueprint/cave-server-commands.xml
----------------------------------------------------------------------
diff --git a/server/command/src/main/resources/OSGI-INF/blueprint/cave-server-commands.xml b/server/command/src/main/resources/OSGI-INF/blueprint/cave-server-commands.xml
deleted file mode 100644
index da38b90..0000000
--- a/server/command/src/main/resources/OSGI-INF/blueprint/cave-server-commands.xml
+++ /dev/null
@@ -1,104 +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="caveRepositoryService" interface="org.apache.karaf.cave.server.api.CaveRepositoryService"/>
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
- <command>
- <action class="org.apache.karaf.cave.server.command.RepositoriesListCommand">
- <property name="caveRepositoryService" ref="caveRepositoryService"/>
- </action>
- </command>
- <command>
- <action class="org.apache.karaf.cave.server.command.RepositoryCreateCommand">
- <property name="caveRepositoryService" ref="caveRepositoryService"/>
- </action>
- </command>
- <command>
- <action class="org.apache.karaf.cave.server.command.RepositoryDestroyCommand">
- <property name="caveRepositoryService" ref="caveRepositoryService"/>
- </action>
- <completers>
- <ref component-id="repositoryCompleter"/>
- <null/>
- </completers>
- </command>
- <command>
- <action class="org.apache.karaf.cave.server.command.RepositoryUninstallCommand">
- <property name="caveRepositoryService" ref="caveRepositoryService"/>
- </action>
- <completers>
- <ref component-id="repositoryCompleter"/>
- <null/>
- </completers>
- </command>
- <command>
- <action class="org.apache.karaf.cave.server.command.RepositoryUpdateCommand">
- <property name="caveRepositoryService" ref="caveRepositoryService"/>
- </action>
- <completers>
- <ref component-id="repositoryCompleter"/>
- <null/>
- </completers>
- </command>
- <command>
- <action class="org.apache.karaf.cave.server.command.RepositoryProxyCommand">
- <property name="caveRepositoryService" ref="caveRepositoryService"/>
- </action>
- <completers>
- <ref component-id="repositoryCompleter"/>
- <null/>
- </completers>
- </command>
- <command>
- <action class="org.apache.karaf.cave.server.command.RepositoryPopulateCommand">
- <property name="caveRepositoryService" ref="caveRepositoryService"/>
- </action>
- <completers>
- <ref component-id="repositoryCompleter"/>
- <null/>
- </completers>
- </command>
- <command>
- <action class="org.apache.karaf.cave.server.command.RepositoryInstallCommand">
- <property name="caveRepositoryService" ref="caveRepositoryService"/>
- </action>
- <completers>
- <ref component-id="repositoryCompleter"/>
- <null/>
- </completers>
- </command>
- <command>
- <action class="org.apache.karaf.cave.server.command.RepositoryUploadArtifactCommand">
- <property name="caveRepositoryService" ref="caveRepositoryService"/>
- </action>
- <completers>
- <ref component-id="repositoryCompleter"/>
- <null/>
- </completers>
- </command>
- </command-bundle>
-
- <bean id="repositoryCompleter" class="org.apache.karaf.cave.server.command.completers.RepositoryCompleter">
- <property name="caveRepositoryService" ref="caveRepositoryService"/>
- </bean>
-
-</blueprint>
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/management/pom.xml
----------------------------------------------------------------------
diff --git a/server/management/pom.xml b/server/management/pom.xml
index 5ba4a86..4ccb8e4 100644
--- a/server/management/pom.xml
+++ b/server/management/pom.xml
@@ -39,27 +39,35 @@
<artifactId>org.apache.karaf.cave.server.api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>org.apache.karaf.util</artifactId>
+ <version>${karaf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
</dependencies>
<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>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Export-Package>
- org.apache.karaf.cave.server.management*;version=${project.version}
+ org.apache.karaf.cave.server.management
</Export-Package>
- <Import-Package>
- javax.management,
- javax.management.loading,
- javax.management.openmbean,
- org.apache.karaf.cave.server.api;version=${project.version}
- </Import-Package>
<Private-Package>
- org.apache.karaf.cave.server.management.internal
+ org.apache.karaf.cave.server.management.internal,
+ org.apache.karaf.util.tracker*
</Private-Package>
</instructions>
</configuration>
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/management/src/main/java/org/apache/karaf/cave/server/management/internal/Activator.java
----------------------------------------------------------------------
diff --git a/server/management/src/main/java/org/apache/karaf/cave/server/management/internal/Activator.java b/server/management/src/main/java/org/apache/karaf/cave/server/management/internal/Activator.java
new file mode 100644
index 0000000..3d61032
--- /dev/null
+++ b/server/management/src/main/java/org/apache/karaf/cave/server/management/internal/Activator.java
@@ -0,0 +1,51 @@
+package org.apache.karaf.cave.server.management.internal;
+
+import java.util.Hashtable;
+
+import org.apache.karaf.cave.server.api.CaveRepositoryService;
+import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.annotation.RequireService;
+import org.apache.karaf.util.tracker.annotation.Services;
+import org.osgi.framework.ServiceRegistration;
+
+/*
+ * 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.
+ */
+
+@Services(
+ requires = { @RequireService(CaveRepositoryService.class) }
+)
+public class Activator extends BaseActivator {
+
+ private volatile ServiceRegistration registration;
+
+ @Override
+ protected void doStart() throws Exception {
+ CaveRepositoryService service = getTrackedService(CaveRepositoryService.class);
+ CaveRepositoryMBeanImpl mbean = new CaveRepositoryMBeanImpl();
+ mbean.setCaveRepositoryService(service);
+
+ Hashtable<String, Object> props = new Hashtable<>();
+ props.put("jmx.objectname", "org.apache.karaf.cave:type=repository,name=" + System.getProperty("karaf.name"));
+ registration = this.bundleContext.registerService(getInterfaceNames(mbean), mbean, props);
+ }
+
+ @Override
+ protected void doStop() {
+ if (registration != null) {
+ registration.unregister();
+ registration = null;
+ }
+ super.doStop();
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/management/src/main/resources/OSGI-INF/blueprint/cave-management.xml
----------------------------------------------------------------------
diff --git a/server/management/src/main/resources/OSGI-INF/blueprint/cave-management.xml b/server/management/src/main/resources/OSGI-INF/blueprint/cave-management.xml
deleted file mode 100644
index a4b9b3d..0000000
--- a/server/management/src/main/resources/OSGI-INF/blueprint/cave-management.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<blueprint 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="]"/>
-
- <!-- reference to the Cave repository service -->
- <reference id="caveRepositoryService" interface="org.apache.karaf.cave.server.api.CaveRepositoryService"/>
-
- <!-- Cave repostiroy MBean -->
- <bean id="caveRepositoryMBean" class="org.apache.karaf.cave.server.management.internal.CaveRepositoryMBeanImpl">
- <property name="caveRepositoryService" ref="caveRepositoryService"/>
- </bean>
- <service ref="caveRepositoryMBean" auto-export="interfaces">
- <service-properties>
- <entry key="jmx.objectname" value="org.apache.karaf.cave:type=repository,name=$[karaf.name]"/>
- </service-properties>
- </service>
-
-</blueprint>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/storage/pom.xml
----------------------------------------------------------------------
diff --git a/server/storage/pom.xml b/server/storage/pom.xml
index 00ca419..eb9dd7c 100644
--- a/server/storage/pom.xml
+++ b/server/storage/pom.xml
@@ -48,18 +48,28 @@
<artifactId>jsoup</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>5.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>org.apache.karaf.util</artifactId>
+ <version>${karaf.version}</version>
</dependency>
</dependencies>
<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>
@@ -73,6 +83,7 @@
org.apache.felix.utils*,
org.apache.karaf.features.internal.resolver,
org.apache.karaf.features.internal.repository,
+ org.apache.karaf.util.tracker*
</Private-Package>
</instructions>
</configuration>
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/storage/src/main/java/org/apache/karaf/cave/server/storage/Activator.java
----------------------------------------------------------------------
diff --git a/server/storage/src/main/java/org/apache/karaf/cave/server/storage/Activator.java b/server/storage/src/main/java/org/apache/karaf/cave/server/storage/Activator.java
new file mode 100644
index 0000000..8b41efd
--- /dev/null
+++ b/server/storage/src/main/java/org/apache/karaf/cave/server/storage/Activator.java
@@ -0,0 +1,45 @@
+package org.apache.karaf.cave.server.storage;
+
+import java.io.File;
+import java.util.Hashtable;
+
+import org.apache.karaf.cave.server.api.CaveRepositoryService;
+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.FrameworkUtil;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ManagedService;
+
+/*
+ * 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.
+ */
+
+@Services(
+ provides = { @ProvideService(CaveRepositoryService.class) }
+)
+@Managed("org.apache.karaf.cave.server.storage")
+public class Activator extends BaseActivator implements ManagedService {
+
+ @Override
+ protected void doStart() throws Exception {
+ CaveRepositoryServiceImpl service = new CaveRepositoryServiceImpl();
+ service.setBundleContext(FrameworkUtil.getBundle(Activator.class).getBundleContext());
+ service.setStorageLocation(new File(getString("storage.location", "cave")));
+ service.init();
+ register(CaveRepositoryService.class, service);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-cave/blob/d36371b2/server/storage/src/main/resources/OSGI-INF/blueprint/cave-storage.xml
----------------------------------------------------------------------
diff --git a/server/storage/src/main/resources/OSGI-INF/blueprint/cave-storage.xml b/server/storage/src/main/resources/OSGI-INF/blueprint/cave-storage.xml
deleted file mode 100644
index 54be010..0000000
--- a/server/storage/src/main/resources/OSGI-INF/blueprint/cave-storage.xml
+++ /dev/null
@@ -1,38 +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"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
- default-activation="lazy">
-
- <bean id="caveRepositoryService" class="org.apache.karaf.cave.server.storage.CaveRepositoryServiceImpl" init-method="init">
- <property name="storageLocation" value="${storage.location}"/>
- <property name="bundleContext" ref="blueprintBundleContext"/>
- </bean>
-
- <service ref="caveRepositoryService" interface="org.apache.karaf.cave.server.api.CaveRepositoryService"/>
-
- <!-- use the cm of Cave filesystem backend -->
- <cm:property-placeholder persistent-id="org.apache.karaf.cave.server.storage" update-strategy="reload">
- <cm:default-properties>
- <cm:property name="storage.location" value="cave"/>
- </cm:default-properties>
- </cm:property-placeholder>
-
-</blueprint>
\ No newline at end of file