felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clement Escoffier <clement.escoff...@gmail.com>
Subject Re: IPOJO @Requires & Setters
Date Mon, 25 Mar 2013 12:06:55 GMT
Hi,

iPOJO does not support setting an injected service dependency. So this is not supported:

@Requires
private Service svc;

…
svc = new MyService()
…

The new sec value will be ignored.
However, you can use bind/unbind methods to set the service object you want to use:


@Bind(filter="…")
public void bind(Service svc) {
    this.svc = svc;
}

Your code can call the bind method to set the object to use. Be aware that the svc field does
not have the @Requires anymore and you need to handle the synchronization yourself.

Regards,

Clement

On 23 mars 2013, at 00:41, lessonz <lessonz.legion@gmail.com> wrote:

> I have a field for which I'd like to use the @Requires annotation with a
> filter. That works just fine, but in a test environment I'd like to be able
> to use a setter to replace the service represented by this field at
> runtime. That is, the @Requires has been fulfilled, and I want to replace
> it by way of a setter. This new value doesn't match the filter. Is that the
> issue? Is there a way to do something like this?
> 
> Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message