Example usage for org.apache.wicket.util.io IOUtils close

List of usage examples for org.apache.wicket.util.io IOUtils close

Introduction

In this page you can find the example usage for org.apache.wicket.util.io IOUtils close.

Prototype

public static void close(final Closeable closeable) throws IOException 

Source Link

Document

Closes a closeable.

Usage

From source file:org.odlabs.wiquery.core.WiQueryInitializer.java

License:Open Source License

/**
 * <p>//  w  w w.j  a v  a 2 s. c  o m
 * Method finding and calling the {@link IWiQueryInitializer}.
 * </p>
 * 
 * This will find find wiquery.properties files in the following order:
 * <ul>
 * <li>wiquery jar/bundle</li>
 * <li>
 * user's application jar/bundle</li>
 * <li>
 * all other resources</li>
 * </ul>
 * 
 */
private void retrieveAndCallInitializers(Application application, WiQuerySettings wiQuerySettings) {

    // Load any wiquery properties files we can find
    try {
        // Load properties files used by all libraries
        final Iterator<URL> resources = application.getApplicationSettings().getClassResolver()
                .getResources("wiquery.properties");
        while (resources.hasNext()) {
            InputStream in = null;
            try {
                final URL url = resources.next();
                final Properties properties = new Properties();
                in = url.openStream();
                properties.load(in);
                load(application, wiQuerySettings, properties);
            } finally {
                IOUtils.close(in);
            }
        }
    } catch (IOException e) {
        throw new WicketRuntimeException("Unable to load initializers file", e);
    }

    // now call any initializers we read
    callInitializers(application, wiQuerySettings);
}