com.ibm.wps.portlets.struts.plugins
Class ViewCommandFactory

java.lang.Object
  extended by com.ibm.wps.portlets.struts.plugins.ViewCommandFactory

public class ViewCommandFactory
extends java.lang.Object

The ViewCommandFactory class is the default factory used in the Struts Portlet Framework. The ViewComandFactory will process the URI and determine the correct type of WpsStrutsViewCommand to create. The createCommand method will determine the type of WpsStrutsViewCommand object to create based on the extension. For example, a URI path of "/login.jsp" will result in the creation of a WpsStrutsViewJspCommand. This class can be extended to allow the application to add new extension types that should result in the creation of a new type of WpsStrutsViewCommand. The ViewCommandFactories are registered per Struts module. A Struts plugin can be used to determine which ViewCommandFactory is used for each Struts module.

Since:
5.1

Field Summary
protected static Log log
          The commons-logging instance for this class.
 
Constructor Summary
ViewCommandFactory()
          Default constructor for the ViewCommandFactory class.
 
Method Summary
 WpsStrutsViewCommand createCommand(ErrorResponseInfo errorInfo, HttpServletRequest request, ViewCommandExecutionContext executionContext)
          Creates a command based on the given ErrorResponseInfo.
 WpsStrutsViewCommand createCommand(java.lang.String uri, HttpServletRequest request, ViewCommandExecutionContext executionContext)
          Creates a command based on the given URI and request.
protected  java.lang.String getExtensionLowerCase(java.lang.String uri)
          Gets the extension from the given String URI.
protected  java.lang.String getExtensionUpperCase(java.lang.String uri)
          Gets the extension from the given String URI.
static ViewCommandFactory getFactory(ModuleContext moduleContext)
          Gets the ViewCommandFactory object for this context.
static ViewCommandFactory getFactory(ViewCommandExecutionContext viewCommandContext)
          Gets the ViewCommandFactory object for the module.
protected  WpsStrutsViewCommand handleUnrecognizedExtension(java.lang.String uri, HttpServletRequest request, ViewCommandExecutionContext executionContext)
          Handles an unrecognized extension.
protected  boolean isDynamicallyIncludedContent(java.lang.String uri)
          Determines whether the given path can be included dynamically (like a JSP).
protected  boolean isDynamicallyIncludedContent(java.lang.String uri, java.lang.String extLowerCase)
          Determines whether the given path can be included dynamically (like a JSP).
protected  boolean isStaticallyIncludedContent(java.lang.String uri)
          Determines whether the given path can be included statically (like HTML).
protected  boolean isStaticallyIncludedContent(java.lang.String uri, java.lang.String extLowerCase)
          Determines whether the given path can be included statically (like HTML).
protected  boolean isTilesIncludedContent(java.lang.String uri, java.lang.String extLowerCase, HttpServletRequest request)
          Determines whether the given path can be included as a Struts Tiles JSP.
static void setFactory(ModuleContext moduleContext, ViewCommandFactory factory)
          Sets a new ViewCommandFactory object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Log log
The commons-logging instance for this class.

Constructor Detail

ViewCommandFactory

public ViewCommandFactory()
Default constructor for the ViewCommandFactory class.

Method Detail

setFactory

public static void setFactory(ModuleContext moduleContext,
                              ViewCommandFactory factory)
Sets a new ViewCommandFactory object.

Parameters:
moduleContext - the module context
factory - the ViewCommandFactory object

getFactory

public static ViewCommandFactory getFactory(ModuleContext moduleContext)
Gets the ViewCommandFactory object for this context.

Parameters:
moduleContext - the module context to use to find the factory
Returns:
returns the ViewCommandFactory

getFactory

public static ViewCommandFactory getFactory(ViewCommandExecutionContext viewCommandContext)
Gets the ViewCommandFactory object for the module.

Parameters:
viewCommandContext - the ViewCommandExecutionContext object
Returns:
returns the ViewCommandFactory

createCommand

public WpsStrutsViewCommand createCommand(java.lang.String uri,
                                          HttpServletRequest request,
                                          ViewCommandExecutionContext executionContext)
Creates a command based on the given URI and request.

Parameters:
uri - path to resource
request - the request object
executionContext - the ViewCommandExecutionContext object
Returns:
returns a WpsStrutsViewCommand or null

createCommand

public WpsStrutsViewCommand createCommand(ErrorResponseInfo errorInfo,
                                          HttpServletRequest request,
                                          ViewCommandExecutionContext executionContext)
Creates a command based on the given ErrorResponseInfo. Creates a WpsStrutsViewErrorCommand object.

Parameters:
errorInfo - ErrorResponseInfo
request - the request
context - ViewCommandExecutionContext
Returns:
returns a WpsStrutsViewCommand object

isStaticallyIncludedContent

protected boolean isStaticallyIncludedContent(java.lang.String uri)
Determines whether the given path can be included statically (like HTML). The analysis is usually based on the extension.

Parameters:
uri - path to resource
Returns:
returns boolean true if the URI is statically included content

isStaticallyIncludedContent

protected boolean isStaticallyIncludedContent(java.lang.String uri,
                                              java.lang.String extLowerCase)
Determines whether the given path can be included statically (like HTML). The analysis is usually based on the extension.

Parameters:
uri - path to resource
extLowerCase - the file extension in lower case
Returns:
returns boolean true if the URI is statically included content

isDynamicallyIncludedContent

protected boolean isDynamicallyIncludedContent(java.lang.String uri)
Determines whether the given path can be included dynamically (like a JSP). The analysis is usually based on the extension.

Parameters:
uri - path to resource
Returns:
returns boolean true if the URI is dynamically included content

isDynamicallyIncludedContent

protected boolean isDynamicallyIncludedContent(java.lang.String uri,
                                               java.lang.String extLowerCase)
Determines whether the given path can be included dynamically (like a JSP). The analysis is usually based on the extension.

Parameters:
uri - path to resource
extLowerCase - file extension from path in lower case
Returns:
returns boolean true if the URI is dynamically included content

isTilesIncludedContent

protected boolean isTilesIncludedContent(java.lang.String uri,
                                         java.lang.String extLowerCase,
                                         HttpServletRequest request)
Determines whether the given path can be included as a Struts Tiles JSP. The analysis is usually based on the extension and presence of the request attribute WpsStrutsConstants.TILES_DEFINITION.

Parameters:
uri - path to resource
extLowerCase - file extension from path in lower case
request - the request object
Returns:
returns boolean true if the URI is Tiles included content

handleUnrecognizedExtension

protected WpsStrutsViewCommand handleUnrecognizedExtension(java.lang.String uri,
                                                           HttpServletRequest request,
                                                           ViewCommandExecutionContext executionContext)
Handles an unrecognized extension. This implementation treats the page as something that is dynamic content, but this can be overridden.

Parameters:
uri - path to resource
request - the request we are processing
executionContext - the ViewCommandExecutionContext object
Returns:
returns the command object to handle the uri

getExtensionLowerCase

protected java.lang.String getExtensionLowerCase(java.lang.String uri)
Gets the extension from the given String URI. Return null if no extension found.

Parameters:
uri - path to resource
Returns:
returns the extension in lower case or null otherwise

getExtensionUpperCase

protected java.lang.String getExtensionUpperCase(java.lang.String uri)
Gets the extension from the given String URI. Return null if no extension found.

Parameters:
uri - path to resource
Returns:
returns the extension in upper case or null otherwise