Author: pderop
Date: Wed Feb 10 07:53:28 2016
New Revision: 1729542
URL: http://svn.apache.org/viewvc?rev=1729542&view=rev
Log:
FELIX-5177: Did some refactoring:
- removed the getCompositionInstances method.
- Created an "invokdeUpdated" method which is now common to the createService()
and updateService() method.
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FactoryConfigurationAdapterImpl.java
Modified:
felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FactoryConfigurationAdapterImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FactoryConfigurationAdapterImpl.java?rev=1729542&r1=1729541&r2=1729542&view=diff
==============================================================================
---
felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FactoryConfigurationAdapterImpl.java
(original)
+++
felix/trunk/dependencymanager/org.apache.felix.dependencymanager/src/org/apache/felix/dm/impl/FactoryConfigurationAdapterImpl.java
Wed Feb 10 07:53:28 2016
@@ -148,22 +148,7 @@ public class FactoryConfigurationAdapter
((ComponentImpl) newService).instantiateComponent();
CallbackTypeDef callbackInfo = createCallbackType(m_logger,
newService, m_configType, settings);
-
- for (Object instance : getCompositionInstances(newService)) {
- try {
- InvocationUtil.invokeCallbackMethod(instance, m_update,
callbackInfo.m_sigs, callbackInfo.m_args);
- }
- catch (InvocationTargetException e) {
- // The component has thrown an exception during it's
callback invocation.
- handleException(e.getTargetException());
- }
- catch (NoSuchMethodException e) {
- // if the method does not exist, ignore it
- }
- catch (Throwable t) {
- handleException(t); // will rethrow a runtime exception.
- }
- }
+ invokeUpdated(newService, callbackInfo);
return newService;
}
@@ -176,14 +161,11 @@ public class FactoryConfigurationAdapter
public void updateService(Object[] properties) {
Dictionary<String, ?> cmSettings = (Dictionary<String, ?>)
properties[0];
Component service = (Component) properties[1];
- Object[] instances = getUpdateCallbackInstances(service);
-
CallbackTypeDef callbackInfo = createCallbackType(m_logger,
service, m_configType, cmSettings);
try {
- for (Object instance : instances) {
- InvocationUtil.invokeCallbackMethod(instance, m_update,
callbackInfo.m_sigs, callbackInfo.m_args);
- }
+ invokeUpdated(service, callbackInfo);
+
if (m_serviceInterfaces != null && m_propagate == true) {
Dictionary<String, ?> serviceProperties =
getServiceProperties(cmSettings);
service.setServiceProperties(serviceProperties);
@@ -195,6 +177,24 @@ public class FactoryConfigurationAdapter
}
}
+ private void invokeUpdated(Component service, CallbackTypeDef
callbackInfo) {
+ for (Object instance : getUpdateCallbackInstances(service)) {
+ try {
+ InvocationUtil.invokeCallbackMethod(instance, m_update,
callbackInfo.m_sigs, callbackInfo.m_args);
+ }
+ catch (InvocationTargetException e) {
+ // The component has thrown an exception during it's
callback invocation.
+ handleException(e.getTargetException());
+ }
+ catch (NoSuchMethodException e) {
+ // if the method does not exist, ignore it
+ }
+ catch (Throwable t) {
+ handleException(t); // will rethrow a runtime exception.
+ }
+ }
+ }
+
/**
* Returns the Update callback instances.
*/
@@ -206,14 +206,6 @@ public class FactoryConfigurationAdapter
}
}
- private Object[] getCompositionInstances(Component component) {
- if (m_updateCallbackInstance != null) {
- return new Object[] { m_updateCallbackInstance };
- } else {
- return component.getInstances();
- }
- }
-
/**
* Merge CM factory configuration setting with the adapter service
properties. The private CM factory configuration
* settings are ignored. A CM factory configuration property is
private if its name starts with a dot (".").
@@ -267,10 +259,9 @@ public class FactoryConfigurationAdapter
}
}
}
-
/**
- * Extends AdapterImpl for MetaType support.
+ * Extends AdapterImpl for MetaType support (deprecated, now users can
directly use bnd metatypes).
*/
class MetaTypeAdapterImpl extends AdapterImpl implements MetaTypeProvider {
// Our MetaType Provider for describing our properties metadata