Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.

1 /*2 3 Derby - Class org.apache.derby.iapi.services.context.SystemContext4 5 Licensed to the Apache Software Foundation (ASF) under one or more6 contributor license agreements. See the NOTICE file distributed with7 this work for additional information regarding copyright ownership.8 The ASF licenses this file to you under the Apache License, Version 2.09 (the "License"); you may not use this file except in compliance with10 the License. You may obtain a copy of the License at11 12 http://www.apache.org/licenses/LICENSE-2.013 14 Unless required by applicable law or agreed to in writing, software15 distributed under the License is distributed on an "AS IS" BASIS,16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.17 See the License for the specific language governing permissions and18 limitations under the License.19 20 */21 22 package org.apache.derby.iapi.services.context;23 24 importorg.apache.derby.iapi.error.StandardException;25 importorg.apache.derby.iapi.services.monitor.Monitor;26 importorg.apache.derby.iapi.error.ExceptionSeverity;27 /**28 A context that shuts the system down if it gets an StandardException29 with a severity greater than or equal to ExceptionSeverity.SYSTEM_SEVERITY30 or an exception that is not a StandardException.31 */32 finalclass SystemContext extendsContextImpl33 {34 SystemContext(ContextManager cm) {35 super(cm, "SystemContext");36 }37 38 publicvoid cleanupOnError(Throwable t) {39 40 boolean doShutdown = false;41 if (t instanceofStandardException) {42 StandardException se = (StandardException) t;43 int severity = se.getSeverity();44 if (severity < ExceptionSeverity.SESSION_SEVERITY)45 return;46 47 popMe();48 49 if (severity >= ExceptionSeverity.SYSTEM_SEVERITY)50 doShutdown = true;51 } elseif (t instanceofShutdownException) {52 // system is already shutting down ...53 } elseif (t instanceofThreadDeath) {54 // ignore this too, it means we explicitly told thread to55 // stop. one way this can happen is after monitor56 // shutdown, so we don't need to shut down again57 }58 59 if (!doShutdown) {60 //ContextManager cm = getContextManager();61 // need to remove me from the list of all contexts.62 getContextManager().owningCsf.removeContext(getContextManager());63 return;64 }65 66 67 try {68 // try to print out that the shutdown is occurring.69 // REVISIT: does this need to be a localizable message?70 System.err.println("Shutting down due to severe error.");71 Monitor.getStream().printlnWithHeader("Shutting down due to severe error." + t.getMessage());72 73 } finally {74 // we need this to happen even if we fail to print out a notice75 Monitor.getMonitor().shutdown();76 }77 78 }79 80 }81 82