felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pde...@apache.org
Subject svn commit: r1729675 - in /felix/trunk/dependencymanager: org.apache.felix.dependencymanager.annotation/src/org/apache/felix/dm/annotation/plugin/bnd/ org.apache.felix.dependencymanager.runtime/src/org/apache/felix/dm/runtime/ org.apache.felix.dependen...
Date Wed, 10 Feb 2016 17:37:02 GMT
Author: pderop
Date: Wed Feb 10 17:37:02 2016
New Revision: 1729675

URL: http://svn.apache.org/viewvc?rev=1729675&view=rev
Log:
FELIX-5177: Added support for configuration proxy on @FactoryConfigurationAdapterService annotation:
if a factoryPidClass is specified when declaring the annotation, then it will be also used
as the configuration proxy.
Also adapted the dictionary.annot sample code.

Modified:
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.annotation/src/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime/src/org/apache/felix/dm/runtime/FactoryConfigurationAdapterServiceBuilder.java
    felix/trunk/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryImpl.java

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.annotation/src/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.annotation/src/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java?rev=1729675&r1=1729674&r2=1729675&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.annotation/src/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.annotation/src/org/apache/felix/dm/annotation/plugin/bnd/AnnotationCollector.java
Wed Feb 10 17:37:02 2016
@@ -921,6 +921,12 @@ public class AnnotationCollector extends
 
         // factory pid attribute (can be specified using the factoryPid attribute, or using
the factoryPidClass attribute)
         String factoryPidClass = parseClassAttrValue(annotation.get(EntryParam.factoryPidClass.toString()));
+        
+        // If a factory pid class is specified, consider it as a possible candidate for a
configuration proxy.
+        if (factoryPidClass != null) {
+            writer.put(EntryParam.confProxyType, factoryPidClass);
+        }
+        
         String factoryPid = factoryPidClass != null ? factoryPidClass : get(annotation, EntryParam.factoryPid.toString(),
m_className);
         
         writer.put(EntryParam.factoryPid, factoryPid);

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime/src/org/apache/felix/dm/runtime/FactoryConfigurationAdapterServiceBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime/src/org/apache/felix/dm/runtime/FactoryConfigurationAdapterServiceBuilder.java?rev=1729675&r1=1729674&r2=1729675&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime/src/org/apache/felix/dm/runtime/FactoryConfigurationAdapterServiceBuilder.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.runtime/src/org/apache/felix/dm/runtime/FactoryConfigurationAdapterServiceBuilder.java
Wed Feb 10 17:37:02 2016
@@ -51,9 +51,23 @@ public class FactoryConfigurationAdapter
         String[] provides = srvMeta.getStrings(Params.provides, null);
         Dictionary<String, Object> properties = srvMeta.getDictionary(Params.properties,
null);
         boolean propagate = "true".equals(srvMeta.getString(Params.propagate, "false"));
-        Component c = dm.createFactoryConfigurationAdapterService(factoryPid, updated, propagate);
+        String configProxyClassName = srvMeta.getString(Params.confProxyType, null);
+        Component c = null;
+        
+        if (configProxyClassName != null)
+        {
+            Class<?> configProxyClass = b.loadClass(configProxyClassName);
+            c = dm.createFactoryConfigurationAdapterService(factoryPid, updated, propagate,
configProxyClass);
+        }
+        else
+        {
+            c = dm.createFactoryConfigurationAdapterService(factoryPid, updated, propagate);
+        }
+
         c.setInterface(provides, properties);
         String factoryMethod = srvMeta.getString(Params.factoryMethod, null);
+        
+        
         if (factoryMethod == null)
         {
             c.setImplementation(implClass);

Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryImpl.java?rev=1729675&r1=1729674&r2=1729675&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryImpl.java
(original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager.samples/src/org/apache/felix/dependencymanager/samples/dictionary/annot/DictionaryImpl.java
Wed Feb 10 17:37:02 2016
@@ -18,7 +18,6 @@
  */
 package org.apache.felix.dependencymanager.samples.dictionary.annot;
 
-import java.util.Dictionary;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.felix.dm.annotation.api.FactoryConfigurationAdapterService;
@@ -26,8 +25,6 @@ import org.apache.felix.dm.annotation.ap
 import org.apache.felix.dm.annotation.api.Start;
 import org.osgi.service.log.LogService;
 
-import aQute.bnd.annotation.metatype.Configurable;
-
 /**
  * A Dictionary Service. This service uses a FactoryConfigurationAdapterService annotation,

  * allowing to instantiate this service from webconsole. This annotation will actually register
@@ -62,16 +59,11 @@ public class DictionaryImpl implements D
      * Our service will be initialized from ConfigAdmin.
      * @param config The configuration where we'll lookup our words list (key=".words").
      */
-    protected void updated(Dictionary<String, ?> config) {
-        if (config != null) {
-            // We use the bnd "Configurable" helper in order to get an implementation for
our DictionaryConfiguration interface.
-			DictionaryConfiguration cnf = Configurable.createConfigurable(DictionaryConfiguration.class,
config);
-
-            m_lang = cnf.lang();
-            m_words.clear();
-            for (String word : cnf.words()) {
-                m_words.add(word);
-            }
+    protected void updated(DictionaryConfiguration cnf) {
+        m_lang = cnf.lang();
+        m_words.clear();
+        for (String word : cnf.words()) {
+            m_words.add(word);
         }
     }
 



Mime
View raw message