use of org.apache.struts.config.ModuleConfig in project sonarqube by SonarSource.
the class CreateAction method getAction.
/* :TODO The Action class' dependency on having its "servlet" property set
* requires this API-dependent subclass of AbstractCreateAction.
*/
protected synchronized Action getAction(ActionContext context, String type, ActionConfig actionConfig) throws Exception {
ModuleConfig moduleConfig = actionConfig.getModuleConfig();
String actionsKey = Constants.ACTIONS_KEY + moduleConfig.getPrefix();
Map actions = (Map) context.getApplicationScope().get(actionsKey);
if (actions == null) {
actions = new HashMap();
context.getApplicationScope().put(actionsKey, actions);
}
Action action = null;
synchronized (actions) {
action = (Action) actions.get(type);
if (action == null) {
action = createAction(context, type);
actions.put(type, action);
}
}
if (action.getServlet() == null) {
ServletActionContext saContext = (ServletActionContext) context;
ActionServlet actionServlet = saContext.getActionServlet();
action.setServlet(actionServlet);
}
return (action);
}
use of org.apache.struts.config.ModuleConfig in project sonarqube by SonarSource.
the class PerformForward method resolveModuleRelativePath.
private String resolveModuleRelativePath(ForwardConfig forwardConfig, ServletContext servletContext, HttpServletRequest request) {
String prefix = forwardConfig.getModule();
ModuleConfig moduleConfig = ModuleUtils.getInstance().getModuleConfig(prefix, request, servletContext);
return RequestUtils.forwardURL(request, forwardConfig, moduleConfig);
}
use of org.apache.struts.config.ModuleConfig in project sonarqube by SonarSource.
the class ActionServlet method init.
/**
* <p>Initialize this servlet. Most of the processing has been factored
* into support methods so that you can override particular functionality
* at a fairly granular level.</p>
*
* @throws ServletException if we cannot configure ourselves correctly
*/
public void init() throws ServletException {
final String configPrefix = "config/";
final int configPrefixLength = configPrefix.length() - 1;
// to the developer
try {
initInternal();
initOther();
initServlet();
initChain();
getServletContext().setAttribute(Globals.ACTION_SERVLET_KEY, this);
initModuleConfigFactory();
// Initialize modules as needed
ModuleConfig moduleConfig = initModuleConfig("", config);
initModuleMessageResources(moduleConfig);
initModulePlugIns(moduleConfig);
initModuleFormBeans(moduleConfig);
initModuleForwards(moduleConfig);
initModuleExceptionConfigs(moduleConfig);
initModuleActions(moduleConfig);
moduleConfig.freeze();
Enumeration names = getServletConfig().getInitParameterNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
if (!name.startsWith(configPrefix)) {
continue;
}
String prefix = name.substring(configPrefixLength);
moduleConfig = initModuleConfig(prefix, getServletConfig().getInitParameter(name));
initModuleMessageResources(moduleConfig);
initModulePlugIns(moduleConfig);
initModuleFormBeans(moduleConfig);
initModuleForwards(moduleConfig);
initModuleExceptionConfigs(moduleConfig);
initModuleActions(moduleConfig);
moduleConfig.freeze();
}
this.initModulePrefixes(this.getServletContext());
this.destroyConfigDigester();
} catch (UnavailableException ex) {
throw ex;
} catch (Throwable t) {
// The follow error message is not retrieved from internal message
// resources as they may not have been able to have been
// initialized
log.error("Unable to initialize Struts ActionServlet due to an " + "unexpected exception or error thrown, so marking the " + "servlet as unavailable. Most likely, this is due to an " + "incorrect or missing library dependency.", t);
throw new UnavailableException(t.getMessage());
}
}
use of org.apache.struts.config.ModuleConfig in project sonarqube by SonarSource.
the class AbstractSelectInput method execute.
// ---------------------------------------------------------- Public Methods
/**
* <p>Select and cache a <code>ForwardConfig</code> for the input page for
* the current request.</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 {
// Skip processing if the current request is valid
Boolean valid = actionCtx.getFormValid();
if ((valid != null) && valid.booleanValue()) {
return (false);
}
// Acquire configuration objects that we need
ActionConfig actionConfig = actionCtx.getActionConfig();
ModuleConfig moduleConfig = actionConfig.getModuleConfig();
// Cache an ForwardConfig back to our input page
ForwardConfig forwardConfig;
String input = actionConfig.getInput();
if (moduleConfig.getControllerConfig().getInputForward()) {
if (LOG.isTraceEnabled()) {
LOG.trace("Finding ForwardConfig for '" + input + "'");
}
forwardConfig = actionConfig.findForwardConfig(input);
if (forwardConfig == null) {
forwardConfig = moduleConfig.findForwardConfig(input);
}
} else {
if (LOG.isTraceEnabled()) {
LOG.trace("Delegating to forward() for '" + input + "'");
}
forwardConfig = forward(actionCtx, moduleConfig, input);
}
if (LOG.isDebugEnabled()) {
LOG.debug("Forwarding back to " + forwardConfig);
}
actionCtx.setForwardConfig(forwardConfig);
return (false);
}
use of org.apache.struts.config.ModuleConfig in project sonarqube by SonarSource.
the class AbstractSetContentType method execute.
// ---------------------------------------------------------- Public Methods
/**
* <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);
}
Aggregations