cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Royal <pro...@apache.org>
Subject Re: [RT] Access to the object model
Date Mon, 19 May 2003 14:31:45 GMT
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

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..

-pete


Mime
View raw message