tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject incubator-tamaya git commit: TAMAYA-123: Added injection for Services.
Date Thu, 22 Oct 2015 20:32:24 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master ad303acc7 -> b12d8952e


TAMAYA-123: Added injection for Services.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/b12d8952
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/b12d8952
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/b12d8952

Branch: refs/heads/master
Commit: b12d8952e47b079bd8c593aa9b075858622fc7ce
Parents: ad303ac
Author: Anatole Tresch <anatole@apache.org>
Authored: Thu Oct 22 22:32:04 2015 +0200
Committer: Anatole Tresch <anatole@apache.org>
Committed: Thu Oct 22 22:32:04 2015 +0200

----------------------------------------------------------------------
 .../org/tamaya/integration/osgi/Activator.java  | 22 +++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b12d8952/modules/integration/osgi/src/main/java/org/tamaya/integration/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/modules/integration/osgi/src/main/java/org/tamaya/integration/osgi/Activator.java
b/modules/integration/osgi/src/main/java/org/tamaya/integration/osgi/Activator.java
index 7da7e77..4488bd4 100644
--- a/modules/integration/osgi/src/main/java/org/tamaya/integration/osgi/Activator.java
+++ b/modules/integration/osgi/src/main/java/org/tamaya/integration/osgi/Activator.java
@@ -18,10 +18,8 @@
  */
 package org.tamaya.integration.osgi;
 
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceRegistration;
+import org.apache.tamaya.inject.ConfigurationInjection;
+import org.osgi.framework.*;
 import org.osgi.service.cm.ConfigurationAdmin;
 
 import java.util.Dictionary;
@@ -31,12 +29,14 @@ import java.util.Hashtable;
  * Activator that registers the Tamaya based Service Class for {@link ConfigurationAdmin},
  * using a default service priority of {@code 0}.
  */
-public class Activator implements BundleActivator {
+public class Activator implements BundleActivator, ServiceListener {
 
     private static final String SERVICE_RANKING_PROP = "org.tamaya.integration.cm.ranking";
 
     private static final Integer DEFAULT_RANKING = Integer.MIN_VALUE + 100;
 
+    private BundleContext context;
+
     ServiceRegistration<ConfigurationAdmin> registration;
 
     @Override
@@ -48,6 +48,7 @@ public class Activator implements BundleActivator {
         } else{
             props.put(Constants.SERVICE_RANKING, Integer.valueOf(ranking));
         }
+        this.context = context;
         TamayaConfigAdminImpl cm = new TamayaConfigAdminImpl(context);
         registration = context.registerService(ConfigurationAdmin.class, cm, null);
     }
@@ -58,4 +59,15 @@ public class Activator implements BundleActivator {
             registration.unregister();
         }
     }
+
+    @Override
+    public void serviceChanged(ServiceEvent serviceEvent) {
+        if(ServiceEvent.MODIFIED==serviceEvent.getType() ||
+                ServiceEvent.REGISTERED==serviceEvent.getType()){
+            ServiceReference ref = serviceEvent.getServiceReference();
+            Object service = context.getService(ref);
+            ConfigurationInjection.getConfigurationInjector().configure(service);
+        }
+
+    }
 }


Mime
View raw message