You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Marcus Crafter <cr...@managesoft.com> on 2003/07/25 17:18:07 UTC

Class rather than ROLE?

Hi All,

Hope all is well!

One questions - I think I remember reading about this a while back on the 
lists but some quick searches couldn't find it.

Our current ROLE convention is to name the class file to be looked up
using the following style:

interface Service {
	String ROLE = Service.class.getName();

	// methods
}

Service s = (Service) m_manager.lookup(Service.ROLE);

Since ROLE is the classes FQN, why not just specify the Class object itself
like:

interface Service {
	// methods
}

Service s = (Service) m_manager.lookup(Service.class);

I know this discussion is not new - just wondering what the advantage is
with the first approach?

Cheers,

Marcus

-- 
        .....
     ,,$$$$$$$$$,      Marcus Crafter
    ;$'      '$$$$:    Computer Systems Engineer
    $:         $$$$:   ManageSoft GmbH
     $       o_)$$$:   82-84 Mainzer Landstrasse
     ;$,    _/\ &&:'   60327 Frankfurt Germany
       '     /( &&&
           \_&&&&'
          &&&&.
    &&&&&&&:

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: Class rather than ROLE?

Posted by Leo Simons <le...@apache.org>.
answers to FAQs like this should really end up in the FAQ (which resides 
on the wiki). Hint, hint ;-)

- Leo

Marcus Crafter wrote:
> Cool - thanks for the clarification :)
 >
 >> Class rather than ROLE?



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: Class rather than ROLE?

Posted by Marcus Crafter <cr...@managesoft.com>.
Cool - thanks for the clarification :)

Cheers,

Marcus

On Fri, Jul 25, 2003 at 11:27:14AM -0400, Berin Loritsch wrote:
> Marcus Crafter wrote:
> 
> >Hi All,
> >
> >
> >I know this discussion is not new - just wondering what the advantage is
> >with the first approach?
> 
> Pretty soon, all containers will allow you to specify an "alias".  That
> way you can look it up like this:
> 
> Service s = (Service) m_manager.lookup("service");
> 
> The container can read the meta information properly so that it knows how
> to map the short name "service" to the actual component type that is needed.
> 
> If we used the Class object, we run into two problems:
> 
> 1) We can't use the alias
> 2) Classloader issues (not all containers are created equally)

-- 
        .....
     ,,$$$$$$$$$,      Marcus Crafter
    ;$'      '$$$$:    Computer Systems Engineer
    $:         $$$$:   ManageSoft GmbH
     $       o_)$$$:   82-84 Mainzer Landstrasse
     ;$,    _/\ &&:'   60327 Frankfurt Germany
       '     /( &&&
           \_&&&&'
          &&&&.
    &&&&&&&:

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: Class rather than ROLE?

Posted by Berin Loritsch <bl...@apache.org>.
Marcus Crafter wrote:

> Hi All,
> 
> 
> I know this discussion is not new - just wondering what the advantage is
> with the first approach?

Pretty soon, all containers will allow you to specify an "alias".  That
way you can look it up like this:

Service s = (Service) m_manager.lookup("service");

The container can read the meta information properly so that it knows how
to map the short name "service" to the actual component type that is needed.

If we used the Class object, we run into two problems:

1) We can't use the alias
2) Classloader issues (not all containers are created equally)

-- 

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


RE: Class rather than ROLE?

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Marcus Crafter wrote:
>
>
> Since ROLE is the classes FQN, why not just specify the Class
> object itself
> like:
>
> interface Service {
> 	// methods
> }
>
> Service s = (Service) m_manager.lookup(Service.class);
>
> I know this discussion is not new - just wondering what the advantage is
> with the first approach?
>
The string approach is more flexible; if you have more than one
implementation
for your role (like e.g. the cocoon generators etc.) then you have
not a one-to-one relationship between the Class and the role string.

Carsten


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org