On 6/29/10 12:15, Joel Schuster wrote:
What's the functional difference b/t
@Component
@Instantiate
And
@Component( immediate=true)
@Component declares some class as an iPOJO component type. It does not
create an instance. The "immediate" attribute tells iPOJO, "if at some
point in time you create an instance of this type, don't defer
creation", but it still doesn't create an instance, it just tells iPOJO
how to handle instance creation.
@Instantiate actually informs iPOJO to create an instance of the
component type when its dependencies are satisfied at which point in
time iPOJO will defer actual instance creation until a request is made
for a service provided by the instance, unless "immediate=true" is
specified, then iPOJO will instantiate the component as soon as its
dependencies are satisfied. Deferring actual instance creation is a
performance optimization, but sometimes you don't want instantiation to
be deferred because you need to kickstart your application.
Note that @Instantiate may seem convenient, but it is bad practice since
it couples types to instances and makes reuse of your types more
difficult. It is better to use a separate bundle with an iPOJO XML file
to create and configure instances.
-> richard
??
-----Original Message-----
From: Clement Escoffier [mailto:[email protected]]
Sent: Tuesday, June 29, 2010 10:08 AM
To: [email protected]
Subject: Re: iPOJO and OSGi LogService
Hi,
On 29.06.2010, at 16:28, LongkerDandy wrote:
Hi
I've problem to inject the LogService with iPOJO.
My environment is:
Framwork 3.0.1 with Gogo Shell
org.apache.felix.log-1.0.0
iPOJO 1.6.2
I'm trying to inject the LogService with a field:
"private transient LogService logger;"
And with iPOJO metadata.xml configured
<ipojo>
<component name="disks-service"
classname="net.redrabbit.homecenter.system.DisksService">
<requires field="logger"/>
<provides />
<callback transition="validate" method="start"/>
<callback transition="invalidate" method="stop"/>
</component>
<instance name="disks-instance" component="disks-service"/>
</ipojo>
But the logger turned out to be NULL when executing.
I can't understand.
This should work. I tried:
@Component
@Instantiate
public class Test {
@Requires
private transient LogService logger;
@Validate
public void start() {
logger.log(LogService.LOG_INFO, "Hello");
}
}
And I got the expected result.
Could to post the code of your component ?
Regards,
Clement
Regards
LongkerDandy
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]