Hi,
I got an active object reference by using:
ao = ComponentAccessor.getOSGiComponentInstanceOfType(ActiveObjects.class);
but when I try to ise it:
ao.find(<Some class>);
a java.lang.reflect.InvocationTargetException is thrown.
Any idea?
Thanks,
Pablo.
ActiveObjects can only be initialized using constructor injection.
The problem is that the object receiving the injected ActiveObject is a spring bean, so all its initialization parameters must be declared in the spring context (META-INF/spring/context.xml) and I am unable to configure ActiveObjects with Spring. Any suggestion?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jobin, I've also read this interesting article from you:
http://www.j-tricks.com/1/post/2012/07/active-objects-injection.html
But I still face the same problem: If I use the JTricksManagerImpl to get a valid reference to the ActiveObject instance, that should also be declared in the spring context:
public class X{ private ActiveObject ao; public X(JTricksManager trick){ ao = trick.getActiveObjects(); } }
In the spring context...
<beans:bean id="foo" class="X"> <beans:constructor-arg index="1" ref="trick" /> </beans:bean>
And the trick reference should also be included in the context:
<beans:bean id="trick" class="com.jtricks.manager.JTricksManagerImpl"> <beans:constructor-arg index="1" ref="ActiveObject?????" /> </beans:bean>
Pablo.
[Edited]
I've guess I did not get the point from your article:
if (this.jTricksManager == null)
this.jTricksManager = ComponentAccessor.getOSGiComponentInstanceOfType(JTricksManager.class);
It looks like I do not need to inject the JtricksManager object.
I'll try your solution!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
FYI,
ComponentAccessor.getOSGiComponentInstanceOfType(JTricksManager.class);
it always returns NULL.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok. Thank you! mainly because this great article:
http://www.j-tricks.com/1/post/2012/07/active-objects-injection.html
Finally, it worked for me.
if (this.jTricksManager == null)
this.jTricksManager = ComponentAccessor.getOSGiComponentInstanceOfType(JTricksManager.class);
it was returning always null becuase it must be called after the spring context is fully initialized, so the problem was in calling it from inside a bean constructor.
Now, I let the bean fully initialize and get the active object reference just before it is going to be used.
Thanks,
Pablo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.