com.ibm.portal.struts.plugins
Class ViewCommandFactory

java.lang.Object
  extended by com.ibm.portal.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 StrutsViewCommand to create. The createCommand method will determine the type StrutsViewCommand object to create based on the extension. For example, a uri path of "/login.jsp" will result in the creation of a StrutsViewJspCommand. This class can be extended to allow the applicaiton to add new extenstion types that should result in the creation of a new type of StrutsViewCommand. 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
          commons logger instance for this class
 
Constructor Summary
ViewCommandFactory()
          Default Constructor for the ViewCommandFactory class
 
Method Summary
 StrutsViewCommand createCommand(ErrorResponseInfo errorInfo, PortletRequest request, ViewCommandExecutionContext context)
          Create a command based on the given ErrorResponseInfo.
 StrutsViewCommand createCommand(java.lang.String uri, PortletRequest request, ViewCommandExecutionContext executionContext)
          Create a command based on the given URI and request
protected  java.lang.String getExtensionLowerCase(java.lang.String uri)
          Get the extension from the given String URI.
protected  java.lang.String getExtensionUpperCase(java.lang.String uri)
          Get the extension from the given String URI.
static ViewCommandFactory getFactory(ModuleContext moduleContext)
          Get the ViewCommandFactory object for this context
static ViewCommandFactory getFactory(ViewCommandExecutionContext viewCommandContext)
          Get the ViewCommandFactory object for the module context obtained from the ViewCommandExecutionContext
protected  StrutsViewCommand handleUnrecognizedExtension(java.lang.String uri, PortletRequest request, ViewCommandExecutionContext executionContext)
          Handle unrecognized extension.
protected  boolean isDynamicallyIncludedContent(java.lang.String uri)
          Answer whether the given path can be included dynamically (like a JSP).
protected  boolean isDynamicallyIncludedContent(java.lang.String uri, java.lang.String extLowerCase)
          Answer whether the given path can be included dynamically (like a JSP).
protected  boolean isStaticallyIncludedContent(java.lang.String uri)
          Answer whether the given path can be included statically (like HTML).
protected  boolean isStaticallyIncludedContent(java.lang.String uri, java.lang.String extLowerCase)
          Answer whether the given path can be included statically (like HTML).
protected  boolean isTilesIncludedContent(java.lang.String uri, java.lang.String extLowerCase, PortletRequest request)
          Answer whether the given path can be included as Struts Tiles JSP.
static void setFactory(ModuleContext moduleContext, ViewCommandFactory factory)
          Set 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
commons logger 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)
Set a new ViewCommandFactory object

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

getFactory

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

Parameters:
moduleContext - the module context to use to find the factory
Returns:
the view command factory for the module context

getFactory

public static ViewCommandFactory getFactory(ViewCommandExecutionContext viewCommandContext)
Get the ViewCommandFactory object for the module context obtained from the ViewCommandExecutionContext

Parameters:
viewCommandContext - the ViewCommandExecutionContext object
Returns:
the view command factory for the module context

createCommand

public StrutsViewCommand createCommand(java.lang.String uri,
                                       PortletRequest request,
                                       ViewCommandExecutionContext executionContext)
Create a command based on the given URI and request

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

createCommand

public StrutsViewCommand createCommand(ErrorResponseInfo errorInfo,
                                       PortletRequest request,
                                       ViewCommandExecutionContext context)
Create a command based on the given ErrorResponseInfo. This implementation will create a StrutsViewErrorCommand object

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

isStaticallyIncludedContent

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

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

isStaticallyIncludedContent

protected boolean isStaticallyIncludedContent(java.lang.String uri,
                                              java.lang.String extLowerCase)
Answer 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:
true if the URI is statically included content

isDynamicallyIncludedContent

protected boolean isDynamicallyIncludedContent(java.lang.String uri)
Answer 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:
true if the URI is dynamically included content

isDynamicallyIncludedContent

protected boolean isDynamicallyIncludedContent(java.lang.String uri,
                                               java.lang.String extLowerCase)
Answer 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:
true if the URI is dynamically included content

isTilesIncludedContent

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

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

handleUnrecognizedExtension

protected StrutsViewCommand handleUnrecognizedExtension(java.lang.String uri,
                                                        PortletRequest request,
                                                        ViewCommandExecutionContext executionContext)
Handle 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 StrutsViewCommand command object to handle the uri

getExtensionLowerCase

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

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

getExtensionUpperCase

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

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