All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.heroku.api.connection.ConnectionFactory Maven / Gradle / Ivy

There is a newer version: 0.46
Show newest version
package com.heroku.api.connection;

import java.util.ServiceLoader;

/**
 * Service locator that determines the default Connection implementation a user is
 * using.
 *
 * @author Naaman Newbold
 */
public class ConnectionFactory {

    static final ServiceLoader loader = ServiceLoader.load(ConnectionProvider.class, ConnectionFactory.class.getClassLoader());

    public static Connection get() {
        for (ConnectionProvider cp : loader) {
            Connection conn = cp.getConnection();
            if (conn != null)
                return conn;
        }
        throw new IllegalArgumentException("ConnectionProvider not found");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy