NIHVIVO-336 Clean up some unused context listeners.
This commit is contained in:
parent
b49317d33b
commit
1d321f6c83
13 changed files with 0 additions and 697 deletions
|
@ -1,35 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.BasicPolicyDecision;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestedAction;
|
||||
|
||||
/**
|
||||
* a policy where every type of action is authorized as INCONCLUSIVE
|
||||
* by default.
|
||||
*
|
||||
* @author bdc34
|
||||
*/
|
||||
public class DefaultAuthorizedPolicy implements PolicyIface{
|
||||
protected static PolicyDecision AUTHORIZED_DECISION = new BasicPolicyDecision(
|
||||
Authorization.AUTHORIZED,
|
||||
"This is the default decision defined in DefaultAuthorizedPolicy");
|
||||
|
||||
public PolicyDecision isAuthorized(IdentifierBundle whoToAuth,
|
||||
RequestedAction whatToAuth) {
|
||||
if (whoToAuth == null)
|
||||
return new BasicPolicyDecision(Authorization.AUTHORIZED,
|
||||
"null was passed as whoToAuth");
|
||||
if (whatToAuth == null)
|
||||
return new BasicPolicyDecision(Authorization.AUTHORIZED,
|
||||
"null was passed as whatToAuth");
|
||||
return AUTHORIZED_DECISION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DefaultAuthorizedPolicy";
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.auth.policy.setup;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ServletPolicyList;
|
||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.ifaces.DefaultAuthorizedPolicy;
|
||||
|
||||
public class AlwaysAuthorizePolicySetup implements ServletContextListener {
|
||||
|
||||
private static final Log log = LogFactory.getLog(AlwaysAuthorizePolicySetup.class.getName());
|
||||
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try{
|
||||
log.trace("WARNING: Setting up AlwaysAuthorizePolicySetup.");
|
||||
|
||||
|
||||
ServletPolicyList.addPolicy(sce.getServletContext(), new DefaultAuthorizedPolicy() );
|
||||
|
||||
|
||||
}catch(Exception e){
|
||||
log.error("could not create AuthorizationFactory: " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void contextDestroyed(ServletContextEvent sce) { /*nothing*/ }
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
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.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.JenaBaseDao;
|
||||
|
||||
public class AttachSubmodels implements ServletContextListener {
|
||||
|
||||
private static String PATH = "/WEB-INF/submodels";
|
||||
|
||||
private static final Log log = LogFactory.getLog( AttachSubmodels.class );
|
||||
|
||||
@Override
|
||||
public void contextInitialized( ServletContextEvent sce ) {
|
||||
|
||||
ServletContext ctx = sce.getServletContext();
|
||||
|
||||
if (true) {
|
||||
(new FileGraphSetup()).contextInitialized(sce);
|
||||
return;
|
||||
// use filegraphs instead of submodels if we're running SDB
|
||||
}
|
||||
|
||||
// The future of AttachSubmodels is uncertain.
|
||||
// Presently unreachable code follows.
|
||||
|
||||
try {
|
||||
int attachmentCount = 0;
|
||||
OntModel baseModel = (OntModel) ctx.getAttribute( JenaBaseDao.ASSERTIONS_ONT_MODEL_ATTRIBUTE_NAME );
|
||||
Set<String> pathSet = ctx.getResourcePaths( PATH );
|
||||
if (pathSet == null) {
|
||||
return;
|
||||
}
|
||||
for ( String p : pathSet ) {
|
||||
File file = new File( ctx.getRealPath( p ) );
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream( file );
|
||||
try {
|
||||
Model m = ModelFactory.createDefaultModel();
|
||||
if ( p.endsWith(".n3") || p.endsWith(".N3") || p.endsWith(".ttl") || p.endsWith(".TTL") ) {
|
||||
m.read( fis, null, "N3" );
|
||||
} else if ( p.endsWith(".owl") || p.endsWith(".OWL") || p.endsWith(".rdf") || p.endsWith(".RDF") || p.endsWith(".xml") || p.endsWith(".XML") ) {
|
||||
m.read( fis, null, "RDF/XML" );
|
||||
} else {
|
||||
log.warn("Ignoring submodel file " + p + " because the file extension is unrecognized.");
|
||||
}
|
||||
if ( !m.isEmpty() ) {
|
||||
baseModel.addSubModel( m );
|
||||
}
|
||||
attachmentCount++;
|
||||
log.info("Attached submodel from file " + p);
|
||||
} catch (Exception ioe) {
|
||||
log.error("Unable to attach submodel from file " + p, ioe);
|
||||
System.out.println("Unable to attach submodel from file " + p);
|
||||
ioe.printStackTrace();
|
||||
} finally {
|
||||
fis.close();
|
||||
}
|
||||
} catch (FileNotFoundException fnfe) {
|
||||
log.warn(p + " not found. Unable to attach as submodel" +
|
||||
((fnfe.getLocalizedMessage() != null) ?
|
||||
fnfe.getLocalizedMessage() : "") );
|
||||
}
|
||||
}
|
||||
System.out.println("Attached " + attachmentCount + " file" + ((attachmentCount == 1) ? "" : "s") + " as submodels");
|
||||
} catch (ClassCastException cce) {
|
||||
String errMsg = "Unable to cast servlet context attribute " + JenaBaseDao.ASSERTIONS_ONT_MODEL_ATTRIBUTE_NAME + " to " + OntModel.class.getName();
|
||||
// Logging this ourselves because Tomcat's tends not to log exceptions thrown in context listeners.
|
||||
log.error( errMsg );
|
||||
throw new ClassCastException( errMsg );
|
||||
} catch (Throwable t) {
|
||||
System.out.println("Throwable in listener " + this.getClass().getName());
|
||||
log.error(t);
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed( ServletContextEvent sce ) {
|
||||
// nothing to worry about
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* This class will request a full garbage collection when
|
||||
* contextInitialized() is called. The goal is to eliminate fragmentation
|
||||
* in the tenured generation and avoid problems with the 'young generation guarantee.'
|
||||
*
|
||||
* This should be the last listener before the context starts.
|
||||
*
|
||||
* See http://blogs.sun.com/jonthecollector/entry/when_the_sum_of_the (retrieved 2010-10-18)
|
||||
*
|
||||
* @author bdc34
|
||||
*
|
||||
*/
|
||||
public class HeapDefragement implements ServletContextListener {
|
||||
private static final Log log = LogFactory.getLog(HeapDefragement.class);
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent arg0) {
|
||||
try{
|
||||
log.info("Calling System.gc() to defragement the heap.");
|
||||
long start = System.currentTimeMillis();
|
||||
System.gc();
|
||||
log.info("GC took " + (System.currentTimeMillis() - start) + " msec");
|
||||
}catch(Exception ex){
|
||||
log.error(ex,ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
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.ModelAuditor;
|
||||
|
||||
public class ModelAuditorSetup extends JenaDataSourceSetupBase implements ServletContextListener {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ModelAuditorSetup.class.getName());
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
ServletContext ctx = sce.getServletContext();
|
||||
try {
|
||||
// the events don't seem to filter down to the writable model of a dynamic union. Bummer. For now we have the ugly workaround of registering twice and recording some duplication.
|
||||
OntModel ontModel = (OntModel) ctx.getAttribute("baseOntModel");
|
||||
Model baseModel = ontModel.getBaseModel();
|
||||
OntModel dynamicUnionModel = (OntModel) ctx.getAttribute("jenaOntModel");
|
||||
log.debug("Setting model auditor database...");
|
||||
OntModel auditModel = ModelFactory.createOntologyModel(MEM_ONT_MODEL_SPEC,makeDBModelFromConfigurationProperties(JENA_AUDIT_MODEL, DB_ONT_MODEL_SPEC, ctx));
|
||||
ctx.setAttribute("jenaAuditModel", auditModel);
|
||||
ModelAuditor ma = new ModelAuditor(auditModel,ontModel);
|
||||
baseModel.register(ma);
|
||||
dynamicUnionModel.getBaseModel().register(ma);
|
||||
log.debug("Successful.");
|
||||
} catch (Exception e) {
|
||||
log.error("Unable to use audit model "+JENA_AUDIT_MODEL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import com.hp.hpl.jena.rdf.model.Model;
|
||||
|
||||
public class NamespacePrefixMapSetup implements ServletContextListener {
|
||||
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
HashMap<String,String> prefixToNamespace = new HashMap<String,String>();
|
||||
HashMap<String,String> namespaceToPrefix = new HashMap<String,String>();
|
||||
Model model = (Model) sce.getServletContext().getAttribute("jenaOntModel");
|
||||
long start = System.currentTimeMillis();
|
||||
int count = 0;
|
||||
String prefixPrefix = "p";
|
||||
for (String ns : (List<String>) model.listNameSpaces().toList() ) {
|
||||
System.out.println(prefixPrefix+count+" => "+ns);
|
||||
prefixToNamespace.put(prefixPrefix+count,ns);
|
||||
namespaceToPrefix.put(ns,prefixPrefix+count);
|
||||
count++;
|
||||
}
|
||||
sce.getServletContext().setAttribute("prefixToNamespaceMap",prefixToNamespace);
|
||||
sce.getServletContext().setAttribute("namespaceToPrefixMap",namespaceToPrefix);
|
||||
System.out.println( (System.currentTimeMillis()-start)+" ms to map namespaces");
|
||||
}
|
||||
|
||||
public void contextDestroyed(ServletContextEvent sce) {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/**
|
||||
* This will attempt to run System.gc() once a night.
|
||||
*
|
||||
* @author bdc34
|
||||
*
|
||||
*/
|
||||
public class NightlyDefragement implements ServletContextListener, Runnable {
|
||||
|
||||
private static NightlyDefragement nightlyDefragement = null;
|
||||
private static boolean stop = false;
|
||||
private static final Log log = LogFactory.getLog(NightlyDefragement.class);
|
||||
|
||||
protected DateTime lastRun;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while( ! stop ){
|
||||
DateTime now = new DateTime();
|
||||
|
||||
if( now.hourOfDay().get() > 0
|
||||
&& now.hourOfDay().get() < 2
|
||||
&& lastRun.isBefore( now.minusHours(22) ) ){
|
||||
|
||||
log.info("running defragement");
|
||||
long start = System.currentTimeMillis();
|
||||
System.gc();
|
||||
log.info("Finished defragement, " + (start - System.currentTimeMillis()) + "msec");
|
||||
lastRun = now;
|
||||
}
|
||||
|
||||
try{
|
||||
synchronized( nightlyDefragement ){
|
||||
this.wait(30*60*1000); //30 min;
|
||||
}
|
||||
}catch( InterruptedException ex){
|
||||
log.debug("woken up");
|
||||
}
|
||||
}
|
||||
log.info(" Stopping NightlyDefragement thread.");
|
||||
}
|
||||
|
||||
|
||||
public void stopNicely(){
|
||||
stop = true;
|
||||
synchronized( nightlyDefragement ){
|
||||
nightlyDefragement.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent arg0) {
|
||||
lastRun = new DateTime().minusHours( 400 );
|
||||
if( nightlyDefragement != null ){
|
||||
log.warn("NightlyDefragement listener has already been setup. Check your web.xml for duplicate listeners.");
|
||||
}else{
|
||||
nightlyDefragement = this;
|
||||
Thread thread = new Thread(this , "nightlyDefragementThread");
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
nightlyDefragement.stopNicely();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.mindswap.pellet.PelletOptions;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.ReasonerConfiguration;
|
||||
|
||||
public class PelletReasonerSetup implements ServletContextListener {
|
||||
private static final Log log = LogFactory.getLog(PelletReasonerSetup.class.getName());
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
if (true) {
|
||||
(new SimpleReasonerSetup()).contextInitialized(sce);
|
||||
return;
|
||||
// use the simple reasoner instead of Pellet for ABox inferences
|
||||
// if we're running SDB
|
||||
}
|
||||
|
||||
// presently unreachable code follows
|
||||
|
||||
try {
|
||||
|
||||
OntModel memoryModel = (OntModel) sce.getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel baseModel = (OntModel) sce.getServletContext().getAttribute("baseOntModel");
|
||||
OntModel inferenceModel = (OntModel) sce.getServletContext().getAttribute("inferenceOntModel");
|
||||
WebappDaoFactoryJena wadf = (WebappDaoFactoryJena) sce.getServletContext().getAttribute("webappDaoFactory");
|
||||
|
||||
if (!baseModel.getProfile().NAMESPACE().equals(OWL.NAMESPACE.getNameSpace())) {
|
||||
log.error("Not connecting Pellet reasoner - base model is not an OWL model");
|
||||
return;
|
||||
}
|
||||
|
||||
// Set various Pellet options for incremental consistency checking, etc.
|
||||
PelletOptions.DL_SAFE_RULES = true;
|
||||
PelletOptions.USE_COMPLETION_QUEUE = true;
|
||||
PelletOptions.USE_TRACING = true;
|
||||
PelletOptions.TRACK_BRANCH_EFFECTS = true;
|
||||
PelletOptions.USE_INCREMENTAL_CONSISTENCY = true;
|
||||
PelletOptions.USE_INCREMENTAL_DELETION = true;
|
||||
|
||||
PelletListener pelletListener = new PelletListener(memoryModel,baseModel,inferenceModel,ReasonerConfiguration.DEFAULT);
|
||||
sce.getServletContext().setAttribute("pelletListener",pelletListener);
|
||||
sce.getServletContext().setAttribute("pelletOntModel", pelletListener.getPelletModel());
|
||||
|
||||
if (wadf != null) {
|
||||
wadf.setPelletListener(pelletListener);
|
||||
}
|
||||
|
||||
log.info("Pellet reasoner connected");
|
||||
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.mindswap.pellet.PelletOptions;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.ReasonerConfiguration;
|
||||
|
||||
public class PelletReasonerSetupComplete implements ServletContextListener {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PelletReasonerSetupComplete.class.getName());
|
||||
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try {
|
||||
|
||||
OntModel memoryModel = (OntModel) sce.getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel baseModel = (OntModel) sce.getServletContext().getAttribute("baseOntModel");
|
||||
OntModel inferenceModel = (OntModel) sce.getServletContext().getAttribute("inferenceOntModel");
|
||||
|
||||
if (!baseModel.getProfile().NAMESPACE().equals(OWL.NAMESPACE.getNameSpace())) {
|
||||
log.error("Not connecting Pellet reasoner - base model is not an OWL model");
|
||||
return;
|
||||
}
|
||||
|
||||
// Set various options
|
||||
PelletOptions.DL_SAFE_RULES = true;
|
||||
PelletOptions.USE_COMPLETION_QUEUE = true;
|
||||
PelletOptions.USE_TRACING = true;
|
||||
PelletOptions.TRACK_BRANCH_EFFECTS = true;
|
||||
PelletOptions.USE_INCREMENTAL_CONSISTENCY = true;
|
||||
PelletOptions.USE_INCREMENTAL_DELETION = true;
|
||||
|
||||
// Pellet 2.0-RC5 is buggy with incremental reasoning through Jena
|
||||
//PelletOptions.USE_INCREMENTAL_CONSISTENCY = true;
|
||||
//PelletOptions.USE_INCREMENTAL_DELETION = true;
|
||||
ReasonerConfiguration config = ReasonerConfiguration.COMPLETE;
|
||||
config.setIncrementalReasongingEnabled(false);
|
||||
|
||||
PelletListener pelletListener = new PelletListener(memoryModel,baseModel,inferenceModel,config);
|
||||
sce.getServletContext().setAttribute("pelletListener",pelletListener);
|
||||
sce.getServletContext().setAttribute("pelletOntModel", pelletListener.getPelletModel());
|
||||
|
||||
log.debug("Reasoner connected");
|
||||
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.mindswap.pellet.PelletOptions;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.ReasonerConfiguration;
|
||||
|
||||
public class PelletReasonerSetupPseudocomplete implements ServletContextListener {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PelletReasonerSetupComplete.class.getName());
|
||||
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try {
|
||||
|
||||
OntModel memoryModel = (OntModel) sce.getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel baseModel = (OntModel) sce.getServletContext().getAttribute("baseOntModel");
|
||||
OntModel inferenceModel = (OntModel) sce.getServletContext().getAttribute("inferenceOntModel");
|
||||
|
||||
if (!baseModel.getProfile().NAMESPACE().equals(OWL.NAMESPACE.getNameSpace())) {
|
||||
log.error("Not connecting Pellet reasoner - base model is not an OWL model");
|
||||
return;
|
||||
}
|
||||
|
||||
// Set various options
|
||||
PelletOptions.DL_SAFE_RULES = true;
|
||||
PelletOptions.USE_COMPLETION_QUEUE = true;
|
||||
PelletOptions.USE_TRACING = true;
|
||||
PelletOptions.TRACK_BRANCH_EFFECTS = true;
|
||||
PelletOptions.USE_INCREMENTAL_CONSISTENCY = true;
|
||||
PelletOptions.USE_INCREMENTAL_DELETION = true;
|
||||
|
||||
// Pellet 2.0-RC5 is buggy with incremental reasoning through Jena
|
||||
//PelletOptions.USE_INCREMENTAL_CONSISTENCY = true;
|
||||
//PelletOptions.USE_INCREMENTAL_DELETION = true;
|
||||
ReasonerConfiguration config = ReasonerConfiguration.PSEUDOCOMPLETE;
|
||||
config.setIncrementalReasongingEnabled(false);
|
||||
|
||||
PelletListener pelletListener = new PelletListener(memoryModel,baseModel,inferenceModel,config);
|
||||
sce.getServletContext().setAttribute("pelletListener",pelletListener);
|
||||
sce.getServletContext().setAttribute("pelletOntModel", pelletListener.getPelletModel());
|
||||
|
||||
log.debug("Reasoner connected");
|
||||
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.mindswap.pellet.PelletOptions;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.ReasonerConfiguration;
|
||||
|
||||
public class PelletReasonerSetupPseudocompleteIgnoreDataproperties implements
|
||||
ServletContextListener {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PelletReasonerSetupPseudocompleteIgnoreDataproperties.class.getName());
|
||||
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
try {
|
||||
OntModel memoryModel = (OntModel) sce.getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel baseModel = (OntModel) sce.getServletContext().getAttribute("baseOntModel");
|
||||
OntModel inferenceModel = (OntModel) sce.getServletContext().getAttribute("inferenceOntModel");
|
||||
|
||||
if (!baseModel.getProfile().NAMESPACE().equals(OWL.NAMESPACE.getNameSpace())) {
|
||||
log.error("Not connecting Pellet reasoner - base model is not an OWL model");
|
||||
return;
|
||||
}
|
||||
|
||||
// Set various options
|
||||
PelletOptions.DL_SAFE_RULES = true;
|
||||
PelletOptions.USE_COMPLETION_QUEUE = true;
|
||||
PelletOptions.USE_TRACING = true;
|
||||
PelletOptions.TRACK_BRANCH_EFFECTS = true;
|
||||
PelletOptions.USE_INCREMENTAL_CONSISTENCY = true;
|
||||
PelletOptions.USE_INCREMENTAL_DELETION = true;
|
||||
|
||||
ReasonerConfiguration config = ReasonerConfiguration.PSEUDOCOMPLETE_IGNORE_DATAPROPERTIES;
|
||||
config.setIncrementalReasongingEnabled(false);
|
||||
|
||||
PelletListener pelletListener = new PelletListener(memoryModel,baseModel,inferenceModel,config);
|
||||
sce.getServletContext().setAttribute("pelletListener",pelletListener);
|
||||
sce.getServletContext().setAttribute("pelletOntModel", pelletListener.getPelletModel());
|
||||
|
||||
log.debug("Reasoner connected");
|
||||
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
// nothing to worry about
|
||||
}
|
||||
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.mindswap.pellet.PelletOptions;
|
||||
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.ontology.OntModelSpec;
|
||||
import com.hp.hpl.jena.vocabulary.OWL;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.ReasonerConfiguration;
|
||||
|
||||
public class RDFSReasonerSetup implements ServletContextListener {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PelletReasonerSetupComplete.class.getName());
|
||||
|
||||
/**
|
||||
* This ContextListener uses the infrastructure designed for Pellet, but switches the OntModelSpec
|
||||
* to use Jena's RDFS reasoner. Pellet itself is not used, despite the current names of some of the
|
||||
* classes involved.
|
||||
*/
|
||||
public void contextInitialized(ServletContextEvent sce) {
|
||||
|
||||
try {
|
||||
|
||||
OntModel memoryModel = (OntModel) sce.getServletContext().getAttribute("jenaOntModel");
|
||||
OntModel baseModel = (OntModel) sce.getServletContext().getAttribute("baseOntModel");
|
||||
OntModel inferenceModel = (OntModel) sce.getServletContext().getAttribute("inferenceOntModel");
|
||||
|
||||
ReasonerConfiguration configuration = ReasonerConfiguration.COMPLETE;
|
||||
configuration.setOntModelSpec(OntModelSpec.RDFS_MEM_RDFS_INF);
|
||||
PelletListener pelletListener = new PelletListener(memoryModel,baseModel,inferenceModel,configuration);
|
||||
sce.getServletContext().setAttribute("pelletListener",pelletListener);
|
||||
sce.getServletContext().setAttribute("pelletOntModel", pelletListener.getPelletModel());
|
||||
|
||||
log.debug("RDFS reasoner connected");
|
||||
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
//
|
||||
}
|
||||
|
||||
}
|
|
@ -44,9 +44,6 @@ ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/startupStatus.c
|
|||
<#if status.errorItems?has_content>
|
||||
<h2>Fatal error</h2>
|
||||
<p>VIVO detected a fatal error during startup.</p>
|
||||
<p>
|
||||
<a href=".">Continue</a>
|
||||
</p>
|
||||
<#list status.errorItems as item>
|
||||
<@statusItem item=item />
|
||||
</#list>
|
||||
|
@ -55,9 +52,6 @@ ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/startupStatus.c
|
|||
<#if status.warningItems?has_content>
|
||||
<h2>Warning</h2>
|
||||
<p>VIVO issued warnings during startup.</p>
|
||||
<p>
|
||||
<a href=".">Continue</a>
|
||||
</p>
|
||||
<#list status.warningItems as item>
|
||||
<@statusItem item=item />
|
||||
</#list>
|
||||
|
|
Loading…
Add table
Reference in a new issue