C3P0 library for connection pool
This commit is contained in:
parent
2e07a5687c
commit
d7551ae44c
18 changed files with 132 additions and 89 deletions
BIN
webapp/lib/c3p0-0.9.2-pre4.jar
Normal file
BIN
webapp/lib/c3p0-0.9.2-pre4.jar
Normal file
Binary file not shown.
BIN
webapp/lib/c3p0-oracle-thin-extras-0.9.2-pre4.jar
Normal file
BIN
webapp/lib/c3p0-oracle-thin-extras-0.9.2-pre4.jar
Normal file
Binary file not shown.
BIN
webapp/lib/mchange-commons-java-0.2.2.jar
Normal file
BIN
webapp/lib/mchange-commons-java-0.2.2.jar
Normal file
Binary file not shown.
|
@ -29,8 +29,8 @@ import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
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.lang.StringEscapeUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -966,7 +966,7 @@ public class JenaIngestController extends BaseEditController {
|
||||||
log.debug("Connecting to DB at "+jdbcUrl);
|
log.debug("Connecting to DB at "+jdbcUrl);
|
||||||
StoreDesc storeDesc = new StoreDesc(LayoutType.LayoutTripleNodesHash,dbTypeObj) ;
|
StoreDesc storeDesc = new StoreDesc(LayoutType.LayoutTripleNodesHash,dbTypeObj) ;
|
||||||
ServletContext ctx = vreq.getSession().getServletContext();
|
ServletContext ctx = vreq.getSession().getServletContext();
|
||||||
BasicDataSource bds = WebappDaoSetup.makeBasicDataSource(
|
DataSource bds = WebappDaoSetup.makeBasicDataSource(
|
||||||
driver, jdbcUrl, username, password, ctx);
|
driver, jdbcUrl, username, password, ctx);
|
||||||
try {
|
try {
|
||||||
VitroJenaSDBModelMaker vsmm = new VitroJenaSDBModelMaker(storeDesc, bds);
|
VitroJenaSDBModelMaker vsmm = new VitroJenaSDBModelMaker(storeDesc, bds);
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Connection;
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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 static final Log log = LogFactory.getLog(RDBGraphGenerator.class.getName());
|
||||||
|
|
||||||
private BasicDataSource ds = null;
|
private DataSource ds = null;
|
||||||
private Connection connection = null;
|
private Connection connection = null;
|
||||||
private String dbTypeStr = null;
|
private String dbTypeStr = null;
|
||||||
private String graphID = null;
|
private String graphID = null;
|
||||||
|
|
||||||
public RDBGraphGenerator(BasicDataSource bds, String dbTypeStr, String graphID) {
|
public RDBGraphGenerator(DataSource ds, String dbTypeStr, String graphID) {
|
||||||
this.ds = bds;
|
this.ds = ds;
|
||||||
this.dbTypeStr = dbTypeStr;
|
this.dbTypeStr = dbTypeStr;
|
||||||
this.graphID = graphID;
|
this.graphID = graphID;
|
||||||
}
|
}
|
||||||
|
@ -43,10 +44,10 @@ public class RDBGraphGenerator implements SQLGraphGenerator {
|
||||||
public Graph generateGraph() {
|
public Graph generateGraph() {
|
||||||
log.info("Regenerate the graph.");
|
log.info("Regenerate the graph.");
|
||||||
try {
|
try {
|
||||||
if (log.isDebugEnabled()) {
|
// if (log.isDebugEnabled()) {
|
||||||
log.debug(ds.getNumActive() + " active SQL connections");
|
// log.debug(ds.getNumActive() + " active SQL connections");
|
||||||
log.debug(ds.getNumIdle() + " idle SQL connections");
|
// log.debug(ds.getNumIdle() + " idle SQL connections");
|
||||||
}
|
// }
|
||||||
if ( ( this.connection == null ) || ( this.connection.isClosed() ) ) {
|
if ( ( this.connection == null ) || ( this.connection.isClosed() ) ) {
|
||||||
this.connection = ds.getConnection();
|
this.connection = ds.getConnection();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,8 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@ -14,10 +15,10 @@ public class SDBGraphConnectionGenerator {
|
||||||
private final static Log log = LogFactory.getLog(
|
private final static Log log = LogFactory.getLog(
|
||||||
SDBGraphConnectionGenerator.class);
|
SDBGraphConnectionGenerator.class);
|
||||||
|
|
||||||
private BasicDataSource ds = null;
|
private DataSource ds = null;
|
||||||
private Connection connection = null;
|
private Connection connection = null;
|
||||||
|
|
||||||
public SDBGraphConnectionGenerator(BasicDataSource dataSource) {
|
public SDBGraphConnectionGenerator(DataSource dataSource) {
|
||||||
this.ds = dataSource;
|
this.ds = dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,11 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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.SDBFactory;
|
||||||
import com.hp.hpl.jena.sdb.Store;
|
import com.hp.hpl.jena.sdb.Store;
|
||||||
import com.hp.hpl.jena.sdb.StoreDesc;
|
import com.hp.hpl.jena.sdb.StoreDesc;
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
public class SDBGraphGenerator implements SQLGraphGenerator {
|
public class SDBGraphGenerator implements SQLGraphGenerator {
|
||||||
|
|
||||||
|
@ -22,7 +24,7 @@ public class SDBGraphGenerator implements SQLGraphGenerator {
|
||||||
private StoreDesc storeDesc;
|
private StoreDesc storeDesc;
|
||||||
private String graphID;
|
private String graphID;
|
||||||
|
|
||||||
public SDBGraphGenerator(BasicDataSource dataSource, StoreDesc storeDesc,
|
public SDBGraphGenerator(DataSource dataSource, StoreDesc storeDesc,
|
||||||
String graphID) {
|
String graphID) {
|
||||||
this.connGen = new SDBGraphConnectionGenerator(dataSource);
|
this.connGen = new SDBGraphConnectionGenerator(dataSource);
|
||||||
this.storeDesc = storeDesc;
|
this.storeDesc = storeDesc;
|
||||||
|
|
|
@ -8,8 +8,8 @@ import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ public class VitroJenaModelMaker implements ModelMaker {
|
||||||
private String username;
|
private String username;
|
||||||
private String password;
|
private String password;
|
||||||
private String dbTypeStr;
|
private String dbTypeStr;
|
||||||
private BasicDataSource dataSource;
|
private DataSource dataSource;
|
||||||
private HashMap<String,Model> modelCache;
|
private HashMap<String,Model> modelCache;
|
||||||
private HttpServletRequest request = null;
|
private HttpServletRequest request = null;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,8 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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 final static Log log = LogFactory.getLog(VitroJenaSDBModelMaker.class);
|
||||||
|
|
||||||
private StoreDesc storeDesc = null;
|
private StoreDesc storeDesc = null;
|
||||||
private BasicDataSource bds = null;
|
private DataSource ds = null;
|
||||||
private SDBConnection conn = null;
|
private SDBConnection conn = null;
|
||||||
private SDBGraphConnectionGenerator connGen = null;
|
private SDBGraphConnectionGenerator connGen = null;
|
||||||
|
|
||||||
|
@ -58,12 +59,12 @@ public class VitroJenaSDBModelMaker implements ModelMaker {
|
||||||
|
|
||||||
private Resource sdbResource; // a resource representing the SDB database
|
private Resource sdbResource; // a resource representing the SDB database
|
||||||
|
|
||||||
public VitroJenaSDBModelMaker(StoreDesc storeDesc, BasicDataSource bds)
|
public VitroJenaSDBModelMaker(StoreDesc storeDesc, DataSource ds)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
|
|
||||||
this.storeDesc = storeDesc;
|
this.storeDesc = storeDesc;
|
||||||
this.bds = bds;
|
this.ds = ds;
|
||||||
connGen = new SDBGraphConnectionGenerator(bds);
|
connGen = new SDBGraphConnectionGenerator(ds);
|
||||||
|
|
||||||
Store store = getStore();
|
Store store = getStore();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -23,8 +23,8 @@ import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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 they asked for other models by URI, set them.
|
||||||
if (anyOtherSpecialProperties(vreq)) {
|
if (anyOtherSpecialProperties(vreq)) {
|
||||||
BasicDataSource bds = JenaDataSourceSetupBase.getApplicationDataSource(_context);
|
DataSource bds = JenaDataSourceSetupBase.getApplicationDataSource(_context);
|
||||||
String dbType = ConfigurationProperties.getBean(_context)
|
String dbType = ConfigurationProperties.getBean(_context)
|
||||||
.getProperty("VitroConnection.DataSource.dbtype", "MySQL");
|
.getProperty("VitroConnection.DataSource.dbtype", "MySQL");
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ public class VitroRequestPrep implements Filter {
|
||||||
* if it's not found.
|
* if it's not found.
|
||||||
*/
|
*/
|
||||||
private OntModel createSpecialModel(VitroRequest vreq, String key,
|
private OntModel createSpecialModel(VitroRequest vreq, String key,
|
||||||
BasicDataSource bds, String dbType) {
|
DataSource bds, String dbType) {
|
||||||
if (!isParameterPresent(vreq, key)) {
|
if (!isParameterPresent(vreq, key)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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");
|
StoreDesc storeDesc = (StoreDesc) _ctx.getAttribute("storeDesc");
|
||||||
OntModelSelector oms = (OntModelSelector) _ctx.getAttribute("unionOntModelSelector");
|
OntModelSelector oms = (OntModelSelector) _ctx.getAttribute("unionOntModelSelector");
|
||||||
String defaultNamespace = (String) _ctx.getAttribute("defaultNamespace");
|
String defaultNamespace = (String) _ctx.getAttribute("defaultNamespace");
|
||||||
|
@ -103,12 +102,12 @@ public class WebappDaoFactorySparqlPrep implements Filter {
|
||||||
WebappDaoFactory wadf = null;
|
WebappDaoFactory wadf = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (bds == null || storeDesc == null || oms == null) {
|
if (ds == null || storeDesc == null || oms == null) {
|
||||||
throw new RuntimeException("SDB store not property set up");
|
throw new RuntimeException("SDB store not property set up");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sqlConn = bds.getConnection();
|
sqlConn = ds.getConnection();
|
||||||
conn = new SDBConnection(sqlConn) ;
|
conn = new SDBConnection(sqlConn) ;
|
||||||
} catch (SQLException sqe) {
|
} catch (SQLException sqe) {
|
||||||
throw new RuntimeException("Unable to connect to database", sqe);
|
throw new RuntimeException("Unable to connect to database", sqe);
|
||||||
|
|
|
@ -6,6 +6,8 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
import org.apache.commons.dbcp.BasicDataSource;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.logging.Log;
|
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 final static Log log = LogFactory.getLog(RDFServiceSDB.class);
|
||||||
|
|
||||||
private BasicDataSource bds;
|
private DataSource ds;
|
||||||
private StoreDesc storeDesc;
|
private StoreDesc storeDesc;
|
||||||
|
|
||||||
public RDFServiceSDB(BasicDataSource dataSource, StoreDesc storeDesc) {
|
public RDFServiceSDB(DataSource dataSource, StoreDesc storeDesc) {
|
||||||
this.bds = dataSource;
|
this.ds = dataSource;
|
||||||
this.storeDesc = storeDesc;
|
this.storeDesc = storeDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected DatasetWrapper getDatasetWrapper() {
|
protected DatasetWrapper getDatasetWrapper() {
|
||||||
try {
|
try {
|
||||||
SDBConnection conn = new SDBConnection(bds.getConnection());
|
SDBConnection conn = new SDBConnection(ds.getConnection());
|
||||||
return new DatasetWrapper(getDataset(conn), conn);
|
return new DatasetWrapper(getDataset(conn), conn);
|
||||||
} catch (SQLException sqle) {
|
} catch (SQLException sqle) {
|
||||||
log.error(sqle, sqle);
|
log.error(sqle, sqle);
|
||||||
|
@ -64,7 +66,7 @@ public class RDFServiceSDB extends RDFServiceJena implements RDFService {
|
||||||
|
|
||||||
SDBConnection conn = null;
|
SDBConnection conn = null;
|
||||||
try {
|
try {
|
||||||
conn = new SDBConnection(bds.getConnection());
|
conn = new SDBConnection(ds.getConnection());
|
||||||
} catch (SQLException sqle) {
|
} catch (SQLException sqle) {
|
||||||
log.error(sqle, sqle);
|
log.error(sqle, sqle);
|
||||||
throw new RDFServiceException(sqle);
|
throw new RDFServiceException(sqle);
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
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.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
import javax.servlet.ServletContextListener;
|
import javax.servlet.ServletContextListener;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
import org.apache.commons.dbcp.BasicDataSource;
|
||||||
import org.apache.commons.logging.Log;
|
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.DateTime;
|
||||||
import org.joda.time.format.ISODateTimeFormat;
|
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.ontology.OntModel;
|
||||||
import com.hp.hpl.jena.query.Query;
|
import com.hp.hpl.jena.query.Query;
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
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
|
* Also, at each start of tomcat, load The display TBox and the
|
||||||
* display/display model.
|
* display/display model.
|
||||||
*/
|
*/
|
||||||
private void setupDisplayModel(BasicDataSource bds, ServletContext ctx,
|
private void setupDisplayModel(DataSource bds, ServletContext ctx,
|
||||||
StartupStatus ss) {
|
StartupStatus ss) {
|
||||||
|
|
||||||
// display, editing and navigation Model
|
// display, editing and navigation Model
|
||||||
|
@ -242,7 +240,7 @@ implements ServletContextListener {
|
||||||
public void contextInitialized(ServletContextEvent sce) {
|
public void contextInitialized(ServletContextEvent sce) {
|
||||||
ServletContext ctx = sce.getServletContext();
|
ServletContext ctx = sce.getServletContext();
|
||||||
StartupStatus ss = StartupStatus.getBean(ctx);
|
StartupStatus ss = StartupStatus.getBean(ctx);
|
||||||
BasicDataSource bds = getApplicationDataSource(ctx);
|
DataSource bds = getApplicationDataSource(ctx);
|
||||||
|
|
||||||
setupDisplayModel(bds, ctx, ss);
|
setupDisplayModel(bds, ctx, ss);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||||
|
|
||||||
|
import java.beans.PropertyVetoException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
@ -9,6 +10,7 @@ import java.sql.SQLException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
import org.apache.commons.dbcp.BasicDataSource;
|
||||||
import org.apache.commons.lang.StringUtils;
|
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.StoreDesc;
|
||||||
import com.hp.hpl.jena.sdb.store.DatabaseType;
|
import com.hp.hpl.jena.sdb.store.DatabaseType;
|
||||||
import com.hp.hpl.jena.sdb.store.LayoutType;
|
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.config.ConfigurationProperties;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
|
@ -174,9 +177,10 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
"VitroConnection.DataSource.username");
|
"VitroConnection.DataSource.username");
|
||||||
String password = ConfigurationProperties.getBean(ctx).getProperty(
|
String password = ConfigurationProperties.getBean(ctx).getProperty(
|
||||||
"VitroConnection.DataSource.password");
|
"VitroConnection.DataSource.password");
|
||||||
BasicDataSource ds = makeBasicDataSource(
|
DataSource ds = makeC3poDataSource(
|
||||||
getDbDriverClassName(ctx), jdbcUrl, username, password, ctx);
|
getDbDriverClassName(ctx), jdbcUrl, username, password, ctx);
|
||||||
|
// DataSource ds = makeBasicDataSource(
|
||||||
|
// getDbDriverClassName(ctx), jdbcUrl, username, password, ctx);
|
||||||
jenaDbOntModelSpec = (jenaDbOntModelSpec != null)
|
jenaDbOntModelSpec = (jenaDbOntModelSpec != null)
|
||||||
? jenaDbOntModelSpec
|
? jenaDbOntModelSpec
|
||||||
: DB_ONT_MODEL_SPEC;
|
: 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.
|
* a properties file.
|
||||||
*/
|
*/
|
||||||
public final BasicDataSource makeDataSourceFromConfigurationProperties(
|
public final DataSource makeDataSourceFromConfigurationProperties(
|
||||||
ServletContext ctx) {
|
ServletContext ctx) {
|
||||||
String dbDriverClassname = ConfigurationProperties.getBean(ctx)
|
String dbDriverClassname = ConfigurationProperties.getBean(ctx)
|
||||||
.getProperty("VitroConnection.DataSource.driver",
|
.getProperty("VitroConnection.DataSource.driver",
|
||||||
|
@ -199,35 +203,51 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
"VitroConnection.DataSource.username");
|
"VitroConnection.DataSource.username");
|
||||||
String password = ConfigurationProperties.getBean(ctx).getProperty(
|
String password = ConfigurationProperties.getBean(ctx).getProperty(
|
||||||
"VitroConnection.DataSource.password");
|
"VitroConnection.DataSource.password");
|
||||||
return makeBasicDataSource(
|
return makeC3poDataSource(
|
||||||
dbDriverClassname, jdbcUrl, username, password, ctx);
|
dbDriverClassname, jdbcUrl, username, password, ctx);
|
||||||
|
// makeBasicDataSource(
|
||||||
|
// dbDriverClassname, jdbcUrl, username, password, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setApplicationDataSource(BasicDataSource bds,
|
public void setApplicationDataSource(DataSource ds,
|
||||||
ServletContext ctx) {
|
ServletContext ctx) {
|
||||||
ctx.setAttribute(getDataSourceAttributeName(), bds);
|
ctx.setAttribute(getDataSourceAttributeName(), ds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BasicDataSource getApplicationDataSource(ServletContext ctx) {
|
public static DataSource getApplicationDataSource(ServletContext ctx) {
|
||||||
return (BasicDataSource) ctx.getAttribute(getDataSourceAttributeName());
|
return (DataSource) ctx.getAttribute(getDataSourceAttributeName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getDataSourceAttributeName() {
|
private static String getDataSourceAttributeName() {
|
||||||
return JenaDataSourceSetupBase.class.getName() + ".dataSource";
|
return JenaDataSourceSetupBase.class.getName() + ".dataSource";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BasicDataSource makeBasicDataSource(String dbDriverClassname,
|
public static DataSource makeC3poDataSource(String dbDriverClassname,
|
||||||
String jdbcUrl,
|
String jdbcUrl,
|
||||||
String username,
|
String username,
|
||||||
String password,
|
String password,
|
||||||
ServletContext ctx) {
|
ServletContext ctx) {
|
||||||
log.debug("makeBasicDataSource('" + dbDriverClassname + "', '"
|
|
||||||
+ jdbcUrl + "', '" + username + "', '" + password + "')");
|
ComboPooledDataSource cpds = new ComboPooledDataSource();
|
||||||
BasicDataSource ds = new BasicDataSource();
|
try {
|
||||||
ds.setDriverClassName(dbDriverClassname);
|
cpds.setDriverClass(dbDriverClassname);
|
||||||
ds.setUrl(jdbcUrl);
|
} catch (PropertyVetoException pve) {
|
||||||
ds.setUsername(username);
|
throw new RuntimeException(pve);
|
||||||
ds.setPassword(password);
|
}
|
||||||
|
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;
|
int maxActiveInt = DEFAULT_MAXACTIVE;
|
||||||
String maxActiveStr = ConfigurationProperties.getBean(ctx).getProperty(
|
String maxActiveStr = ConfigurationProperties.getBean(ctx).getProperty(
|
||||||
MAX_ACTIVE_PROPERTY);
|
MAX_ACTIVE_PROPERTY);
|
||||||
|
@ -247,11 +267,11 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
+ maxActiveStr + " as an integer");
|
+ maxActiveStr + " as an integer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
String maxIdleStr = ConfigurationProperties.getBean(ctx).getProperty(
|
||||||
|
MAX_IDLE_PROPERTY);
|
||||||
int maxIdleInt = (maxActiveInt > DEFAULT_MAXACTIVE)
|
int maxIdleInt = (maxActiveInt > DEFAULT_MAXACTIVE)
|
||||||
? maxActiveInt / 4
|
? maxActiveInt / 4
|
||||||
: DEFAULT_MAXIDLE;
|
: DEFAULT_MAXIDLE;
|
||||||
String maxIdleStr = ConfigurationProperties.getBean(ctx).getProperty(
|
|
||||||
MAX_IDLE_PROPERTY);
|
|
||||||
if (!StringUtils.isEmpty(maxIdleStr)) {
|
if (!StringUtils.isEmpty(maxIdleStr)) {
|
||||||
try {
|
try {
|
||||||
maxIdleInt = Integer.parseInt(maxIdleStr);
|
maxIdleInt = Integer.parseInt(maxIdleStr);
|
||||||
|
@ -259,15 +279,34 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
log.error("Unable to parse connection pool maxIdle setting "
|
log.error("Unable to parse connection pool maxIdle setting "
|
||||||
+ maxIdleStr + " as an integer");
|
+ maxIdleStr + " as an integer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ds.setMaxActive(maxActiveInt);
|
int[] result = new int[2];
|
||||||
ds.setMaxIdle(maxIdleInt);
|
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.setMaxWait(DEFAULT_MAXWAIT);
|
||||||
ds.setValidationQuery(getValidationQuery(ctx));
|
ds.setValidationQuery(getValidationQuery(ctx));
|
||||||
ds.setTestOnBorrow(DEFAULT_TESTONBORROW);
|
ds.setTestOnBorrow(DEFAULT_TESTONBORROW);
|
||||||
ds.setTestOnReturn(DEFAULT_TESTONRETURN);
|
ds.setTestOnReturn(DEFAULT_TESTONRETURN);
|
||||||
ds.setMinEvictableIdleTimeMillis(DEFAULT_MINEVICTIONIDLETIME);
|
ds.setMinEvictableIdleTimeMillis(DEFAULT_MINEVICTIONIDLETIME);
|
||||||
ds.setNumTestsPerEvictionRun(maxActiveInt);
|
ds.setNumTestsPerEvictionRun(maxActiveAndIdle[0]);
|
||||||
ds.setTimeBetweenEvictionRunsMillis(DEFAULT_TIMEBETWEENEVICTIONS);
|
ds.setTimeBetweenEvictionRunsMillis(DEFAULT_TIMEBETWEENEVICTIONS);
|
||||||
ds.setInitialSize(ds.getMaxActive() / 10);
|
ds.setInitialSize(ds.getMaxActive() / 10);
|
||||||
|
|
||||||
|
@ -292,7 +331,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
firstStartup = true;
|
firstStartup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Model makeDBModel(BasicDataSource ds,
|
protected Model makeDBModel(DataSource ds,
|
||||||
String jenaDbModelname,
|
String jenaDbModelname,
|
||||||
OntModelSpec jenaDbOntModelSpec,
|
OntModelSpec jenaDbOntModelSpec,
|
||||||
ServletContext ctx) {
|
ServletContext ctx) {
|
||||||
|
@ -300,7 +339,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
ds, jenaDbModelname, jenaDbOntModelSpec, TripleStoreType.RDB, ctx);
|
ds, jenaDbModelname, jenaDbOntModelSpec, TripleStoreType.RDB, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Model makeDBModel(BasicDataSource ds,
|
protected Model makeDBModel(DataSource ds,
|
||||||
String jenaDbModelName,
|
String jenaDbModelName,
|
||||||
OntModelSpec jenaDbOntModelSpec,
|
OntModelSpec jenaDbOntModelSpec,
|
||||||
TripleStoreType storeType, ServletContext ctx) {
|
TripleStoreType storeType, ServletContext ctx) {
|
||||||
|
@ -308,7 +347,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
getDbType(ctx), ctx);
|
getDbType(ctx), ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Model makeDBModel(BasicDataSource ds,
|
public static Model makeDBModel(DataSource ds,
|
||||||
String jenaDbModelName,
|
String jenaDbModelName,
|
||||||
OntModelSpec jenaDbOntModelSpec,
|
OntModelSpec jenaDbOntModelSpec,
|
||||||
TripleStoreType storeType, String dbType,
|
TripleStoreType storeType, String dbType,
|
||||||
|
@ -343,7 +382,7 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
"Unsupported store type " + storeType);
|
"Unsupported store type " + storeType);
|
||||||
}
|
}
|
||||||
dbModel = ModelFactory.createModelForGraph(g);
|
dbModel = ModelFactory.createModelForGraph(g);
|
||||||
log.debug("Using database at "+ds.getUrl());
|
//log.debug("Using database at " + ds.getUrl());
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -429,11 +468,13 @@ public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||||
} else if (TripleStoreType.SDB.equals(type)) {
|
} else if (TripleStoreType.SDB.equals(type)) {
|
||||||
StoreDesc storeDesc = new StoreDesc(
|
StoreDesc storeDesc = new StoreDesc(
|
||||||
LayoutType.LayoutTripleNodesHash, DatabaseType.fetch(dbtypeStr));
|
LayoutType.LayoutTripleNodesHash, DatabaseType.fetch(dbtypeStr));
|
||||||
BasicDataSource bds = WebappDaoSetup.makeBasicDataSource(
|
DataSource bds = WebappDaoSetup.makeC3poDataSource(
|
||||||
getDbDriverClassName(ctx), jdbcUrl, username, password, ctx);
|
getDbDriverClassName(ctx), jdbcUrl, username, password, ctx);
|
||||||
bds.setMaxActive(4); // for now, the SDB model makers should not use more
|
// DataSource bds = WebappDaoSetup.makeBasicDataSource(
|
||||||
// than a small handful of connections
|
// getDbDriverClassName(ctx), jdbcUrl, username, password, ctx);
|
||||||
bds.setMaxIdle(2);
|
// bds.setMaxActive(4); // for now, the SDB model makers should not use more
|
||||||
|
// // than a small handful of connections
|
||||||
|
// bds.setMaxIdle(2);
|
||||||
try {
|
try {
|
||||||
vsmm = new VitroJenaSDBModelMaker(storeDesc, bds);
|
vsmm = new VitroJenaSDBModelMaker(storeDesc, bds);
|
||||||
} catch (SQLException sqle) {
|
} catch (SQLException sqle) {
|
||||||
|
|
|
@ -5,17 +5,13 @@ package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
import javax.servlet.ServletContextListener;
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntDocumentManager;
|
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;
|
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
|
// we do not want to fetch imports when we wrap Models in OntModels
|
||||||
OntDocumentManager.getInstance().setProcessImports(false);
|
OntDocumentManager.getInstance().setProcessImports(false);
|
||||||
|
|
||||||
BasicDataSource bds = makeDataSourceFromConfigurationProperties(ctx);
|
DataSource bds = makeDataSourceFromConfigurationProperties(ctx);
|
||||||
setApplicationDataSource(bds, ctx);
|
setApplicationDataSource(bds, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.sql.SQLException;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
import org.apache.commons.dbcp.BasicDataSource;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -82,8 +83,8 @@ implements javax.servlet.ServletContextListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void useSDB(ServletContext ctx, StartupStatus ss) throws SQLException {
|
private void useSDB(ServletContext ctx, StartupStatus ss) throws SQLException {
|
||||||
BasicDataSource bds = getApplicationDataSource(ctx);
|
DataSource ds = getApplicationDataSource(ctx);
|
||||||
if( bds == null ){
|
if( ds == null ){
|
||||||
ss.fatal(this, "A DataSource must be setup before SDBSetup "+
|
ss.fatal(this, "A DataSource must be setup before SDBSetup "+
|
||||||
"is run. Make sure that JenaPersistentDataSourceSetup runs before "+
|
"is run. Make sure that JenaPersistentDataSourceSetup runs before "+
|
||||||
"SDBSetup.");
|
"SDBSetup.");
|
||||||
|
@ -96,7 +97,7 @@ implements javax.servlet.ServletContextListener {
|
||||||
StoreDesc storeDesc = makeStoreDesc(ctx);
|
StoreDesc storeDesc = makeStoreDesc(ctx);
|
||||||
setApplicationStoreDesc(storeDesc, ctx);
|
setApplicationStoreDesc(storeDesc, ctx);
|
||||||
|
|
||||||
Store store = connectStore(bds, storeDesc);
|
Store store = connectStore(ds, storeDesc);
|
||||||
setApplicationStore(store, ctx);
|
setApplicationStore(store, ctx);
|
||||||
|
|
||||||
if (!isSetUp(store)) {
|
if (!isSetUp(store)) {
|
||||||
|
@ -104,7 +105,7 @@ implements javax.servlet.ServletContextListener {
|
||||||
setupSDB(ctx, store);
|
setupSDB(ctx, store);
|
||||||
}
|
}
|
||||||
|
|
||||||
RDFService rdfService = new RDFServiceSDB(bds, storeDesc);
|
RDFService rdfService = new RDFServiceSDB(ds, storeDesc);
|
||||||
RDFServiceFactory rdfServiceFactory = new RDFServiceFactorySingle(rdfService);
|
RDFServiceFactory rdfServiceFactory = new RDFServiceFactorySingle(rdfService);
|
||||||
RDFServiceUtils.setRDFServiceFactory(ctx, rdfServiceFactory);
|
RDFServiceUtils.setRDFServiceFactory(ctx, rdfServiceFactory);
|
||||||
|
|
||||||
|
@ -145,7 +146,7 @@ implements javax.servlet.ServletContextListener {
|
||||||
DatabaseType.fetch(dbtypeStr) );
|
DatabaseType.fetch(dbtypeStr) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Store connectStore(BasicDataSource bds, StoreDesc storeDesc)
|
public static Store connectStore(DataSource bds, StoreDesc storeDesc)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
SDBConnection conn = new SDBConnection(bds.getConnection());
|
SDBConnection conn = new SDBConnection(bds.getConnection());
|
||||||
return SDBFactory.connectStore(conn, storeDesc);
|
return SDBFactory.connectStore(conn, storeDesc);
|
||||||
|
|
|
@ -12,8 +12,8 @@ import java.util.List;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
import javax.servlet.ServletContextListener;
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class SimpleReasonerSetup implements ServletContextListener {
|
||||||
// set up simple reasoning for the ABox
|
// set up simple reasoning for the ABox
|
||||||
|
|
||||||
ServletContext ctx = sce.getServletContext();
|
ServletContext ctx = sce.getServletContext();
|
||||||
BasicDataSource bds = JenaDataSourceSetupBase
|
DataSource bds = JenaDataSourceSetupBase
|
||||||
.getApplicationDataSource(ctx);
|
.getApplicationDataSource(ctx);
|
||||||
String dbType = ConfigurationProperties.getBean(ctx).getProperty( // database type
|
String dbType = ConfigurationProperties.getBean(ctx).getProperty( // database type
|
||||||
"VitroConnection.DataSource.dbtype","MySQL");
|
"VitroConnection.DataSource.dbtype","MySQL");
|
||||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
import javax.servlet.ServletContextListener;
|
import javax.servlet.ServletContextListener;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
import org.apache.commons.dbcp.BasicDataSource;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -33,7 +34,7 @@ public class UserModelSetup extends JenaDataSourceSetupBase
|
||||||
ServletContext ctx = sce.getServletContext();
|
ServletContext ctx = sce.getServletContext();
|
||||||
StartupStatus ss = StartupStatus.getBean(ctx);
|
StartupStatus ss = StartupStatus.getBean(ctx);
|
||||||
|
|
||||||
BasicDataSource bds = getApplicationDataSource(ctx);
|
DataSource bds = getApplicationDataSource(ctx);
|
||||||
if( bds == null ){
|
if( bds == null ){
|
||||||
ss.fatal(this, "A DataSource must be setup before ModelSetup "+
|
ss.fatal(this, "A DataSource must be setup before ModelSetup "+
|
||||||
"is run. Make sure that JenaPersistentDataSourceSetup runs before "+
|
"is run. Make sure that JenaPersistentDataSourceSetup runs before "+
|
||||||
|
@ -49,7 +50,7 @@ public class UserModelSetup extends JenaDataSourceSetupBase
|
||||||
// Does nothing.
|
// Does nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupUserAccountModel (BasicDataSource bds, ServletContext ctx ,StartupStatus ss){
|
private void setupUserAccountModel (DataSource bds, ServletContext ctx ,StartupStatus ss){
|
||||||
try {
|
try {
|
||||||
Model userAccountsDbModel = makeDBModel(bds,
|
Model userAccountsDbModel = makeDBModel(bds,
|
||||||
JENA_USER_ACCOUNTS_MODEL, DB_ONT_MODEL_SPEC, ctx);
|
JENA_USER_ACCOUNTS_MODEL, DB_ONT_MODEL_SPEC, ctx);
|
||||||
|
|
Loading…
Add table
Reference in a new issue