karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [2/4] git commit: [KARAF-2985] Provide a plugin to automatically generate generic requirements / dependencies for karaf internal activators
Date Mon, 19 May 2014 07:19:53 GMT
[KARAF-2985] Provide a plugin to automatically generate generic requirements / dependencies for karaf internal activators


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/005c0a30
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/005c0a30
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/005c0a30

Branch: refs/heads/master
Commit: 005c0a30e773ee10ba9cd90f559ffaa6f7a3d5df
Parents: 17c4526
Author: Guillaume Nodet <gnodet@gmail.com>
Authored: Mon May 19 09:16:35 2014 +0200
Committer: Guillaume Nodet <gnodet@gmail.com>
Committed: Mon May 19 09:19:09 2014 +0200

----------------------------------------------------------------------
 bundle/core/pom.xml                             |  10 ++
 .../bundle/core/internal/osgi/Activator.java    |  12 +-
 config/pom.xml                                  |  10 ++
 .../karaf/config/core/impl/osgi/Activator.java  |  12 +-
 deployer/blueprint/pom.xml                      |  10 ++
 .../deployer/blueprint/osgi/Activator.java      |   2 +-
 deployer/features/pom.xml                       |  15 ++
 .../karaf/deployer/features/osgi/Activator.java |  13 +-
 deployer/kar/pom.xml                            |  21 +++
 .../karaf/deployer/kar/osgi/Activator.java      |  10 +-
 deployer/spring/pom.xml                         |  10 ++
 .../karaf/deployer/spring/osgi/Activator.java   |   2 +-
 deployer/wrap/pom.xml                           |  10 ++
 .../karaf/deployer/wrap/osgi/Activator.java     |  17 +--
 diagnostic/pom.xml                              |  10 ++
 features/core/pom.xml                           |   8 +-
 .../karaf/features/internal/osgi/Activator.java |  17 ++-
 .../internal/region/SubsystemResolver.java      |  13 ++
 .../internal/resolver/ResourceUtils.java        |  10 ++
 .../features/internal/service/Deployer.java     |  18 ++-
 http/pom.xml                                    |   6 +
 .../http/core/internal/osgi/Activator.java      |   3 +
 instance/pom.xml                                |  15 +-
 .../instance/core/internal/osgi/Activator.java  |   3 +
 jaas/config/pom.xml                             |   3 +
 jdbc/pom.xml                                    |  10 ++
 .../karaf/jdbc/internal/osgi/Activator.java     |   3 +
 jndi/pom.xml                                    |  10 ++
 .../karaf/jndi/internal/osgi/Activator.java     |  11 +-
 kar/pom.xml                                     |   4 +
 .../karaf/kar/internal/osgi/Activator.java      |  15 +-
 log/pom.xml                                     |  10 ++
 .../karaf/log/core/internal/osgi/Activator.java |  15 +-
 management/server/pom.xml                       |   9 +-
 .../karaf/management/internal/Activator.java    |  19 ++-
 obr/pom.xml                                     |  10 ++
 .../karaf/obr/core/internal/osgi/Activator.java |  10 +-
 package/pom.xml                                 |  10 ++
 .../packages/core/internal/osgi/Activator.java  |   3 +
 pom.xml                                         |  40 ++---
 scheduler/pom.xml                               |  10 ++
 .../apache/karaf/scheduler/core/Activator.java  |   3 +
 .../osgi/secured/SecuredSessionFactoryImpl.java |   5 +-
 shell/ssh/pom.xml                               |  10 ++
 .../org/apache/karaf/shell/ssh/Activator.java   |  11 +-
 system/pom.xml                                  |  10 ++
 .../karaf/system/internal/osgi/Activator.java   |   3 +
 tooling/karaf-services-maven-plugin/pom.xml     | 142 ++++++++++++++++++
 .../tracker/GenerateServiceMetadata.java        | 148 +++++++++++++++++++
 tooling/pom.xml                                 |   1 +
 .../karaf/util/tracker/BaseActivator.java       |  81 ++++------
 .../org/apache/karaf/util/tracker/Managed.java  |  30 ++++
 .../karaf/util/tracker/ProvideService.java      |  27 ++++
 .../karaf/util/tracker/RequireService.java      |  31 ++++
 .../org/apache/karaf/util/tracker/Services.java |  32 ++++
 .../util/tracker/SingleServiceTracker.java      |  22 +--
 web/pom.xml                                     |  10 ++
 .../karaf/web/internal/osgi/Activator.java      |  14 +-
 wrapper/pom.xml                                 |  10 ++
 .../karaf/wrapper/internal/osgi/Activator.java  |   3 +
 60 files changed, 869 insertions(+), 173 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/bundle/core/pom.xml
----------------------------------------------------------------------
diff --git a/bundle/core/pom.xml b/bundle/core/pom.xml
index fc99d53..1f568b7 100644
--- a/bundle/core/pom.xml
+++ b/bundle/core/pom.xml
@@ -115,6 +115,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -132,6 +136,12 @@
                             org.apache.felix.utils.version,
                             org.apache.felix.utils.manifest
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Embed-Dependency>
                             org.apache.karaf.jaas.modules;inline="org/apache/karaf/jaas/modules/JaasHelper*.class"
                         </Embed-Dependency>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/osgi/Activator.java b/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/osgi/Activator.java
index 6999485..c5c765b 100644
--- a/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/osgi/Activator.java
+++ b/bundle/core/src/main/java/org/apache/karaf/bundle/core/internal/osgi/Activator.java
@@ -24,22 +24,24 @@ import org.apache.karaf.bundle.core.internal.BundleWatcherImpl;
 import org.apache.karaf.bundle.core.internal.BundlesMBeanImpl;
 import org.apache.karaf.bundle.core.internal.MavenConfigService;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.util.tracker.ServiceTracker;
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
+@Services(
+        requires = @RequireService(ConfigurationAdmin.class),
+        provides = @ProvideService(BundleService.class)
+)
 public class Activator extends BaseActivator {
 
     private ServiceTracker<BundleStateService, BundleStateService> bundleStateServicesTracker;
     private BundleWatcherImpl bundleWatcher;
 
     @Override
-    protected void doOpen() throws Exception {
-        trackService(ConfigurationAdmin.class);
-    }
-
-    @Override
     protected void doStart() throws Exception {
         ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
         if (configurationAdmin == null) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/config/pom.xml
----------------------------------------------------------------------
diff --git a/config/pom.xml b/config/pom.xml
index af0de85..84be65e 100644
--- a/config/pom.xml
+++ b/config/pom.xml
@@ -91,6 +91,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -107,6 +111,12 @@
                             org.apache.karaf.config.core.impl.osgi,
                             org.apache.karaf.util.tracker
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.config.core.impl.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/config/src/main/java/org/apache/karaf/config/core/impl/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/config/src/main/java/org/apache/karaf/config/core/impl/osgi/Activator.java b/config/src/main/java/org/apache/karaf/config/core/impl/osgi/Activator.java
index bdfab09..ca5268f 100644
--- a/config/src/main/java/org/apache/karaf/config/core/impl/osgi/Activator.java
+++ b/config/src/main/java/org/apache/karaf/config/core/impl/osgi/Activator.java
@@ -20,15 +20,17 @@ import org.apache.karaf.config.core.ConfigRepository;
 import org.apache.karaf.config.core.impl.ConfigMBeanImpl;
 import org.apache.karaf.config.core.impl.ConfigRepositoryImpl;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
 import org.osgi.service.cm.ConfigurationAdmin;
 
+@Services(
+        requires = @RequireService(ConfigurationAdmin.class),
+        provides = @ProvideService(ConfigRepository.class)
+)
 public class Activator extends BaseActivator {
 
-    @Override
-    protected void doOpen() throws Exception {
-        trackService(ConfigurationAdmin.class);
-    }
-
     protected void doStart() throws Exception {
         ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
         if (configurationAdmin == null) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/deployer/blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/deployer/blueprint/pom.xml b/deployer/blueprint/pom.xml
index 008f533..3fa0fea 100644
--- a/deployer/blueprint/pom.xml
+++ b/deployer/blueprint/pom.xml
@@ -84,6 +84,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -95,6 +99,12 @@
                             org.apache.karaf.util,
                             org.apache.karaf.util.tracker
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.deployer.blueprint.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/deployer/blueprint/src/main/java/org/apache/karaf/deployer/blueprint/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/deployer/blueprint/src/main/java/org/apache/karaf/deployer/blueprint/osgi/Activator.java b/deployer/blueprint/src/main/java/org/apache/karaf/deployer/blueprint/osgi/Activator.java
index 5251150..fe9f0dc 100644
--- a/deployer/blueprint/src/main/java/org/apache/karaf/deployer/blueprint/osgi/Activator.java
+++ b/deployer/blueprint/src/main/java/org/apache/karaf/deployer/blueprint/osgi/Activator.java
@@ -33,7 +33,7 @@ public class Activator extends BaseActivator {
         Hashtable<String, Object> props = new Hashtable<String, Object>();
         props.put("url.handler.protocol", "blueprint");
         register(URLStreamHandlerService.class, new BlueprintURLHandler(), props);
-        register(new String[]{ArtifactUrlTransformer.class.getName(), ArtifactListener.class.getName()},
+        register(new Class[] { ArtifactUrlTransformer.class, ArtifactListener.class },
                 new BlueprintDeploymentListener());
     }
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/deployer/features/pom.xml
----------------------------------------------------------------------
diff --git a/deployer/features/pom.xml b/deployer/features/pom.xml
index c3414a0..9a1bbbd 100644
--- a/deployer/features/pom.xml
+++ b/deployer/features/pom.xml
@@ -54,6 +54,11 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
             <groupId>org.springframework.osgi</groupId>
             <artifactId>spring-osgi-core</artifactId>
             <scope>provided</scope>
@@ -87,6 +92,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -98,6 +107,12 @@
                             org.apache.karaf.util,
                             org.apache.karaf.util.tracker
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.deployer.features.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/deployer/features/src/main/java/org/apache/karaf/deployer/features/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/deployer/features/src/main/java/org/apache/karaf/deployer/features/osgi/Activator.java b/deployer/features/src/main/java/org/apache/karaf/deployer/features/osgi/Activator.java
index cffb688..43c5ba3 100644
--- a/deployer/features/src/main/java/org/apache/karaf/deployer/features/osgi/Activator.java
+++ b/deployer/features/src/main/java/org/apache/karaf/deployer/features/osgi/Activator.java
@@ -25,18 +25,16 @@ import org.apache.karaf.deployer.features.FeatureDeploymentListener;
 import org.apache.karaf.deployer.features.FeatureURLHandler;
 import org.apache.karaf.features.FeaturesService;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
 import org.osgi.service.url.URLStreamHandlerService;
 
+@Services(requires = @RequireService(FeaturesService.class))
 public class Activator extends BaseActivator {
 
     private FeatureDeploymentListener listener;
 
     @Override
-    protected void doOpen() throws Exception {
-        trackService(FeaturesService.class);
-    }
-
-    @Override
     protected void doStart() throws Exception {
         FeaturesService service = getTrackedService(FeaturesService.class);
         if (service == null) {
@@ -52,9 +50,8 @@ public class Activator extends BaseActivator {
         listener.setFeaturesService(service);
         listener.setBundleContext(bundleContext);
         listener.init();
-        register(new String[]{
-                ArtifactUrlTransformer.class.getName(), ArtifactListener.class.getName()
-        }, listener);
+        register(new Class[] { ArtifactUrlTransformer.class, ArtifactListener.class },
+                 listener);
     }
 
     protected void doStop() {

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/deployer/kar/pom.xml
----------------------------------------------------------------------
diff --git a/deployer/kar/pom.xml b/deployer/kar/pom.xml
index d90dbac..45228a6 100644
--- a/deployer/kar/pom.xml
+++ b/deployer/kar/pom.xml
@@ -53,6 +53,17 @@
             <artifactId>org.osgi.core</artifactId>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.karaf.features</groupId>
+            <artifactId>org.apache.karaf.features.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
 
         <dependency>
             <groupId>org.apache.karaf.kar</groupId>
@@ -90,6 +101,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -100,6 +115,12 @@
                             org.apache.karaf.deployer.kar.osgi,
                             org.apache.karaf.util.tracker
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.deployer.kar.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/deployer/kar/src/main/java/org/apache/karaf/deployer/kar/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/deployer/kar/src/main/java/org/apache/karaf/deployer/kar/osgi/Activator.java b/deployer/kar/src/main/java/org/apache/karaf/deployer/kar/osgi/Activator.java
index ac3b520..e86e7cf 100644
--- a/deployer/kar/src/main/java/org/apache/karaf/deployer/kar/osgi/Activator.java
+++ b/deployer/kar/src/main/java/org/apache/karaf/deployer/kar/osgi/Activator.java
@@ -22,21 +22,19 @@ import org.apache.felix.fileinstall.ArtifactListener;
 import org.apache.karaf.deployer.kar.KarArtifactInstaller;
 import org.apache.karaf.kar.KarService;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
 
+@Services(requires = @RequireService(KarService.class))
 public class Activator extends BaseActivator {
 
     @Override
-    protected void doOpen() throws Exception {
-        trackService(KarService.class);
-    }
-
-    @Override
     protected void doStart() throws Exception {
         KarService service = getTrackedService(KarService.class);
         if (service != null) {
             KarArtifactInstaller installer = new KarArtifactInstaller();
             installer.setKarService(service);
-            register(new String[] { ArtifactInstaller.class.getName(), ArtifactListener.class.getName() },
+            register(new Class[] { ArtifactInstaller.class, ArtifactListener.class },
                      installer);
         }
     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/deployer/spring/pom.xml
----------------------------------------------------------------------
diff --git a/deployer/spring/pom.xml b/deployer/spring/pom.xml
index a812842..28f4f3c 100644
--- a/deployer/spring/pom.xml
+++ b/deployer/spring/pom.xml
@@ -88,6 +88,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -99,6 +103,12 @@
                             org.apache.karaf.util,
                             org.apache.karaf.util.tracker
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.deployer.spring.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/deployer/spring/src/main/java/org/apache/karaf/deployer/spring/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/deployer/spring/src/main/java/org/apache/karaf/deployer/spring/osgi/Activator.java b/deployer/spring/src/main/java/org/apache/karaf/deployer/spring/osgi/Activator.java
index 116524c..d878e99 100644
--- a/deployer/spring/src/main/java/org/apache/karaf/deployer/spring/osgi/Activator.java
+++ b/deployer/spring/src/main/java/org/apache/karaf/deployer/spring/osgi/Activator.java
@@ -33,7 +33,7 @@ public class Activator extends BaseActivator {
         Hashtable<String, Object> props = new Hashtable<String, Object>();
         props.put("url.handler.protocol", "spring");
         register(URLStreamHandlerService.class, new SpringURLHandler(), props);
-        register(new String[] { ArtifactUrlTransformer.class.getName(), ArtifactListener.class.getName() },
+        register(new Class[] { ArtifactUrlTransformer.class, ArtifactListener.class },
                  new SpringDeploymentListener());
     }
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/deployer/wrap/pom.xml
----------------------------------------------------------------------
diff --git a/deployer/wrap/pom.xml b/deployer/wrap/pom.xml
index 12269d4..c02bc2d 100644
--- a/deployer/wrap/pom.xml
+++ b/deployer/wrap/pom.xml
@@ -73,6 +73,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -84,6 +88,12 @@
                             org.apache.karaf.util,
                             org.apache.karaf.util.tracker
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.deployer.wrap.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/deployer/wrap/src/main/java/org/apache/karaf/deployer/wrap/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/deployer/wrap/src/main/java/org/apache/karaf/deployer/wrap/osgi/Activator.java b/deployer/wrap/src/main/java/org/apache/karaf/deployer/wrap/osgi/Activator.java
index e992f91..4486492 100644
--- a/deployer/wrap/src/main/java/org/apache/karaf/deployer/wrap/osgi/Activator.java
+++ b/deployer/wrap/src/main/java/org/apache/karaf/deployer/wrap/osgi/Activator.java
@@ -22,22 +22,15 @@ import java.util.Hashtable;
 import org.apache.felix.fileinstall.ArtifactUrlTransformer;
 import org.apache.karaf.deployer.wrap.WrapDeploymentListener;
 import org.apache.karaf.util.tracker.BaseActivator;
-import org.apache.karaf.util.tracker.SingleServiceTracker;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
 import org.osgi.service.url.URLStreamHandlerService;
 
+@Services(requires = {
+    @RequireService(value = URLStreamHandlerService.class, filter = "(url.handler.protocol=wrap)")
+})
 public class Activator extends BaseActivator {
 
-    private BundleContext bundleContext;
-    private ServiceRegistration<ArtifactUrlTransformer> urlTransformerRegistration;
-    private SingleServiceTracker<URLStreamHandlerService> urlHandlerTracker;
-
-    @Override
-    protected void doOpen() throws Exception {
-        trackService(URLStreamHandlerService.class, "(url.handler.protocol=wrap)");
-    }
-
     @Override
     protected void doStart() throws Exception {
         Hashtable<String, Object> props = new Hashtable<String, Object>();

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/diagnostic/pom.xml
----------------------------------------------------------------------
diff --git a/diagnostic/pom.xml b/diagnostic/pom.xml
index c89a72d..cacb84f 100644
--- a/diagnostic/pom.xml
+++ b/diagnostic/pom.xml
@@ -87,6 +87,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -106,6 +110,12 @@
                             org.apache.karaf.util,
                             org.apache.karaf.util.tracker
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.diagnostic.core.internal.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/features/core/pom.xml
----------------------------------------------------------------------
diff --git a/features/core/pom.xml b/features/core/pom.xml
index 7972022..2a78de9 100644
--- a/features/core/pom.xml
+++ b/features/core/pom.xml
@@ -108,6 +108,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -125,12 +129,10 @@
                             !org.eclipse.osgi.service.resolver,
                             *
                         </Import-Package>
-                        <Provide-Capability>
-                            osgi.service;effective:=active;objectClass=org.apache.karaf.features.FeaturesService
-                        </Provide-Capability>
                         <Private-Package>
                             org.apache.karaf.features.internal.*,
                             org.apache.felix.resolver,
+                            org.apache.felix.utils.collections,
                             org.apache.felix.utils.version,
                             org.apache.felix.utils.properties,
                             org.apache.felix.utils.manifest,

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
index 5db6204..3be20e5 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
@@ -45,6 +45,9 @@ import org.apache.karaf.features.internal.service.FeatureFinder;
 import org.apache.karaf.features.internal.service.FeaturesServiceImpl;
 import org.apache.karaf.features.internal.service.StateStorage;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
 import org.eclipse.equinox.internal.region.DigraphHelper;
 import org.eclipse.equinox.internal.region.StandardRegionDigraph;
 import org.eclipse.equinox.internal.region.management.StandardManageableRegionDigraph;
@@ -62,6 +65,17 @@ import org.osgi.util.tracker.ServiceTracker;
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
 import org.slf4j.LoggerFactory;
 
+@Services(
+    requires = {
+            @RequireService(ConfigurationAdmin.class),
+            @RequireService(value = URLStreamHandlerService.class, filter = "(url.handler.protocol=mvn)")
+    },
+    provides = {
+            @ProvideService(FeaturesService.class),
+            @ProvideService(RegionDigraph.class),
+            @ProvideService(Resolver.class)
+    }
+)
 public class Activator extends BaseActivator {
 
     public static final String FEATURES_REPOS_PID = "org.apache.karaf.features.repos";
@@ -82,8 +96,7 @@ public class Activator extends BaseActivator {
 
     @Override
     protected void doOpen() throws Exception {
-        trackService(URLStreamHandlerService.class, "(url.handler.protocol=mvn)");
-        trackService(ConfigurationAdmin.class);
+        super.doOpen();
 
         Properties configuration = new Properties();
         File configFile = new File(System.getProperty("karaf.etc"), FEATURES_SERVICE_CONFIG_FILE);

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolver.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolver.java b/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolver.java
index d3b826f..2682e58 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolver.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolver.java
@@ -26,12 +26,14 @@ import java.util.Set;
 
 import org.apache.felix.resolver.ResolverImpl;
 import org.apache.felix.resolver.Util;
+import org.apache.felix.utils.collections.DictionaryAsMap;
 import org.apache.karaf.features.BundleInfo;
 import org.apache.karaf.features.Feature;
 import org.apache.karaf.features.internal.download.DownloadManager;
 import org.apache.karaf.features.internal.download.Downloader;
 import org.apache.karaf.features.internal.download.StreamProvider;
 import org.apache.karaf.features.internal.download.simple.SimpleDownloader;
+import org.apache.karaf.features.internal.resolver.CapabilityImpl;
 import org.apache.karaf.features.internal.resolver.CapabilitySet;
 import org.apache.karaf.features.internal.resolver.ResourceBuilder;
 import org.apache.karaf.features.internal.resolver.ResourceImpl;
@@ -45,6 +47,7 @@ import org.osgi.framework.BundleException;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.Version;
 import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.namespace.service.ServiceNamespace;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
@@ -146,7 +149,16 @@ public class SubsystemResolver {
                 ss = ss.getChild(path);
             }
             if (ss != null) {
+                ResourceImpl dummy = new ResourceImpl("dummy", "dummy", Version.emptyVersion);
                 for (BundleRevision res : entry.getValue()) {
+                    // We need to explicitely provide service capabilities for bundles
+                    // We use both actual services and services declared from the headers
+                    // TODO: use actual services
+                    Map<String, String> headers = new DictionaryAsMap<>(res.getBundle().getHeaders());
+                    Resource tmp = ResourceBuilder.build(res.getBundle().getLocation(), headers);
+                    for (Capability cap : tmp.getCapabilities(ServiceNamespace.SERVICE_NAMESPACE)) {
+                        dummy.addCapability(new CapabilityImpl(dummy, cap.getNamespace(), cap.getDirectives() ,cap.getAttributes()));
+                    }
                     ss.addSystemResource(res);
                     for (Capability cap : res.getCapabilities(null)) {
                         hasEeCap |= cap.getNamespace().equals(EXECUTION_ENVIRONMENT_NAMESPACE);
@@ -155,6 +167,7 @@ public class SubsystemResolver {
                         sysBundleRev = res;
                     }
                 }
+                ss.addSystemResource(dummy);
             }
         }
         // Under Equinox, the osgi.ee capabilities are not provided by the system bundle

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceUtils.java b/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceUtils.java
index 9657689..d6cfe1d 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceUtils.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/resolver/ResourceUtils.java
@@ -43,6 +43,16 @@ public final class ResourceUtils {
     private ResourceUtils() {
     }
 
+    public static String getType(Resource resource) {
+        List<Capability> caps = resource.getCapabilities(null);
+        for (Capability cap : caps) {
+            if (cap.getNamespace().equals(IDENTITY_NAMESPACE)) {
+                return cap.getAttributes().get(CAPABILITY_TYPE_ATTRIBUTE).toString();
+            }
+        }
+        return null;
+    }
+
     public static String getUri(Resource resource) {
         List<Capability> caps = resource.getCapabilities(null);
         for (Capability cap : caps) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
index c636fbe..5a1cd02 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
@@ -70,6 +70,7 @@ import static org.apache.felix.resolver.Util.getVersion;
 import static org.apache.karaf.features.FeaturesService.ROOT_REGION;
 import static org.apache.karaf.features.internal.resolver.ResourceUtils.TYPE_SUBSYSTEM;
 import static org.apache.karaf.features.internal.resolver.ResourceUtils.getFeatureId;
+import static org.apache.karaf.features.internal.resolver.ResourceUtils.getType;
 import static org.apache.karaf.features.internal.resolver.ResourceUtils.getUri;
 import static org.apache.karaf.features.FeaturesService.UPDATEABLE_URIS;
 import static org.apache.karaf.features.FeaturesService.UPDATE_SNAPSHOTS_ALWAYS;
@@ -88,8 +89,8 @@ import static org.osgi.framework.Bundle.STARTING;
 import static org.osgi.framework.Bundle.STOPPING;
 import static org.osgi.framework.Bundle.STOP_TRANSIENT;
 import static org.osgi.framework.Bundle.UNINSTALLED;
-import static org.osgi.framework.namespace.IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE;
 import static org.osgi.framework.namespace.IdentityNamespace.IDENTITY_NAMESPACE;
+import static org.osgi.framework.namespace.IdentityNamespace.TYPE_BUNDLE;
 import static org.osgi.resource.Namespace.CAPABILITY_EFFECTIVE_DIRECTIVE;
 import static org.osgi.resource.Namespace.EFFECTIVE_ACTIVE;
 
@@ -749,13 +750,11 @@ public class Deployer {
     }
 
     private boolean isSubsystem(Resource resource) {
-        for (Capability cap : resource.getCapabilities(null)) {
-            if (cap.getNamespace().equals(IDENTITY_NAMESPACE)) {
-                String type = (String) cap.getAttributes().get(CAPABILITY_TYPE_ATTRIBUTE);
-                return (type != null) && type.equals(TYPE_SUBSYSTEM);
-            }
-        }
-        return false;
+        return TYPE_SUBSYSTEM.equals(getType(resource));
+    }
+
+    private boolean isBundle(Resource resource) {
+        return TYPE_BUNDLE.equals(getType(resource));
     }
 
     private FeaturesService.RequestedState mergeStates(FeaturesService.RequestedState s1, FeaturesService.RequestedState s2) {
@@ -795,6 +794,9 @@ public class Deployer {
                 List<Wire> newWires = resolution.get(wiring.getRevision());
                 if (newWires != null) {
                     for (Wire wire : newWires) {
+                        if (!isBundle(wire.getProvider())) {
+                            continue;
+                        }
                         Bundle b;
                         if (wire.getProvider() instanceof BundleRevision) {
                             b = ((BundleRevision) wire.getProvider()).getBundle();

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/http/pom.xml
----------------------------------------------------------------------
diff --git a/http/pom.xml b/http/pom.xml
index e162765..df78746 100644
--- a/http/pom.xml
+++ b/http/pom.xml
@@ -104,6 +104,12 @@
                             org.apache.felix.utils.version,
                             org.apache.felix.utils.manifest,
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.http.core.internal.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/http/src/main/java/org/apache/karaf/http/core/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/http/src/main/java/org/apache/karaf/http/core/internal/osgi/Activator.java b/http/src/main/java/org/apache/karaf/http/core/internal/osgi/Activator.java
index a294229..9eb4b21 100644
--- a/http/src/main/java/org/apache/karaf/http/core/internal/osgi/Activator.java
+++ b/http/src/main/java/org/apache/karaf/http/core/internal/osgi/Activator.java
@@ -21,8 +21,11 @@ import org.apache.karaf.http.core.internal.HttpMBeanImpl;
 import org.apache.karaf.http.core.internal.ServletEventHandler;
 import org.apache.karaf.http.core.internal.ServletServiceImpl;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.Services;
 import org.ops4j.pax.web.service.spi.ServletListener;
 
+@Services(provides = @ProvideService(ServletService.class))
 public class Activator extends BaseActivator {
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/instance/pom.xml
----------------------------------------------------------------------
diff --git a/instance/pom.xml b/instance/pom.xml
index bd04934..55948fa 100644
--- a/instance/pom.xml
+++ b/instance/pom.xml
@@ -47,6 +47,12 @@
         </dependency>
 
         <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
             <scope>provided</scope>
@@ -148,6 +154,10 @@
                 </executions>
             </plugin>
             <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>
@@ -164,8 +174,11 @@
                             *
                         </Import-Package>
                         <Provide-Capability>
-                            osgi.service;effective:=active;objectClass=org.apache.karaf.instance.core.InstanceService
+                            ${capabilities}
                         </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Private-Package>
                             org.apache.karaf.jpm,
                             org.apache.karaf.jpm.impl,

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/instance/src/main/java/org/apache/karaf/instance/core/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/instance/src/main/java/org/apache/karaf/instance/core/internal/osgi/Activator.java b/instance/src/main/java/org/apache/karaf/instance/core/internal/osgi/Activator.java
index a50db46..17f68c9 100644
--- a/instance/src/main/java/org/apache/karaf/instance/core/internal/osgi/Activator.java
+++ b/instance/src/main/java/org/apache/karaf/instance/core/internal/osgi/Activator.java
@@ -20,7 +20,10 @@ import org.apache.karaf.instance.core.InstanceService;
 import org.apache.karaf.instance.core.internal.InstanceServiceImpl;
 import org.apache.karaf.instance.core.internal.InstancesMBeanImpl;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.Services;
 
+@Services(provides = @ProvideService(InstanceService.class))
 public class Activator extends BaseActivator {
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/jaas/config/pom.xml
----------------------------------------------------------------------
diff --git a/jaas/config/pom.xml b/jaas/config/pom.xml
index f66ad75..2c561f2 100644
--- a/jaas/config/pom.xml
+++ b/jaas/config/pom.xml
@@ -108,6 +108,9 @@
                         <Private-Package>
                             org.apache.karaf.util.collections
                         </Private-Package>
+                        <Provide-Capability>
+                            osgi.service;effective:=active;objectClass="org.apache.karaf.jaas.config.KeystoreManager
+                        </Provide-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.jaas.config.impl.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/jdbc/pom.xml
----------------------------------------------------------------------
diff --git a/jdbc/pom.xml b/jdbc/pom.xml
index be8ef62..41bc234 100644
--- a/jdbc/pom.xml
+++ b/jdbc/pom.xml
@@ -73,6 +73,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -88,6 +92,12 @@
                             org.apache.karaf.util,
                             org.apache.karaf.util.tracker
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.jdbc.internal.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/jdbc/src/main/java/org/apache/karaf/jdbc/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/karaf/jdbc/internal/osgi/Activator.java b/jdbc/src/main/java/org/apache/karaf/jdbc/internal/osgi/Activator.java
index 8ede97a..8fe66a7 100644
--- a/jdbc/src/main/java/org/apache/karaf/jdbc/internal/osgi/Activator.java
+++ b/jdbc/src/main/java/org/apache/karaf/jdbc/internal/osgi/Activator.java
@@ -20,7 +20,10 @@ import org.apache.karaf.jdbc.JdbcService;
 import org.apache.karaf.jdbc.internal.JdbcMBeanImpl;
 import org.apache.karaf.jdbc.internal.JdbcServiceImpl;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.Services;
 
+@Services(provides = @ProvideService(JdbcService.class))
 public class Activator extends BaseActivator {
     @Override
     protected void doStart() throws Exception {

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/jndi/pom.xml
----------------------------------------------------------------------
diff --git a/jndi/pom.xml b/jndi/pom.xml
index 1b01030..d7b8df6 100644
--- a/jndi/pom.xml
+++ b/jndi/pom.xml
@@ -81,6 +81,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -95,6 +99,12 @@
                             org.apache.karaf.jndi.internal.osgi,
                             org.apache.karaf.util.tracker
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Karaf-Commands>*</Karaf-Commands>
                         <Bundle-Activator>
                             org.apache.karaf.jndi.internal.osgi.Activator

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/jndi/src/main/java/org/apache/karaf/jndi/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/jndi/src/main/java/org/apache/karaf/jndi/internal/osgi/Activator.java b/jndi/src/main/java/org/apache/karaf/jndi/internal/osgi/Activator.java
index 5470e7e..bc6baa8 100644
--- a/jndi/src/main/java/org/apache/karaf/jndi/internal/osgi/Activator.java
+++ b/jndi/src/main/java/org/apache/karaf/jndi/internal/osgi/Activator.java
@@ -26,12 +26,15 @@ import org.apache.karaf.jndi.KarafInitialContextFactory;
 import org.apache.karaf.jndi.internal.JndiMBeanImpl;
 import org.apache.karaf.jndi.internal.JndiServiceImpl;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
 
+@Services(
+        requires = @RequireService(ProxyManager.class),
+        provides = @ProvideService(JndiService.class)
+)
 public class Activator extends BaseActivator {
-    @Override
-    protected void doOpen() throws Exception {
-        trackService(ProxyManager.class);
-    }
 
     @Override
     protected void doStart() throws Exception {

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/kar/pom.xml
----------------------------------------------------------------------
diff --git a/kar/pom.xml b/kar/pom.xml
index f32eaf7..d513632 100644
--- a/kar/pom.xml
+++ b/kar/pom.xml
@@ -98,6 +98,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/kar/src/main/java/org/apache/karaf/kar/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/kar/src/main/java/org/apache/karaf/kar/internal/osgi/Activator.java b/kar/src/main/java/org/apache/karaf/kar/internal/osgi/Activator.java
index 05a1b59..5db2141 100644
--- a/kar/src/main/java/org/apache/karaf/kar/internal/osgi/Activator.java
+++ b/kar/src/main/java/org/apache/karaf/kar/internal/osgi/Activator.java
@@ -21,16 +21,19 @@ import org.apache.karaf.kar.KarService;
 import org.apache.karaf.kar.internal.KarServiceImpl;
 import org.apache.karaf.kar.internal.KarsMBeanImpl;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.Managed;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
 import org.osgi.service.cm.ManagedService;
 
+@Services(
+        requires = @RequireService(FeaturesService.class),
+        provides = @ProvideService(KarService.class)
+)
+@Managed("org.apache.karaf.kar")
 public class Activator extends BaseActivator implements ManagedService {
 
-    @Override
-    protected void doOpen() throws Exception {
-        manage("org.apache.karaf.kar");
-        trackService(FeaturesService.class);
-    }
-
     protected void doStart() throws Exception {
         FeaturesService featuresService = getTrackedService(FeaturesService.class);
         if (featuresService == null) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/log/pom.xml
----------------------------------------------------------------------
diff --git a/log/pom.xml b/log/pom.xml
index 5dec97a..4b3ba9c 100644
--- a/log/pom.xml
+++ b/log/pom.xml
@@ -90,6 +90,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -107,6 +111,12 @@
                             org.apache.karaf.log.core.internal.osgi,
                             org.apache.karaf.util.tracker
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.log.core.internal.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/log/src/main/java/org/apache/karaf/log/core/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/log/src/main/java/org/apache/karaf/log/core/internal/osgi/Activator.java b/log/src/main/java/org/apache/karaf/log/core/internal/osgi/Activator.java
index 2e8c4d8..8540ff0 100644
--- a/log/src/main/java/org/apache/karaf/log/core/internal/osgi/Activator.java
+++ b/log/src/main/java/org/apache/karaf/log/core/internal/osgi/Activator.java
@@ -25,18 +25,21 @@ import org.apache.karaf.log.core.internal.LogMBeanImpl;
 import org.apache.karaf.log.core.internal.LogServiceImpl;
 import org.apache.karaf.log.core.internal.LruList;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.Managed;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
 import org.ops4j.pax.logging.spi.PaxAppender;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.cm.ManagedService;
 
+@Services(
+        requires = @RequireService(ConfigurationAdmin.class),
+        provides = @ProvideService(LogService.class)
+)
+@Managed("org.apache.karaf.log")
 public class Activator extends BaseActivator implements ManagedService {
 
-    @Override
-    protected void doOpen() throws Exception {
-        manage("org.apache.karaf.log");
-        trackService(ConfigurationAdmin.class);
-    }
-
     protected void doStart() throws Exception {
         ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
         if (configurationAdmin == null) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/management/server/pom.xml
----------------------------------------------------------------------
diff --git a/management/server/pom.xml b/management/server/pom.xml
index 1722865..670b024 100644
--- a/management/server/pom.xml
+++ b/management/server/pom.xml
@@ -107,6 +107,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -119,8 +123,11 @@
                             org.apache.karaf.util.tracker
                         </Private-Package>
                         <Provide-Capability>
-                            osgi.service;effective:=active;objectClass=javax.management.MBeanServer
+                            ${capabilities}
                         </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.management.internal.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/management/server/src/main/java/org/apache/karaf/management/internal/Activator.java
----------------------------------------------------------------------
diff --git a/management/server/src/main/java/org/apache/karaf/management/internal/Activator.java b/management/server/src/main/java/org/apache/karaf/management/internal/Activator.java
index 8745d82..45bce44 100644
--- a/management/server/src/main/java/org/apache/karaf/management/internal/Activator.java
+++ b/management/server/src/main/java/org/apache/karaf/management/internal/Activator.java
@@ -29,22 +29,27 @@ import org.apache.karaf.management.KarafMBeanServerGuard;
 import org.apache.karaf.management.MBeanServerFactory;
 import org.apache.karaf.management.RmiRegistryFactory;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.Managed;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.cm.ManagedService;
 
+@Services(
+        requires = {
+                @RequireService(ConfigurationAdmin.class),
+                @RequireService(KeystoreManager.class)
+        },
+        provides = @ProvideService(MBeanServer.class)
+)
+@Managed("org.apache.karaf.management")
 public class Activator extends BaseActivator implements ManagedService {
 
     private ConnectorServerFactory connectorServerFactory;
     private RmiRegistryFactory rmiRegistryFactory;
     private MBeanServerFactory mbeanServerFactory;
 
-    @Override
-    protected void doOpen() throws Exception {
-        manage("org.apache.karaf.management");
-        trackService(ConfigurationAdmin.class);
-        trackService(KeystoreManager.class);
-    }
-
     protected void doStart() throws Exception {
         // Verify dependencies
         ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/obr/pom.xml
----------------------------------------------------------------------
diff --git a/obr/pom.xml b/obr/pom.xml
index 1e9b381..32ab70b 100644
--- a/obr/pom.xml
+++ b/obr/pom.xml
@@ -79,6 +79,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -93,6 +97,12 @@
                             org.apache.karaf.obr.core.internal.osgi,
                             org.apache.karaf.util.tracker
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.obr.core.internal.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/obr/src/main/java/org/apache/karaf/obr/core/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/obr/src/main/java/org/apache/karaf/obr/core/internal/osgi/Activator.java b/obr/src/main/java/org/apache/karaf/obr/core/internal/osgi/Activator.java
index 183508e..70f3f23 100644
--- a/obr/src/main/java/org/apache/karaf/obr/core/internal/osgi/Activator.java
+++ b/obr/src/main/java/org/apache/karaf/obr/core/internal/osgi/Activator.java
@@ -19,15 +19,15 @@ package org.apache.karaf.obr.core.internal.osgi;
 import org.apache.felix.bundlerepository.RepositoryAdmin;
 import org.apache.karaf.obr.core.internal.ObrMBeanImpl;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
 
+@Services(
+        requires = @RequireService(RepositoryAdmin.class)
+)
 public class Activator extends BaseActivator {
 
     @Override
-    protected void doOpen() throws Exception {
-        trackService(RepositoryAdmin.class);
-    }
-
-    @Override
     protected void doStart() throws Exception {
         RepositoryAdmin admin = getTrackedService(RepositoryAdmin.class);
         ObrMBeanImpl mbean = new ObrMBeanImpl(bundleContext, admin);

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/package/pom.xml
----------------------------------------------------------------------
diff --git a/package/pom.xml b/package/pom.xml
index 8c3e1a1..c3a774a 100644
--- a/package/pom.xml
+++ b/package/pom.xml
@@ -100,6 +100,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -115,6 +119,12 @@
                             org.apache.felix.utils.version,
                             org.apache.felix.utils.manifest
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.packages.core.internal.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/package/src/main/java/org/apache/karaf/packages/core/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/package/src/main/java/org/apache/karaf/packages/core/internal/osgi/Activator.java b/package/src/main/java/org/apache/karaf/packages/core/internal/osgi/Activator.java
index ea8ce1d..bf5f526 100644
--- a/package/src/main/java/org/apache/karaf/packages/core/internal/osgi/Activator.java
+++ b/package/src/main/java/org/apache/karaf/packages/core/internal/osgi/Activator.java
@@ -20,7 +20,10 @@ import org.apache.karaf.packages.core.PackageService;
 import org.apache.karaf.packages.core.internal.PackageServiceImpl;
 import org.apache.karaf.packages.core.internal.PackagesMBeanImpl;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.Services;
 
+@Services(provides = @ProvideService(PackageService.class))
 public class Activator extends BaseActivator {
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ccd2259..8aeb574 100644
--- a/pom.xml
+++ b/pom.xml
@@ -162,7 +162,7 @@
         <felix.framework.version>4.4.0</felix.framework.version>
         <felix.framework.security.version>2.4.0</felix.framework.security.version>
         <felix.gogo.version>0.12.0</felix.gogo.version>
-        <felix.plugin.version>2.4.0</felix.plugin.version>
+        <felix.plugin.version>2.4.1-SNAPSHOT</felix.plugin.version>
         <felix.utils.version>1.6.0</felix.utils.version>
         <felix.webconsole.version>4.2.0</felix.webconsole.version>
         <felix.webconsole.api.version>3.1.2</felix.webconsole.api.version>
@@ -1884,23 +1884,6 @@
                     </configuration>
                 </plugin>
                 <plugin>
-                    <groupId>org.apache.felix</groupId>
-                    <artifactId>maven-bundle-plugin</artifactId>
-                    <version>${felix.plugin.version}</version>
-                    <extensions>true</extensions>
-                    <configuration>
-                        <instructions>
-                            <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                            <Export-Package>${project.artifactId}*;version=${project.version}</Export-Package>
-                            <_versionpolicy>${bnd.version.policy}</_versionpolicy>
-                            <!--
-                            <nsh_interface>org.apache.aries.blueprint.NamespaceHandler</nsh_interface>
-                            <nsh_namespace>osgi.service.blueprint.namespace</nsh_namespace>
-                            -->
-                        </instructions>
-                    </configuration>
-                </plugin>
-                <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-idea-plugin</artifactId>
                     <version>2.2.1</version>
@@ -2074,6 +2057,20 @@
                         </lifecycleMappingMetadata>
                     </configuration>
                 </plugin>
+                <plugin>
+                    <groupId>org.apache.karaf.tooling</groupId>
+                    <artifactId>karaf-services-maven-plugin</artifactId>
+                    <version>${project.version}</version>
+                    <executions>
+                        <execution>
+                            <id>service-metadata-generate</id>
+                            <phase>process-classes</phase>
+                            <goals>
+                                <goal>service-metadata-generate</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
             </plugins>
         </pluginManagement>
         <plugins>
@@ -2133,12 +2130,17 @@
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
+                <version>${felix.plugin.version}</version>
                 <inherited>true</inherited>
+                <extensions>true</extensions>
                 <configuration>
                     <instructions>
                         <nsh_interface>org.apache.aries.blueprint.NamespaceHandler</nsh_interface>
                         <nsh_namespace>osgi.service.blueprint.namespace</nsh_namespace>
-                        <_removeheaders>Private-Package,Include-Resource</_removeheaders>
+                        <_removeheaders>Private-Package,Include-Resource,Embed-Dependency,Created-By,Bnd-LastModified,Built-By,Tool</_removeheaders>
+                        <Bundle-DocURL>http://karaf.apache.org/</Bundle-DocURL>
+                        <Provide-Capability>${capabilities}</Provide-Capability>
+                        <Require-Capability>${requirements}</Require-Capability>
                     </instructions>
                 </configuration>
                 <executions>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/scheduler/pom.xml
----------------------------------------------------------------------
diff --git a/scheduler/pom.xml b/scheduler/pom.xml
index 9ea1cf0..9d5287f 100644
--- a/scheduler/pom.xml
+++ b/scheduler/pom.xml
@@ -52,6 +52,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -81,6 +85,12 @@
                             org.quartz.simpl.*,
                             org.quartz.utils.*,
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                     </instructions>
                 </configuration>
             </plugin>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/scheduler/src/main/java/org/apache/karaf/scheduler/core/Activator.java
----------------------------------------------------------------------
diff --git a/scheduler/src/main/java/org/apache/karaf/scheduler/core/Activator.java b/scheduler/src/main/java/org/apache/karaf/scheduler/core/Activator.java
index 925d35b..81f6ede 100644
--- a/scheduler/src/main/java/org/apache/karaf/scheduler/core/Activator.java
+++ b/scheduler/src/main/java/org/apache/karaf/scheduler/core/Activator.java
@@ -18,9 +18,12 @@ package org.apache.karaf.scheduler.core;
 
 import org.apache.karaf.scheduler.Scheduler;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.Services;
 import org.quartz.simpl.SimpleThreadPool;
 import org.quartz.spi.ThreadPool;
 
+@Services(provides = @ProvideService(Scheduler.class))
 public class Activator extends BaseActivator {
 
     private ThreadPool threadPool;

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/secured/SecuredSessionFactoryImpl.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/secured/SecuredSessionFactoryImpl.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/secured/SecuredSessionFactoryImpl.java
index 6c4048a..def3bd1 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/secured/SecuredSessionFactoryImpl.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/osgi/secured/SecuredSessionFactoryImpl.java
@@ -40,6 +40,7 @@ import org.apache.karaf.shell.impl.console.SessionFactoryImpl;
 import org.apache.karaf.util.tracker.SingleServiceTracker;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.cm.Configuration;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -61,11 +62,11 @@ public class SecuredSessionFactoryImpl extends SessionFactoryImpl implements Con
     private SingleServiceTracker<ConfigurationAdmin> configAdminTracker;
     private ServiceRegistration registration;
 
-    public SecuredSessionFactoryImpl(BundleContext bundleContext, ThreadIO threadIO) {
+    public SecuredSessionFactoryImpl(BundleContext bundleContext, ThreadIO threadIO) throws InvalidSyntaxException {
         super(threadIO);
         this.bundleContext = bundleContext;
         this.registration = bundleContext.registerService(ConfigurationListener.class, this, null);
-        this.configAdminTracker = new SingleServiceTracker<ConfigurationAdmin>(bundleContext, ConfigurationAdmin.class, this);
+        this.configAdminTracker = new SingleServiceTracker<>(bundleContext, ConfigurationAdmin.class, this);
         this.configAdminTracker.open();
     }
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/shell/ssh/pom.xml
----------------------------------------------------------------------
diff --git a/shell/ssh/pom.xml b/shell/ssh/pom.xml
index 2c103bf..d297159 100644
--- a/shell/ssh/pom.xml
+++ b/shell/ssh/pom.xml
@@ -103,6 +103,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -115,6 +119,12 @@
                             org.apache.karaf.util.jaas,
                             org.apache.karaf.util.tracker
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>org.apache.karaf.shell.ssh.Activator</Bundle-Activator>
                     </instructions>
                 </configuration>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
index 543ccf4..ac5185d 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
@@ -26,6 +26,9 @@ import org.apache.karaf.shell.api.action.lifecycle.Manager;
 import org.apache.karaf.shell.api.console.Session;
 import org.apache.karaf.shell.api.console.SessionFactory;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.Managed;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
 import org.apache.sshd.SshServer;
 import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.server.command.ScpCommandFactory;
@@ -40,6 +43,10 @@ import org.slf4j.LoggerFactory;
 /**
  * Activate this bundle
  */
+@Services(
+        requires = @RequireService(SessionFactory.class)
+)
+@Managed("org.apache.karaf.shell")
 public class Activator extends BaseActivator implements ManagedService {
 
     static final Logger LOGGER = LoggerFactory.getLogger(Activator.class);
@@ -54,8 +61,8 @@ public class Activator extends BaseActivator implements ManagedService {
     protected void doOpen() throws Exception {
         agentFactory = new KarafAgentFactory();
         sshClientFactory = new SshClientFactory(agentFactory, new File(bundleContext.getProperty("user.home"), ".sshkaraf/known_hosts"));
-        manage("org.apache.karaf.shell");
-        trackService(SessionFactory.class);
+
+        super.doOpen();
 
         sessionTracker = new ServiceTracker<Session, Session>(bundleContext, Session.class, null) {
             @Override

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/system/pom.xml
----------------------------------------------------------------------
diff --git a/system/pom.xml b/system/pom.xml
index 59d338a..8729359 100644
--- a/system/pom.xml
+++ b/system/pom.xml
@@ -85,6 +85,10 @@
         </resources>
         <plugins>
             <plugin>
+                <groupId>org.apache.karaf.tooling</groupId>
+                <artifactId>karaf-services-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
                 <configuration>
@@ -101,6 +105,12 @@
                             org.apache.karaf.util.tracker,
                             org.apache.felix.utils.properties
                         </Private-Package>
+                        <Provide-Capability>
+                            ${capabilities}
+                        </Provide-Capability>
+                        <Require-Capability>
+                            ${requirements}
+                        </Require-Capability>
                         <Bundle-Activator>
                             org.apache.karaf.system.internal.osgi.Activator
                         </Bundle-Activator>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/system/src/main/java/org/apache/karaf/system/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/system/src/main/java/org/apache/karaf/system/internal/osgi/Activator.java b/system/src/main/java/org/apache/karaf/system/internal/osgi/Activator.java
index b7f8eab..3bedd82 100644
--- a/system/src/main/java/org/apache/karaf/system/internal/osgi/Activator.java
+++ b/system/src/main/java/org/apache/karaf/system/internal/osgi/Activator.java
@@ -20,7 +20,10 @@ import org.apache.karaf.system.SystemService;
 import org.apache.karaf.system.internal.SystemServiceImpl;
 import org.apache.karaf.system.management.internal.SystemMBeanImpl;
 import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.Services;
 
+@Services(provides = @ProvideService(SystemService.class))
 public class Activator extends BaseActivator {
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/tooling/karaf-services-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/karaf-services-maven-plugin/pom.xml b/tooling/karaf-services-maven-plugin/pom.xml
new file mode 100644
index 0000000..fc48710
--- /dev/null
+++ b/tooling/karaf-services-maven-plugin/pom.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.karaf.tooling</groupId>
+        <artifactId>tooling</artifactId>
+        <version>4.0.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>karaf-services-maven-plugin</artifactId>
+    <packaging>maven-plugin</packaging>
+    <name>Apache Karaf :: Tooling :: Maven Karaf Plugin for Services Metadata</name>
+
+    <properties>
+        <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+            <version>3.0.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.sonatype.aether</groupId>
+            <artifactId>aether-api</artifactId>
+            <version>1.11</version>
+        </dependency>
+        <dependency>
+            <groupId>org.sonatype.aether</groupId>
+            <artifactId>aether-util</artifactId>
+            <version>1.11</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.aether</groupId>
+            <artifactId>aether-api</artifactId>
+            <version>0.9.0.M2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.aether</groupId>
+            <artifactId>aether-util</artifactId>
+            <version>0.9.0.M2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-artifact</artifactId>
+            <version>3.0.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-core</artifactId>
+            <version>3.0.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-compat</artifactId>
+            <version>3.0.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.wagon</groupId>
+            <artifactId>wagon-http-lightweight</artifactId>
+            <version>2.6</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.karaf</groupId>
+            <artifactId>org.apache.karaf.util</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>compile</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-jdk14</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.maven.shared</groupId>
+            <artifactId>maven-filtering</artifactId>
+            <version>1.0-beta-4</version>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.plexus</groupId>
+            <artifactId>plexus-utils</artifactId>
+            <version>3.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>maven-bundle-plugin</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.felix</groupId>
+                    <artifactId>org.apache.felix.bundlerepository</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.xbean</groupId>
+            <artifactId>xbean-finder-shaded</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <reporting>
+        <!--<outputDirectory>target/site</outputDirectory>-->
+        <plugins>
+            <plugin>
+                <artifactId>maven-plugin-plugin</artifactId>
+                <version>2.9</version>
+            </plugin>
+        </plugins>
+    </reporting>
+
+</project>

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java
new file mode 100644
index 0000000..bcf5655
--- /dev/null
+++ b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java
@@ -0,0 +1,148 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.karaf.tooling.tracker;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.karaf.util.tracker.ProvideService;
+import org.apache.karaf.util.tracker.RequireService;
+import org.apache.karaf.util.tracker.Services;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.xbean.finder.ClassFinder;
+
+/**
+ * Generates service requirement and capabilities for activators
+ *
+ * @goal service-metadata-generate
+ * @phase process-classes
+ * @execute phase="generate-resources"
+ * @requiresDependencyResolution compile+runtime
+ * @inheritByDefault false
+ * @description Generates service requirement and capabilities for activators
+ */
+public class GenerateServiceMetadata extends AbstractMojo {
+
+    /**
+     * The maven project.
+     *
+     * @parameter default-value="${project}"
+     * @required
+     */
+    protected MavenProject project;
+
+    /**
+     * @parameter default-value="requirements"
+     * @required
+     */
+    protected String requirementsProperty;
+
+    /**
+     * @parameter default-value="capabilities"
+     * @required
+     */
+    protected String capabilitiesProperty;
+
+    /**
+     * The classloader to use for loading the commands.
+     * Can be "project" or "plugin"
+     *
+     * @parameter default-value="project"
+     */
+    protected String classLoader;
+
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        try {
+            StringBuilder requirements = new StringBuilder();
+            StringBuilder capabilities = new StringBuilder();
+
+            ClassFinder finder = createFinder(classLoader);
+            List<Class<?>> classes = finder.findAnnotatedClasses(Services.class);
+
+            for (Class<?> clazz : classes) {
+                URL classUrl = clazz.getClassLoader().getResource(clazz.getName().replace('.', '/') + ".class");
+                if (classUrl == null || !classUrl.getPath().startsWith(project.getBuild().getOutputDirectory())) {
+                    System.out.println("Ignoring " + classUrl);
+                    continue;
+                }
+                Services services = clazz.getAnnotation(Services.class);
+                if (services != null) {
+                    for (RequireService req : services.requires()) {
+                        String flt = req.filter();
+                        if (flt != null && !flt.isEmpty()) {
+                            flt = "(&(objectClass=" + req.value().getName() + ")" + flt + ")";
+                        } else {
+                            flt = "(objectClass=" + req.value().getName() + ")";
+                        }
+                        if (requirements.length() > 0) {
+                            requirements.append(",");
+                        }
+                        requirements.append("osgi.service;effective:=active;filter:=\"")
+                                    .append(flt)
+                                    .append("\"");
+                    }
+                    for (ProvideService cap : services.provides()) {
+                        if (capabilities.length() > 0) {
+                            capabilities.append(",");
+                        }
+                        capabilities.append("osgi.service;effective:=active;objectClass=")
+                                    .append(cap.value().getName());
+                    }
+                }
+            }
+
+            project.getProperties().setProperty(requirementsProperty, requirements.toString());
+            project.getProperties().setProperty(capabilitiesProperty, capabilities.toString());
+
+        } catch (Exception e) {
+            throw new MojoExecutionException("Error building commands help", e);
+        }
+    }
+
+    private ClassFinder createFinder(String classloaderType) throws Exception {
+        ClassFinder finder;
+        if ("project".equals(classloaderType)) {
+            List<URL> urls = new ArrayList<>();
+
+            urls.add( new File(project.getBuild().getOutputDirectory()).toURI().toURL() );
+            for ( Artifact artifact : project.getArtifacts() ) {
+                File file = artifact.getFile();
+                if ( file != null ) {
+                    urls.add( file.toURI().toURL() );
+                    System.out.println("classpath: " + file);
+                }
+            }
+            ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());
+            finder = new ClassFinder(loader, urls);
+        } else if ("plugin".equals(classLoader)) {
+            finder = new ClassFinder(getClass().getClassLoader());
+        } else {
+            throw new MojoFailureException("classLoader attribute must be 'project' or 'plugin'");
+        }
+        return finder;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/005c0a30/tooling/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/pom.xml b/tooling/pom.xml
index 1437809..317eb8a 100644
--- a/tooling/pom.xml
+++ b/tooling/pom.xml
@@ -34,6 +34,7 @@
     <name>Apache Karaf :: Tooling</name>
 
     <modules>
+        <module>karaf-services-maven-plugin</module>
         <module>karaf-maven-plugin</module>
     </modules>
 


Mime
View raw message