Package org.apache.shale.remoting

Examples of org.apache.shale.remoting.Mappings


     *
     * @param context <code>FacesContext</code> for the current request
     */
    public Mappings getMappings(FacesContext context) {

        Mappings mappings = (Mappings)
            context.getExternalContext().getApplicationMap().
                get(Constants.MAPPINGS_ATTR);
        if (mappings == null) {
            mappings = createMappings(context);
            context.getExternalContext().getApplicationMap().
View Full Code Here


     *  or configured
     */
    private Mappings createMappings(FacesContext context) {

        // Instantiate a Mappings instance to configure
        Mappings mappings = null;
        String mappingsClass = MappingsImpl.class.getName();
        String mappingsClassParam =
          context.getExternalContext().getInitParameter(Constants.MAPPINGS_CLASS);
        if (mappingsClassParam != null) {
            mappingsClass = mappingsClassParam;
        }
        Class clazz = null;
        try {
            if (log().isInfoEnabled()) {
                log().info(bundle.getString("mappings.configure"));
                log().info(mappingsClass);
            }
            clazz = loadClass(mappingsClass);
        } catch (Exception e) {
            throw new FacesException(e);
        }
        try {
            mappings = (Mappings) clazz.newInstance();
        } catch (Exception e) {
            throw new FacesException(e);
        }

        // Configure the Mapping instances for this Mappings instance
        configureMappings(context, mappings, Constants.CLASS_RESOURCES_PARAM,
                          Constants.CLASS_RESOURCES_EXCLUDES,
                          Constants.CLASS_RESOURCES_EXCLUDES_DEFAULT,
                          Constants.CLASS_RESOURCES_INCLUDES,
                          Constants.CLASS_RESOURCES_INCLUDES_DEFAULT,
                          Mechanism.CLASS_RESOURCE,
                          "/static/*:org.apache.shale.remoting.impl.ClassResourceProcessor");
        configureMappings(context, mappings, Constants.DYNAMIC_RESOURCES_PARAM,
                          Constants.DYNAMIC_RESOURCES_EXCLUDES,
                          Constants.DYNAMIC_RESOURCES_EXCLUDES_DEFAULT,
                          Constants.DYNAMIC_RESOURCES_INCLUDES,
                          Constants.DYNAMIC_RESOURCES_INCLUDES_DEFAULT,
                          Mechanism.DYNAMIC_RESOURCE,
                          "/dynamic/*:org.apache.shale.remoting.impl.MethodBindingProcessor");
        configureMappings(context, mappings, Constants.OTHER_RESOURCES_PARAM,
                          Constants.OTHER_RESOURCES_EXCLUDES,
                          Constants.OTHER_RESOURCES_EXCLUDES_DEFAULT,
                          Constants.OTHER_RESOURCES_INCLUDES,
                          Constants.OTHER_RESOURCES_INCLUDES_DEFAULT,
                          Mechanism.OTHER_RESOURCE,
                          null);
        configureMappings(context, mappings, Constants.WEBAPP_RESOURCES_PARAM,
                          Constants.WEBAPP_RESOURCES_EXCLUDES,
                          Constants.WEBAPP_RESOURCES_EXCLUDES_DEFAULT,
                          Constants.WEBAPP_RESOURCES_INCLUDES,
                          Constants.WEBAPP_RESOURCES_INCLUDES_DEFAULT,
                          Mechanism.WEBAPP_RESOURCE,
                          "/webapp/*:org.apache.shale.remoting.impl.WebResourceProcessor");

        // Calculate and set the replacement extension, to be used
        // if FacesServlet is extension mapped
        String extension = context.getExternalContext().
                getInitParameter(ViewHandler.DEFAULT_SUFFIX_PARAM_NAME);
        if (extension == null) {
            extension = ViewHandler.DEFAULT_SUFFIX;
        }
        mappings.setExtension(extension);

        // Calculate and set the URL patterns that FacesServlet is mapped with
        // FIXME - hard coded to "*.faces" for now
        String[] patterns = patterns(context);
        if (log().isTraceEnabled()) {
            for (int i = 0; i < patterns.length; i++) {
                log().trace("FacesServlet is mapped with URL pattern '" + patterns[i] + "'");
            }
        }
        mappings.setPatterns(patterns);

        // Calculate the index of the pattern to use by default
        int patternIndex = 0;
        String patternIndexString =
          context.getExternalContext().getInitParameter(Constants.FACES_SERVLET_URL_PARAM);
        if (patternIndexString != null) {
            patternIndex = Integer.parseInt(patternIndexString.trim());
        }
        if (patternIndex >= patterns.length) {
            log.warn("FacesServlet pattern index of " + patternIndex
                     + " does not match any specified pattern");
        }
        mappings.setPatternIndex(patternIndex);

        // Return the configured Mappings instance
        return mappings;

    }
View Full Code Here

TOP

Related Classes of org.apache.shale.remoting.Mappings

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.