Todor,
Clement should probably be answering this question, since he knows the
details better than me, but I will answer and he can correct me if I am
wrong.
I don't believe that iPOJO ends up using the fields at all, so it
doesn't matter that they are final. As far as nasty surprises, I don't
think there will be an issue since iPOJO handles synchronization for the
POJO. When a thread enters the POJO, it creates a copy of any services
the thread uses until the thread exits the POJO (even if the thread
calls out from the POJO and re-enters it). When the thread makes a
request for a service it always gets the same copy, so the thread never
sees a different value.
Of course, it is possible that its copy has departed and stopped
working, so it may throw exceptions, but that is the nature of OSGi
programming, so that is to be expected.
-> richard
Todor Boev wrote:
Hello,
I managed to make my pojo appear to be constructor injected like so:
@Component(name = "HelloClient", immediate = true)
public class HelloClient {
@Property
private final int delay;
@Requires
private final Hello[] hello;
private Thread thread;
private boolean running;
@SuppressWarnings("unused")
private HelloClient() {
this(null, 0);
}
public HelloClient(Hello[] hello, int delay) {
this.hello = hello;
this.delay = delay;
}
....
}
From the iPojo documentation on the byte code manipulation it appears
to be irrelevant if I have my fields declared final - they are
bypassed at runtime anyway right? Still there seems to be potential
for danger here. The code is compiled against final fields but later
on is manipulated to run against a getter, which can return a
different value every time it is called. Can this cause any nasty
surprises?
Cheers,
Todor
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]