On Jan 27, 8:30 am, Attila Szegedi <[email protected]> wrote:
> I'd go with one filter that opens/closes a context early in the filter
> chain; not necessarily because of the cost, but just to have the
> concern clearly expressed in the system architecture.
> Also, if you're doing request forwarding (i.e. from a controller to a
> view), you might want to have a single context open for both the
> controller action + view rendering.
>
> Attila.
>
> On 2009.01.27., at 16:45, Robert Koberg wrote:
>
> > Hi,
>
> > Say I have two (maybe more) servlet filters. Each filter executes a
> > separate script. For example, the first filter does some
> > authentication/authorization and a second does some business logic.
>
> > Is there no to relatively little cost to Context.enter()/exit() in
> > each filter? Or would it be worthwhile to Context.open() in the
> > first filter and leave open for the rest of the filter chain and
> > finally closing when it returns back down the chain, e.g.
>
> > What would you do?
>
> > Filter1
>
> > Context.open()
>
> > //auth
>
> > next.doFilter(req, res)
>
> > Context.exit()
>
> > Filter2
>
> > if (something) {
> > res.sendRedirect(...)
> > Context.exit()
> > return;
> > }
>
> > // do something
>
> > next.doFilter(req, res
>
> > thanks,
> > -Rob
This is interesting. I think I hadn't fully groked what a context is.
So if I do this
class MyClass{
public synchronized entryPoint(){
Context cx = cxFactory.enterContext();
try{
//run a script
result = cx.evaluateReader( scope, reader, name, 1,
null );
doSomethingElse();
return result;
}finally{
Context.exit();
}
}
private doSomethingElse(){
Context cx = cxFactory.enterContext();
try{
//run a different script
result = cx.evaluateReader( scope, anotherReader, name, 1,
null );
return result;
}finally{
Context.exit();
}
}
Is this a problem/error, or is it just sloppy (since doSomething
actually runs in the context created by the calling function) (right?)
Thanks!
A
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino