Source code: org/apache/derby/iapi/services/context/ContextImpl.java
1 /*
2
3 Derby - Class org.apache.derby.iapi.services.context.ContextImpl
4
5 Copyright 1999, 2004 The Apache Software Foundation or its licensors, as applicable.
6
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18
19 */
20
21 package org.apache.derby.iapi.services.context;
22
23 /**
24 * Contexts are created and used to manage the execution
25 * environment. They provide a convenient location for
26 * storing globals organized by the module using the
27 * globals.
28 * <p>
29 * We provide this abstract class for other implementations
30 * to use so that they can simply add fields and operations on
31 * them. To be usable by the context manager, the subclasses
32 * must define CleanupOnError and call super() in any constructor.
33 * <p>
34 * Contexts assist in cleanup
35 * when errors are caught in the outer block.
36 * <p>
37 * Contexts implement the sanity interface to check and provide
38 * information about their contents.
39 */
40 public abstract class ContextImpl
41 implements Context
42 {
43 private final String myIdName;
44 private final ContextManager myContextManager;
45
46 /*
47 * class interface
48 */
49 protected ContextImpl(ContextManager cm, String id) {
50 myIdName = id;
51 myContextManager = cm;
52 cm.pushContext(this);
53 }
54
55 /*
56 * Context interface
57 */
58 /**
59 * @see org.apache.derby.iapi.services.context.Context#getContextManager
60 */
61 final public ContextManager getContextManager()
62 {
63 return myContextManager;
64 }
65
66 /**
67 * @see org.apache.derby.iapi.services.context.Context#getIdName
68 */
69 final public String getIdName()
70 {
71 return myIdName;
72 }
73
74 final public void pushMe() {
75 getContextManager().pushContext(this);
76 }
77
78 /** @see Context#popMe */
79 final public void popMe() {
80 getContextManager().popContext(this);
81 }
82
83 /**
84 * @see Context#isLastHandler
85 */
86 public boolean isLastHandler(int severity)
87 {
88 return false;
89 }
90
91 public StringBuffer appendErrorInfo() {
92 return null;
93 }
94 }