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.

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.

-- 

"They that give up essential liberty to obtain a little temporary safety
  deserve neither liberty nor safety."
                 - Benjamin Franklin


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

Reply via email to