FELIX-624: Use the classloader of the bundle exporting the service to load the service class.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@674514 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/DependencyManager.java b/scr/src/main/java/org/apache/felix/scr/impl/DependencyManager.java
index a842320..983c696 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/DependencyManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/DependencyManager.java
@@ -702,13 +702,14 @@
* @param targetClass the class to which the method belongs to
* @param parameterClassName the name of the class of the parameter that is
* passed to the method
+ * @param serviceBundle the bundle of the registered service.
* @return the method or null
* @throws ClassNotFoundException if the class for parameterClassName cannot
* be found.
* @throws InvocationTargetException If an unexpected error occurrs trying
* to get the method from the targetClass.
*/
- private Method getBindingMethod( String methodname, Class targetClass, String parameterClassName )
+ private Method getBindingMethod( String methodname, Class targetClass, Bundle serviceBundle, String parameterClassName )
throws InvocationTargetException
{
Class parameterClass = null;
@@ -731,7 +732,7 @@
try
{
// Case2 - Service object parameter
- parameterClass = m_componentManager.getActivator().getBundleContext().getBundle().loadClass(
+ parameterClass = serviceBundle.loadClass(
parameterClassName );
return AbstractComponentManager.getMethod( targetClass, methodname, new Class[]
{ parameterClass }, true );
@@ -790,7 +791,7 @@
// if we get here, we have no method, so check the super class
targetClass = targetClass.getSuperclass();
- return ( targetClass != null ) ? getBindingMethod( methodname, targetClass, parameterClassName ) : null;
+ return ( targetClass != null ) ? getBindingMethod( methodname, targetClass, serviceBundle, parameterClassName ) : null;
}
@@ -825,7 +826,7 @@
if ( m_bind == null )
{
m_bind = getBindingMethod( m_dependencyMetadata.getBind(), implementationObject.getClass(),
- m_dependencyMetadata.getInterface() );
+ ref.getBundle(), m_dependencyMetadata.getInterface() );
// 112.3.1 If the method is not found , SCR must log an error
// message with the log service, if present, and ignore the
@@ -929,7 +930,7 @@
if ( m_unbind == null )
{
m_unbind = getBindingMethod( m_dependencyMetadata.getUnbind(), implementationObject.getClass(),
- m_dependencyMetadata.getInterface() );
+ ref.getBundle(), m_dependencyMetadata.getInterface() );
if ( m_unbind == null )
{