1 21 22 package org.apache.derby.impl.sql.execute; 23 24 import org.apache.derby.iapi.sql.execute.ExecutionContext; 25 import org.apache.derby.iapi.sql.execute.ExecutionFactory; 26 import org.apache.derby.iapi.sql.execute.ResultSetFactory; 27 import org.apache.derby.iapi.sql.execute.ResultSetStatisticsFactory; 28 29 import org.apache.derby.iapi.sql.ResultSet; 30 31 import org.apache.derby.iapi.services.sanity.SanityManager; 32 33 import org.apache.derby.iapi.services.context.ContextImpl; 34 import org.apache.derby.iapi.services.context.ContextManager; 35 36 import org.apache.derby.iapi.services.monitor.Monitor; 37 38 import org.apache.derby.iapi.error.StandardException; 39 40 import java.util.Properties ; 41 import org.apache.derby.iapi.error.ExceptionSeverity; 42 52 class GenericExecutionContext 53 extends ContextImpl 54 implements ExecutionContext { 55 56 private ResultSet sourceRS; 57 58 private ResultSetFactory rsFactory; 62 private ResultSetStatisticsFactory rssFactory; 63 private ExecutionFactory execFactory; 64 65 74 public ResultSetFactory getResultSetFactory() 75 { 76 79 if (rsFactory == null) 80 { 81 rsFactory = execFactory.getResultSetFactory(); 82 } 83 return rsFactory; 84 } 85 86 94 public ResultSetStatisticsFactory getResultSetStatisticsFactory() 95 throws StandardException { 96 if (rssFactory == null) { 97 rssFactory = (ResultSetStatisticsFactory) 98 Monitor.bootServiceModule( 99 false, 100 execFactory, 101 ResultSetStatisticsFactory.MODULE, 102 (Properties ) null); 103 } 104 105 return rssFactory; 106 } 107 108 public ExecutionFactory getExecutionFactory() { 109 return execFactory; 110 } 111 112 116 public void beginStatement(ResultSet sourceRS) throws StandardException { 117 this.sourceRS = sourceRS; 118 } 119 120 124 public void endStatement() throws StandardException { 125 sourceRS = null; 126 } 127 128 132 public Object [] siftForeignKeys( Object [] fullList ) throws StandardException 133 { 134 138 return fullList; 139 } 140 141 145 public Object siftTriggers(Object triggerInfo) throws StandardException 146 { 147 return triggerInfo; 151 } 152 153 157 160 public void cleanupOnError(Throwable error) throws StandardException { 161 if (error instanceof StandardException) { 162 163 StandardException se = (StandardException) error; 164 int severity = se.getSeverity(); 165 if (severity >= ExceptionSeverity.SESSION_SEVERITY) 166 { 167 popMe(); 168 return; 169 } 170 if (severity > ExceptionSeverity.STATEMENT_SEVERITY) 171 { 172 return; 173 } 174 175 176 if (sourceRS != null) 177 { 178 sourceRS.close(); 179 sourceRS = null; 180 } 181 182 endStatement(); 183 return; 184 } 185 } 186 187 GenericExecutionContext( 191 ResultSetFactory rsf, 192 ContextManager cm, 193 ExecutionFactory ef) 194 { 195 196 super(cm, ExecutionContext.CONTEXT_ID); 197 rsFactory = rsf; 198 execFactory = ef; 199 } 200 201 } 202 | Popular Tags |