Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 2.9
-
Fix Version/s: 2.10
-
Component/s: PicoContainer (Java)
-
Labels:None
-
Environment:Windows Vista Business 64bit, Eclipse Galileo, Java 1.6.0_17 (64-bit)
-
Testcase included:yes
-
Number of attachments :2
Description
Run the TestInjector test case in the attached Eclipse project to see the test fail. The output contains more information.
It seems that the "into" parameter of the getComponentInstance method of a FactoryInjector subclass (see AliceFactory in attachment) cannot be used to selectively inject different instances of a component based on the type of the class being injected into; it always resolves to be of type org.picocontainer.ComponentAdapter$NOTHING.
This should be possible as inferred from http://www.picocontainer.org/factory-injection.html.
-
Hide
- TestInjector.zip
- 263 kB
- Johan Hoogenboezem
-
- TestInjector/.classpath 0.4 kB
- TestInjector/.project 0.4 kB
- TestInjector/.../org.eclipse.jdt.core.prefs 0.6 kB
- TestInjector/bin/.../injector/Alice.class 0.1 kB
- TestInjector/bin/.../AliceFactory$1.class 0.6 kB
- TestInjector/bin/.../AliceFactory.class 2 kB
- TestInjector/bin/test/.../injector/Bob.class 0.8 kB
- TestInjector/bin/.../TestInjector.class 2 kB
- TestInjector/lib/picocontainer-2.9.jar 293 kB
- TestInjector/src/.../injector/Alice.java 0.1 kB
- TestInjector/src/.../AliceFactory.java 0.5 kB
- TestInjector/src/test/.../injector/Bob.java 0.3 kB
- TestInjector/src/.../TestInjector.java 0.7 kB
-
Hide
- TestInjector-2.zip
- 766 kB
- Johan Hoogenboezem
-
- TestInjector/.classpath 0.4 kB
- TestInjector/.project 0.4 kB
- TestInjector/.../org.eclipse.jdt.core.prefs 0.6 kB
- TestInjector/bin/.../injector/Alice.class 0.1 kB
- TestInjector/bin/.../AliceFactory.class 2 kB
- TestInjector/bin/.../AliceImpl.class 0.3 kB
- TestInjector/bin/test/.../injector/Bob.class 0.8 kB
- TestInjector/bin/.../TestInjector.class 2 kB
- TestInjector/.../picocontainer-2.10-SNAPSHOT.jar 296 kB
- TestInjector/lib/picocontainer-2.8.jar 280 kB
- TestInjector/lib/picocontainer-2.9.jar 293 kB
- TestInjector/src/.../injector/Alice.java 0.1 kB
- TestInjector/src/.../AliceFactory.java 0.6 kB
- TestInjector/src/.../injector/AliceImpl.java 0.1 kB
- TestInjector/src/test/.../injector/Bob.java 0.3 kB
- TestInjector/src/.../TestInjector.java 0.8 kB
Activity
I had to update AliceFactory to cast the 'into' parameter to InjectInto. Would be nice to have this documented...
awesome work. will apply later. what's your need in respect of a release ?
I can use the snapshot I created, so there's no rush, thanks.
Patch applied with thanks.
Here's a patch:
Index: DefaultPicoContainer.java
===================================================================
DefaultPicoContainer.java (revision 5565)
+++ DefaultPicoContainer.java (working copy)
@@ -684,8 +684,7 @@
intoThreadLocal = new IntoThreadLocal();
}
}
+ instance = componentAdapter.getComponentInstance(this, intoThreadLocal.get());
}
} catch (AbstractInjector.CyclicDependencyException e) {
if (parent != null) {