Berin Loritsch wrote:

> In order to satisfy my RT about service attributes used to provide 
> automated assembly logic, we need to make some API changes to Meta. 
> What we are comparing is a Service Reference (i.e. requires service) 
> to a component (i.e. Type) implementation.  The Service descriptor 
> with all the attributes provides the rules to interpret the 
> attributes.  To that end, we need the Service to generate a Comparator. 


Is it Service or DepedencyDescriptor that generates the comparitor?

  * A Container is handling selection of a Type from possibly
    multiple alternatives based on an unresolved dependency.

  * The dependency is declared through a DependencyDescriptor
    that uses a ReferenceDescriptor to point to a Service.

  * A Type is consider a candidate by virtue of the fact that
    it declares that it provides the service through exposure
    of a ServiceDescriptor

  * Ranking of candidate types is achieved by the application of
    "constraints" declared under the DependencyDescriptor relative to
    the attribute values declared under the ServiceDescriptor exposed
    by the candidate Type.

So considering we has two service descriptors SD1 and SD2 and we want to 
compare these for order.  The Comparitor implemetation needs the 
DepedencyDescriptor as the source of criteria for ranking.  The compare 
operation is invoked such that:

   int j = comparitor.compare( SD1, SD2 );

In which case it seems to me that the Comparitor factory is the 
DependencyDescriptor class - not the Service class.  Alternatively, you 
could also look at the DepedecyDescriptor as a comparator.  

Anyway - yes - this would be a usefull addition to the meta package.

Cheers, Steve.

>
>
> public class Service extends Descriptor
> {
>     // .... skip everything else
>
>     public java.lang.Comparator getComparator()
>     {
>         // logic to build the comparator using predicates, etc.
>     }
> } 

>
>
> That way we can create a nice little utility that would find the best
> match:
>
> public final class MetaUtil
> {
>     private MetaUtil() {}
>
>     public static final Object findBestMatch( List components,
>                                               Service service )
>     {
>         // Order so that the best match comes first
>         Collections.order( components, service.getComparator() );
>         return components.get(0);
>     }
> }
>
> Granted, it can still be overridden by an assembly file, but
> this way we can provide the default logic to find the best way to
> generate the assembly file to begin with.
>
-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:[EMAIL PROTECTED]
http://www.osm.net




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to