001: /*
002:
003: Derby - Class org.apache.derby.impl.sql.conn.CachedStatement
004:
005: Licensed to the Apache Software Foundation (ASF) under one or more
006: contributor license agreements. See the NOTICE file distributed with
007: this work for additional information regarding copyright ownership.
008: The ASF licenses this file to you under the Apache License, Version 2.0
009: (the "License"); you may not use this file except in compliance with
010: the License. You may obtain a copy of the License at
011:
012: http://www.apache.org/licenses/LICENSE-2.0
013:
014: Unless required by applicable law or agreed to in writing, software
015: distributed under the License is distributed on an "AS IS" BASIS,
016: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: See the License for the specific language governing permissions and
018: limitations under the License.
019:
020: */
021:
022: package org.apache.derby.impl.sql.conn;
023:
024: import org.apache.derby.iapi.services.context.ContextManager;
025:
026: import org.apache.derby.iapi.error.StandardException;
027: import org.apache.derby.impl.sql.GenericPreparedStatement;
028: import org.apache.derby.impl.sql.GenericStatement;
029:
030: import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
031:
032: import org.apache.derby.iapi.sql.PreparedStatement;
033:
034: import org.apache.derby.iapi.services.cache.Cacheable;
035:
036: import org.apache.derby.iapi.services.sanity.SanityManager;
037:
038: import org.apache.derby.iapi.services.monitor.Monitor;
039:
040: /**
041: @author ames
042: */
043: public class CachedStatement implements Cacheable {
044:
045: private GenericPreparedStatement ps;
046: private Object identity;
047:
048: public CachedStatement() {
049: }
050:
051: /**
052: * Get the PreparedStatement that is associated with this Cacheable
053: */
054: public GenericPreparedStatement getPreparedStatement() {
055: return ps;
056: }
057:
058: /* Cacheable interface */
059:
060: /**
061:
062: @see Cacheable#clean
063: */
064: public void clean(boolean forRemove) {
065: }
066:
067: /**
068: */
069: public Cacheable setIdentity(Object key) {
070:
071: identity = key;
072: ps = new GenericPreparedStatement((GenericStatement) key);
073: ps.setCacheHolder(this );
074:
075: return this ;
076: }
077:
078: /** @see Cacheable#createIdentity */
079: public Cacheable createIdentity(Object key, Object createParameter) {
080: if (SanityManager.DEBUG)
081: SanityManager
082: .THROWASSERT("Not expecting any create() calls");
083:
084: return null;
085:
086: }
087:
088: /** @see Cacheable#clearIdentity */
089: public void clearIdentity() {
090:
091: if (SanityManager.DEBUG)
092: SanityManager.DEBUG("StatementCacheInfo",
093: "CLEARING IDENTITY: " + ps.getSource());
094: ps.setCacheHolder(null);
095:
096: identity = null;
097: ps = null;
098: }
099:
100: /** @see Cacheable#getIdentity */
101: public Object getIdentity() {
102: return identity;
103: }
104:
105: /** @see Cacheable#isDirty */
106: public boolean isDirty() {
107: return false;
108: }
109:
110: /* Cacheable interface */
111: }
|