?? actionservlet.java
字號:
for (int i = 0; i < fpc.length; i++) {
newBeanConfig.addFormPropertyConfig(fpc[i]);
}
} catch (Exception e) {
handleCreationException(baseConfigClassName, e);
}
// replace beanConfig with newBeanConfig
moduleConfig.removeFormBeanConfig(beanConfig);
moduleConfig.addFormBeanConfig(newBeanConfig);
beanConfig = newBeanConfig;
}
}
return beanConfig;
}
/**
* <p>Initialize the forwards for the specified module.</p>
*
* @param config ModuleConfig information for this module
* @throws ServletException if initialization cannot be performed
*/
protected void initModuleForwards(ModuleConfig config)
throws ServletException {
if (log.isDebugEnabled()) {
log.debug("Initializing module path '" + config.getPrefix()
+ "' forwards");
}
// Process forwards extensions.
ForwardConfig[] forwards = config.findForwardConfigs();
for (int i = 0; i < forwards.length; i++) {
ForwardConfig forward = forwards[i];
processForwardExtension(forward, config, null);
}
for (int i = 0; i < forwards.length; i++) {
ForwardConfig forward = forwards[i];
// Verify that required fields are all present for the forward
if (forward.getPath() == null) {
handleValueRequiredException("path", forward.getName(),
"global forward");
}
}
}
/**
* <p>Extend the forward's configuration as necessary. If actionConfig is
* provided, then this method will process the forwardConfig as part
* of that actionConfig. If actionConfig is null, the forwardConfig
* will be processed as a global forward.</p>
*
* @param forwardConfig the configuration to process.
* @param moduleConfig the module configuration for this module.
* @param actionConfig If applicable, the config for the current action.
* @throws ServletException if initialization cannot be performed.
*/
protected void processForwardExtension(ForwardConfig forwardConfig,
ModuleConfig moduleConfig, ActionConfig actionConfig)
throws ServletException {
try {
if (!forwardConfig.isExtensionProcessed()) {
if (log.isDebugEnabled()) {
log.debug("Processing extensions for '"
+ forwardConfig.getName() + "'");
}
forwardConfig =
processForwardConfigClass(forwardConfig, moduleConfig,
actionConfig);
forwardConfig.processExtends(moduleConfig, actionConfig);
}
} catch (ServletException e) {
throw e;
} catch (Exception e) {
handleGeneralExtensionException("Forward", forwardConfig.getName(),
e);
}
}
/**
* <p>Checks if the current forwardConfig is using the correct class based
* on the class of its configuration ancestor. If actionConfig is
* provided, then this method will process the forwardConfig as part
* of that actionConfig. If actionConfig is null, the forwardConfig
* will be processed as a global forward.</p>
*
* @param forwardConfig The forward to check.
* @param moduleConfig The config for the current module.
* @param actionConfig If applicable, the config for the current action.
* @return The forward config using the correct class as determined by the
* config's ancestor and its own overridden value.
* @throws UnavailableException if an instance of the forward config class
* cannot be created.
* @throws ServletException on class creation error
*/
protected ForwardConfig processForwardConfigClass(
ForwardConfig forwardConfig, ModuleConfig moduleConfig,
ActionConfig actionConfig)
throws ServletException {
String ancestor = forwardConfig.getExtends();
if (ancestor == null) {
// Nothing to do, then
return forwardConfig;
}
// Make sure that this config is of the right class
ForwardConfig baseConfig = null;
if (actionConfig != null) {
// Look for this in the actionConfig
baseConfig = actionConfig.findForwardConfig(ancestor);
}
if (baseConfig == null) {
// Either this is a forwardConfig that inherits a global config,
// or actionConfig is null
baseConfig = moduleConfig.findForwardConfig(ancestor);
}
if (baseConfig == null) {
throw new UnavailableException("Unable to find " + "forward '"
+ ancestor + "' to extend.");
}
// Was our forwards's class overridden already?
if (forwardConfig.getClass().equals(ActionForward.class)) {
// Ensure that our forward is using the correct class
if (!baseConfig.getClass().equals(forwardConfig.getClass())) {
// Replace the config with an instance of the correct class
ForwardConfig newForwardConfig = null;
String baseConfigClassName = baseConfig.getClass().getName();
try {
newForwardConfig =
(ForwardConfig) RequestUtils.applicationInstance(
baseConfigClassName);
// copy the values
BeanUtils.copyProperties(newForwardConfig, forwardConfig);
} catch (Exception e) {
handleCreationException(baseConfigClassName, e);
}
// replace forwardConfig with newForwardConfig
if (actionConfig != null) {
actionConfig.removeForwardConfig(forwardConfig);
actionConfig.addForwardConfig(newForwardConfig);
} else {
// this is a global forward
moduleConfig.removeForwardConfig(forwardConfig);
moduleConfig.addForwardConfig(newForwardConfig);
}
forwardConfig = newForwardConfig;
}
}
return forwardConfig;
}
/**
* <p>Initialize the exception handlers for the specified module.</p>
*
* @param config ModuleConfig information for this module
* @throws ServletException if initialization cannot be performed
* @since Struts 1.3
*/
protected void initModuleExceptionConfigs(ModuleConfig config)
throws ServletException {
if (log.isDebugEnabled()) {
log.debug("Initializing module path '" + config.getPrefix()
+ "' forwards");
}
// Process exception config extensions.
ExceptionConfig[] exceptions = config.findExceptionConfigs();
for (int i = 0; i < exceptions.length; i++) {
ExceptionConfig exception = exceptions[i];
processExceptionExtension(exception, config, null);
}
for (int i = 0; i < exceptions.length; i++) {
ExceptionConfig exception = exceptions[i];
// Verify that required fields are all present for the config
if (exception.getKey() == null) {
handleValueRequiredException("key", exception.getType(),
"global exception config");
}
}
}
/**
* <p>Extend the exception's configuration as necessary. If actionConfig is
* provided, then this method will process the exceptionConfig as part
* of that actionConfig. If actionConfig is null, the exceptionConfig
* will be processed as a global forward.</p>
*
* @param exceptionConfig the configuration to process.
* @param moduleConfig the module configuration for this module.
* @param actionConfig If applicable, the config for the current action.
* @throws ServletException if initialization cannot be performed.
*/
protected void processExceptionExtension(ExceptionConfig exceptionConfig,
ModuleConfig moduleConfig, ActionConfig actionConfig)
throws ServletException {
try {
if (!exceptionConfig.isExtensionProcessed()) {
if (log.isDebugEnabled()) {
log.debug("Processing extensions for '"
+ exceptionConfig.getType() + "'");
}
exceptionConfig =
processExceptionConfigClass(exceptionConfig, moduleConfig,
actionConfig);
exceptionConfig.processExtends(moduleConfig, actionConfig);
}
} catch (ServletException e) {
throw e;
} catch (Exception e) {
handleGeneralExtensionException("Exception",
exceptionConfig.getType(), e);
}
}
/**
* <p>Checks if the current exceptionConfig is using the correct class
* based on the class of its configuration ancestor. If actionConfig is
* provided, then this method will process the exceptionConfig as part
* of that actionConfig. If actionConfig is null, the exceptionConfig
* will be processed as a global forward.</p>
*
* @param exceptionConfig The config to check.
* @param moduleConfig The config for the current module.
* @param actionConfig If applicable, the config for the current action.
* @return The exception config using the correct class as determined by
* the config's ancestor and its own overridden value.
* @throws ServletException if an instance of the exception config class
* cannot be created.
*/
protected ExceptionConfig processExceptionConfigClass(
ExceptionConfig exceptionConfig, ModuleConfig moduleConfig,
ActionConfig actionConfig)
throws ServletException {
String ancestor = exceptionConfig.getExtends();
if (ancestor == null) {
// Nothing to do, then
return exceptionConfig;
}
// Make sure that this config is of the right class
ExceptionConfig baseConfig = null;
if (actionConfig != null) {
baseConfig = actionConfig.findExceptionConfig(ancestor);
}
if (baseConfig == null) {
// This means either there's no actionConfig anyway, or the
// ancestor is not defined within the action.
baseConfig = moduleConfig.findExceptionConfig(ancestor);
}
if (baseConfig == null) {
throw new UnavailableException("Unable to find "
+ "exception config '" + ancestor + "' to extend.");
}
// Was our config's class overridden already?
if (exceptionConfig.getClass().equals(ExceptionConfig.class)) {
// Ensure that our config is using the correct class
if (!baseConfig.getClass().equals(exceptionConfig.getClass())) {
// Replace the config with an instance of the correct class
ExceptionConfig newExceptionConfig = null;
String baseConfigClassName = baseConfig.getClass().getName();
try {
newExceptionConfig =
(ExceptionConfig) RequestUtils.applicationInstance(
baseConfigClassName);
// copy the values
BeanUtils.copyProperties(newExceptionConfig,
exceptionConfig);
} catch (Exception e) {
handleCreationException(baseConfigClassName, e);
}
// replace exceptionConfig with newExceptionConfig
if (actionConfig != null) {
actionConfig.removeExceptionConfig(exceptionConfig);
actionConfig.addExceptionConfig(newExceptionConfig);
} else {
moduleConfig.removeExceptionConfig(exceptionConfig);
moduleConfig.addExceptionConfig(newExceptionConfig);
}
exceptionConfig = newExceptionConfig;
}
}
return exceptionConfig;
}
/**
* <p>Initialize the action configs for the specified module.</p>
*
* @param config ModuleConfig information for this module
* @throws ServletException if initialization cannot be performed
* @since Struts 1.3
*/
protected void initModuleActions(ModuleConfig config)
throws ServletException {
if (log.isDebugEnabled()) {
log.debug("Initializing module path '" + config.getPrefix()
+ "' action configs");
}
// Process ActionConfig extensions.
ActionConfig[] actionConfigs = config.findActionConfigs();
for (int i = 0; i < actionConfigs.length; i++) {
ActionConfig actionConfig = actionConfigs[i];
processActionConfigExtension(actionConfig, config);
}
for (int i = 0; i < actionConfigs.length; i++) {
ActionConfig actionConfig = actionConfigs[i];
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -