private Object loadPoolingDataSource(Reference ref) { // If DataSource exists, return it String name = getProperty(ref, "dataSourceName"); PGPoolingDataSource pds = PGPoolingDataSource.getDataSource(name); if (pds != null) { return pds; } // Otherwise, create a new one pds = new PGPoolingDataSource(); pds.setDataSourceName(name); loadBaseDataSource(pds, ref); String min = getProperty(ref, "initialConnections"); if (min != null) { pds.setInitialConnections(Integer.parseInt(min)); } String max = getProperty(ref, "maxConnections"); if (max != null) { pds.setMaxConnections(Integer.parseInt(max)); } return pds; }
/** * Dereferences a PostgreSQL DataSource. Other types of references are ignored. */ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception { Reference ref = (Reference) obj; String className = ref.getClassName(); // Old names are here for those who still use them if (className.equals("org.postgresql.ds.PGSimpleDataSource") || className.equals("org.postgresql.jdbc2.optional.SimpleDataSource") || className.equals("org.postgresql.jdbc3.Jdbc3SimpleDataSource")) { return loadSimpleDataSource(ref); } else if (className.equals("org.postgresql.ds.PGConnectionPoolDataSource") || className.equals("org.postgresql.jdbc2.optional.ConnectionPool") || className.equals("org.postgresql.jdbc3.Jdbc3ConnectionPool")) { return loadConnectionPool(ref); } else if (className.equals("org.postgresql.ds.PGPoolingDataSource") || className.equals("org.postgresql.jdbc2.optional.PoolingDataSource") || className.equals("org.postgresql.jdbc3.Jdbc3PoolingDataSource")) { return loadPoolingDataSource(ref); } else { return null; } }
private Object loadSimpleDataSource(Reference ref) { PGSimpleDataSource ds = new PGSimpleDataSource(); return loadBaseDataSource(ds, ref); }
protected Object loadBaseDataSource(BaseDataSource ds, Reference ref) { ds.setDatabaseName(getProperty(ref, "databaseName")); ds.setPassword(getProperty(ref, "password")); String port = getProperty(ref, "portNumber"); if (port != null) { ds.setPortNumber(Integer.parseInt(port)); } ds.setServerName(getProperty(ref, "serverName")); ds.setUser(getProperty(ref, "user")); String prepareThreshold = getProperty(ref, "prepareThreshold"); if (prepareThreshold != null) ds.setPrepareThreshold(Integer.parseInt(prepareThreshold)); return ds; }
private Object loadConnectionPool(Reference ref) { PGConnectionPoolDataSource cp = new PGConnectionPoolDataSource(); return loadBaseDataSource(cp, ref); }
protected Object loadBaseDataSource(BaseDataSource ds, Reference ref) { ds.setDatabaseName(getProperty(ref, "databaseName")); ds.setPassword(getProperty(ref, "password")); String port = getProperty(ref, "portNumber"); if (port != null) { ds.setPortNumber(Integer.parseInt(port)); } ds.setServerName(getProperty(ref, "serverName")); ds.setUser(getProperty(ref, "user")); String prepareThreshold = getProperty(ref, "prepareThreshold"); if (prepareThreshold != null) ds.setPrepareThreshold(Integer.parseInt(prepareThreshold)); return ds; }
|| className.equals("org.postgresql.jdbc3.Jdbc3SimpleDataSource")) return loadSimpleDataSource(ref); || className.equals("org.postgresql.jdbc3.Jdbc3ConnectionPool")) return loadConnectionPool(ref); || className.equals("org.postgresql.jdbc3.Jdbc3PoolingDataSource")) return loadPoolingDataSource(ref);
private Object loadPoolingDataSource(Reference ref) { // If DataSource exists, return it String name = getProperty(ref, "dataSourceName"); PGPoolingDataSource pds = PGPoolingDataSource.getDataSource(name); if (pds != null) { return pds; } // Otherwise, create a new one pds = new PGPoolingDataSource(); pds.setDataSourceName(name); loadBaseDataSource(pds, ref); String min = getProperty(ref, "initialConnections"); if (min != null) { pds.setInitialConnections(Integer.parseInt(min)); } String max = getProperty(ref, "maxConnections"); if (max != null) { pds.setMaxConnections(Integer.parseInt(max)); } return pds; }
private Object loadSimpleDataSource(Reference ref) { PGSimpleDataSource ds = new PGSimpleDataSource(); return loadBaseDataSource(ds, ref); }
protected Object loadBaseDataSource(BaseDataSource ds, Reference ref) { ds.setDatabaseName(getProperty(ref, "databaseName")); ds.setPassword(getProperty(ref, "password")); String port = getProperty(ref, "portNumber"); if (port != null) { ds.setPortNumber(Integer.parseInt(port)); } ds.setServerName(getProperty(ref, "serverName")); ds.setUser(getProperty(ref, "user")); String prepareThreshold = getProperty(ref, "prepareThreshold"); if (prepareThreshold != null) ds.setPrepareThreshold(Integer.parseInt(prepareThreshold)); return ds; }
|| className.equals("org.postgresql.jdbc3.Jdbc3SimpleDataSource")) return loadSimpleDataSource(ref); || className.equals("org.postgresql.jdbc3.Jdbc3ConnectionPool")) return loadConnectionPool(ref); || className.equals("org.postgresql.jdbc3.Jdbc3PoolingDataSource")) return loadPoolingDataSource(ref);
private Object loadPoolingDataSource(Reference ref) { // If DataSource exists, return it String name = getProperty(ref, "dataSourceName"); PGPoolingDataSource pds = PGPoolingDataSource.getDataSource(name); if (pds != null) { return pds; } // Otherwise, create a new one pds = new PGPoolingDataSource(); pds.setDataSourceName(name); loadBaseDataSource(pds, ref); String min = getProperty(ref, "initialConnections"); if (min != null) { pds.setInitialConnections(Integer.parseInt(min)); } String max = getProperty(ref, "maxConnections"); if (max != null) { pds.setMaxConnections(Integer.parseInt(max)); } return pds; }
private Object loadConnectionPool(Reference ref) { PGConnectionPoolDataSource cp = new PGConnectionPoolDataSource(); return loadBaseDataSource(cp, ref); }
|| className.equals("org.postgresql.jdbc3.Jdbc3SimpleDataSource")) return loadSimpleDataSource(ref); || className.equals("org.postgresql.jdbc3.Jdbc3ConnectionPool")) return loadConnectionPool(ref); || className.equals("org.postgresql.jdbc3.Jdbc3PoolingDataSource")) return loadPoolingDataSource(ref);
private Object loadPoolingDataSource(Reference ref) { // If DataSource exists, return it String name = getProperty(ref, "dataSourceName"); PGPoolingDataSource pds = PGPoolingDataSource.getDataSource(name); if (pds != null) { return pds; } // Otherwise, create a new one pds = new PGPoolingDataSource(); pds.setDataSourceName(name); loadBaseDataSource(pds, ref); String min = getProperty(ref, "initialConnections"); if (min != null) { pds.setInitialConnections(Integer.parseInt(min)); } String max = getProperty(ref, "maxConnections"); if (max != null) { pds.setMaxConnections(Integer.parseInt(max)); } return pds; }
private Object loadConnectionPool(Reference ref) { PGConnectionPoolDataSource cp = new PGConnectionPoolDataSource(); return loadBaseDataSource(cp, ref); }
private Object loadSimpleDataSource(Reference ref) { PGSimpleDataSource ds = new PGSimpleDataSource(); return loadBaseDataSource(ds, ref); }
private Object loadConnectionPool(Reference ref) { PGConnectionPoolDataSource cp = new PGConnectionPoolDataSource(); return loadBaseDataSource(cp, ref); }
private Object loadSimpleDataSource(Reference ref) { PGSimpleDataSource ds = new PGSimpleDataSource(); return loadBaseDataSource(ds, ref); }