C3P0 library for connection pool

This commit is contained in:
brianjlowe 2012-08-30 18:08:41 +00:00
parent 2e07a5687c
commit d7551ae44c
18 changed files with 132 additions and 89 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -29,8 +29,8 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -966,7 +966,7 @@ public class JenaIngestController extends BaseEditController {
log.debug("Connecting to DB at "+jdbcUrl);
StoreDesc storeDesc = new StoreDesc(LayoutType.LayoutTripleNodesHash,dbTypeObj) ;
ServletContext ctx = vreq.getSession().getServletContext();
BasicDataSource bds = WebappDaoSetup.makeBasicDataSource(
DataSource bds = WebappDaoSetup.makeBasicDataSource(
driver, jdbcUrl, username, password, ctx);
try {
VitroJenaSDBModelMaker vsmm = new VitroJenaSDBModelMaker(storeDesc, bds);

View file

@ -2,10 +2,11 @@
package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -21,13 +22,13 @@ public class RDBGraphGenerator implements SQLGraphGenerator {
private static final Log log = LogFactory.getLog(RDBGraphGenerator.class.getName());
private BasicDataSource ds = null;
private DataSource ds = null;
private Connection connection = null;
private String dbTypeStr = null;
private String graphID = null;
public RDBGraphGenerator(BasicDataSource bds, String dbTypeStr, String graphID) {
this.ds = bds;
public RDBGraphGenerator(DataSource ds, String dbTypeStr, String graphID) {
this.ds = ds;
this.dbTypeStr = dbTypeStr;
this.graphID = graphID;
}
@ -43,10 +44,10 @@ public class RDBGraphGenerator implements SQLGraphGenerator {
public Graph generateGraph() {
log.info("Regenerate the graph.");
try {
if (log.isDebugEnabled()) {
log.debug(ds.getNumActive() + " active SQL connections");
log.debug(ds.getNumIdle() + " idle SQL connections");
}
// if (log.isDebugEnabled()) {
// log.debug(ds.getNumActive() + " active SQL connections");
// log.debug(ds.getNumIdle() + " idle SQL connections");
// }
if ( ( this.connection == null ) || ( this.connection.isClosed() ) ) {
this.connection = ds.getConnection();
}

View file

@ -5,7 +5,8 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.sql.Connection;
import java.sql.SQLException;
import org.apache.commons.dbcp.BasicDataSource;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -14,10 +15,10 @@ public class SDBGraphConnectionGenerator {
private final static Log log = LogFactory.getLog(
SDBGraphConnectionGenerator.class);
private BasicDataSource ds = null;
private DataSource ds = null;
private Connection connection = null;
public SDBGraphConnectionGenerator(BasicDataSource dataSource) {
public SDBGraphConnectionGenerator(DataSource dataSource) {
this.ds = dataSource;
}

View file

@ -2,7 +2,11 @@
package edu.cornell.mannlib.vitro.webapp.dao.jena;
import org.apache.commons.dbcp.BasicDataSource;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -10,8 +14,6 @@ import com.hp.hpl.jena.graph.Graph;
import com.hp.hpl.jena.sdb.SDBFactory;
import com.hp.hpl.jena.sdb.Store;
import com.hp.hpl.jena.sdb.StoreDesc;
import java.sql.Connection;
import java.sql.SQLException;
public class SDBGraphGenerator implements SQLGraphGenerator {
@ -22,7 +24,7 @@ public class SDBGraphGenerator implements SQLGraphGenerator {
private StoreDesc storeDesc;
private String graphID;
public SDBGraphGenerator(BasicDataSource dataSource, StoreDesc storeDesc,
public SDBGraphGenerator(DataSource dataSource, StoreDesc storeDesc,
String graphID) {
this.connGen = new SDBGraphConnectionGenerator(dataSource);
this.storeDesc = storeDesc;

View file

@ -8,8 +8,8 @@ import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -47,7 +47,7 @@ public class VitroJenaModelMaker implements ModelMaker {
private String username;
private String password;
private String dbTypeStr;
private BasicDataSource dataSource;
private DataSource dataSource;
private HashMap<String,Model> modelCache;
private HttpServletRequest request = null;

View file

@ -11,7 +11,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.commons.dbcp.BasicDataSource;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -46,7 +47,7 @@ public class VitroJenaSDBModelMaker implements ModelMaker {
private final static Log log = LogFactory.getLog(VitroJenaSDBModelMaker.class);
private StoreDesc storeDesc = null;
private BasicDataSource bds = null;
private DataSource ds = null;
private SDBConnection conn = null;
private SDBGraphConnectionGenerator connGen = null;
@ -58,12 +59,12 @@ public class VitroJenaSDBModelMaker implements ModelMaker {
private Resource sdbResource; // a resource representing the SDB database
public VitroJenaSDBModelMaker(StoreDesc storeDesc, BasicDataSource bds)
public VitroJenaSDBModelMaker(StoreDesc storeDesc, DataSource ds)
throws SQLException {
this.storeDesc = storeDesc;
this.bds = bds;
connGen = new SDBGraphConnectionGenerator(bds);
this.ds = ds;
connGen = new SDBGraphConnectionGenerator(ds);
Store store = getStore();
try {

View file

@ -23,8 +23,8 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -248,7 +248,7 @@ public class VitroRequestPrep implements Filter {
// If they asked for other models by URI, set them.
if (anyOtherSpecialProperties(vreq)) {
BasicDataSource bds = JenaDataSourceSetupBase.getApplicationDataSource(_context);
DataSource bds = JenaDataSourceSetupBase.getApplicationDataSource(_context);
String dbType = ConfigurationProperties.getBean(_context)
.getProperty("VitroConnection.DataSource.dbtype", "MySQL");
@ -286,7 +286,7 @@ public class VitroRequestPrep implements Filter {
* if it's not found.
*/
private OntModel createSpecialModel(VitroRequest vreq, String key,
BasicDataSource bds, String dbType) {
DataSource bds, String dbType) {
if (!isParameterPresent(vreq, key)) {
return null;
}

View file

@ -21,7 +21,6 @@ import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -92,7 +91,7 @@ public class WebappDaoFactorySparqlPrep implements Filter {
}
}
BasicDataSource bds = JenaDataSourceSetupBase.getApplicationDataSource(_ctx);
javax.sql.DataSource ds = JenaDataSourceSetupBase.getApplicationDataSource(_ctx);
StoreDesc storeDesc = (StoreDesc) _ctx.getAttribute("storeDesc");
OntModelSelector oms = (OntModelSelector) _ctx.getAttribute("unionOntModelSelector");
String defaultNamespace = (String) _ctx.getAttribute("defaultNamespace");
@ -103,12 +102,12 @@ public class WebappDaoFactorySparqlPrep implements Filter {
WebappDaoFactory wadf = null;
try {
if (bds == null || storeDesc == null || oms == null) {
if (ds == null || storeDesc == null || oms == null) {
throw new RuntimeException("SDB store not property set up");
}
try {
sqlConn = bds.getConnection();
sqlConn = ds.getConnection();
conn = new SDBConnection(sqlConn) ;
} catch (SQLException sqe) {
throw new RuntimeException("Unable to connect to database", sqe);

View file

@ -6,6 +6,8 @@ import java.io.ByteArrayInputStream;
import java.sql.SQLException;
import java.util.Iterator;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
@ -32,18 +34,18 @@ public class RDFServiceSDB extends RDFServiceJena implements RDFService {
private final static Log log = LogFactory.getLog(RDFServiceSDB.class);
private BasicDataSource bds;
private DataSource ds;
private StoreDesc storeDesc;
public RDFServiceSDB(BasicDataSource dataSource, StoreDesc storeDesc) {
this.bds = dataSource;
public RDFServiceSDB(DataSource dataSource, StoreDesc storeDesc) {
this.ds = dataSource;
this.storeDesc = storeDesc;
}
@Override
protected DatasetWrapper getDatasetWrapper() {
try {
SDBConnection conn = new SDBConnection(bds.getConnection());
SDBConnection conn = new SDBConnection(ds.getConnection());
return new DatasetWrapper(getDataset(conn), conn);
} catch (SQLException sqle) {
log.error(sqle, sqle);
@ -64,7 +66,7 @@ public class RDFServiceSDB extends RDFServiceJena implements RDFService {
SDBConnection conn = null;
try {
conn = new SDBConnection(bds.getConnection());
conn = new SDBConnection(ds.getConnection());
} catch (SQLException sqle) {
log.error(sqle, sqle);
throw new RDFServiceException(sqle);

View file

@ -1,14 +1,13 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.DISPLAY_ONT_MODEL;
import java.io.File;
import java.io.FileOutputStream;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
@ -16,7 +15,6 @@ import org.apache.commons.logging.LogFactory;
import org.joda.time.DateTime;
import org.joda.time.format.ISODateTimeFormat;
import com.hp.hpl.jena.ontology.OntDocumentManager;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
@ -53,7 +51,7 @@ implements ServletContextListener {
* Also, at each start of tomcat, load The display TBox and the
* display/display model.
*/
private void setupDisplayModel(BasicDataSource bds, ServletContext ctx,
private void setupDisplayModel(DataSource bds, ServletContext ctx,
StartupStatus ss) {
// display, editing and navigation Model
@ -242,7 +240,7 @@ implements ServletContextListener {
public void contextInitialized(ServletContextEvent sce) {
ServletContext ctx = sce.getServletContext();
StartupStatus ss = StartupStatus.getBean(ctx);
BasicDataSource bds = getApplicationDataSource(ctx);
DataSource bds = getApplicationDataSource(ctx);
setupDisplayModel(bds, ctx, ss);
}

View file

@ -2,6 +2,7 @@
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
import java.beans.PropertyVetoException;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
@ -9,6 +10,7 @@ import java.sql.SQLException;
import java.util.Set;
import javax.servlet.ServletContext;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.lang.StringUtils;
@ -31,6 +33,7 @@ import com.hp.hpl.jena.sdb.Store;
import com.hp.hpl.jena.sdb.StoreDesc;
import com.hp.hpl.jena.sdb.store.DatabaseType;
import com.hp.hpl.jena.sdb.store.LayoutType;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
@ -174,9 +177,10 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
"VitroConnection.DataSource.username");
String password = ConfigurationProperties.getBean(ctx).getProperty(
"VitroConnection.DataSource.password");
BasicDataSource ds = makeBasicDataSource(
DataSource ds = makeC3poDataSource(
getDbDriverClassName(ctx), jdbcUrl, username, password, ctx);
// DataSource ds = makeBasicDataSource(
// getDbDriverClassName(ctx), jdbcUrl, username, password, ctx);
jenaDbOntModelSpec = (jenaDbOntModelSpec != null)
? jenaDbOntModelSpec
: DB_ONT_MODEL_SPEC;
@ -186,10 +190,10 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
}
/**
* Sets up a BasicDataSource using values from
* Sets up a DataSource using values from
* a properties file.
*/
public final BasicDataSource makeDataSourceFromConfigurationProperties(
public final DataSource makeDataSourceFromConfigurationProperties(
ServletContext ctx) {
String dbDriverClassname = ConfigurationProperties.getBean(ctx)
.getProperty("VitroConnection.DataSource.driver",
@ -199,35 +203,51 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
"VitroConnection.DataSource.username");
String password = ConfigurationProperties.getBean(ctx).getProperty(
"VitroConnection.DataSource.password");
return makeBasicDataSource(
return makeC3poDataSource(
dbDriverClassname, jdbcUrl, username, password, ctx);
// makeBasicDataSource(
// dbDriverClassname, jdbcUrl, username, password, ctx);
}
public void setApplicationDataSource(BasicDataSource bds,
public void setApplicationDataSource(DataSource ds,
ServletContext ctx) {
ctx.setAttribute(getDataSourceAttributeName(), bds);
ctx.setAttribute(getDataSourceAttributeName(), ds);
}
public static BasicDataSource getApplicationDataSource(ServletContext ctx) {
return (BasicDataSource) ctx.getAttribute(getDataSourceAttributeName());
public static DataSource getApplicationDataSource(ServletContext ctx) {
return (DataSource) ctx.getAttribute(getDataSourceAttributeName());
}
private static String getDataSourceAttributeName() {
return JenaDataSourceSetupBase.class.getName() + ".dataSource";
}
public static BasicDataSource makeBasicDataSource(String dbDriverClassname,
public static DataSource makeC3poDataSource(String dbDriverClassname,
String jdbcUrl,
String username,
String password,
ServletContext ctx) {
log.debug("makeBasicDataSource('" + dbDriverClassname + "', '"
+ jdbcUrl + "', '" + username + "', '" + password + "')");
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName(dbDriverClassname);
ds.setUrl(jdbcUrl);
ds.setUsername(username);
ds.setPassword(password);
ComboPooledDataSource cpds = new ComboPooledDataSource();
try {
cpds.setDriverClass(dbDriverClassname);
} catch (PropertyVetoException pve) {
throw new RuntimeException(pve);
}
cpds.setJdbcUrl(jdbcUrl);
cpds.setUser(username);
cpds.setPassword(password);
int[] maxActiveAndIdle = getMaxActiveAndIdle(ctx);
cpds.setMaxPoolSize(maxActiveAndIdle[0]);
cpds.setMinPoolSize(maxActiveAndIdle[1]);
cpds.setMaxIdleTime(3600); // ms
cpds.setMaxIdleTimeExcessConnections(300);
cpds.setAcquireIncrement(5);
cpds.setNumHelperThreads(6);
return cpds;
}
private static int[] getMaxActiveAndIdle(ServletContext ctx) {
int maxActiveInt = DEFAULT_MAXACTIVE;
String maxActiveStr = ConfigurationProperties.getBean(ctx).getProperty(
MAX_ACTIVE_PROPERTY);
@ -247,11 +267,11 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
+ maxActiveStr + " as an integer");
}
}
String maxIdleStr = ConfigurationProperties.getBean(ctx).getProperty(
MAX_IDLE_PROPERTY);
int maxIdleInt = (maxActiveInt > DEFAULT_MAXACTIVE)
? maxActiveInt / 4
: DEFAULT_MAXIDLE;
String maxIdleStr = ConfigurationProperties.getBean(ctx).getProperty(
MAX_IDLE_PROPERTY);
if (!StringUtils.isEmpty(maxIdleStr)) {
try {
maxIdleInt = Integer.parseInt(maxIdleStr);
@ -259,15 +279,34 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
log.error("Unable to parse connection pool maxIdle setting "
+ maxIdleStr + " as an integer");
}
}
ds.setMaxActive(maxActiveInt);
ds.setMaxIdle(maxIdleInt);
}
int[] result = new int[2];
result[0] = maxActiveInt;
result[1] = maxIdleInt;
return result;
}
public static DataSource makeBasicDataSource(String dbDriverClassname,
String jdbcUrl,
String username,
String password,
ServletContext ctx) {
log.debug("makeBasicDataSource('" + dbDriverClassname + "', '"
+ jdbcUrl + "', '" + username + "', '" + password + "')");
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName(dbDriverClassname);
ds.setUrl(jdbcUrl);
ds.setUsername(username);
ds.setPassword(password);
int[] maxActiveAndIdle = getMaxActiveAndIdle(ctx);
ds.setMaxActive(maxActiveAndIdle[0]);
ds.setMaxIdle(maxActiveAndIdle[1]);
ds.setMaxWait(DEFAULT_MAXWAIT);
ds.setValidationQuery(getValidationQuery(ctx));
ds.setTestOnBorrow(DEFAULT_TESTONBORROW);
ds.setTestOnReturn(DEFAULT_TESTONRETURN);
ds.setMinEvictableIdleTimeMillis(DEFAULT_MINEVICTIONIDLETIME);
ds.setNumTestsPerEvictionRun(maxActiveInt);
ds.setNumTestsPerEvictionRun(maxActiveAndIdle[0]);
ds.setTimeBetweenEvictionRunsMillis(DEFAULT_TIMEBETWEENEVICTIONS);
ds.setInitialSize(ds.getMaxActive() / 10);
@ -292,7 +331,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
firstStartup = true;
}
protected Model makeDBModel(BasicDataSource ds,
protected Model makeDBModel(DataSource ds,
String jenaDbModelname,
OntModelSpec jenaDbOntModelSpec,
ServletContext ctx) {
@ -300,7 +339,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
ds, jenaDbModelname, jenaDbOntModelSpec, TripleStoreType.RDB, ctx);
}
protected Model makeDBModel(BasicDataSource ds,
protected Model makeDBModel(DataSource ds,
String jenaDbModelName,
OntModelSpec jenaDbOntModelSpec,
TripleStoreType storeType, ServletContext ctx) {
@ -308,7 +347,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
getDbType(ctx), ctx);
}
public static Model makeDBModel(BasicDataSource ds,
public static Model makeDBModel(DataSource ds,
String jenaDbModelName,
OntModelSpec jenaDbOntModelSpec,
TripleStoreType storeType, String dbType,
@ -343,7 +382,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
"Unsupported store type " + storeType);
}
dbModel = ModelFactory.createModelForGraph(g);
log.debug("Using database at "+ds.getUrl());
//log.debug("Using database at " + ds.getUrl());
} catch (Throwable t) {
t.printStackTrace();
}
@ -429,11 +468,13 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
} else if (TripleStoreType.SDB.equals(type)) {
StoreDesc storeDesc = new StoreDesc(
LayoutType.LayoutTripleNodesHash, DatabaseType.fetch(dbtypeStr));
BasicDataSource bds = WebappDaoSetup.makeBasicDataSource(
DataSource bds = WebappDaoSetup.makeC3poDataSource(
getDbDriverClassName(ctx), jdbcUrl, username, password, ctx);
bds.setMaxActive(4); // for now, the SDB model makers should not use more
// than a small handful of connections
bds.setMaxIdle(2);
// DataSource bds = WebappDaoSetup.makeBasicDataSource(
// getDbDriverClassName(ctx), jdbcUrl, username, password, ctx);
// bds.setMaxActive(4); // for now, the SDB model makers should not use more
// // than a small handful of connections
// bds.setMaxIdle(2);
try {
vsmm = new VitroJenaSDBModelMaker(storeDesc, bds);
} catch (SQLException sqle) {

View file

@ -5,17 +5,13 @@ package edu.cornell.mannlib.vitro.webapp.servlet.setup;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.ontology.OntDocumentManager;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelSynchronizer;
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
/**
@ -35,7 +31,7 @@ public class JenaPersistentDataSourceSetup extends JenaDataSourceSetupBase
// we do not want to fetch imports when we wrap Models in OntModels
OntDocumentManager.getInstance().setProcessImports(false);
BasicDataSource bds = makeDataSourceFromConfigurationProperties(ctx);
DataSource bds = makeDataSourceFromConfigurationProperties(ctx);
setApplicationDataSource(bds, ctx);
}

View file

@ -5,6 +5,7 @@ import java.sql.SQLException;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
@ -82,8 +83,8 @@ implements javax.servlet.ServletContextListener {
}
private void useSDB(ServletContext ctx, StartupStatus ss) throws SQLException {
BasicDataSource bds = getApplicationDataSource(ctx);
if( bds == null ){
DataSource ds = getApplicationDataSource(ctx);
if( ds == null ){
ss.fatal(this, "A DataSource must be setup before SDBSetup "+
"is run. Make sure that JenaPersistentDataSourceSetup runs before "+
"SDBSetup.");
@ -96,7 +97,7 @@ implements javax.servlet.ServletContextListener {
StoreDesc storeDesc = makeStoreDesc(ctx);
setApplicationStoreDesc(storeDesc, ctx);
Store store = connectStore(bds, storeDesc);
Store store = connectStore(ds, storeDesc);
setApplicationStore(store, ctx);
if (!isSetUp(store)) {
@ -104,7 +105,7 @@ implements javax.servlet.ServletContextListener {
setupSDB(ctx, store);
}
RDFService rdfService = new RDFServiceSDB(bds, storeDesc);
RDFService rdfService = new RDFServiceSDB(ds, storeDesc);
RDFServiceFactory rdfServiceFactory = new RDFServiceFactorySingle(rdfService);
RDFServiceUtils.setRDFServiceFactory(ctx, rdfServiceFactory);
@ -145,7 +146,7 @@ implements javax.servlet.ServletContextListener {
DatabaseType.fetch(dbtypeStr) );
}
public static Store connectStore(BasicDataSource bds, StoreDesc storeDesc)
public static Store connectStore(DataSource bds, StoreDesc storeDesc)
throws SQLException {
SDBConnection conn = new SDBConnection(bds.getConnection());
return SDBFactory.connectStore(conn, storeDesc);

View file

@ -12,8 +12,8 @@ import java.util.List;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -82,7 +82,7 @@ public class SimpleReasonerSetup implements ServletContextListener {
// set up simple reasoning for the ABox
ServletContext ctx = sce.getServletContext();
BasicDataSource bds = JenaDataSourceSetupBase
DataSource bds = JenaDataSourceSetupBase
.getApplicationDataSource(ctx);
String dbType = ConfigurationProperties.getBean(ctx).getProperty( // database type
"VitroConnection.DataSource.dbtype","MySQL");

View file

@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.servlet.setup;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.logging.Log;
@ -33,7 +34,7 @@ public class UserModelSetup extends JenaDataSourceSetupBase
ServletContext ctx = sce.getServletContext();
StartupStatus ss = StartupStatus.getBean(ctx);
BasicDataSource bds = getApplicationDataSource(ctx);
DataSource bds = getApplicationDataSource(ctx);
if( bds == null ){
ss.fatal(this, "A DataSource must be setup before ModelSetup "+
"is run. Make sure that JenaPersistentDataSourceSetup runs before "+
@ -49,7 +50,7 @@ public class UserModelSetup extends JenaDataSourceSetupBase
// Does nothing.
}
private void setupUserAccountModel (BasicDataSource bds, ServletContext ctx ,StartupStatus ss){
private void setupUserAccountModel (DataSource bds, ServletContext ctx ,StartupStatus ss){
try {
Model userAccountsDbModel = makeDBModel(bds,
JENA_USER_ACCOUNTS_MODEL, DB_ONT_MODEL_SPEC, ctx);