org.roscopeco.janno.util
Class StackUtils

java.lang.Object
  extended by org.roscopeco.janno.util.StackUtils

public class StackUtils
extends Object

Provides utility methods for working with the request stack. This class can be used both 'manually' or instantiated and managed by the request tree. If used from the tree it must be registered in the request stack itself (so that it can see the ServletRequest).

This class implements no thread safety whatsoever. It is intended to be used on a per-request basis and must be synchronized at some higher level if used across threads.

Version:
$Revision: 1.1 $ $Date: 2005/08/24 16:33:15 $
Author:
Ross Bamford (rosco<at>roscopeco.co.uk)

Constructor Summary
StackUtils(ServletRequest req)
          Create a StackUtils instance that will work with the request stack allocated to the given ServletRequest
 
Method Summary
 PicoContainerStack getStack()
          Returns the PicoContainerStack this StackUtils was instantiated with.
 MutablePicoContainer newContainer()
          Make a new MutablePicoContainer and push it onto the request stack.
 PicoContainer pop()
          Attempts to pop the top container off the stack (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StackUtils

public StackUtils(ServletRequest req)
Create a StackUtils instance that will work with the request stack allocated to the given ServletRequest

Parameters:
req - The ServletRequest for this request.
Throws:
{@link - java.lang.IllegalArgumentException} if the supplied request has no stack associated with it.
Method Detail

newContainer

public MutablePicoContainer newContainer()
Make a new MutablePicoContainer and push it onto the request stack. You should not call the lifecycle methods on this container at any time - it will be managed in synchronization with the stack. Doing so will cause IllegalStateExceptions to be thrown at an indeterminate time (usually shutdown but sometimes session cleanup).

Returns:
The MutablePicoContainer that was pushed.

pop

public PicoContainer pop()
Attempts to pop the top container off the stack (i.e. remove it). This method will only modify the stack if there are more containers on the stack than when this instance was created - this doesn't stop it popping containers abandoned on the stack by nested code (e.g. forwarded views), but does prevent containers above the caller's responsibility from being popped.

This restriction can of course be bypassed by directly manipulating the stack - it exists here for as a general safety measure for action code.

Returns:
The PicoContainer that was removed from the stack, or null if nothing was removed.

getStack

public PicoContainerStack getStack()
Returns the PicoContainerStack this StackUtils was instantiated with.

Returns:
The PicoContainerStack this StackUtils is working with.


Copyright © 2005 Roscopeco Open Technologies. All Rights Reserved.