com.bea.struts.adapter.framework
Class AutoRegisterActionServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.apache.struts.action.ActionServlet
              extended by com.bea.struts.adapter.framework.AutoRegisterActionServlet
All Implemented Interfaces
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class AutoRegisterActionServlet
extends ActionServlet

See Also
Serialized Form

Nested Class Summary
static interface AutoRegisterActionServlet.ModuleConfigLocator
          Interface for specifying alternate locations for auto-registered Struts modules.
 
Field Summary
protected static Debug debug
           
static String MODULE_CONFIG_LOCATOR_CLASS_ATTR
          Deprecated To register AutoRegisterActionServlet.ModuleConfigLocators, use the module-config-locators element in pageflow-config of /WEB-INF/netui-config.xml.
 
Fields inherited from class org.apache.struts.action.ActionServlet
config, configDigester, convertNull, dataSources, internal, internalName, log, processor, registrations, servletMapping, servletName
 
Constructor Summary
AutoRegisterActionServlet()
           
 
Method Summary
 void destroy()
           
 ModuleConfig ensureModuleRegistered(String modulePath)
           
 ModuleConfig ensureModuleRegistered(String modulePath, javax.servlet.ServletRequest request)
          Deprecated Use #ensureModuleRegistered(String) instead.
protected  URL getConfigResource(String path)
          Get a resource URL for a module configuration file.
protected  InputStream getConfigResourceAsStream(String path)
          Get a resource stream for a module configuration file.
protected  AutoRegisterActionServlet.ModuleConfigLocator[] getDefaultModuleConfigLocators()
          Get the base list of ModuleConfigLocators, to specify locations for auto-registered Struts modules.
 String getInitParameter(String s)
           
 Enumeration getInitParameterNames()
           
protected  ModuleConfig getModuleConfig(String modulePath, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
          Deprecated Use ensureModuleRegistered(java.lang.String, javax.servlet.ServletRequest) instead.
 List<AutoRegisterActionServlet.ModuleConfigLocator> getModuleConfigLocators()
          Get the current list of registered ModuleConfigLocators.
 String getModuleConfPath(String modulePath)
          Get the webapp-relative path to the Struts module configration file for a given module path, based on registered ModuleConfigLocators.
 void init()
           
protected  ModuleConfig initModuleConfig(String prefix, String paths)
          This method is almost exactly the same as the base class initModuleConfig.
protected  boolean moduleCanHandlePath(ModuleConfig moduleConfig, RequestProcessor rp, String servletPath)
          Tell whether the given module can handle the given path.
protected  void process(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This override of the base class process() registers a Struts module on the fly if the config file can be found in our standard place (named in our standard way), regardless of whether the module is configured in web.xml.
protected  boolean processUnhandledAction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String uri)
          Last chance to handle an unhandled action URI.
protected  ModuleConfig registerModule(String modulePath, String configFilePath)
          Register a Struts module, initialized by the given configuration file.
 
Methods inherited from class org.apache.struts.action.ActionServlet
addServletMapping, destroyConfigDigester, destroyInternal, destroyModules, doGet, doPost, getInternal, getModuleConfig, getRequestProcessor, initInternal, initModuleConfigFactory, initModuleDataSources, initModuleMessageResources, initModulePlugIns, initModulePrefixes, initOther, initServlet, parseModuleConfigFile
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODULE_CONFIG_LOCATOR_CLASS_ATTR

public static String MODULE_CONFIG_LOCATOR_CLASS_ATTR
Deprecated To register AutoRegisterActionServlet.ModuleConfigLocators, use the module-config-locators element in pageflow-config of /WEB-INF/netui-config.xml.

debug

protected static Debug debug
Constructor Detail

AutoRegisterActionServlet

public AutoRegisterActionServlet()
Method Detail

init

public void init()
          throws javax.servlet.ServletException
Overrides:
init in class ActionServlet
Throws
javax.servlet.ServletException

getDefaultModuleConfigLocators

protected AutoRegisterActionServlet.ModuleConfigLocator[] getDefaultModuleConfigLocators()
Get the base list of ModuleConfigLocators, to specify locations for auto-registered Struts modules. By default, this list is empty; derived classes may override to provide locators, or the user may specify them using the "moduleConfigLocators" init-parameter. When an unrecognized Struts module is requested, each registered ModuleConfigLocator is queried for a possible path to the configuration file for the module. If the configuration file is found, the module is auto-registered against the file.

Returns
list of default ModuleconfigLocators

getModuleConfigLocators

public List<AutoRegisterActionServlet.ModuleConfigLocator> getModuleConfigLocators()
Get the current list of registered ModuleConfigLocators.

Returns
an array of registered ModuleConfigLocators.
See Also
getDefaultModuleConfigLocators()

getModuleConfPath

public String getModuleConfPath(String modulePath)
Get the webapp-relative path to the Struts module configration file for a given module path, based on registered ModuleConfigLocators.

Parameters
modulePath - the Struts module path.
Returns
a String that is the path to the Struts configuration file, relative to the web application root, or null if no appropriate configuration file is found.
See Also
getDefaultModuleConfigLocators()

getInitParameter

public String getInitParameter(String s)
Specified by:
getInitParameter in interface javax.servlet.ServletConfig
Overrides:
getInitParameter in class javax.servlet.GenericServlet

getInitParameterNames

public Enumeration getInitParameterNames()
Specified by:
getInitParameterNames in interface javax.servlet.ServletConfig
Overrides:
getInitParameterNames in class javax.servlet.GenericServlet

initModuleConfig

protected ModuleConfig initModuleConfig(String prefix,
                                        String paths)
                                 throws javax.servlet.ServletException
This method is almost exactly the same as the base class initModuleConfig. The only difference is that it does not throw an UnavailableException if a module configuration file is missing or invalid.

Overrides:
initModuleConfig in class ActionServlet
Throws
javax.servlet.ServletException

getConfigResource

protected URL getConfigResource(String path)
                         throws MalformedURLException
Get a resource URL for a module configuration file. By default, this looks in the ServletContext and in the context classloader.

Parameters
path - the path to the resource.
Returns
an URL for the resource, or null if the resource is not found.
Throws
MalformedURLException - throw if the URL is invalid

getConfigResourceAsStream

protected InputStream getConfigResourceAsStream(String path)
Get a resource stream for a module configuration file. By default, this looks in the ServletContext and in the context classloader.

Parameters
path - the path to the resource.
Returns
an InputStream for the resource, or null if the resource is not found.

registerModule

protected ModuleConfig registerModule(String modulePath,
                                      String configFilePath)
                               throws javax.servlet.ServletException
Register a Struts module, initialized by the given configuration file.

Parameters
modulePath - the module path, starting at the webapp root, e.g., "/info/help".
configFilePath - the path, starting at the webapp root, to the module configuration file (e.g., "/WEB-INF/my-generated-struts-config-info-help.xml").
Returns
the Struts ModuleConfig that was initialized.
Throws
javax.servlet.ServletException

process

protected void process(javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response)
                throws IOException,
                       javax.servlet.ServletException
This override of the base class process() registers a Struts module on the fly if the config file can be found in our standard place (named in our standard way), regardless of whether the module is configured in web.xml.

Overrides:
process in class ActionServlet
Throws
IOException
javax.servlet.ServletException

moduleCanHandlePath

protected boolean moduleCanHandlePath(ModuleConfig moduleConfig,
                                      RequestProcessor rp,
                                      String servletPath)
Tell whether the given module can handle the given path. By default, this is always true.

Parameters
moduleConfig - the ModuleConfig
rp - the current RequestProcessor
servletPath - the current servlet path
Returns
true if the ModuleConfig can handle the request at path

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class ActionServlet

getModuleConfig

protected ModuleConfig getModuleConfig(String modulePath,
                                       javax.servlet.ServletRequest request,
                                       javax.servlet.ServletResponse response)
                                throws IOException,
                                       javax.servlet.ServletException
Deprecated Use ensureModuleRegistered(java.lang.String, javax.servlet.ServletRequest) instead.

Get the Struts ModuleConfig for the given module path.

Parameters
modulePath - the module path, from the request URI.
request - the current ServletRequest
response - the current HttpServletResponse
Returns
the Struts ModuleConfig that corresponds with modulePath
Throws
IOException
javax.servlet.ServletException

ensureModuleRegistered

public ModuleConfig ensureModuleRegistered(String modulePath,
                                           javax.servlet.ServletRequest request)
                                    throws IOException,
                                           javax.servlet.ServletException
Deprecated Use #ensureModuleRegistered(String) instead.

Ensures that the Struts module for the given path is registered (dynamically, if necessary).

Parameters
modulePath - the module path, from the request URI.
request - the current ServletRequest
Throws
IOException
javax.servlet.ServletException

ensureModuleRegistered

public ModuleConfig ensureModuleRegistered(String modulePath)
                                    throws IOException,
                                           javax.servlet.ServletException
Throws
IOException
javax.servlet.ServletException

processUnhandledAction

protected boolean processUnhandledAction(javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response,
                                         String uri)
                                  throws IOException,
                                         javax.servlet.ServletException
Last chance to handle an unhandled action URI.

Returns
true if this method handled it (by forwarding somewhere or writing to the response).
Throws
IOException
javax.servlet.ServletException


Copyright © 2011, Oracle. All rights reserved.