felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gokt...@apache.org
Subject svn commit: r1355560 - /felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
Date Fri, 29 Jun 2012 21:10:20 GMT
Author: gokturk
Date: Fri Jun 29 21:10:19 2012
New Revision: 1355560

URL: http://svn.apache.org/viewvc?rev=1355560&view=rev
Log:
Fix for Felix-3576.

InstanceManager is changed to retrieve BundleContext contructor parameters at configure()
time, and register the first occurence as injector into appropriate position before checking
injector index space consistency.

Modified:
    felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java

Modified: felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java?rev=1355560&r1=1355559&r2=1355560&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
(original)
+++ felix/trunk/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/InstanceManager.java
Fri Jun 29 21:10:19 2012
@@ -30,6 +30,7 @@ import org.apache.felix.ipojo.metadata.E
 import org.apache.felix.ipojo.parser.FieldMetadata;
 import org.apache.felix.ipojo.parser.MethodMetadata;
 import org.apache.felix.ipojo.util.Logger;
+import org.apache.felix.ipojo.util.Property;
 import org.osgi.framework.BundleContext;
 
 /**
@@ -201,6 +202,31 @@ public class InstanceManager implements 
         for (int i = 0; i < m_handlers.length; i++) {
             m_handlers[i].init(this, metadata, configuration);
         }
+        
+        /* Fix for Felix-3576
+         * BundleContext injection is not registered with the InstanceManager.
+         * We're iterating through factory's all constructors and register first
+         * BundleContext parameter as constructor injection. So rest of the code
+         * don't have to do anything to handle BundleContext mixed with other
+         * injections.
+         */
+        MethodMetadata[] constructors = getFactory().getPojoMetadata().getConstructors();
+        for(int i=0; i < constructors.length; i++ )
+        {
+        	String[] ctorArguments = constructors[i].getMethodArguments();
+        	for(int index = 0; index < ctorArguments.length; index++ )
+        	{
+        		if(ctorArguments[index].equals(BundleContext.class.getName()))
+        		{
+        			Property contextInjection = 
+        					new Property("__context", null, null, index, null, 
+        							BundleContext.class.getName(), this, null);
+        			
+        			contextInjection.setValue(getContext());        			
+        			register(index, contextInjection);
+        		}
+        	}
+        }
 
         // Check that the constructor parameter are continuous.
         if (m_constructorRegistration != null) {



Mime
View raw message