Stefano Mazzocchi wrote:
>
> No, it is clear now and it was clear before, just that I do not perceive
>
> lookup(role,hint);
>
> and
>
> lookup(role+"/"+hint);
>
> to be architectrually equivalent since they represent two different
> cognitive ways to access to components
Correct.
> and we loose completely the
> ability to match a role to a java interface.
Which is exactly what the proposers of this say: a role is not an
interface, it's just a "tag".
> While using java interfaces for metadata is a limited approach, at least
> it allowed stronger typing. The same can be said for 'role = interface'.
The fact is that the lookup they proposed is not based on roles.
The roles and other metadata are bound by the container, not requested
by the lookup...
> Anyway, since it seems like I'm the only one having such vision, I'll
> shut up and let you guys do your job.
You're not the only one, I still think that it's more natural to ask for
a component using
lookup(role, metadata)
In fact, since I must do a cast, it's reasonable to thik that role is an
interface:
(Role) myobj = (Role)lookup(role, metadata)
Of course, metadata can be more than a string, the fact is that I have
role=what and metadata=how.
The only way in which Java enforces "whats" is by interfaces.
This said, I would like to see answers to all the points I've written
here, so that I can understand better why it's a bad idea.
Maybe I should not call it lookup(), maybe I'm doing the wrong thing...
-oOo-
Anyway, let me try to see alternatives.
Now, lookup(role, metadata) can be intuitive, but how is it used?
Well, role is fixed, while metadata could be fixed or not.
If metadata is fixed, ok, I'm just doing a fixed lookup and I could as
well use a single String to do the lookup...
But I loose the evidence that I'm requesting a component with the strong
contract of an interface.
As for dynamic lookups, I will have a fixed role but varying metadata...
But how do I do the right lookup?
I need to
1. know beforehand all possible components
2. or take a look at the descriptor
But
1. lookup is useless to me if I need to do all the work
2. I'm breaking encapsulation
Static example using a String as metadata.
------------------------------------------
String RoleString=Role.class.toString();
Role myobj1 = (Role) lookup(RoleString, "one");
Role myobj2 = (Role) lookup(RoleString, "two");
Static example using a fixed lookup
------------------------------------
Role myobj1 = (Role) lookup("tag1");
Role myobj2 = (Role) lookup("tag2");
Dynamic example using a String as metadata.
------------------------------------------
String RoleString=Role.class.toString();
ArrayList Metas = userrequests.getMetas();
RoleArrayList MyObjs = new ArrayList;
for(int i=0; i<Metas.size(); i++)
{
RoleArrayList.addObj((Role) lookup(RoleString, Metas.get(i));
}
Static example using a fixed lookup
------------------------------------------
?
--
Nicola Ken Barozzi [EMAIL PROTECTED]
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>