org.norther.tammi.spray.engine.context
Class DefaultTemplateContext

java.lang.Object
  extended by org.norther.tammi.core.pool.RecyclableSupport
      extended by org.norther.tammi.core.pool.PoolableSupport
          extended by org.norther.tammi.spray.engine.context.DefaultTemplateContext
All Implemented Interfaces:
Serializable, EventListener, HttpSessionBindingListener, Poolable, Recyclable, TemplateContext, ServletRequestBindingListener
Direct Known Subclasses:
DefaultContextToolFilter.InternalTemplateContext

public class DefaultTemplateContext
extends PoolableSupport
implements TemplateContext, HttpSessionBindingListener, ServletRequestBindingListener, Serializable

A default implementation of TemplateContext.

Version:
$Id: DefaultTemplateContext.java,v 1.12 2009/09/28 15:08:28 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
DefaultTemplateContext()
          Constructs a new context.
DefaultTemplateContext(TemplateContext ctx)
          Constructs a new context with a parent.
 
Method Summary
 boolean addParent(int index, TemplateContext context)
          Adds a parent context to a specied index.
 boolean addParent(TemplateContext context)
          Adds a parent context.
 void clear()
          Clears the context but not its parents.
 void clearParents()
          Clears all parents from this context.
 boolean containsKey(String key)
          Checks whether a key is in the context or in its parents.
 void dispose()
          Disposes the object by setting its disposed flag.
 Object get(String key)
          Gets an object from the context or from its parents.
 Content getContent()
          Gets the content of this context.
 ContextToolFilter getContextToolFilter()
          Gets the context tool filter of this context.
 HttpFilterChain getFilterChain()
          Gets the filter chain of this context.
 MBeanServer getMBeanServer()
          Gets the MBean server.
 TemplateContext getParent(int index)
          Gets the indexed parent from the context.
 List<TemplateContext> getParents()
          Gets a read-only list of parents.
 Set<String> keySet()
          Gets a set of all keys in the context and in its parents.
 int numberOfParents()
          Returns the number of parents.
 Object put(String key, Object value)
          Puts an object into the context.
 void recycle(TemplateContext ctx)
          Recycles a context with a parent.
 Object remove(String key)
          Removes an object from the context.
 TemplateContext removeParent(int index)
          Removes an indexed parent context.
 boolean removeParent(TemplateContext context)
          Removes a parent context.
 void set(String key, Object value)
          Sets an object int the context.
protected  void setContextToolFilterMBean(MBeanReference<? extends ContextToolFilter> ref)
          Sets the context tool filter of this context.
 TemplateContext setParent(int index, TemplateContext context)
          Sets a parent context to a specied index.
 int size()
          Gets the size of the context including its parents.
 void valueBound(HttpSessionBindingEvent event)
           
 void valueBound(ServletRequestBindingEvent event)
          Notifies the object that it is being bound to a request.
 Collection<Object> values()
          Gets a collection of all values in the context and in its parents.
 void valueUnbound(HttpSessionBindingEvent event)
           
 void valueUnbound(ServletRequestBindingEvent event)
          Notifies the object that it is being unbound from a request.
 
Methods inherited from class org.norther.tammi.core.pool.PoolableSupport
disposed, recycled
 
Methods inherited from class org.norther.tammi.core.pool.RecyclableSupport
isDisposed, recycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.pool.Recyclable
isDisposed, recycle
 

Constructor Detail

DefaultTemplateContext

public DefaultTemplateContext()
Constructs a new context.


DefaultTemplateContext

public DefaultTemplateContext(TemplateContext ctx)
Constructs a new context with a parent.

Parameters:
ctx - a parent context.
Method Detail

recycle

public void recycle(TemplateContext ctx)
Recycles a context with a parent.

Parameters:
ctx - a parent context.

dispose

public void dispose()
Description copied from class: RecyclableSupport
Disposes the object by setting its disposed flag.

Specified by:
dispose in interface Recyclable
Overrides:
dispose in class RecyclableSupport

getParents

public List<TemplateContext> getParents()
Description copied from interface: TemplateContext
Gets a read-only list of parents.

Specified by:
getParents in interface TemplateContext
Returns:
a list of parents.

getParent

public TemplateContext getParent(int index)
Description copied from interface: TemplateContext
Gets the indexed parent from the context.

Specified by:
getParent in interface TemplateContext
Parameters:
index - the index.
Returns:
the parent context.

setParent

public TemplateContext setParent(int index,
                                 TemplateContext context)
Description copied from interface: TemplateContext
Sets a parent context to a specied index. If the same parent is already included in the context, the duplicate will be removed.

Specified by:
setParent in interface TemplateContext
Parameters:
index - the index.
context - a parent context.
Returns:
the previous parent, if any.

addParent

public boolean addParent(TemplateContext context)
Description copied from interface: TemplateContext
Adds a parent context. If the same parent is already included in the context, it will not be added.

Specified by:
addParent in interface TemplateContext
Parameters:
context - a parent context.
Returns:
true if added, false otherwise.

addParent

public boolean addParent(int index,
                         TemplateContext context)
Description copied from interface: TemplateContext
Adds a parent context to a specied index. If the same parent is already included in the context, it will not be added. The parent at the lowest index has the highest precedence.

Specified by:
addParent in interface TemplateContext
Parameters:
index - the index.
context - a parent context.
Returns:
true if added, false otherwise.

removeParent

public boolean removeParent(TemplateContext context)
Description copied from interface: TemplateContext
Removes a parent context.

Specified by:
removeParent in interface TemplateContext
Parameters:
context - a parent context.
Returns:
true if removed, false otherwise.

removeParent

public TemplateContext removeParent(int index)
Description copied from interface: TemplateContext
Removes an indexed parent context.

Specified by:
removeParent in interface TemplateContext
Parameters:
index - the index.
Returns:
the removed parent or null.

numberOfParents

public int numberOfParents()
Description copied from interface: TemplateContext
Returns the number of parents.

Specified by:
numberOfParents in interface TemplateContext
Returns:
the number of parents.

clearParents

public void clearParents()
Description copied from interface: TemplateContext
Clears all parents from this context.

Specified by:
clearParents in interface TemplateContext

getContent

public Content getContent()
Description copied from interface: TemplateContext
Gets the content of this context.

Specified by:
getContent in interface TemplateContext
Returns:
the content.

getFilterChain

public HttpFilterChain getFilterChain()
Description copied from interface: TemplateContext
Gets the filter chain of this context.

Specified by:
getFilterChain in interface TemplateContext
Returns:
the filter chain.

get

public Object get(String key)
Description copied from interface: TemplateContext
Gets an object from the context or from its parents.

Specified by:
get in interface TemplateContext
Parameters:
key - the key.
Returns:
the value.

set

public void set(String key,
                Object value)
Description copied from interface: TemplateContext
Sets an object int the context.

Specified by:
set in interface TemplateContext
Parameters:
key - the key.
value - the value.

put

public Object put(String key,
                  Object value)
Description copied from interface: TemplateContext
Puts an object into the context.

Specified by:
put in interface TemplateContext
Parameters:
key - the key.
value - the value.
Returns:
the previous value.

remove

public Object remove(String key)
Description copied from interface: TemplateContext
Removes an object from the context.

Specified by:
remove in interface TemplateContext
Parameters:
key - the key.
Returns:
the removed value.

containsKey

public boolean containsKey(String key)
Description copied from interface: TemplateContext
Checks whether a key is in the context or in its parents.

Specified by:
containsKey in interface TemplateContext
Parameters:
key - the key.
Returns:
true if found.

keySet

public Set<String> keySet()
Description copied from interface: TemplateContext
Gets a set of all keys in the context and in its parents.

Specified by:
keySet in interface TemplateContext
Returns:
a set of keys.

values

public Collection<Object> values()
Description copied from interface: TemplateContext
Gets a collection of all values in the context and in its parents.

Specified by:
values in interface TemplateContext
Returns:
a collection of values.

size

public int size()
Description copied from interface: TemplateContext
Gets the size of the context including its parents.

Specified by:
size in interface TemplateContext
Returns:
the size of the context.

clear

public void clear()
Description copied from interface: TemplateContext
Clears the context but not its parents.

Specified by:
clear in interface TemplateContext

getContextToolFilter

public ContextToolFilter getContextToolFilter()
Description copied from interface: TemplateContext
Gets the context tool filter of this context.

Specified by:
getContextToolFilter in interface TemplateContext
Returns:
the context tool filter.

getMBeanServer

public MBeanServer getMBeanServer()
Description copied from interface: TemplateContext
Gets the MBean server.

Specified by:
getMBeanServer in interface TemplateContext
Returns:
the MBean server.

valueBound

public void valueBound(HttpSessionBindingEvent event)
Specified by:
valueBound in interface HttpSessionBindingListener

valueUnbound

public void valueUnbound(HttpSessionBindingEvent event)
Specified by:
valueUnbound in interface HttpSessionBindingListener

valueBound

public void valueBound(ServletRequestBindingEvent event)
Description copied from interface: ServletRequestBindingListener
Notifies the object that it is being bound to a request.

Specified by:
valueBound in interface ServletRequestBindingListener
Parameters:
event - the binding event.

valueUnbound

public void valueUnbound(ServletRequestBindingEvent event)
Description copied from interface: ServletRequestBindingListener
Notifies the object that it is being unbound from a request.

Specified by:
valueUnbound in interface ServletRequestBindingListener
Parameters:
event - the binding event.

setContextToolFilterMBean

protected void setContextToolFilterMBean(MBeanReference<? extends ContextToolFilter> ref)
Sets the context tool filter of this context.

Parameters:
ref - the context tool filter reference.


Copyright © 2004 The Norther Organization. All rights reserved.