You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Jason Clark <je...@gmail.com> on 2005/06/21 19:29:00 UTC

globally accessible object

Is there a way in james to create an object that is globally accessible?

I have an object that loads a great deal of information into memory for 
quick retrieval.
Until recently, only one mailet ever accesesed the object so I placed the 
initialization of that object
in the init method of the mailet. 

Now I want to expose this object to more mailets, but I only want to 
initialize it once.

Can anyone point me in the right direction here? Is there a document that I 
can use to help me along 
with this.

Cheers,
Jason

Re: globally accessible object

Posted by Stefano Bagnara <io...@bago.org>.
> Is there a way in james to create an object that is globally 
> accessible?
> [..]
> Can anyone point me in the right direction here? Is there a 
> document that I can use to help me along with this.

You could create an Avalon Service.
Look at the Avalon documentation and try to understand how kernel.xml and
assembly.xml works.
Once you have a new Avalon Service deployed you can look for it from your
mailets with this code:

ServiceManager serviceMgr =
(ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_M
ANAGER);
YourObject yourObject = (YourObject)
serviceMgr.lookup("fully.qualified.name.of.your.component.interface.YourInte
rface");

To understand how to create services look at the AbstractJamesService and
for example at POP3Server.java, POP3Server.xinfo.

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


R: globally accessible object

Posted by Marcello Marangio <m....@tno.it>.
Hi.
I made a dummy mailet, with and empty service method and static variables
initialized and valued in the init method. 
Could it be enough?
Cheers
Marcello

> -----Messaggio originale-----
> Da: Jason Clark [mailto:jeclark@gmail.com] 
> Inviato: martedì 21 giugno 2005 19.29
> A: James Users List
> Oggetto: globally accessible object
> 
> Is there a way in james to create an object that is globally 
> accessible?
> 
> I have an object that loads a great deal of information into 
> memory for quick retrieval.
> Until recently, only one mailet ever accesesed the object so 
> I placed the initialization of that object in the init method 
> of the mailet. 
> 
> Now I want to expose this object to more mailets, but I only 
> want to initialize it once.
> 
> Can anyone point me in the right direction here? Is there a 
> document that I can use to help me along with this.
> 
> Cheers,
> Jason
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org