Applied patch (FELIX-220) to allow callbacks to be private/protected and
fix an issue with managed service configuration.
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@514829 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/ComponentFactory.java b/ipojo/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
index 513a67b..711fabf 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/ComponentFactory.java
@@ -364,8 +364,9 @@
*/
public void updated(String pid, Dictionary properties) throws ConfigurationException {
InstanceManager cm = (InstanceManager) m_componentInstances.get(pid);
- if (cm == null) {
+ if (cm == null) {
try {
+ properties.put("name", pid); // Add the name in the configuration
createComponentInstance(properties);
} catch (UnacceptableConfiguration e) {
m_logger.log(Logger.ERROR, "The configuration is not acceptable : " + e.getMessage());
@@ -376,6 +377,7 @@
cm.stop(); // Stop the component
try {
+ properties.put("name", pid); // Add the name in the configuration
_isAcceptable(properties); // Test if the configuration is acceptable
} catch (UnacceptableConfiguration e) {
m_logger.log(Logger.ERROR, "The configuration is not acceptable : " + e.getMessage());
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java
index 022156b..993bbcd 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/handlers/dependency/DependencyCallback.java
@@ -89,7 +89,8 @@
*/
protected void call() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
// Get the method object
- Method method = m_manager.getClazz().getMethod(m_callback, new Class[] {});
+ Method method = m_manager.getClazz().getDeclaredMethod(m_callback, new Class[] {});
+ method.setAccessible(true);
if (m_isStatic) { method.invoke(null, new Object[] {}); }
else {
@@ -116,7 +117,8 @@
*/
protected void call(ServiceReference ref) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
// Get the method object
- Method method = m_manager.getClazz().getMethod(m_callback, new Class[] {ServiceReference.class});
+ Method method = m_manager.getClazz().getDeclaredMethod(m_callback, new Class[] {ServiceReference.class});
+ method.setAccessible(true);
if (m_isStatic) { method.invoke(null, new Object[] {ref}); }
else {
@@ -143,7 +145,8 @@
*/
protected void call(Object o) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
// Get the method object
- Method method = m_manager.getClazz().getMethod(m_callback, new Class[] {Object.class});
+ Method method = m_manager.getClazz().getDeclaredMethod(m_callback, new Class[] {Object.class});
+ method.setAccessible(true);
if (m_isStatic) { method.invoke(null, new Object[] {o}); }
else {
@@ -169,7 +172,8 @@
* @throws InvocationTargetException : an error happens in the called method
*/
protected void callOnInstance(Object instance) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
- Method method = instance.getClass().getMethod(m_callback, new Class[] {});
+ Method method = instance.getClass().getDeclaredMethod(m_callback, new Class[] {});
+ method.setAccessible(true);
method.invoke(instance, new Object[] {});
}
@@ -183,7 +187,8 @@
* @throws InvocationTargetException
*/
protected void callOnInstance(Object instance, ServiceReference ref) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
- Method method = instance.getClass().getMethod(m_callback, new Class[] {ServiceReference.class});
+ Method method = instance.getClass().getDeclaredMethod(m_callback, new Class[] {ServiceReference.class});
+ method.setAccessible(true);
method.invoke(instance, new Object[] {ref});
}
@@ -197,7 +202,8 @@
* @throws InvocationTargetException
*/
protected void callOnInstance(Object instance, Object o) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
- Method method = instance.getClass().getMethod(m_callback, new Class[] {Object.class});
+ Method method = instance.getClass().getDeclaredMethod(m_callback, new Class[] {Object.class});
+ method.setAccessible(true);
method.invoke(instance, new Object[] {o});
}
}
diff --git a/ipojo/src/main/java/org/apache/felix/ipojo/util/Callback.java b/ipojo/src/main/java/org/apache/felix/ipojo/util/Callback.java
index 9153e53..8e3f2b6 100644
--- a/ipojo/src/main/java/org/apache/felix/ipojo/util/Callback.java
+++ b/ipojo/src/main/java/org/apache/felix/ipojo/util/Callback.java
@@ -66,7 +66,7 @@
*/
public void call() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
m_manager.getFactory().getLogger().log(Logger.INFO, "[" + m_manager.getClassName() + "] Call an callback method : " + m_method);
- Method method = m_manager.getClazz().getMethod(m_method, new Class[] {});
+ Method method = m_manager.getClazz().getDeclaredMethod(m_method, new Class[] {});
method.setAccessible(true);
if (m_isStatic) { method.invoke(null, new Object[]{}); }
@@ -95,7 +95,7 @@
*/
public void call(Object instance) throws NoSuchMethodException,
IllegalAccessException, InvocationTargetException {
- Method method = m_manager.getClazz().getMethod(m_method, new Class[] {});
+ Method method = m_manager.getClazz().getDeclaredMethod(m_method, new Class[] {});
method.setAccessible(true);
method.invoke(instance, new Object[] {});
}
@@ -116,7 +116,7 @@
classes[i] = arg[i].getClass();
}
- Method method = m_manager.getClazz().getMethod(m_method, classes);
+ Method method = m_manager.getClazz().getDeclaredMethod(m_method, classes);
method.setAccessible(true);
if (m_isStatic) { method.invoke(null, arg); }
@@ -150,7 +150,7 @@
classes[i] = arg[i].getClass();
}
- Method method = m_manager.getClazz().getMethod(m_method, classes);
+ Method method = m_manager.getClazz().getDeclaredMethod(m_method, classes);
method.setAccessible(true);
method.invoke(instance, arg);
}