Richard S. Hall a écrit :
Steven E. Harris wrote:
Clement Escoffier <[EMAIL PROTECTED]> writes:
If you want to create on POJO object, add immediate="true" in the
component tag. By default, the POJO instantiation are delayed
(lazzy). If you do not have "immediate="true" or a invalid->invalid
callback, your POJO is not instantiated until it is really needed
(to serve a service for example).
That's not what I'm seeing here. I took another bundle of mine that
exposes one service. Here's the iPOJO metadata file with the names
changed:
,----
| <?xml version="1.0" encoding="UTF-8"?>
| <iPOJO>
| <component className="mycorp.Service"
| factory="no">
| <provides/>
| </component>
| <instance component="mycorp.Service"
| name="myservice"/>
| </iPOJO>
`----
Note that by specifying the "factory" attribute as "no", my intention
was to not expose a service factory for this component.
When this bundle starts, I see that it's registered a service with
"mycorp.Service" as the service class, a "factory.pid" property of
"mycorp.Service", and a "service.pid" property of "myservice". No
other bundles are using the service or have every requested it, so I'm
surprised to see the service registered.
I'm trying to emulate the lazy loading and exposure of services
(non-immediate, delayed activation) provided by DS. Does iPOJO offer
the same capability? It looks like the "mycorp.Service" component
described above is being treated as an "immediate" component, at least
by default.
Your above metadata is creating an instance of your component with the
<instance> element, thus you are seeing a service being registered
immediately. However, an actual component instance should not be
created until someone actually tries to use the service. At least that
is my understanding of how iPOJO works by default.
You understand correctly ;-)
The component attribute disable the exposition of factory services (both
ManagedServiceFactory and iPOJO Factory). As you declare an instance, it
create the container of the instance. But, the content is empty. The
service provided by the instance is published (it's one of the task
managed by the container). The instance content is only created when
needed (i.e. when the service is used).
Clement
--
Clement Escoffier
Grenoble University
LSR - Bat. C
220, Rue de la Chimie
BP 53
38041 GRENOBLE CEDEX 9
04.76.51.40.24
http://clement.plop-plop.net