org.dasein.persist
Class Execution

java.lang.Object
  extended by org.dasein.persist.Execution
Direct Known Subclasses:
LoadTranslator, RemoveTranslator, SaveTranslator

public abstract class Execution
extends Object

Represents a database event, generally a specific query or update. You implement this class for all statements you wish to manage.
Last modified: $Date: 2006/08/23 14:59:27 $

Version:
$Revision: 1.13 $
Author:
George Reese

Field Summary
 Connection connection
          The connection to be used for the execution of this event.
 Map<String,Object> data
          The data to be used for the execution of this event.
 String dsn
           
static String PROPERTIES
           
 ResultSet results
          The JDBC results from the execution of this event.
 PreparedStatement statement
          The prepared statement that will execute the event.
 
Constructor Summary
Execution()
           
 
Method Summary
 void close()
          Closes out the event and returns it to the shared stack.
 HashMap<String,Object> execute(Transaction trans, Map<String,Object> args)
          Deprecated. do not make direct calls to this method
 Connection getConnection()
           
 String getDataSource()
          Events should implement this method to provide the name of the data source that will be used to create connections for this event.
static String getDataSourceName(String cname)
           
 String getIdentifier(String val)
           
 String getIdentifier(String tbl, String col)
           
static
<T extends Execution>
T
getInstance(Class<T> cls)
          Provides an instance of an execution object for a specific subclass.
 String getQuotes()
           
 String getState()
           
 String getStatement()
           
 String getStatement(Connection conn)
           
 String getStatement(Connection conn, Map<String,Object> params)
           
 boolean isUpperCase()
           
 Map<String,Translator<String>> loadStringTranslations(Transaction xaction, Class cls, String id)
           
 void removeStringTranslations(Transaction xaction, Class cls, String id)
           
 Map<String,Object> run()
          Deprecated. use run(Transaction, Map)
 Map<String,Object> run(Transaction xaction, Map<String,Object> params)
           
 void saveStringTranslation(Transaction xaction, Class cls, String id, String attr, Translator<String> t)
           
 void saveStringTranslation(Transaction xaction, String cname, String id, String attr, Translator<String> t)
           
 void setData(HashMap<String,Object> data)
          Method to set the data to be used in the transaction.
protected  void setDsn(String dsn)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTIES

public static final String PROPERTIES
See Also:
Constant Field Values

connection

public Connection connection
The connection to be used for the execution of this event.


data

public Map<String,Object> data
The data to be used for the execution of this event.


dsn

public String dsn

results

public ResultSet results
The JDBC results from the execution of this event.


statement

public PreparedStatement statement
The prepared statement that will execute the event.

Constructor Detail

Execution

public Execution()
Method Detail

getDataSourceName

public static String getDataSourceName(String cname)

getInstance

public static <T extends Execution> T getInstance(Class<T> cls)
Provides an instance of an execution object for a specific subclass. Executions are stored in a hash map of stacks. This enables an instance to be reused, if possible. Otherwise a new one is created.

Parameters:
cls - the subclass of Execution to be retrieved
Returns:
an instance of the specified class

close

public void close()
Closes out the event and returns it to the shared stack.


getIdentifier

public String getIdentifier(String val)
                     throws SQLException
Throws:
SQLException

getIdentifier

public String getIdentifier(String tbl,
                            String col)
                     throws SQLException
Throws:
SQLException

getQuotes

public String getQuotes()
                 throws SQLException
Throws:
SQLException

execute

public HashMap<String,Object> execute(Transaction trans,
                                      Map<String,Object> args)
                               throws PersistenceException
Deprecated. do not make direct calls to this method

Executes this event in the specified transaction context.

Parameters:
trans - the transaction context
args - the data to be used in the event
Returns:
the results of the transaction
Throws:
PersistenceException - an error occurred executing the event

getConnection

public Connection getConnection()

getDataSource

public String getDataSource()
                     throws NamingException
Events should implement this method to provide the name of the data source that will be used to create connections for this event.

Returns:
the name of the JDBC data source
Throws:
NamingException - an error occurred providing the name of the data source

getState

public final String getState()
Returns:
EXECUTING or IDLE

getStatement

public String getStatement()
                    throws SQLException
Returns:
the SQL for this event
Throws:
SQLException

getStatement

public String getStatement(Connection conn)
                    throws SQLException
Throws:
SQLException

getStatement

public String getStatement(Connection conn,
                           Map<String,Object> params)
                    throws SQLException
Throws:
SQLException

isUpperCase

public boolean isUpperCase()
                    throws SQLException
Throws:
SQLException

loadStringTranslations

public Map<String,Translator<String>> loadStringTranslations(Transaction xaction,
                                                             Class cls,
                                                             String id)
                                                      throws PersistenceException,
                                                             SQLException
Throws:
PersistenceException
SQLException

removeStringTranslations

public void removeStringTranslations(Transaction xaction,
                                     Class cls,
                                     String id)
                              throws PersistenceException,
                                     SQLException
Throws:
PersistenceException
SQLException

run

public Map<String,Object> run()
                       throws PersistenceException,
                              SQLException
Deprecated. use run(Transaction, Map)

Event implementations should implement this method to process the actual event.

Returns:
the results of the event
Throws:
PersistenceException - a non-JDBC error occurred executing the event
SQLException - a JDBC error occurred executing the event

run

public Map<String,Object> run(Transaction xaction,
                              Map<String,Object> params)
                       throws PersistenceException,
                              SQLException
Throws:
PersistenceException
SQLException

saveStringTranslation

public void saveStringTranslation(Transaction xaction,
                                  Class cls,
                                  String id,
                                  String attr,
                                  Translator<String> t)
                           throws SQLException,
                                  PersistenceException
Throws:
SQLException
PersistenceException

saveStringTranslation

public void saveStringTranslation(Transaction xaction,
                                  String cname,
                                  String id,
                                  String attr,
                                  Translator<String> t)
                           throws SQLException,
                                  PersistenceException
Throws:
SQLException
PersistenceException

setData

public void setData(HashMap<String,Object> data)
Method to set the data to be used in the transaction.

Parameters:
data - the data to be set

setDsn

protected void setDsn(String dsn)