01: /*
02:
03: Derby - Class org.apache.derby.iapi.services.context.ContextImpl
04:
05: Licensed to the Apache Software Foundation (ASF) under one or more
06: contributor license agreements. See the NOTICE file distributed with
07: this work for additional information regarding copyright ownership.
08: The ASF licenses this file to you under the Apache License, Version 2.0
09: (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.context;
23:
24: /**
25: * Contexts are created and used to manage the execution
26: * environment. They provide a convenient location for
27: * storing globals organized by the module using the
28: * globals.
29: * <p>
30: * We provide this abstract class for other implementations
31: * to use so that they can simply add fields and operations on
32: * them. To be usable by the context manager, the subclasses
33: * must define CleanupOnError and call super() in any constructor.
34: * <p>
35: * Contexts assist in cleanup
36: * when errors are caught in the outer block.
37: * <p>
38: * Contexts implement the sanity interface to check and provide
39: * information about their contents.
40: */
41: public abstract class ContextImpl implements Context {
42: private final String myIdName;
43: private final ContextManager myContextManager;
44:
45: /*
46: * class interface
47: */
48: protected ContextImpl(ContextManager cm, String id) {
49: myIdName = id;
50: myContextManager = cm;
51: cm.pushContext(this );
52: }
53:
54: /*
55: * Context interface
56: */
57: /**
58: * @see org.apache.derby.iapi.services.context.Context#getContextManager
59: */
60: final public ContextManager getContextManager() {
61: return myContextManager;
62: }
63:
64: /**
65: * @see org.apache.derby.iapi.services.context.Context#getIdName
66: */
67: final public String getIdName() {
68: return myIdName;
69: }
70:
71: final public void pushMe() {
72: getContextManager().pushContext(this );
73: }
74:
75: /** @see Context#popMe */
76: final public void popMe() {
77: getContextManager().popContext(this );
78: }
79:
80: /**
81: * @see Context#isLastHandler
82: */
83: public boolean isLastHandler(int severity) {
84: return false;
85: }
86:
87: public StringBuffer appendErrorInfo() {
88: return null;
89: }
90: }
|