org.apache.beehive.netui.pageflow
Class DefaultServletContainerAdapter

Object
  extended by DefaultServletContainerAdapter
All Implemented Interfaces:
Adapter, ServletContainerAdapter

public abstract class DefaultServletContainerAdapter
extends Object
implements ServletContainerAdapter

Default implementation of a Servlet container adapter.


Constructor Summary
protected DefaultServletContainerAdapter()
           
 
Method Summary
 void beginRequest(HttpServletRequest request, HttpServletResponse response)
          Called at the beginning of each processed request.
 Object createControlBeanContext(HttpServletRequest request, HttpServletResponse response)
          Get a context object to support Beehive Controls.
protected  PageFlowEventReporter createEventReporter()
           
 boolean doSecurityRedirect(String path, HttpServletRequest request, HttpServletResponse response)
          Cause the server to do a security check for the given path.
 void endRequest(HttpServletRequest request, HttpServletResponse response)
          Called at the end of each processed request.
 void ensureFailover(String attrName, Object attrVal, HttpServletRequest request)
          Ensure that the given session attribute is replicated in a cluster for session failover.
 PageFlowEventReporter getEventReporter()
          Get an event reporter, which will be notified of events like "page flow created", "action raised", etc.
 Factory getFactory(Class factoryType, String id, FactoryConfig config)
          Generic method to get a Factory class that may be container dependent.
 String getFullContextPath(HttpServletRequest request)
          Return the webapp context path for the given request.
 int getListenPort(HttpServletRequest request)
          Get the port on which the server is listening for unsecure connections.
 String getPlatformName()
          Get the name of the platform, which may be used to find platform-specific configuration files.
 int getSecureListenPort(HttpServletRequest request)
          Get the port on which the server is listening for secure connections.
 SecurityProtocol getSecurityProtocol(String path, HttpServletRequest request)
          Tell whether a web application resource requires a secure transport protocol.
protected  ServletContext getServletContext()
          Get the current ServletContext.
 boolean isInProductionMode()
          Tell whether the system is in production mode.
 void login(String username, String password, HttpServletRequest request, HttpServletResponse response)
          Log in the user, using "weak" username/password authentication.
 void logout(boolean invalidateSessions, HttpServletRequest request, HttpServletResponse response)
          Log out the user.
 void setContext(AdapterContext context)
          Set the AdapterContext.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface Adapter
accept
 

Constructor Detail

DefaultServletContainerAdapter

protected DefaultServletContainerAdapter()
Method Detail

isInProductionMode

public boolean isInProductionMode()
Tell whether the system is in production mode.

Specified by:
isInProductionMode in interface ServletContainerAdapter
Returns:
true if the system property "beehive.productionmode" is set to "true", or if asserts are disabled for this class in the case where the system property has no value; false if the system property is set to "false", or if asserts are enabled for this class in the case where the system property has no value.

getSecurityProtocol

public SecurityProtocol getSecurityProtocol(String path,
                                            HttpServletRequest request)
Tell whether a web application resource requires a secure transport protocol. This default implementation simply returns SecurityProtocol.UNSPECIFIED for all paths.

Specified by:
getSecurityProtocol in interface ServletContainerAdapter
Parameters:
path - a webapp-relative path for a resource.
request - the current HttpServletRequest.
Returns:
SecurityProtocol.UNSPECIFIED.

doSecurityRedirect

public boolean doSecurityRedirect(String path,
                                  HttpServletRequest request,
                                  HttpServletResponse response)
Cause the server to do a security check for the given path. This default implementation does nothing.

Specified by:
doSecurityRedirect in interface ServletContainerAdapter
Parameters:
path - the webapp-relative path on which to run security checks.
request - the current HttpServletRequest.
response - the current HttpServletResponse.
Returns:
false

getListenPort

public int getListenPort(HttpServletRequest request)
Get the port on which the server is listening for unsecure connections. This default implementation always returns -1.

Specified by:
getListenPort in interface ServletContainerAdapter
Parameters:
request - the current HttpServletRequest.
Returns:
-1.

getSecureListenPort

public int getSecureListenPort(HttpServletRequest request)
Get the port on which the server is listening for secure connections. This default implementation always returns -1.

Specified by:
getSecureListenPort in interface ServletContainerAdapter
Parameters:
request - the current HttpServletRequest.
Returns:
-1.

login

public void login(String username,
                  String password,
                  HttpServletRequest request,
                  HttpServletResponse response)
           throws LoginException
Log in the user, using "weak" username/password authentication. This default implementation always throws UnsupportedOperationException.

Specified by:
login in interface ServletContainerAdapter
Parameters:
username - the user's login name.
password - the user's password.
request - the current HttpServletRequest.
response - the current HttpServletResponse.
Throws:
UnsupportedOperationException - in all cases.
LoginException - if the authentication failed

logout

public void logout(boolean invalidateSessions,
                   HttpServletRequest request,
                   HttpServletResponse response)
Log out the user. This default implementation always throws UnsupportedOperationException.

Specified by:
logout in interface ServletContainerAdapter
Parameters:
invalidateSessions - if true, the session is invalidated (on all single-signon webapps); otherwise the session and its data are left intact. To invalidate the session in only the current webapp, set this parameter to false and call invalidate() on the HttpSession.
request - the current HttpServletRequest.
response - the current HttpServletResponse.
Throws:
UnsupportedOperationException - in all cases.

getFullContextPath

public String getFullContextPath(HttpServletRequest request)
Return the webapp context path for the given request. This can differ from HttpServletRequest.getContextPath() only in that it will return a valid value even if the request is for the default webapp. This default implementation always returns the value of getContextPath() on the request.

Specified by:
getFullContextPath in interface ServletContainerAdapter
Parameters:
request - the current HttpServletRequest.
Returns:
the value of getContextPath() on the current request.

ensureFailover

public void ensureFailover(String attrName,
                           Object attrVal,
                           HttpServletRequest request)
Ensure that the given session attribute is replicated in a cluster for session failover. This method does not need to be implemented for servers that do not support clustering and session failover. The default implementation does nothing.

Specified by:
ensureFailover in interface ServletContainerAdapter
Parameters:
attrName - the name of the session attribute for which failover should be ensured.
attrVal - the value of the given session attribute.
request - the current HttpServletRequest.

beginRequest

public void beginRequest(HttpServletRequest request,
                         HttpServletResponse response)
Called at the beginning of each processed request. This default implementation does nothing.

Specified by:
beginRequest in interface ServletContainerAdapter
Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse.

endRequest

public void endRequest(HttpServletRequest request,
                       HttpServletResponse response)
Called at the end of each processed request. This default implementation does nothing.

Specified by:
endRequest in interface ServletContainerAdapter
Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse.

createControlBeanContext

public Object createControlBeanContext(HttpServletRequest request,
                                       HttpServletResponse response)
Get a context object to support Beehive Controls. This default implementation returns an instance of PageFlowBeanContext.

Specified by:
createControlBeanContext in interface ServletContainerAdapter
Parameters:
request - the current HttpServletRequest.
response - the current HttpServletResponse.
Returns:
a new ControlBeanContext.

getServletContext

protected ServletContext getServletContext()
Get the current ServletContext.

Returns:
the current ServletContext.

setContext

public void setContext(AdapterContext context)
Set the AdapterContext.

Specified by:
setContext in interface Adapter
Parameters:
context - the AdapterContext to set.

getPlatformName

public String getPlatformName()
Get the name of the platform, which may be used to find platform-specific configuration files. This default implementation returns "generic".

Specified by:
getPlatformName in interface ServletContainerAdapter
Returns:
the name of the platform ("generic" in this default implementation).

getEventReporter

public PageFlowEventReporter getEventReporter()
Get an event reporter, which will be notified of events like "page flow created", "action raised", etc. This default implementation returns an instance of DefaultPageFlowEventReporter.

Specified by:
getEventReporter in interface ServletContainerAdapter
Returns:
a PageFlowEventReporter.

createEventReporter

protected PageFlowEventReporter createEventReporter()

getFactory

public Factory getFactory(Class factoryType,
                          String id,
                          FactoryConfig config)
Generic method to get a Factory class that may be container dependent.

This method is called to get the following Factory implementations:

Specified by:
getFactory in interface ServletContainerAdapter
Parameters:
factoryType - the class type that the factory should extend or implement
id - can be used for the case where there is more than one possible Factory that extends or implaments the class type.
config - a configuration object passed to a Factory
Returns:
a Factory class that extends or implemtents the given class type.