org.apache.synapse.mediators.db
Class AbstractDBMediator

java.lang.Object
  extended by org.apache.synapse.mediators.AbstractMediator
      extended by org.apache.synapse.mediators.db.AbstractDBMediator
All Implemented Interfaces:
ManagedLifecycle, Mediator
Direct Known Subclasses:
DBLookupMediator, DBReportMediator

public abstract class AbstractDBMediator
extends AbstractMediator
implements ManagedLifecycle

This abstract DB mediator will perform common DB connection pooling etc. for all DB mediators


Field Summary
protected  Map dataSourceProps
          Hold JDBC properties
 
Fields inherited from class org.apache.synapse.mediators.AbstractMediator
log, trace, traceState
 
Constructor Summary
AbstractDBMediator()
           
 
Method Summary
 void addDataSourceProperty(QName name, String value)
           
 void addDataSourceProperty(String name, String value)
           
 void addStatement(Statement stmnt)
           
 void destroy()
          Destroys the mediator.
 DataSource getDataSource()
           
 Map getDataSourceProps()
           
protected  String getDSName()
          Return the name or (hopefully) unique connection URL specific to the DataSource being used This is used for logging purposes only
protected  PreparedStatement getPreparedStatement(Statement stmnt, MessageContext msgCtx)
          Return a Prepared statement for the given Statement object, which is ready to be executed
 List getStatementList()
           
 void init(SynapseEnvironment se)
          Initializes the mediator.
 boolean mediate(MessageContext synCtx)
          Process each SQL statement against the current message
protected abstract  void processStatement(Statement query, MessageContext msgCtx)
          Subclasses must specify how each SQL statement is processed
 void setDataSource(DataSource dataSource)
           
 
Methods inherited from class org.apache.synapse.mediators.AbstractMediator
auditLog, auditWarn, getTraceState, getType, handleException, handleException, isTraceOn, isTraceOrDebugOn, setEffectiveTraceState, setTraceState, shouldTrace, traceOrDebug, traceOrDebugWarn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataSourceProps

protected Map dataSourceProps
Hold JDBC properties

Constructor Detail

AbstractDBMediator

public AbstractDBMediator()
Method Detail

init

public void init(SynapseEnvironment se)
Initializes the mediator. Does nothing right now. If DataSource lookup is supported, could do the IC lookup here

Specified by:
init in interface ManagedLifecycle
Parameters:
se - the Synapse environment reference

destroy

public void destroy()
Destroys the mediator. If we are using our custom DataSource, then shut down the connections

Specified by:
destroy in interface ManagedLifecycle

mediate

public boolean mediate(MessageContext synCtx)
Process each SQL statement against the current message

Specified by:
mediate in interface Mediator
Parameters:
synCtx - the current message
Returns:
true, always

processStatement

protected abstract void processStatement(Statement query,
                                         MessageContext msgCtx)
Subclasses must specify how each SQL statement is processed

Parameters:
query - the SQL statement
msgCtx - current message

getDSName

protected String getDSName()
Return the name or (hopefully) unique connection URL specific to the DataSource being used This is used for logging purposes only

Returns:
a unique name or URL to refer to the DataSource being used

getDataSource

public DataSource getDataSource()

setDataSource

public void setDataSource(DataSource dataSource)

addDataSourceProperty

public void addDataSourceProperty(QName name,
                                  String value)

addDataSourceProperty

public void addDataSourceProperty(String name,
                                  String value)

getDataSourceProps

public Map getDataSourceProps()

addStatement

public void addStatement(Statement stmnt)

getStatementList

public List getStatementList()

getPreparedStatement

protected PreparedStatement getPreparedStatement(Statement stmnt,
                                                 MessageContext msgCtx)
                                          throws SQLException
Return a Prepared statement for the given Statement object, which is ready to be executed

Parameters:
stmnt -
msgCtx -
Returns:
Throws:
SQLException


Copyright © 2005-2008 Apache Software Foundation. All Rights Reserved.