本文整理汇总了Java中org.apache.struts.config.ModuleConfig类的典型用法代码示例。如果您正苦于以下问题:Java ModuleConfig类的具体用法?Java ModuleConfig怎么用?Java ModuleConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ModuleConfig类属于org.apache.struts.config包,在下文中一共展示了ModuleConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
/**
* Initialize and load our resources.
*
* @param servlet The ActionServlet for our application
* @param config The ModuleConfig for our owning module
* @throws ServletException if we cannot configure ourselves correctly
*/
public void init(ActionServlet servlet, ModuleConfig config)
throws ServletException {
// Remember our associated configuration and servlet
this.config = config;
this.servlet = servlet;
// Load our database from persistent storage
try {
this.initResources();
servlet.getServletContext().setAttribute(VALIDATOR_KEY + config.getPrefix(),
resources);
servlet.getServletContext().setAttribute(STOP_ON_ERROR_KEY + '.' + config.getPrefix(),
(this.stopOnFirstError ? Boolean.TRUE : Boolean.FALSE));
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new UnavailableException("Cannot load a validator resource from '" + pathnames + "'");
}
}
示例2: actionURL
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
/**
* <p>Return the context-relative URL that corresponds to the specified
* {@link ActionConfig}, relative to the module associated
* with the current modules's {@link ModuleConfig}.</p>
*
* @param request The servlet request we are processing
* @param action ActionConfig to be evaluated
* @param pattern URL pattern used to map the controller servlet
* @return context-relative URL relative to the module
*
* @since Struts 1.1
*/
public static String actionURL(
HttpServletRequest request,
ActionConfig action,
String pattern) {
StringBuffer sb = new StringBuffer();
if (pattern.endsWith("/*")) {
sb.append(pattern.substring(0, pattern.length() - 2));
sb.append(action.getPath());
} else if (pattern.startsWith("*.")) {
ModuleConfig appConfig =
ModuleUtils.getInstance().getModuleConfig(request);
sb.append(appConfig.getPrefix());
sb.append(action.getPath());
sb.append(pattern.substring(1));
} else {
throw new IllegalArgumentException(pattern);
}
return sb.toString();
}
示例3: init
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
/**
* <p>Receive notification that the specified module is being
* started up.</p>
*
* @param servlet ActionServlet that is managing all the modules
* in this web application.
* @param moduleConfig ModuleConfig for the module with which
* this plugin is associated.
*
* @exception ServletException if this <code>PlugIn</code> cannot
* be successfully initialized.
*/
public void init(ActionServlet servlet, ModuleConfig moduleConfig)
throws ServletException {
// Create factory config object
DefinitionsFactoryConfig factoryConfig =
readFactoryConfig(servlet, moduleConfig);
// Set the module name in the config. This name will be used to compute
// the name under which the factory is stored.
factoryConfig.setFactoryName(moduleConfig.getPrefix());
// Set RequestProcessor class
this.initRequestProcessorClass(moduleConfig);
this.initTilesUtil();
this.initDefinitionsFactory(servlet.getServletContext(), moduleConfig, factoryConfig);
}
示例4: getModuleConfig
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
/**
* Get the current ModuleConfig.
* <br>
* Lookup in the request and do selectModule if not found. The side effect
* is, that the ModuleConfig object is set in the request if it was not present.
* @param request Current request.
* @param servletContext Current servlet context*.
* @return The ModuleConfig for current request.
*/
protected ModuleConfig getModuleConfig(
HttpServletRequest request,
ServletContext servletContext) {
ModuleConfig moduleConfig =
ModuleUtils.getInstance().getModuleConfig(request);
if (moduleConfig == null) {
// ModuleConfig not found in current request. Select it.
ModuleUtils.getInstance().selectModule(request, servletContext);
moduleConfig = ModuleUtils.getInstance().getModuleConfig(request);
}
return moduleConfig;
}
示例5: testWithMetaInfConfig
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
/**
* Tests whether the New functionality is called when the paths is passed with
* "classpath*:/META-INF/struts-config.xml".
* and successfully parses the struts-config.xml which is there in META-INF folder.
* @throws Exception
*/
@Test
public void testWithMetaInfConfig() throws Exception {
//initialize
String prefix = "MyTest";
String paths = "classpath*:/META-INF/struts-config.xml";
//test
ModuleConfig moduleConfig = target.initModuleConfig(prefix, paths);
//verify
assertNotNull("ActionFormBean should have been set", moduleConfig.getActionFormBeanClass());
assertNotNull("ActionForward should have been set", moduleConfig.getActionForwardClass());
assertNotNull("ActionMapping should have been set", moduleConfig.getActionMappingClass());
assertEquals("Prefix Value should be set on ModuleConfig", prefix, moduleConfig.getPrefix());
assertEquals("Prefix Value should be set on ModuleConfig", prefix, moduleConfig.getPrefix());
verify(mockServletContext).setAttribute(anyString(), any());
}
示例6: init
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
public void init(ActionServlet actionServlet,ModuleConfig moduleConfig) throws ServletException{
super.init(actionServlet,moduleConfig);
try{
// Inicializamos implementacion de firma (almacenamos en contexto)
if (StringUtils.isEmpty((String) getServletContext().getAttribute(Constants.IMPLEMENTACION_FIRMA_KEY))){
getServletContext().setAttribute(Constants.IMPLEMENTACION_FIRMA_KEY,PluginFactory.getInstance().getPluginFirma().getProveedor());
}
// Inicializamos si se obligaran los avisos a los expedientes generados desde modulo de gestion expedientes
ConfiguracionDelegate config = DelegateUtil.getConfiguracionDelegate();
Properties configProps = config.obtenerConfiguracion();
getServletContext().setAttribute(Constants.GESTIONEXPEDIENTES_OBLIGATORIOAVISOS,StringUtils.defaultString(configProps.getProperty("gestionExpedientes.avisosObligatorios"), "false"));
}catch (Exception ex){
log.error("Error obteniendo implementacion firma",ex);
throw new ServletException(ex);
}
}
示例7: init
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
public void init(ActionServlet actionServlet,ModuleConfig moduleConfig) throws ServletException{
super.init(actionServlet,moduleConfig);
String obligAvisosNotif;
String contextoSistra;
try {
// Indicamos si son obligatorias los avisos para las notificaciones
ConfiguracionDelegate config = DelegateUtil.getConfiguracionDelegate();
Properties configProps = config.obtenerConfiguracion();
contextoSistra = StringUtils.defaultString(configProps.getProperty("sistra.contextoRaiz"), "");
obligAvisosNotif = StringUtils.defaultString(configProps.getProperty("sistra.avisoObligatorioNotificaciones"), "false");
}catch (Exception ex){
log.error("Error obteniendo obligatoriedad avisos para notificaciones (ponemos a false): " + ex.getMessage(),ex);
obligAvisosNotif = "false";
contextoSistra = "";
}
getServletContext().setAttribute(Constants.AVISOS_OBLIGATORIOS_NOTIFICACIONES,obligAvisosNotif);
getServletContext().setAttribute(Constants.CONTEXTO_RAIZ, contextoSistra);
}
示例8: init
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
/**
* Initialize and load our resources.
*
* @param servlet The ActionServlet for our application
* @param config The ModuleConfig for our owning module
* @throws ServletException if we cannot configure ourselves correctly
*/
public void init(ActionServlet servlet, ModuleConfig config)
throws ServletException {
// Remember our associated configuration and servlet
this.config = config;
this.servlet = servlet;
// Load our database from persistent storage
try {
this.initResources();
servlet.getServletContext().setAttribute(VALIDATOR_KEY
+ config.getPrefix(), resources);
servlet.getServletContext().setAttribute(STOP_ON_ERROR_KEY + '.'
+ config.getPrefix(),
(this.stopOnFirstError ? Boolean.TRUE : Boolean.FALSE));
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new UnavailableException(
"Cannot load a validator resource from '" + pathnames + "'");
}
}
示例9: createModuleConfig
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
/**
* Create a module configuration
* @param moduleName
*/
public ModuleConfig createModuleConfig(
String moduleName,
String configFileName,
boolean moduleAware) {
ModuleConfig moduleConfig =
ModuleConfigFactory.createFactory().createModuleConfig(moduleName);
context.setAttribute(Globals.MODULE_KEY + moduleName, moduleConfig);
// Set tiles plugin
PlugInConfig pluginConfig = new PlugInConfig();
pluginConfig.setClassName("org.apache.struts.tiles.TilesPlugin");
pluginConfig.addProperty(
"moduleAware",
(moduleAware == true ? "true" : "false"));
pluginConfig.addProperty(
"definitions-config",
"/org/apache/struts/tiles/config/" + configFileName);
moduleConfig.addPlugInConfig(pluginConfig);
return moduleConfig;
}
示例10: handle
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
protected ForwardConfig handle(ActionContext context, Exception exception,
ExceptionConfig exceptionConfig, ActionConfig actionConfig,
ModuleConfig moduleConfig)
throws Exception {
// Look up the remaining properties needed for this handler
ServletActionContext sacontext = (ServletActionContext) context;
ActionForm actionForm = (ActionForm) sacontext.getActionForm();
HttpServletRequest request = sacontext.getRequest();
HttpServletResponse response = sacontext.getResponse();
// Handle this exception
org.apache.struts.action.ExceptionHandler handler =
(org.apache.struts.action.ExceptionHandler) ClassUtils
.getApplicationInstance(exceptionConfig.getHandler());
return (handler.execute(exception, exceptionConfig,
(ActionMapping) actionConfig, actionForm, request, response));
}
示例11: execute
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
/**
* <p>Check to see if the content type is set, and if so, set it for this
* response.</p>
*
* @param actionCtx The <code>Context</code> for the current request
* @return <code>false</code> so that processing continues
* @throws Exception if thrown by the Action class
*/
public boolean execute(ActionContext actionCtx)
throws Exception {
// Retrieve the ModuleConfig instance
ModuleConfig moduleConfig = actionCtx.getModuleConfig();
// If the content type is configured, set it for the response
String contentType =
moduleConfig.getControllerConfig().getContentType();
if (contentType != null) {
setContentType(actionCtx, contentType);
}
return (false);
}
示例12: actionURL
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
/**
* <p>Return the context-relative URL that corresponds to the specified
* {@link ActionConfig}, relative to the module associated with the
* current modules's {@link ModuleConfig}.</p>
*
* @param request The servlet request we are processing
* @param action ActionConfig to be evaluated
* @param pattern URL pattern used to map the controller servlet
* @return context-relative URL relative to the module
* @since Struts 1.1
*/
public static String actionURL(HttpServletRequest request,
ActionConfig action, String pattern) {
StringBuffer sb = new StringBuffer();
if (pattern.endsWith("/*")) {
sb.append(pattern.substring(0, pattern.length() - 2));
sb.append(action.getPath());
} else if (pattern.startsWith("*.")) {
ModuleConfig appConfig =
ModuleUtils.getInstance().getModuleConfig(request);
sb.append(appConfig.getPrefix());
sb.append(action.getPath());
sb.append(pattern.substring(1));
} else {
throw new IllegalArgumentException(pattern);
}
return sb.toString();
}
示例13: getRequestProcessor
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
/**
* <p>Look up and return the {@link RequestProcessor} responsible for the
* specified module, creating a new one if necessary.</p>
*
* @param config The module configuration for which to acquire and return
* a RequestProcessor.
* @return The {@link RequestProcessor} responsible for the specified
* module,
* @throws ServletException If we cannot instantiate a RequestProcessor
* instance a {@link UnavailableException} is
* thrown, meaning your application is not loaded
* and will not be available.
* @since Struts 1.1
*/
protected synchronized RequestProcessor getRequestProcessor(
ModuleConfig config) throws ServletException {
RequestProcessor processor = this.getProcessorForModule(config);
if (processor == null) {
try {
processor =
(RequestProcessor) RequestUtils.applicationInstance(config.getControllerConfig()
.getProcessorClass());
} catch (Exception e) {
throw new UnavailableException(
"Cannot initialize RequestProcessor of class "
+ config.getControllerConfig().getProcessorClass() + ": "
+ e);
}
processor.init(this, config);
String key = Globals.REQUEST_PROCESSOR_KEY + config.getPrefix();
getServletContext().setAttribute(key, processor);
}
return (processor);
}
示例14: process
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
/**
* <p>Perform the standard request processing for this request, and create
* the corresponding response.</p>
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
* @throws IOException if an input/output error occurs
* @throws ServletException if a servlet exception is thrown
*/
protected void process(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
ModuleUtils.getInstance().selectModule(request, getServletContext());
ModuleConfig config = getModuleConfig(request);
RequestProcessor processor = getProcessorForModule(config);
if (processor == null) {
processor = getRequestProcessor(config);
}
processor.process(request, response);
}
示例15: testSelectApplication2b
import org.apache.struts.config.ModuleConfig; //导入依赖的package包/类
public void testSelectApplication2b() {
String[] prefixes = { "/1", "/2" };
context.setAttribute(Globals.MODULE_PREFIXES_KEY, prefixes);
request.setPathElements("/myapp", "/noform.do", null, null);
request.setAttribute(RequestProcessor.INCLUDE_SERVLET_PATH,
"/2/noform.do");
ModuleUtils.getInstance().selectModule(request, context);
ModuleConfig moduleConfig =
(ModuleConfig) request.getAttribute(Globals.MODULE_KEY);
assertNotNull("Selected a module", moduleConfig);
assertEquals("Selected correct module", "/2", moduleConfig.getPrefix());
// FIXME - check application resources?
}