Leo Sutic wrote:

> 
>>Hi Leo,
>>
>>I agree with you BUT I am not talking about that.
>>
>>I am not talking about changing the type of a Role but about changing 
>>the type (and name) of the parameter for ComponentManager.lookup() 
>>from:
>>  ComponentManager.lookup(String role)
>>to:
>>  ComponentManager.lookup(Object query)
>>
>  
> Yes, but the query object sent in must match something in the configuration
> of the component manager. That is, for every query object, one must be able 
> to specify something in the configuration to guarantee that the query object
> results in just that component.
> 
> I just see this as making the CM much harder to use - how does the Composable
> component know what query to pass to the CM? How does the CM know how to
> parse an NDimQuery?
> 
> The way I see it, the power of the CM lies in not letting the Composable
> specify *too much* what it wants. The more intricate queries you allow the
> Composable to send, the more complex is the contract between the Composable
> and the CM and the higher the coupling. 


Paulo and Leo,

I spent some time thinking about it last night, and I think the perfect Query

Object would be our very own Context.
It would operate something like this:

ComponentQuery query = new ComponentQuery ();

manager.lookup( query.role( MyComponent.ROLE, myContext ) );



The ComponentQuerywould be an interface similar to this:

interface ComponentQuery
{
     RoleContext role( String role );
     RoleContext role( String role, Context hints );
}

The RoleContext is an object that implements the Context interface, and can
allow any number of hints necessary for the system.  The interface for the
RoleContext would be something like this:

interface RoleContext extends Context
{
     String getRole();
}

The ComponentManager would only use the Role if that is all that is needed.
If there are multiple Components to choose from for the same Role, the
ComponentManager is in charge of the logic to use the hints supplied in the
Context.  The Objects stored in the Context are merely used as hints--nothing
more.

This allows the ComponentManager to be in charge of the query itself.

Of course all this could be simplified with the following changes to the
ComponentManager interface:

interface ComponentManager
{
     Object lookup( String role );
     Object lookup( String role, Context hint );
}



-- 

"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