Package org.apache.shale.dialog.basic.config

Examples of org.apache.shale.dialog.basic.config.ConfigurationParser


            log.info("Initializing Dialog Basic Implementation");
        }

        // Set up to parse our specified configuration resources and cache the results
        boolean didDefault = false;
        ConfigurationParser parser = new ConfigurationParser();
        parser.setDialogs(new HashMap());

        // Parse implicitly specified resources embedded in JAR files
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        if (loader == null) {
            loader = this.getClass().getClassLoader();
        }
        try {
            Enumeration resources = loader.getResources(EMBEDDED_CONFIGURATION_RESOURCE);
            while (resources.hasMoreElements()) {
                URL resource = (URL) resources.nextElement();
                if (log.isDebugEnabled()) {
                    log.debug("Parsing configuration resource '"
                              + resource + "'");
                }
                parser.setResource(resource);
                parser.parse();
            }
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new FacesException(e);
        }

        // Parse explicitly specified resources
        String resources =
          event.getServletContext().getInitParameter(Globals.CONFIGURATION);
        if (resources == null) {
            resources = "";
            // Because we process the default resource even if it is not
            // explicitly listed, we don't want to warn here
        }
        int comma = 0;
        String path = null;
        try {
            while (true) {
                comma = resources.indexOf(",");
                if (comma < 0) {
                    path = resources.trim();
                    resources = "";
                } else {
                    path = resources.substring(0, comma).trim();
                    resources = resources.substring(comma + 1);
                }
                if (path.length() < 1) {
                    break;
                }
                URL resource = event.getServletContext().getResource(path);
                if (log.isDebugEnabled()) {
                    log.debug("Parsing configuration resource '"
                              + resource + "'");
                }
                parser.setResource(resource);
                parser.parse();
                if (DEFAULT_CONFIGURATION_RESOURCE.equals(path)) {
                    didDefault = true;
                }
            }
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new FacesException(e);
        }

        // Parse the default configuration resource if it exists and has not
        // already been parsed
        if (!didDefault) {
            try {
                URL resource =
                  event.getServletContext().getResource(DEFAULT_CONFIGURATION_RESOURCE);
                if (resource != null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Parsing configuration resource '"
                                  + resource + "'");
                    }
                    parser.setResource(resource);
                    parser.parse();
                }
            } catch (RuntimeException e) {
                throw e;
            } catch (Exception e) {
                throw new FacesException(e);
            }
        }

        // Cache the results in application scope
        Map dialogs = parser.getDialogs();
        if (dialogs.size() == 0) {
            if (log.isWarnEnabled()) {
                log.warn("No dialog configuration information present.  No default configuration found at: " +
                          DEFAULT_CONFIGURATION_RESOURCE + ".  No embedded configuration found at: " +
                          EMBEDDED_CONFIGURATION_RESOURCE);
View Full Code Here

TOP

Related Classes of org.apache.shale.dialog.basic.config.ConfigurationParser

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.