cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler" <cziege...@s-und-n.de>
Subject RE: [RT] Access to the object model
Date Mon, 19 May 2003 14:37:58 GMT
Peter Royal wrote:
> 
> On Monday, May 19, 2003, at 09:15  AM, Carsten Ziegeler wrote:
> > I'm not sure if this is working. A component can be thread safe,
> > but each request has an own object model, so I think at least the 
> > context
> > must either be thread local (which would not be that efficient) or
> > you must store some kind of thread handler for the object model
> > in the context. Or do I oversee something?
> 
> Ah, good point :) (I wasn't thinking everything through first thing in 
> the morning).
> 
> The Avalon DefaultContext actually has a solution for this.. Rather 
> than storing the value in the context, store a placeholder object that 
> implements the org.apache.avalon.framework.context.Resolvable 
> interface.. When an item is retrieved from the context, the following 
> occurs:
> 
>              if( data instanceof Resolvable )
>              {
>                  return ( (Resolvable)data ).resolve( this );
>              }
> 
> Then you could have a core, container-level component, the 
> ObjectModelManager such as:
> 
> interface ObjectModelManager
> {
> 	void setModel( Map model );
>       Request getRequest();
>       ...etc...
> }
> 
> which would be responsible for hiding the values for a given request in 
> ThreadLocal's
> 
Ah, thanks Peter, I didn't know Resolvable - ok, that would work then.

> And then the object that is stored in the context would just do a 
> callback to the ObjectModelManager whenever a context value is 
> requested (so for ThreadSafe components, the context value would need 
> to be looked up whenever it is needed, thus guaranteeing that you 
> always retrieve what you want).
> 
> Of course now that I think this through more, its just more trappings 
> on top of your original (a) proposal :)  It seems somehow cleaner to me 
> as components don't have to deal with the static accessor methods 
> themselves though..
> 
Yes, I currently don't know which way is better. Using Context and
Resolvable is somehow cleaner (IoC), but the static version is very
simple. Hmm, has anyone else an opinion?

Carsten

Mime
View raw message