KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > iapi > services > loader > ClassFactoryContext


1 /*
2
3    Derby - Class org.apache.derby.iapi.services.loader.ClassFactoryContext
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    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 and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.iapi.services.loader;
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.property.PersistentSet;
27 import org.apache.derby.iapi.error.ExceptionSeverity;
28 import org.apache.derby.iapi.error.StandardException;
29
30 /**
31  * Context that provides the correct ClassFactory for the
32  * current service. Allows stateless code to obtain the
33  * correct class loading scheme.
34 */

35 public abstract class ClassFactoryContext extends ContextImpl {
36
37     public static final String JavaDoc CONTEXT_ID = "ClassFactoryContext";
38
39     private final ClassFactory cf;
40
41     protected ClassFactoryContext(ContextManager cm, ClassFactory cf) {
42
43         super(cm, CONTEXT_ID);
44
45         this.cf = cf;
46     }
47
48     public final ClassFactory getClassFactory() {
49         return cf;
50     }
51
52     /**
53      * Get the lock compatibility space to use for the
54      * transactional nature of the class loading lock.
55      * Used when the classpath changes or a database
56      * jar file is installed, removed or replaced.
57      */

58     public abstract Object JavaDoc getLockSpace() throws StandardException;
59
60     /**
61      * Get the set of properties stored with this service.
62     */

63     public abstract PersistentSet getPersistentSet() throws StandardException;
64
65     /**
66         Get the mechanism to rad jar files. The ClassFactory
67         may keep the JarReader reference from the first class load.
68     */

69     public abstract JarReader getJarReader();
70
71     /**
72      * Handle any errors. Only work here is to pop myself
73      * on a session or greater severity error.
74      */

75     public final void cleanupOnError(Throwable JavaDoc error) {
76         if (error instanceof StandardException) {
77
78             StandardException se = (StandardException) error;
79             
80             if (se.getSeverity() >= ExceptionSeverity.SESSION_SEVERITY)
81                 popMe();
82         }
83     }
84 }
85
Popular Tags