Hello,
On 13.12.10 11:41, "Bigard Olivier" <[email protected]> wrote:
>Hello,
>
>
>
>We have an interrogation regarding iPojo instrumentation. We read
>somewhere in the forum that iPopo can instrument inner classes, but we
>are facing a problem when using them in our project.
>
>Here is our use case:
>
>
>
>A first component C1 provides a service with a method "callMe()".
>Another component C2 requires this service.
>
>
>
>Class C2
>
>{
>
> @Requires
>
> Private C1 c1;
>
>
>
> public boolean authenticate()
>
> {
>
> c1.callMe();
>
> return true;
>
> }
>
>}
>
>
>
>A third component C3 requires the component C2. This component C2 is
>used inside an inner class MyFilter.
>
>
>
>Class C3
>
>{
>
> @Requires
>
> private C2 c2;
>
>
>
> @Override
>
> public MyFilter getFilter()
>
> {
>
> return new MyFilter()
>
> {
>
>
>
> @Override
>
> public boolean authenticate()
>
> {
>
> return c2.authenticate();
>
> }
>
> };
>
> }
>
>}
>
>
>
>At last, a component C4 listens for arrival and removal of C3 component
>instances with @Bind/@Unbind methods.
>
>
>
>Class C4
>
>{
>
> @Requires(id = "apis", optional = true)
>
> C3[] apis;
>
>
>
> @Bind(id = "apis")
>
> public void addApi(ServiceReference ref)
>
> {
>
> C3 api = (C3) bundleCtxt.getService(ref);
>
> filter = api.getFilter();
>
> filter.authenticate();
>
> }
>
>}
>
>
>
>Everything works perfectly the first time all the components are
>started. But when we stop and restart the C1 and C2 instances, a
>NullPointerException occurs when calling the method authenticate() of
>the C2 component, because c1 is null. All the iPojo are present and
>valid after the restart, but it seems c1 reference is not updated in c2.
>
>
>
>We manage to make it work by modifiying a little bit the getFilter()
>implementation in the C3 component:
>
>
>
>Class C3
>
>{
>
> public MyFilter getFilter()
>
> {
>
> return new MyFilterImpl(c2);
>
> }
>
>}
>
>
>
>where MyFilterImpl is an implementation of the MyFilter interface.
>
>
>
>Does it trouble iPojo instrumentation when we instantiate inner classes
>like we do or are we misusing iPojo in another way ?
Normally this should work, but I will test it because it looks pretty
strange.
Which version of iPOJO and of the manipulator are you using?
Regards,
Clement
>
>
>
>Thanks
>
>Olivier
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]