You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Noel J. Bergman" <no...@devtech.com> on 2002/08/20 22:28:19 UTC

ComponentManager.put() vs james-assembly.xml

Danny,

I am looking at the code, and trying to understand something.  In
James.java, there are some places were we have:

   compMgr.put(MailServer.ROLE, this);

A similar call

   compMgr.put("org.apache.mailet.MailetContext", this)

is commented out.

JamesSpoolManager gets the MailetContext by looking it up with exactly that
string from the component manager, so clearly it is registered.  The only
other reference to the string is in james-assembly, where the
JamesSpoolManager block has an element that says:

  <provide name="James" role="org.apache.mailet.MailetContext"/>

which I understand to say that the entity labeled as James provides the
MailetContext role to the Spooler.

Is the difference because MailServer.ROLE is looked up by many objects that
are not components, and don't have their own block in the assembly file,
thus there is no other way to specify what object provides that role to
them?

	--- Noel


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ComponentManager.put() vs james-assembly.xml

Posted by Stephen McConnell <mc...@apache.org>.

Noel J. Bergman wrote:

>Harmeet,
>
>Thanks, but that doesn't appear to address the question.  I wasn't concerned
>about the use of a string being a class member or an embedded constant.  I
>was asking about the use of ComponentManager.put() compared with the XML
>registration of components, e.g.,
>
>   compMgr.put("org.apache.mailet.MailetContext", this)
>
>vs
>
>   <provide name="James" role="org.apache.mailet.MailetContext"/>
>

In the compMger.put("something", this ) - your basically defining a 
container context relective to some components your going to supply this 
component manager to.  This is handy when you dealing with fine grain 
components.  In the <provide/> case, you giving instructions to a higher 
level container (in this case Phoenix) to handle the responsibility. 
 Generally speaking I would say that it better to declare this formally 
(i.e. use the provide clause and the associated block infomation) 
because the overall picture of the James component model stays a tad 
clearer for people like me!  It also forces you to be more strict about 
the declaration of components.

Cheers, Steve.

>
>	--- Noel
>
>-----Original Message-----
>From: Harmeet Bedi [mailto:harmeet@kodemuse.com]
>Sent: Tuesday, August 20, 2002 19:43
>To: James Developers List
>Subject: Re: ComponentManager.put() vs james-assembly.xml
>
>
>Avalon folks recommended that the each component should have a ROLE
>constant. Lookup should be based on that components ROLE rather than
>hardcoded class name.  I guess it has been partially followed. I
>think at some point Paul or Peter had made a sweep.
>
>Recommendation is to use ROLE, so at least new code should follow it.
>
>Harmeet
>----- Original Message -----
>From: "Noel J. Bergman" <no...@devtech.com>
>To: "James-Dev Mailing List" <ja...@jakarta.apache.org>
>Sent: Tuesday, August 20, 2002 1:28 PM
>Subject: ComponentManager.put() vs james-assembly.xml
>
>
>  
>
>>Danny,
>>
>>I am looking at the code, and trying to understand something.  In
>>James.java, there are some places were we have:
>>
>>   compMgr.put(MailServer.ROLE, this);
>>
>>A similar call
>>
>>   compMgr.put("org.apache.mailet.MailetContext", this)
>>
>>is commented out.
>>
>>JamesSpoolManager gets the MailetContext by looking it up with exactly
>>that string from the component manager, so clearly it is registered.  The
>>    
>>
>only
>  
>
>>other reference to the string is in james-assembly, where the
>>JamesSpoolManager block has an element that says:
>>
>>  <provide name="James" role="org.apache.mailet.MailetContext"/>
>>
>>which I understand to say that the entity labeled as James provides the
>>MailetContext role to the Spooler.
>>
>>Is the difference because MailServer.ROLE is looked up by many objects
>>that are not components, and don't have their own block in the assembly
>>    
>>
>file,
>  
>
>>thus there is no other way to specify what object provides that role to
>>them?
>>
>>--- Noel
>>    
>>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>  
>

-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: ComponentManager.put() vs james-assembly.xml

Posted by "Noel J. Bergman" <no...@devtech.com>.
Harmeet,

Thanks, but that doesn't appear to address the question.  I wasn't concerned
about the use of a string being a class member or an embedded constant.  I
was asking about the use of ComponentManager.put() compared with the XML
registration of components, e.g.,

   compMgr.put("org.apache.mailet.MailetContext", this)

vs

   <provide name="James" role="org.apache.mailet.MailetContext"/>

	--- Noel

-----Original Message-----
From: Harmeet Bedi [mailto:harmeet@kodemuse.com]
Sent: Tuesday, August 20, 2002 19:43
To: James Developers List
Subject: Re: ComponentManager.put() vs james-assembly.xml


Avalon folks recommended that the each component should have a ROLE
constant. Lookup should be based on that components ROLE rather than
hardcoded class name.  I guess it has been partially followed. I
think at some point Paul or Peter had made a sweep.

Recommendation is to use ROLE, so at least new code should follow it.

Harmeet
----- Original Message -----
From: "Noel J. Bergman" <no...@devtech.com>
To: "James-Dev Mailing List" <ja...@jakarta.apache.org>
Sent: Tuesday, August 20, 2002 1:28 PM
Subject: ComponentManager.put() vs james-assembly.xml


> Danny,
>
> I am looking at the code, and trying to understand something.  In
> James.java, there are some places were we have:
>
>    compMgr.put(MailServer.ROLE, this);
>
> A similar call
>
>    compMgr.put("org.apache.mailet.MailetContext", this)
>
> is commented out.
>
> JamesSpoolManager gets the MailetContext by looking it up with exactly
> that string from the component manager, so clearly it is registered.  The
only
> other reference to the string is in james-assembly, where the
> JamesSpoolManager block has an element that says:
>
>   <provide name="James" role="org.apache.mailet.MailetContext"/>
>
> which I understand to say that the entity labeled as James provides the
> MailetContext role to the Spooler.
>
> Is the difference because MailServer.ROLE is looked up by many objects
> that are not components, and don't have their own block in the assembly
file,
> thus there is no other way to specify what object provides that role to
> them?
>
> --- Noel


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ComponentManager.put() vs james-assembly.xml

Posted by Harmeet Bedi <ha...@kodemuse.com>.
Avalon folks recommended that the each component should have a ROLE
constant. Lookup should be based on that components ROLE rather than
hardcoded class name.
I guess it has been partially followed. I think at some point Paul or Peter
had made a sweep.

Recommendation is to use ROLE, so at least new code should follow it.

Harmeet
----- Original Message -----
From: "Noel J. Bergman" <no...@devtech.com>
To: "James-Dev Mailing List" <ja...@jakarta.apache.org>
Sent: Tuesday, August 20, 2002 1:28 PM
Subject: ComponentManager.put() vs james-assembly.xml


> Danny,
>
> I am looking at the code, and trying to understand something.  In
> James.java, there are some places were we have:
>
>    compMgr.put(MailServer.ROLE, this);
>
> A similar call
>
>    compMgr.put("org.apache.mailet.MailetContext", this)
>
> is commented out.
>
> JamesSpoolManager gets the MailetContext by looking it up with exactly
that
> string from the component manager, so clearly it is registered.  The only
> other reference to the string is in james-assembly, where the
> JamesSpoolManager block has an element that says:
>
>   <provide name="James" role="org.apache.mailet.MailetContext"/>
>
> which I understand to say that the entity labeled as James provides the
> MailetContext role to the Spooler.
>
> Is the difference because MailServer.ROLE is looked up by many objects
that
> are not components, and don't have their own block in the assembly file,
> thus there is no other way to specify what object provides that role to
> them?
>
> --- Noel
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>