1 21 22 package org.apache.derby.impl.db; 23 24 import org.apache.derby.iapi.services.context.ContextImpl; 25 import org.apache.derby.iapi.services.context.ContextManager; 26 import org.apache.derby.iapi.services.context.ContextService; 27 import org.apache.derby.iapi.services.monitor.Monitor; 28 import org.apache.derby.iapi.db.Database; 29 import org.apache.derby.iapi.db.DatabaseContext; 30 import org.apache.derby.iapi.error.StandardException; 31 import org.apache.derby.iapi.error.ExceptionSeverity; 32 33 34 37 final class DatabaseContextImpl extends ContextImpl implements DatabaseContext 38 { 39 40 private final Database db; 41 42 DatabaseContextImpl(ContextManager cm, Database db) { 43 super(cm, DatabaseContextImpl.CONTEXT_ID); 44 this.db = db; 45 } 46 47 public void cleanupOnError(Throwable t) { 48 if (!(t instanceof StandardException)) return; 49 StandardException se = (StandardException)t; 50 51 if (se.getSeverity() < ExceptionSeverity.SESSION_SEVERITY) 54 return; 55 56 popMe(); 57 58 if (se.getSeverity() == ExceptionSeverity.DATABASE_SEVERITY) { 59 ContextService.getFactory().notifyAllActiveThreads(this); 60 Monitor.getMonitor().shutdown(db); 61 } 62 } 63 64 public boolean equals(Object other) { 65 if (other instanceof DatabaseContext) { 66 return ((DatabaseContextImpl) other).db == db; 67 } 68 return false; 69 } 70 71 public int hashCode() { 72 return db.hashCode(); 73 } 74 75 public Database getDatabase() {return db;} 76 } 77 | Popular Tags |