Hi,
I am trying to solve a problem that requires more advanced component lookup semantics
than is currently available in Cocoon.
Consider the following service interface:
/**
* A SourceDescriptor describes Source objects
* using SourceProperty objects.
*/
interface SourceDescriptor {
/**
* Find a named SourceProperty associated with a given Source.
*/
SourceProperty getSourceProperty(Source source, String name);
}
Components implementing this interface assert responsibility for a subset of all
possible SourceProperties a Source can have.
Clients that wish to query a Source for all its SourceProperties need to find all
available components that implement this service, clients that wish to query a Source
for one particular SourceProperty need to find the special component that is
responsible for it.
The original solution to this problem has been implemented by a manager component that
acts as a containter to these SourceDescriptor components. Just to indicate the kinds
of problems this created, it turned out that the manager component does not follow the
standard Avalon lifecycle sequence and was never updated to support the Serviceable
stage - both leading to unexpected bugs in my own SourceDescriptor implementation -.
I am wondering whether or not there is a way for components to communicate its
alternative lookup needs to the container. For instance, if I could specify multiple
aliases for a certain component then I could implement my component as follows:
/**
* My SourceDescriptor handles DAV:contentlength and HIP:keywords properties.
*
* @avalon.component
* @avalon.service
* type=SourceDescriptor
* @x-avalon.lifestyle
* type=singleton
* @x-avalon.info
* name=mine
* @x-avalon.alias
* name=HIP:keywords
* @x-avalon.alias
* name=DAV:contentlength
*/
class MySourceDescriptor {
<snip implementation />
}
Client code could now use the name of a property it wants to retrieve as a lookup hint
to the service manager:
manager.lookup(SourceDescriptor.ROLE + "/DAV:contentlength");
Is this possible in one of the current containers? What about the other problem of
retrieving all implemenations of a particular service?
Or shouldn't I be having this requirement in the first place?
Regards, Unico
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]