Package org.apache.struts.config

Examples of org.apache.struts.config.ApplicationConfig


                JspException e = new JspException
                    (messages.getMessage("imgTag.src"));
                RequestUtils.saveException(pageContext, e);
                throw e;
            }
            ApplicationConfig config = (ApplicationConfig)
                pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
            HttpServletRequest request =
                (HttpServletRequest) pageContext.getRequest();
            if (config == null) {
                return (request.getContextPath() + this.page);
            } else {
                return (request.getContextPath() + config.getPrefix() +
                        this.page);
            }
        }

        // Deal with an indirect context-relative page that has been specified
        if (this.pageKey != null) {
            if ((this.src != null) || (this.srcKey != null)) {
                JspException e = new JspException
                    (messages.getMessage("imgTag.src"));
                RequestUtils.saveException(pageContext, e);
                throw e;
            }
            ApplicationConfig config = (ApplicationConfig)
                pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
            HttpServletRequest request =
                (HttpServletRequest) pageContext.getRequest();
            if (config == null) {
                return (request.getContextPath() +
                        RequestUtils.message(pageContext, getBundle(),
                                             getLocale(), this.pageKey));
            } else {
                return (request.getContextPath() + config.getPrefix() +
                        RequestUtils.message(pageContext, getBundle(),
                                             getLocale(), this.pageKey));
            }
        }
View Full Code Here


    protected String getActionMappingURL() {

        HttpServletRequest request =
            (HttpServletRequest) pageContext.getRequest();
        StringBuffer value = new StringBuffer(request.getContextPath());
        ApplicationConfig config = (ApplicationConfig)
            pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
        if (config != null) {
            value.append(config.getPrefix());
        }

        // Use our servlet mapping, if one is specified
        String servletMapping = (String)
            pageContext.getAttribute(Action.SERVLET_KEY,
View Full Code Here

        initOther();
        initServlet();

        // Initialize application modules as needed
        getServletContext().setAttribute(Action.ACTION_SERVLET_KEY, this);
        ApplicationConfig ac = initApplicationConfig("", config);
        initApplicationMessageResources(ac);
        initApplicationDataSources(ac);
        initApplicationPlugIns(ac);
        ac.freeze();
        Enumeration names = getServletConfig().getInitParameterNames();
        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();
            if (!name.startsWith("config/")) {
                continue;
            }
            String prefix = name.substring(6);
            ac = initApplicationConfig
                (prefix, getServletConfig().getInitParameter(name));
            initApplicationMessageResources(ac);
            initApplicationDataSources(ac);
            initApplicationPlugIns(ac);
            ac.freeze();
        }
        destroyConfigDigester();

    }
View Full Code Here

        Iterator keys = values.iterator();
        while (keys.hasNext()) {
            String name = (String) keys.next();
            Object value = getServletContext().getAttribute(name);
            if (value instanceof ApplicationConfig) {
                ApplicationConfig config = (ApplicationConfig) value;
                try {
                    getRequestProcessor(config).destroy();
                } catch (Throwable t) {
                    ;
                }
                PlugIn plugIns[] = (PlugIn[])
                    getServletContext().getAttribute
                    (Action.PLUG_INS_KEY + config.getPrefix());
                if (plugIns != null) {
                    for (int i = 0; i < plugIns.length; i++) {
                        int j = plugIns.length - (i + 1);
                        plugIns[j].destroy();
                    }
View Full Code Here

     * @since Struts 1.1
     */
    protected ApplicationConfig getApplicationConfig
        (HttpServletRequest request) {

        ApplicationConfig config = (ApplicationConfig)
            request.getAttribute(Action.APPLICATION_KEY);
        if (config == null) {
            config = (ApplicationConfig)
                getServletContext().getAttribute(Action.APPLICATION_KEY);
        }
View Full Code Here

            log.debug("Initializing application path '" + prefix +
                "' configuration from '" + path + "'");
        }

        // Parse the application configuration for this module
        ApplicationConfig config = null;
        InputStream input = null;
        String mapping = null;
        try {
            config = new ApplicationConfig(prefix);

            // Support for module-wide ActionMapping type override
            mapping = getServletConfig().getInitParameter("mapping");
            if (mapping != null) {
                config.setActionMappingClass(mapping);
            }

            Digester digester = initConfigDigester();
            digester.push(config);
            URL url = getServletContext().getResource(path);
            InputSource is = new InputSource(url.toExternalForm());
            input = getServletContext().getResourceAsStream(path);
            is.setByteStream(input);
            digester.parse(is);
            input.close();
            getServletContext().setAttribute
                (Action.APPLICATION_KEY + prefix, config);
        } catch (Throwable t) {
            log.error(internal.getMessage("configParse", path), t);
            throw new UnavailableException
                (internal.getMessage("configParse", path));
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                    ;
                }
            }
        }

        // Force creation and registration of DynaActionFormClass instances
        // for all dynamic form beans we wil be using
        FormBeanConfig fbs[] = config.findFormBeanConfigs();
        for (int i = 0; i < fbs.length; i++) {
            if (fbs[i].getDynamic()) {
                DynaActionFormClass.createDynaActionFormClass(fbs[i]);
            }
        }
View Full Code Here

            throw new MalformedURLException
                (messages.getMessage("computeURL.specifier"));
        }

        // Look up the application module configuration for this request
        ApplicationConfig config = (ApplicationConfig)
            pageContext.getRequest().getAttribute(Action.APPLICATION_KEY);
        if (config == null) { // Backwards compatibility hack
            config = (ApplicationConfig)
                pageContext.getServletContext().getAttribute
                (Action.APPLICATION_KEY);
            pageContext.getRequest().setAttribute(Action.APPLICATION_KEY,
                                                  config);
        }

        // Calculate the appropriate URL
        StringBuffer url = new StringBuffer();
        HttpServletRequest request =
            (HttpServletRequest) pageContext.getRequest();
        if (forward != null) {
            ForwardConfig fc = config.findForwardConfig(forward);
            if (fc == null) {
                throw new MalformedURLException
                    (messages.getMessage("computeURL.forward", forward));
            }
            if (fc.getRedirect()) {
View Full Code Here

            if (multipartHandler != null)
                return multipartHandler;
        }

        ApplicationConfig appConfig = (ApplicationConfig)
            request.getAttribute(Action.APPLICATION_KEY);
        multipartClass = appConfig.getControllerConfig().getMultipartClass();

        // Try to initialize the global request handler
        if (multipartClass != null) {
            try {
                multipartHandler = (MultipartRequestHandler)
View Full Code Here

        StringBuffer sb = new StringBuffer();
        if (pattern.endsWith("/*")) {
            sb.append(pattern.substring(0, pattern.length() - 2));
            sb.append(action.getPath());
        } else if (pattern.startsWith("*.")) {
            ApplicationConfig appConfig = (ApplicationConfig)
                request.getAttribute(Action.APPLICATION_KEY);
            sb.append(appConfig.getPrefix());
            sb.append(action.getPath());
            sb.append(pattern.substring(1));
        } else {
            throw new IllegalArgumentException(pattern);
        }
View Full Code Here

            sb.append(path);
            return (sb.toString());
        }

        // Calculate a context relative path for this ForwardConfig
        ApplicationConfig appConfig = (ApplicationConfig)
            request.getAttribute(Action.APPLICATION_KEY);
        String forwardPattern =
            appConfig.getControllerConfig().getForwardPattern();
        if (forwardPattern == null) {
            // Performance optimization for previous default behavior
            sb.append(appConfig.getPrefix());
            // smoothly insert a '/' if needed
            if (!path.startsWith("/")) {
                sb.append("/");
            }
            sb.append(path);
        } else {
            boolean dollar = false;
            for (int i = 0; i < forwardPattern.length(); i++) {
                char ch = forwardPattern.charAt(i);
                if (dollar) {
                    switch (ch) {
                    case 'M':
                        sb.append(appConfig.getPrefix());
                        break;
                    case 'P':
                        // add '/' if needed
                        if (!path.startsWith("/")) {
                            sb.append("/");
View Full Code Here

TOP

Related Classes of org.apache.struts.config.ApplicationConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.