You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2015/11/16 21:55:32 UTC
svn commit: r1714673 - in
/felix/trunk/dependencymanager/org.apache.felix.dependencymanager: bnd.bnd
src/org/apache/felix/dm/ConfigurationDependency.java
src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
src/org/apache/felix/dm/packageinfo
Author: pderop
Date: Mon Nov 16 20:55:32 2015
New Revision: 1714673
URL: http://svn.apache.org/viewvc?rev=1714673&view=rev
Log:
FELIX-5104: Call a conf dependency callback Instance with an instantiated component
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager/bnd.bnd
felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/ConfigurationDependency.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/packageinfo
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager/bnd.bnd?rev=1714673&r1=1714672&r2=1714673&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager/bnd.bnd (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager/bnd.bnd Mon Nov 16 20:55:32 2015
@@ -14,11 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
--buildpath: \
+-buildpath: \
osgi.core;version=4.2,\
osgi.cmpn;version=4.2,\
org.mockito.mockito-all;version=1.9,\
- ${junit}
+ ${junit},\
+ biz.aQute.bndlib;version=3.0
Private-Package: \
org.apache.felix.dm.impl,\
org.apache.felix.dm.impl.index,\
@@ -35,7 +36,7 @@ Include-Resource: META-INF/=resources/LI
META-INF/=${workspace}/release/resources/changelog.txt
Import-Package: !org.junit,!org.mockito.*,*
Bundle-Activator: org.apache.felix.dm.impl.Activator
-Bundle-Version: 4.1.2
+Bundle-Version: 4.2.0
Bundle-Name: Apache Felix Dependency Manager
Bundle-Description: Provides dynamic service and component dependency management
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/ConfigurationDependency.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/ConfigurationDependency.java?rev=1714673&r1=1714672&r2=1714673&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/ConfigurationDependency.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/ConfigurationDependency.java Mon Nov 16 20:55:32 2015
@@ -18,6 +18,8 @@
*/
package org.apache.felix.dm;
+import aQute.bnd.annotation.ProviderType;
+
/**
* Configuration dependency that can track the availability of a (valid) configuration. To use
* it, specify a PID for the configuration. The dependency is always required, because if it is
@@ -50,12 +52,15 @@ package org.apache.felix.dm;
*
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
+@ProviderType
public interface ConfigurationDependency extends Dependency, ComponentDependencyDeclaration {
/**
* Sets the name of the callback method that should be invoked when a configuration
* is available. The contract for this method is identical to that of
* <code>ManagedService.updated(Dictionary) throws ConfigurationException</code>.
* By default, if this method is not called, the callback name is "updated".
+ * The callback is always invoked with an already instantiated component (the component implementation class(es) are
+ * always instantiated before the updated callback is invoked).
*
* @param callback the name of the callback method
*/
@@ -65,6 +70,8 @@ public interface ConfigurationDependency
* Sets the name of the callback method that should be invoked when a configuration
* is available. The contract for this method is identical to that of
* <code>ManagedService.updated(Dictionary) throws ConfigurationException</code>.
+ * The callback is called with a component that is not yet instantiated. This allows factory objects to get
+ * injected with a configuration before its <code>create</code> method is called.
*
* @param instance the instance to call the callbacks on
* @param callback the name of the callback method
@@ -72,6 +79,19 @@ public interface ConfigurationDependency
ConfigurationDependency setCallback(Object instance, String callback);
/**
+ * Sets the name of the callback method that should be invoked when a configuration
+ * is available. The contract for this method is identical to that of
+ * <code>ManagedService.updated(Dictionary) throws ConfigurationException</code>.
+ * The component instance is instantiated before the callback is invoked only the the <code>needsInstance</code> parameter is set to true.
+ *
+ * @param instance the instance to call the callback on
+ * @param callback the name of the callback method
+ * @param needsInstance true if the component implementation class(es) must be created before the
+ * callback instance is invoked, else false.
+ */
+ ConfigurationDependency setCallback(Object instance, String callback, boolean needsInstance);
+
+ /**
* Sets the <code>service.pid</code> of the configuration you are depending
* on.
*/
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java?rev=1714673&r1=1714672&r2=1714673&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/ConfigurationDependencyImpl.java Mon Nov 16 20:55:32 2015
@@ -51,6 +51,7 @@ public class ConfigurationDependencyImpl
private final AtomicBoolean m_updateInvokedCache = new AtomicBoolean();
private final Logger m_logger;
private final BundleContext m_context;
+ private boolean m_needsInstance = true;
public ConfigurationDependencyImpl() {
this(null, null);
@@ -69,6 +70,7 @@ public class ConfigurationDependencyImpl
m_pid = prototype.m_pid;
m_logger = prototype.m_logger;
m_metaType = prototype.m_metaType != null ? new MetaTypeProviderImpl(prototype.m_metaType, this, null) : null;
+ m_needsInstance = prototype.needsInstance();
}
@Override
@@ -87,13 +89,18 @@ public class ConfigurationDependencyImpl
}
public ConfigurationDependencyImpl setCallback(Object instance, String callback) {
+ return setCallback(instance, callback, false);
+ }
+
+ public ConfigurationDependencyImpl setCallback(Object instance, String callback, boolean needsInstance) {
super.setCallbacks(instance, callback, null);
+ m_needsInstance = needsInstance;
return this;
}
@Override
public boolean needsInstance() {
- return m_callbackInstance == null;
+ return m_needsInstance;
}
@Override
Modified: felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/packageinfo
URL: http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/packageinfo?rev=1714673&r1=1714672&r2=1714673&view=diff
==============================================================================
--- felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/packageinfo (original)
+++ felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/packageinfo Mon Nov 16 20:55:32 2015
@@ -1 +1 @@
-version 4.1.0
\ No newline at end of file
+version 4.2.0
\ No newline at end of file