Adding code to use AbortSetup to VClassGroupCache

This commit is contained in:
bdc34 2011-02-03 21:48:44 +00:00
parent 70c0039372
commit 7ed25b3937

View file

@ -33,6 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.filtering.WebappDaoFactoryFiltering;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilterUtils; import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilterUtils;
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters; import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
import edu.cornell.mannlib.vitro.webapp.flags.PortalFlag; import edu.cornell.mannlib.vitro.webapp.flags.PortalFlag;
import edu.cornell.mannlib.vitro.webapp.servlet.setup.AbortStartup;
public class VClassGroupCache{ public class VClassGroupCache{
private static final Log log = LogFactory.getLog(VClassGroupCache.class); private static final Log log = LogFactory.getLog(VClassGroupCache.class);
@ -63,6 +64,11 @@ public class VClassGroupCache{
this._groupListMap = new ConcurrentHashMap<Integer, List<VClassGroup>>(); this._groupListMap = new ConcurrentHashMap<Integer, List<VClassGroup>>();
this._rebuildQueue = new ConcurrentLinkedQueue<String>(); this._rebuildQueue = new ConcurrentLinkedQueue<String>();
if( AbortStartup.isStartupAborted(context)){
_cacheRebuildThread = null;
return;
}
VClassGroupCacheChangeListener bccl = new VClassGroupCacheChangeListener(this); VClassGroupCacheChangeListener bccl = new VClassGroupCacheChangeListener(this);
ModelContext.getJenaOntModel(context).register(bccl); ModelContext.getJenaOntModel(context).register(bccl);
ModelContext.getBaseOntModel(context).register(bccl); ModelContext.getBaseOntModel(context).register(bccl);
@ -255,16 +261,15 @@ public class VClassGroupCache{
} }
private void requestStop() { private void requestStop() {
log.info("Killing the thread."); if( _cacheRebuildThread != null ){
_cacheRebuildThread.kill(); _cacheRebuildThread.kill();
try { try {
_cacheRebuildThread.join(); _cacheRebuildThread.join();
log.info("The thread is dead.");
} catch (InterruptedException e) { } catch (InterruptedException e) {
log.warn("Waiting for the thread to die, but interrupted.", e); log.warn("Waiting for the thread to die, but interrupted.", e);
} }
} }
}
protected VClassGroupDao getVCGDao(){ protected VClassGroupDao getVCGDao(){
WebappDaoFactory wdf =(WebappDaoFactory)context.getAttribute("webappDaoFactory"); WebappDaoFactory wdf =(WebappDaoFactory)context.getAttribute("webappDaoFactory");
@ -368,7 +373,7 @@ public class VClassGroupCache{
@Override @Override
public void contextDestroyed(ServletContextEvent sce) { public void contextDestroyed(ServletContextEvent sce) {
Object o = sce.getServletContext().getAttribute(ATTRIBUTE_NAME); Object o = sce.getServletContext().getAttribute(ATTRIBUTE_NAME);
if (o instanceof VClassGroupCache) { if (o instanceof VClassGroupCache ) {
((VClassGroupCache) o).requestStop(); ((VClassGroupCache) o).requestStop();
} }
} }