Search in sources :

Example 1 with PlugInConfig

use of org.apache.struts.config.PlugInConfig in project sonar-java by SonarSource.

the class TestTilesPlugin method createModuleConfig.

// ------------------------------------------------------- Individual Tests
/**
 * 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;
}
Also used : PlugInConfig(org.apache.struts.config.PlugInConfig) ModuleConfig(org.apache.struts.config.ModuleConfig)

Example 2 with PlugInConfig

use of org.apache.struts.config.PlugInConfig in project sonar-java by SonarSource.

the class ActionServlet method initModulePlugIns.

/**
 * <p>Initialize the plug ins for the specified module.</p>
 *
 * @param config ModuleConfig information for this module
 * @throws ServletException if initialization cannot be performed
 * @since Struts 1.1
 */
protected void initModulePlugIns(ModuleConfig config) throws ServletException {
    if (log.isDebugEnabled()) {
        log.debug("Initializing module path '" + config.getPrefix() + "' plug ins");
    }
    PlugInConfig[] plugInConfigs = config.findPlugInConfigs();
    PlugIn[] plugIns = new PlugIn[plugInConfigs.length];
    getServletContext().setAttribute(Globals.PLUG_INS_KEY + config.getPrefix(), plugIns);
    for (int i = 0; i < plugIns.length; i++) {
        try {
            plugIns[i] = (PlugIn) RequestUtils.applicationInstance(plugInConfigs[i].getClassName());
            BeanUtils.populate(plugIns[i], plugInConfigs[i].getProperties());
            // This plugin config object is needed by Tiles
            try {
                PropertyUtils.setProperty(plugIns[i], "currentPlugInConfigObject", plugInConfigs[i]);
            } catch (Exception e) {
                ;
            // FIXME Whenever we fail silently, we must document a valid
            // reason for doing so.  Why should we fail silently if a
            // property can't be set on the plugin?
            /**
             * Between version 1.138-1.140 cedric made these changes.
             * The exceptions are caught to deal with containers
             * applying strict security. This was in response to bug
             * #15736
             *
             * Recommend that we make the currentPlugInConfigObject part
             * of the PlugIn Interface if we can, Rob
             */
            }
            plugIns[i].init(this, config);
        } catch (ServletException e) {
            throw e;
        } catch (Exception e) {
            String errMsg = internal.getMessage("plugIn.init", plugInConfigs[i].getClassName());
            log(errMsg, e);
            throw new UnavailableException(errMsg);
        }
    }
}
Also used : ServletException(javax.servlet.ServletException) PlugInConfig(org.apache.struts.config.PlugInConfig) UnavailableException(javax.servlet.UnavailableException) ServletException(javax.servlet.ServletException) MissingResourceException(java.util.MissingResourceException) SAXException(org.xml.sax.SAXException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnavailableException(javax.servlet.UnavailableException)

Example 3 with PlugInConfig

use of org.apache.struts.config.PlugInConfig in project sonarqube by SonarSource.

the class ActionServlet method initModulePlugIns.

/**
     * <p>Initialize the plug ins for the specified module.</p>
     *
     * @param config ModuleConfig information for this module
     * @throws ServletException if initialization cannot be performed
     * @since Struts 1.1
     */
protected void initModulePlugIns(ModuleConfig config) throws ServletException {
    if (log.isDebugEnabled()) {
        log.debug("Initializing module path '" + config.getPrefix() + "' plug ins");
    }
    PlugInConfig[] plugInConfigs = config.findPlugInConfigs();
    PlugIn[] plugIns = new PlugIn[plugInConfigs.length];
    getServletContext().setAttribute(Globals.PLUG_INS_KEY + config.getPrefix(), plugIns);
    for (int i = 0; i < plugIns.length; i++) {
        try {
            plugIns[i] = (PlugIn) RequestUtils.applicationInstance(plugInConfigs[i].getClassName());
            BeanUtils.populate(plugIns[i], plugInConfigs[i].getProperties());
            // This plugin config object is needed by Tiles
            try {
                PropertyUtils.setProperty(plugIns[i], "currentPlugInConfigObject", plugInConfigs[i]);
            } catch (Exception e) {
                ;
            // FIXME Whenever we fail silently, we must document a valid
            // reason for doing so.  Why should we fail silently if a
            // property can't be set on the plugin?
            /**
                     * Between version 1.138-1.140 cedric made these changes.
                     * The exceptions are caught to deal with containers
                     * applying strict security. This was in response to bug
                     * #15736
                     *
                     * Recommend that we make the currentPlugInConfigObject part
                     * of the PlugIn Interface if we can, Rob
                     */
            }
            plugIns[i].init(this, config);
        } catch (ServletException e) {
            throw e;
        } catch (Exception e) {
            String errMsg = internal.getMessage("plugIn.init", plugInConfigs[i].getClassName());
            log(errMsg, e);
            throw new UnavailableException(errMsg);
        }
    }
}
Also used : ServletException(javax.servlet.ServletException) PlugInConfig(org.apache.struts.config.PlugInConfig) UnavailableException(javax.servlet.UnavailableException) ServletException(javax.servlet.ServletException) MissingResourceException(java.util.MissingResourceException) SAXException(org.xml.sax.SAXException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnavailableException(javax.servlet.UnavailableException)

Example 4 with PlugInConfig

use of org.apache.struts.config.PlugInConfig in project sonarqube by SonarSource.

the class ModuleConfigImpl method freeze.

/**
     * <p> Freeze the configuration of this module.  After this method
     * returns, any attempt to modify the configuration will return an
     * IllegalStateException. </p>
     */
public void freeze() {
    super.freeze();
    ActionConfig[] aconfigs = findActionConfigs();
    for (int i = 0; i < aconfigs.length; i++) {
        aconfigs[i].freeze();
    }
    matcher = new ActionConfigMatcher(aconfigs);
    getControllerConfig().freeze();
    ExceptionConfig[] econfigs = findExceptionConfigs();
    for (int i = 0; i < econfigs.length; i++) {
        econfigs[i].freeze();
    }
    FormBeanConfig[] fbconfigs = findFormBeanConfigs();
    for (int i = 0; i < fbconfigs.length; i++) {
        fbconfigs[i].freeze();
    }
    ForwardConfig[] fconfigs = findForwardConfigs();
    for (int i = 0; i < fconfigs.length; i++) {
        fconfigs[i].freeze();
    }
    MessageResourcesConfig[] mrconfigs = findMessageResourcesConfigs();
    for (int i = 0; i < mrconfigs.length; i++) {
        mrconfigs[i].freeze();
    }
    PlugInConfig[] piconfigs = findPlugInConfigs();
    for (int i = 0; i < piconfigs.length; i++) {
        piconfigs[i].freeze();
    }
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) ExceptionConfig(org.apache.struts.config.ExceptionConfig) FormBeanConfig(org.apache.struts.config.FormBeanConfig) PlugInConfig(org.apache.struts.config.PlugInConfig) ForwardConfig(org.apache.struts.config.ForwardConfig) ActionConfigMatcher(org.apache.struts.config.ActionConfigMatcher) MessageResourcesConfig(org.apache.struts.config.MessageResourcesConfig)

Example 5 with PlugInConfig

use of org.apache.struts.config.PlugInConfig in project sonar-java by SonarSource.

the class ModuleConfigImpl method freeze.

/**
 * <p> Freeze the configuration of this module.  After this method
 * returns, any attempt to modify the configuration will return an
 * IllegalStateException. </p>
 */
public void freeze() {
    super.freeze();
    ActionConfig[] aconfigs = findActionConfigs();
    for (int i = 0; i < aconfigs.length; i++) {
        aconfigs[i].freeze();
    }
    matcher = new ActionConfigMatcher(aconfigs);
    getControllerConfig().freeze();
    ExceptionConfig[] econfigs = findExceptionConfigs();
    for (int i = 0; i < econfigs.length; i++) {
        econfigs[i].freeze();
    }
    FormBeanConfig[] fbconfigs = findFormBeanConfigs();
    for (int i = 0; i < fbconfigs.length; i++) {
        fbconfigs[i].freeze();
    }
    ForwardConfig[] fconfigs = findForwardConfigs();
    for (int i = 0; i < fconfigs.length; i++) {
        fconfigs[i].freeze();
    }
    MessageResourcesConfig[] mrconfigs = findMessageResourcesConfigs();
    for (int i = 0; i < mrconfigs.length; i++) {
        mrconfigs[i].freeze();
    }
    PlugInConfig[] piconfigs = findPlugInConfigs();
    for (int i = 0; i < piconfigs.length; i++) {
        piconfigs[i].freeze();
    }
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) ExceptionConfig(org.apache.struts.config.ExceptionConfig) FormBeanConfig(org.apache.struts.config.FormBeanConfig) PlugInConfig(org.apache.struts.config.PlugInConfig) ForwardConfig(org.apache.struts.config.ForwardConfig) ActionConfigMatcher(org.apache.struts.config.ActionConfigMatcher) MessageResourcesConfig(org.apache.struts.config.MessageResourcesConfig)

Aggregations

PlugInConfig (org.apache.struts.config.PlugInConfig)5 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 MissingResourceException (java.util.MissingResourceException)2 ServletException (javax.servlet.ServletException)2 UnavailableException (javax.servlet.UnavailableException)2 ActionConfig (org.apache.struts.config.ActionConfig)2 ActionConfigMatcher (org.apache.struts.config.ActionConfigMatcher)2 ExceptionConfig (org.apache.struts.config.ExceptionConfig)2 FormBeanConfig (org.apache.struts.config.FormBeanConfig)2 ForwardConfig (org.apache.struts.config.ForwardConfig)2 MessageResourcesConfig (org.apache.struts.config.MessageResourcesConfig)2 SAXException (org.xml.sax.SAXException)2 ModuleConfig (org.apache.struts.config.ModuleConfig)1