> -----Original Message-----
> From: Justin Permar [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 06, 2004 11:59 PM
> To: Olaf Bergner
> Subject: RE: merlin's use of .xinfo
>
>
> So if I attempt to start up a component that has a dependency,
> and the dependency doesn't exist anywhere (no corresponding
> .xinfo file), merlin will tell you about it?
>
> If so, that answers part of my question.
>
> >Upon
> >deploying a jar Merlin will scan it for any .xinfo files
> included and thus
> >determine which services are provided by this jar. Merlin
> will use this
> >information to automagically resolve service dependencies. If
> you have a
> >look at HelloComponent in the dependencies tutorial you will
> notice the
> >
> >@avalon.dependency type="tutorial.RandomGenerator:1.0"
> > key="random"
> >
> >tag in the service() method. It tells Merlin that this
> component is
> >dependent on another component offering the
> tutorial.RandomGenerator
> >(Version 1.0) service. You do not need to specify the
> implementation class
> >since Merlin will look up a fitting candidate using the
> .xinfo information.
>
> One more question, however. In the dependency example,
> RandomGeneratorProvidor provides service
> "tutorial.RandomGenerator". In addition, the component's name
> is "random". In HelloComponent, the service example gets its
> dependencies in two different ways.
>
> The first is by name. For a variety of reasons, that seems
> awfully brittle (it ties the manager resolution of that
> dependency to declared only in the implementation class, does
> it not?), and really breaks the service-only dependence the
> container tries to achieve, imo. Am I understanding this
> correctly?
>
I am not sure if I understand you correctly but nonetheless I will try to
answer your question. The
@avalon.dependency type="tutorial.RandomGenerator:1.0"
key="random"
tag in HelloComponent's service() method tells Merlin that this component
(HelloComponent) expects to find a component implementing the service
interface "tutorial.RandomGenerator" (Version 1.0) under the key "random" in
the service manager passed to it. It is not the case that the component
offering said service has to tell Merlin that it should be stored under the
key "random" in the ServiceManager. Instead, Merlin will at runtime look up
an implementation of "tutorial.RandomGenerator" (using the knowledge gleaned
from the .xinfo files) and store it under the key "random" in the
ServiceManager passed to HelloComponent. I hope this answers your question.
> The second way is by Identifiable.class.getName(). Using this
> way, does the ServiceManager indeed get a component simply
> based on the interface (service) that HelloComponent depends
> upon (Identifiable). In other words, will this always work:
>
> A depends upon service "Foo". There is a "Foo" interface (java
> interface) written. In addition "FooImpl" implements the
> interface.
>
> Can I actually always say:
>
> manager.lookup(Foo.class.getName()), and the component
> implementing that service interface will be returned to me?
I think you can always look up a service by using its fully qualified
classname as a key. Otherwise a component has to explicitly tell Merlin
under which key it expects to find a specific service in its ServiceManager.
> What happens when there are two implementations of the same
> service? Does the container simply check that versions of the
> implementations are different, or complain if they are the same?
>
This is a different story and to the best of my knowledge an as yet
unresolved issue. The ECM (a now deprecated container) supported the concept
of "hints" given to the container by a requesting component. This turned out
to be problematic (don't ask me why) and the issue is being worked on. In
the meantime it is commonly advised that in cases where you might need
different implementation of the same service interface you should store a
factory for this service in the service manager, not the service proper.
> Thanks!
>
> Justin
Have fun,
Olaf
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]