--- /dev/null
+/*\r
+\r
+ Derby - Class org.apache.derby.iapi.services.loader.ClassFactoryContext\r
+\r
+ Licensed to the Apache Software Foundation (ASF) under one or more\r
+ contributor license agreements. See the NOTICE file distributed with\r
+ this work for additional information regarding copyright ownership.\r
+ The ASF licenses this file to you under the Apache License, Version 2.0\r
+ (the "License"); you may not use this file except in compliance with\r
+ the License. You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
+ */\r
+\r
+package org.apache.derby.iapi.services.loader;\r
+\r
+import org.apache.derby.iapi.services.context.ContextImpl;\r
+import org.apache.derby.iapi.services.context.ContextManager;\r
+import org.apache.derby.iapi.services.locks.CompatibilitySpace;\r
+import org.apache.derby.iapi.services.property.PersistentSet;\r
+import org.apache.derby.iapi.error.ExceptionSeverity;\r
+import org.apache.derby.iapi.error.StandardException;\r
+\r
+/**\r
+ * Context that provides the correct ClassFactory for the\r
+ * current service. Allows stateless code to obtain the\r
+ * correct class loading scheme.\r
+*/\r
+public abstract class ClassFactoryContext extends ContextImpl {\r
+\r
+ public static final String CONTEXT_ID = "ClassFactoryContext";\r
+\r
+ private final ClassFactory cf;\r
+\r
+ protected ClassFactoryContext(ContextManager cm, ClassFactory cf) {\r
+\r
+ super(cm, CONTEXT_ID);\r
+\r
+ this.cf = cf;\r
+ }\r
+\r
+ public final ClassFactory getClassFactory() {\r
+ return cf;\r
+ }\r
+\r
+ /**\r
+ * Get the lock compatibility space to use for the\r
+ * transactional nature of the class loading lock.\r
+ * Used when the classpath changes or a database\r
+ * jar file is installed, removed or replaced.\r
+ */\r
+ public abstract CompatibilitySpace getLockSpace() throws StandardException;\r
+\r
+ /**\r
+ * Get the set of properties stored with this service.\r
+ */\r
+ public abstract PersistentSet getPersistentSet() throws StandardException;\r
+\r
+ /**\r
+ Get the mechanism to rad jar files. The ClassFactory\r
+ may keep the JarReader reference from the first class load.\r
+ */\r
+ public abstract JarReader getJarReader();\r
+\r
+ /**\r
+ * Handle any errors. Only work here is to pop myself\r
+ * on a session or greater severity error.\r
+ */\r
+ public final void cleanupOnError(Throwable error) {\r
+ if (error instanceof StandardException) {\r
+\r
+ StandardException se = (StandardException) error;\r
+ \r
+ if (se.getSeverity() >= ExceptionSeverity.SESSION_SEVERITY)\r
+ popMe();\r
+ }\r
+ }\r
+}\r