net.wgen.op.db
Class CallExecutorDB

java.lang.Object
  extended bynet.wgen.op.db.CallExecutorDB
All Implemented Interfaces:
CallExecutor

public class CallExecutorDB
extends java.lang.Object
implements CallExecutor

Executes DatabaseCalls against a database.

During normal operations this CallExecutor is instantiated by the DirectOpExecutor.

The connection used in the CallExecutor is intentionally hidden and unreachable. If there is a specific need to gain access to the connection, you should look into using the HandlingOptions and providing something you can set using the DatabaseCall.setOptions().

Version:
$Id: CallExecutorDB.html,v 1.2 2007/01/28 04:09:36 paulfeuer Exp $
Author:
Paul Feuer, Wireless Generation, Inc.
See Also:
DirectOpExecutor.executeOp(net.wgen.op.Op)

Field Summary
private  MappedConnectionFactory _cxFactory
          Provides connections to the DB.
static java.lang.String CONTEXT_TAG
          Used for HandlingOption pre and post call methods.
private static int ORACLE_PACKAGE_STATE_ERROR
          Oracle error associated with recompiling package bodies.
 
Constructor Summary
CallExecutorDB(MappedConnectionFactory cxFactory)
          Default constructor requires a factory to provide database connections.
 
Method Summary
 void executeDatabaseCall(DatabaseCall dbCall)
          Executes an operation described by the DatabaseCall and registers that operations output in the appropriate parameter objects in the DatabaseCall.
 void executeOp(Op op)
          Executes another op.
 java.util.Collection executeQueryWithResultSet(DatabaseCall dbCall)
          Executes an operation described by the DatabaseCall and returns the Collection representing the data returned by the PreparedStatement in the ResultSet.
 void executeUpdate(DatabaseCall dbCall)
          Runs a call against the database using the executeUpdate method of PreparedStatement.
private  boolean isOraclePackageStateError(DatabaseCall dbCall, java.lang.Exception ex)
          Whether or not this error was a package state error caused by the recompiling of a database package.
protected  DatabaseCallException makeDatabaseCallException(DatabaseCall dbCall, java.lang.Exception ex)
          Make a DatabaseCallException out of an exception.
protected  void processCompletionInfo(DatabaseCall dbCall, long t1, long t2, java.lang.String amountOfWork)
          Called in the finally block of a call execution, this method adds information to the trace key and handles the call to the WebAppStats and the app log.
protected  void processPostCallOptions(DatabaseCall dbCall)
          Called at the end of the finally statement to process any options that should be evaluated after everything is called.
protected  void processPreCallOptions(DatabaseCall dbCall)
          Copies options from the DatabaseCall's opOwner, and invokes HandlingOption preCall() on any registered HandlingOption keys.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_TAG

public static final java.lang.String CONTEXT_TAG
Used for HandlingOption pre and post call methods.

See Also:
processPreCallOptions(DatabaseCall), processPostCallOptions(DatabaseCall), Constant Field Values

ORACLE_PACKAGE_STATE_ERROR

private static final int ORACLE_PACKAGE_STATE_ERROR
Oracle error associated with recompiling package bodies. This error can occur during web app operations if you recompile a an oracle package body, rendering the connection's stored reference to it invalid. The connection will re-acquire it, however, on the next attempt. If this is encountered, the Executor will attempt to execute the call a second time, which usually gets around this.

See Also:
executeDatabaseCall(DatabaseCall), isOraclePackageStateError(DatabaseCall, Exception), Constant Field Values

_cxFactory

private final MappedConnectionFactory _cxFactory
Provides connections to the DB.

Constructor Detail

CallExecutorDB

public CallExecutorDB(MappedConnectionFactory cxFactory)
Default constructor requires a factory to provide database connections.

Parameters:
cxFactory - the factory that will provide the connections
Method Detail

executeOp

public void executeOp(Op op)
               throws OpException
Executes another op. This is here as a convenience method to Ops as a CallExecutor is what is passed in for them to execute stuff.

Specified by:
executeOp in interface CallExecutor
Parameters:
op - the op to be executed
Throws:
OpException
See Also:
OpUtils.runOp(net.wgen.op.Op, CallExecutor)

executeDatabaseCall

public void executeDatabaseCall(DatabaseCall dbCall)
                         throws DatabaseCallException
Executes an operation described by the DatabaseCall and registers that operations output in the appropriate parameter objects in the DatabaseCall.

Specified by:
executeDatabaseCall in interface CallExecutor
Parameters:
dbCall - the object describing the operation to be performed
Throws:
DatabaseCallException

executeQueryWithResultSet

public java.util.Collection executeQueryWithResultSet(DatabaseCall dbCall)
                                               throws DatabaseCallException
Executes an operation described by the DatabaseCall and returns the Collection representing the data returned by the PreparedStatement in the ResultSet.

Specified by:
executeQueryWithResultSet in interface CallExecutor
Parameters:
dbCall - the object describing the operation to be run
Returns:
the list representing the returned data
Throws:
DatabaseCallException

executeUpdate

public void executeUpdate(DatabaseCall dbCall)
                   throws DatabaseCallException
Runs a call against the database using the executeUpdate method of PreparedStatement.

Specified by:
executeUpdate in interface CallExecutor
Parameters:
dbCall - the call to run
Throws:
DatabaseCallException

processPreCallOptions

protected void processPreCallOptions(DatabaseCall dbCall)
Copies options from the DatabaseCall's opOwner, and invokes HandlingOption preCall() on any registered HandlingOption keys.

Parameters:
dbCall - the call about to be executed
See Also:
HandlingOption.preCall(String, DatabaseCall)

processPostCallOptions

protected void processPostCallOptions(DatabaseCall dbCall)
Called at the end of the finally statement to process any options that should be evaluated after everything is called.

Parameters:
dbCall - the call being finished
See Also:
HandlingOption.postCall(String, DatabaseCall)

processCompletionInfo

protected void processCompletionInfo(DatabaseCall dbCall,
                                     long t1,
                                     long t2,
                                     java.lang.String amountOfWork)
Called in the finally block of a call execution, this method adds information to the trace key and handles the call to the WebAppStats and the app log.

Parameters:
dbCall -
t1 - the start time of the call
t2 - the end time of the call (after call and processing of outputs)
amountOfWork - a characterization of the amount of work done in handling the call's outputs which generally is the number of rows returned

makeDatabaseCallException

protected DatabaseCallException makeDatabaseCallException(DatabaseCall dbCall,
                                                          java.lang.Exception ex)
Make a DatabaseCallException out of an exception.

Parameters:
dbCall - the statement being executed when the error was encountered
ex - the exception that occurred
Returns:
the exception to be thrown

isOraclePackageStateError

private boolean isOraclePackageStateError(DatabaseCall dbCall,
                                          java.lang.Exception ex)
Whether or not this error was a package state error caused by the recompiling of a database package.

Parameters:
ex - the exception to evaluate
Returns:
whether or not this error is a package state error