private void parseJarResources()

in web/src/main/java/org/apache/commons/chain2/web/ChainListener.java [223:274]


    private void parseJarResources(ServletContext context,
                                   XmlConfigParser parser, Log log) {
        @SuppressWarnings( "unchecked" ) // it is known that always returns String inside
        Set<String> jars = context.getResourcePaths("/WEB-INF/lib");
        if (jars == null) {
            jars = new HashSet<String>();
        }
        String path;

        for (String jar : jars) {

            path = jar;
            if (!path.endsWith(".jar")) {
                continue;
            }
            URL resourceURL = null;
            try {
                URL jarURL = context.getResource(path);
                resourceURL = new URL("jar:"
                        + translate(jarURL.toExternalForm())
                        + "!/META-INF/chain-config.xml");
                InputStream is = null;
                try {
                    is = resourceURL.openStream();
                } catch (Exception e) {
                    // means there is no such resource
                }
                if (is == null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Not Found: " + resourceURL);
                    }
                    continue;
                } else {
                    is.close();
                }
                if (log.isDebugEnabled()) {
                    log.debug("Parsing: " + resourceURL);
                }
                @SuppressWarnings("unused") // FIXME we have to assign the factory here to help the compiler with the type arguments
                CatalogFactory<Object, Object,Map<Object,Object>> factory = parser.parse(resourceURL);
            } catch (Exception e) {
                String externalURL = "null";
                if (resourceURL != null) {
                    externalURL = resourceURL.toExternalForm();
                }
                throw new RuntimeException
                        ("Exception parsing chain config resource '"
                                + externalURL + "': "
                                + e.getMessage());
            }
        }
    }