org.apache.beehive.controls.runtime.servlet
Class ServletBeanContext

Object
  extended by ControlBeanContext
      extended by ControlContainerContext
          extended by ServletBeanContext
All Implemented Interfaces:
BeanContext, BeanContextChild, BeanContextServiceRevokedListener, BeanContextServices, BeanContextServicesListener, DesignMode, PropertyChangeListener, VetoableChangeListener, Visibility, Serializable, Iterable, Collection, EventListener, ControlBeanContext, ControlContainerContext, EventDispatcher

public class ServletBeanContext
extends ControlContainerContext

The ServletBeanContext provides a ControlBeanContext implementation that offers services and a resource management context that is appropriate to web tier usage of controls.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface ControlBeanContext
ControlBeanContext.LifeCycle
 
Field Summary
 
Fields inherited from interface BeanContext
globalHierarchyLock
 
Fields inherited from interface DesignMode
PROPERTYNAME
 
Constructor Summary
ServletBeanContext()
           
 
Method Summary
 void beginContext(ServletContext context, ServletRequest req, ServletResponse resp)
          Begins a new execution context, associated with a specific ServletRequest
 void endContext()
          Ends the current execution context, and resetes the current active ServletRequest.
 URL getResource(String name, BeanContextChild bcc)
          Override BeanContext.getResource() so it delegates to the current ServletContext.
 InputStream getResourceAsStream(String name, BeanContextChild bcc)
          Override BeanContext.getResourceAsStream() so it delegates to the current ServletContext.
<T> T
getService(Class<T> serviceClass, Object selector)
          Override ControlBeanContext.getService().
 ServletContext getServletContext()
          Returns the ServletContext associated with this context (or null if not currently processing a request)
 ServletRequest getServletRequest()
          Returns the ServletRequest associated with this context (or null if not currently processing a request)
 ServletResponse getServletResponse()
          Returns the ServletResponse associated with this context (or null if not currently processing a request)
 void initialize()
          Called by BeanContextSupport superclass during construction and deserialization to initialize subclass transient state
 void setWrappers(boolean useWrappers)
          Enables/disable the use of request/response wrappers for this context.
protected  boolean useWrappers()
           
 
Methods inherited from class ControlContainerContext
addResourceContext, beginContext, dispatchEvent, getControlHandle, isSingleThreadedContainer, releaseResources, removeResourceContext
 
Methods inherited from class ControlBeanContext
add, addAll, addBeanContextMembershipListener, addBeanContextServicesListener, addLifeCycleListener, addPropertyChangeListener, addService, addVetoableChangeListener, avoidingGui, clear, contains, containsAll, dontUseGui, equals, generateUniqueID, getAnnotationMap, getBean, getBeanAnnotationMap, getBeanContext, getBeanContextServicesFactory, getClassLoader, getControlBean, getControlHandle, getControlInterface, getControlPropertyMap, getControlPropertySet, getCurrentServiceClasses, getCurrentServiceSelectors, getDefaultControlBinding, getMethodPropertySet, getParameterNames, getParameterPropertySet, getParameterValue, getService, hashCode, hasService, hasSingleThreadedParent, initializeControl, instantiateChild, isDesignTime, isEmpty, iterator, needsGui, okToUseGui, prioritizeInterceptors, propertyChange, releaseService, remove, removeAll, removeBeanContextMembershipListener, removeBeanContextServicesListener, removeLifeCycleListener, removePropertyChangeListener, removeVetoableChangeListener, resolveDefaultBinding, retainAll, revokeService, serviceAvailable, serviceRevoked, setBeanContext, setDelegateMap, setDesignTime, size, toArray, toArray, vetoableChange
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface ControlBeanContext
addLifeCycleListener, getAnnotationMap, getBean, getClassLoader, getControlBean, getControlHandle, getControlInterface, getControlPropertyMap, getControlPropertySet, getMethodPropertySet, getParameterNames, getParameterPropertySet, getParameterValue, removeLifeCycleListener
 
Methods inherited from interface BeanContextServices
addBeanContextServicesListener, addService, getCurrentServiceClasses, getCurrentServiceSelectors, getService, hasService, releaseService, removeBeanContextServicesListener, revokeService
 
Methods inherited from interface BeanContext
addBeanContextMembershipListener, instantiateChild, removeBeanContextMembershipListener
 
Methods inherited from interface BeanContextChild
addPropertyChangeListener, addVetoableChangeListener, getBeanContext, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext
 
Methods inherited from interface Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface DesignMode
isDesignTime, setDesignTime
 
Methods inherited from interface Visibility
avoidingGui, dontUseGui, needsGui, okToUseGui
 
Methods inherited from interface BeanContextServicesListener
serviceAvailable
 
Methods inherited from interface BeanContextServiceRevokedListener
serviceRevoked
 

Constructor Detail

ServletBeanContext

public ServletBeanContext()
Method Detail

initialize

public void initialize()
Called by BeanContextSupport superclass during construction and deserialization to initialize subclass transient state

Overrides:
initialize in class ControlContainerContext

beginContext

public void beginContext(ServletContext context,
                         ServletRequest req,
                         ServletResponse resp)
Begins a new execution context, associated with a specific ServletRequest


endContext

public void endContext()
Ends the current execution context, and resetes the current active ServletRequest.

Specified by:
endContext in interface ControlContainerContext
Overrides:
endContext in class ControlContainerContext

getServletContext

public ServletContext getServletContext()
Returns the ServletContext associated with this context (or null if not currently processing a request)


getServletRequest

public ServletRequest getServletRequest()
Returns the ServletRequest associated with this context (or null if not currently processing a request)


getServletResponse

public ServletResponse getServletResponse()
Returns the ServletResponse associated with this context (or null if not currently processing a request)


setWrappers

public void setWrappers(boolean useWrappers)
Enables/disable the use of request/response wrappers for this context. By default, wrappers are enabled if this API is not invoked.


getResourceAsStream

public InputStream getResourceAsStream(String name,
                                       BeanContextChild bcc)
                                throws IllegalArgumentException
Override BeanContext.getResourceAsStream() so it delegates to the current ServletContext.

Specified by:
getResourceAsStream in interface BeanContext
Overrides:
getResourceAsStream in class ControlBeanContext
Parameters:
name - the resource name
bcc - the specified child
Returns:
an InputStream for reading the resource, or null if the resource could not be found.
Throws:
IllegalArgumentException - IllegalArgumentException if the resource is not valid

getResource

public URL getResource(String name,
                       BeanContextChild bcc)
                throws IllegalArgumentException
Override BeanContext.getResource() so it delegates to the current ServletContext.

Specified by:
getResource in interface BeanContext
Overrides:
getResource in class ControlBeanContext
Parameters:
name - the resource name
bcc - the specified child
Returns:
a URL for the named resource for the specified child
Throws:
IllegalArgumentException - IllegalArgumentException if the resource is not valid

getService

public <T> T getService(Class<T> serviceClass,
                        Object selector)
Override ControlBeanContext.getService(). A control bean creates its bean context using the ControlBeanContextFactory service provided by this context. A control bean will attempt to create its context before adding its self to this context as a child. This creates a chicken/egg problem since only a child of a context may request a service from it. This method provides a way to crack the chicken/egg problem by first trying to get the service using the control bean context's getService() method, and if that call returns null and the requested service is the ControlBeanContextFactory then returning an instance of the service provider.

Specified by:
getService in interface ControlBeanContext
Overrides:
getService in class ControlBeanContext
Parameters:
serviceClass -
selector -
Returns:
an instance of the request service, or null if unavailable
See Also:
BeanContextServices.getService(java.beans.beancontext.BeanContextChild, java.lang.Object, java.lang.Class, java.lang.Object, java.beans.beancontext.BeanContextServiceRevokedListener)

useWrappers

protected boolean useWrappers()