Example usage for org.apache.commons.jocl JOCLContentHandler parse

List of usage examples for org.apache.commons.jocl JOCLContentHandler parse

Introduction

In this page you can find the example usage for org.apache.commons.jocl JOCLContentHandler parse.

Prototype

public static JOCLContentHandler parse(InputSource in) throws SAXException, IOException 

Source Link

Document

Parses a JOCL document from the specified InputSource , using thethe XMLReader specified by the org.xml.sax.driver property.

Usage

From source file:orca.util.db.MySqlPool.java

/**
 * Create the connection pool from the parameters found in the specified
 * JOCL file. If the JOCL file cannot be found, then the default
 * configuration is used./* w ww .  java 2s .  co m*/
 * @param loc location of the JOCL file (can be null)
 * @return The connection pool
 * @throws Exception
 */
private static GenericObjectPool createConnectionPool(String loc) {
    try {
        System.setProperty("org.xml.sax.driver", "org.apache.xerces.parsers.SAXParser");

        InputStream is = null;
        if (loc == null) {
            is = getDefaultConfiguration();
        } else {
            File f = new File(loc);
            if (!f.exists()) {
                is = getDefaultConfiguration();
            } else {
                is = new FileInputStream(f);
            }
        }
        JOCLContentHandler handler = JOCLContentHandler.parse(is);
        return (GenericObjectPool) handler.getValue(0);
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException("Failed to create connection pool", e);
    }
}