Created
April 1, 2016 13:04
-
-
Save aweiland/a5ad1472ed79e3514a11ce87e3844b79 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.rethinkdb.RethinkDB; | |
import com.rethinkdb.net.Connection; | |
import org.springframework.beans.factory.config.AbstractFactoryBean; | |
import java.util.concurrent.TimeoutException; | |
public class RethinkDBFactoryBean extends AbstractFactoryBean<Connection> { | |
private final Connection conn; | |
private static final RethinkDB r = RethinkDB.r; | |
public RethinkDBFactoryBean(String host, Integer port) throws TimeoutException { | |
conn = r.connection().hostname(host).port(port).connect(); | |
} | |
public RethinkDBFactoryBean(String host, String port) throws TimeoutException { | |
this(host, Integer.valueOf(port)); | |
} | |
@Override | |
public Class<?> getObjectType() { | |
return Connection.class; | |
} | |
@Override | |
protected Connection createInstance() throws Exception { | |
return conn; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment