01: /*
02:
03: Derby - Class org.apache.derby.impl.sql.catalog.DataDictionaryContextImpl
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.impl.sql.catalog;
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.error.StandardException;
27: import org.apache.derby.iapi.sql.dictionary.DataDictionary;
28: import org.apache.derby.iapi.sql.dictionary.DataDictionaryContext;
29: import org.apache.derby.iapi.error.ExceptionSeverity;
30:
31: /*
32: * DataDictionaryContextImpl
33: *
34: * This class supports both nested and outer data dictionaries. The
35: * outer data dictionary defines the name space for a database.
36: * A nested data dictionary defines a name space for a publication
37: * (or schema in the future).
38: *
39: * During error processing, a nested data dictionary context is popped
40: * for statement errors or higher. The outer data dictionary context
41: * is not popped by cleanupOnError.
42: */
43: class DataDictionaryContextImpl extends ContextImpl implements
44: DataDictionaryContext {
45: //
46: // DataDictionaryContext interface
47: //
48: // we might want these to refuse to return
49: // anything if they are in-use -- would require
50: // the interface provide a 'done' call, and
51: // we would mark them in-use whenever a get happened.
52: public DataDictionary getDataDictionary() {
53: return dataDictionary;
54: }
55:
56: public void cleanupOnError(Throwable error) {
57: if (error instanceof StandardException) {
58: StandardException se = (StandardException) error;
59: if (se.getSeverity() < ExceptionSeverity.SESSION_SEVERITY)
60: return;
61: }
62: popMe();
63: }
64:
65: //
66: // class interface
67: //
68: // this constructor is called with the data dictionary
69: // to be saved when the context
70: // is created
71:
72: DataDictionaryContextImpl(ContextManager cm,
73: DataDictionary dataDictionary) {
74: super (cm, DataDictionaryContext.CONTEXT_ID);
75:
76: this .dataDictionary = dataDictionary;
77: }
78:
79: final DataDictionary dataDictionary;
80: }
|