com.jenkov.mrpersister.impl.command
Class DaoCommandExecutor

java.lang.Object
  extended by com.jenkov.mrpersister.impl.command.DaoCommandExecutor
All Implemented Interfaces:
IDaoCommandExecutor

public class DaoCommandExecutor
extends java.lang.Object
implements IDaoCommandExecutor

Author:
Jakob Jenkov - Copyright 2005 Jenkov Development

Constructor Summary
DaoCommandExecutor(PersistenceManager persistenceManager)
           
 
Method Summary
 java.lang.Object execute(IDaoCommand command)
          Obtains a connection from the default data source, executes this dao command and closes the connection afterwards.
 java.lang.Object execute(IDaoCommand command, java.sql.Connection connection)
          Executes this dao command using the given connection, and closes the connection afterwards.
 java.lang.Object execute(java.lang.Object configKey, IDaoCommand command)
          Obtains a connection from the data source set on the IPersistenceConfiguration stored by the given configKey (in the persistence managers config factory), executes this dao command and closes the connection afterwards.
 java.lang.Object execute(java.lang.Object configKey, IDaoCommand command, java.sql.Connection connection)
          Executes the dao command using the given connection and the IPersistenceConfiguration stored by the given configKey in the persistence managers config factory), and closes the connection afterwards.
protected  java.lang.Object execute(java.lang.Object configKey, IDaoCommand command, java.sql.Connection connection, IDaosFactoryStrategy daosFactoryStrategy)
           
 java.lang.Object executeTransaction(IDaoCommand command)
          Obtains a connection from the default data source, sets auto commit to false, executes the dao command and tries to commit the transaction.
 java.lang.Object executeTransaction(IDaoCommand command, java.sql.Connection connection)
          Sets auto commit to false on the given connection, executes the dao command and tries to commit the transaction.
 java.lang.Object executeTransaction(java.lang.Object configKey, IDaoCommand command)
          Obtains a connection from the data source set on the IPersistenceConfiguration stored by the given configKey (in the persistence managers config factory), sets auto commit to false, executes the dao command and tries to commit the transaction.
 java.lang.Object executeTransaction(java.lang.Object configKey, IDaoCommand command, java.sql.Connection connection)
          Obtains the persistence configuration stored by the given config key, (in the persistence managers config factory), sets auto commit to false on the given connection, executes the dao command, and tries to commit the transaction.
protected  java.lang.Object executeTransaction(java.lang.Object configKey, IDaoCommand command, java.sql.Connection connection, IDaosFactoryStrategy daosFactoryStrategy)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DaoCommandExecutor

public DaoCommandExecutor(PersistenceManager persistenceManager)
Method Detail

execute

public java.lang.Object execute(IDaoCommand command)
                         throws PersistenceException
Description copied from interface: IDaoCommandExecutor
Obtains a connection from the default data source, executes this dao command and closes the connection afterwards.

Specified by:
execute in interface IDaoCommandExecutor
Parameters:
command - The dao command to execute.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

execute

public java.lang.Object execute(IDaoCommand command,
                                java.sql.Connection connection)
                         throws PersistenceException
Description copied from interface: IDaoCommandExecutor
Executes this dao command using the given connection, and closes the connection afterwards.

Specified by:
execute in interface IDaoCommandExecutor
Parameters:
command - The dao command to execute
connection - The connection used by the dao command during execution.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

execute

public java.lang.Object execute(java.lang.Object configKey,
                                IDaoCommand command)
                         throws PersistenceException
Description copied from interface: IDaoCommandExecutor
Obtains a connection from the data source set on the IPersistenceConfiguration stored by the given configKey (in the persistence managers config factory), executes this dao command and closes the connection afterwards.

Specified by:
execute in interface IDaoCommandExecutor
Parameters:
configKey - The key of the IPersistenceConfiguration to get the data source from.
command - The dao command to execute.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

execute

public java.lang.Object execute(java.lang.Object configKey,
                                IDaoCommand command,
                                java.sql.Connection connection)
                         throws PersistenceException
Description copied from interface: IDaoCommandExecutor
Executes the dao command using the given connection and the IPersistenceConfiguration stored by the given configKey in the persistence managers config factory), and closes the connection afterwards.

Specified by:
execute in interface IDaoCommandExecutor
Parameters:
configKey - The IPersistenceConfiguration used by the dao command during execution.
command - The dao command to execute
connection - The connection used by the dao command during execution.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

execute

protected java.lang.Object execute(java.lang.Object configKey,
                                   IDaoCommand command,
                                   java.sql.Connection connection,
                                   IDaosFactoryStrategy daosFactoryStrategy)
                            throws PersistenceException
Throws:
PersistenceException

executeTransaction

public java.lang.Object executeTransaction(IDaoCommand command)
                                    throws PersistenceException
Description copied from interface: IDaoCommandExecutor
Obtains a connection from the default data source, sets auto commit to false, executes the dao command and tries to commit the transaction. If an exception is thrown from the dao commands execute() method the transaction will be aborted (rolled back).

Specified by:
executeTransaction in interface IDaoCommandExecutor
Parameters:
command - The dao command to execute.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

executeTransaction

public java.lang.Object executeTransaction(IDaoCommand command,
                                           java.sql.Connection connection)
                                    throws PersistenceException
Description copied from interface: IDaoCommandExecutor
Sets auto commit to false on the given connection, executes the dao command and tries to commit the transaction. If an exception is thrown from the dao commands execute() method the transaction will be aborted (rolled back). The connection will be closed after execution of the dao command.

Specified by:
executeTransaction in interface IDaoCommandExecutor
Parameters:
command - The dao command to execute.
connection - The connection the dao command will use during execution.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

executeTransaction

public java.lang.Object executeTransaction(java.lang.Object configKey,
                                           IDaoCommand command)
                                    throws PersistenceException
Description copied from interface: IDaoCommandExecutor
Obtains a connection from the data source set on the IPersistenceConfiguration stored by the given configKey (in the persistence managers config factory), sets auto commit to false, executes the dao command and tries to commit the transaction. If an exception is thrown from the dao commands execute() method the transaction will be aborted (rolled back).

Specified by:
executeTransaction in interface IDaoCommandExecutor
Parameters:
configKey - The key of the persistence configuration the dao command is to use during execution.
command - The dao command to execute.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

executeTransaction

public java.lang.Object executeTransaction(java.lang.Object configKey,
                                           IDaoCommand command,
                                           java.sql.Connection connection)
                                    throws PersistenceException
Description copied from interface: IDaoCommandExecutor
Obtains the persistence configuration stored by the given config key, (in the persistence managers config factory), sets auto commit to false on the given connection, executes the dao command, and tries to commit the transaction. If an exception is thrown from the dao commands execute() method the transaction will be aborted (rolled back).

Specified by:
executeTransaction in interface IDaoCommandExecutor
Parameters:
configKey - The key of the persistence configuration the dao command is to use during execution.
command - The dao command to execute.
connection - The connection the dao command will use during execution.
Returns:
The object returned by the IDaoCommand.execute() call.
Throws:
PersistenceException - If something goes wrong during execution of the dao command. Fx. if an exception is thrown by the dao command.

executeTransaction

protected java.lang.Object executeTransaction(java.lang.Object configKey,
                                              IDaoCommand command,
                                              java.sql.Connection connection,
                                              IDaosFactoryStrategy daosFactoryStrategy)
                                       throws PersistenceException
Throws:
PersistenceException