org.mule.transport.jdbc
Class JdbcConnector

java.lang.Object
  extended by org.mule.transport.AbstractConnector
      extended by org.mule.transport.jdbc.JdbcConnector
All Implemented Interfaces:
ExceptionListener, EventListener, javax.resource.spi.work.WorkListener, MuleContextAware, Disposable, Initialisable, Lifecycle, Startable, Stoppable, NamedObject, Connectable, Connector

public class JdbcConnector
extends AbstractConnector


Field Summary
protected  DataSource dataSource
           
static long DEFAULT_POLLING_FREQUENCY
           
static String JDBC
           
protected  long pollingFrequency
           
static String PROPERTY_POLLING_FREQUENCY
           
protected  Map queries
           
protected  org.apache.commons.dbutils.QueryRunner queryRunner
           
protected  org.apache.commons.dbutils.ResultSetHandler resultSetHandler
           
protected  boolean transactionPerMessage
          Should each DB record be received in a separate transaction or should there be a single transaction for the entire ResultSet?
 
Fields inherited from class org.mule.transport.AbstractConnector
connected, createMultipleTransactedReceivers, DEFAULT_NUM_CONCURRENT_TX_RECEIVERS, dispatcherFactory, dispatchers, disposed, exceptionListener, initialised, logger, muleContext, name, numberOfConcurrentTransactedReceivers, receivers, requesterFactory, requesters, serviceDescriptor, serviceOverrides, sessionHandler, started, startOnConnect
 
Fields inherited from interface org.mule.api.transport.Connector
INT_VALUE_NOT_SET
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Startable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Stoppable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
JdbcConnector()
           
 
Method Summary
 MessageReceiver createReceiver(Service service, InboundEndpoint endpoint)
          Create a Message receiver for this connector
protected  void doConnect()
          Template method where any connections should be made for the connector
protected  void doDisconnect()
          Template method where any connected resources used by the connector should be disconnected
protected  void doDispose()
          Template method to perform any work when destroying the connectoe
protected  void doInitialise()
           
protected  void doStart()
          Template method to perform any work when starting the connectoe
protected  void doStop()
          Template method to perform any work when stopping the connectoe
 Connection getConnection()
           
 DataSource getDataSource()
           
protected  String getNameFromParam(String param)
           
 Object[] getParams(ImmutableEndpoint endpoint, List paramNames, MuleMessage message, String query)
           
 long getPollingFrequency()
           
 String getProtocol()
           
 Map getQueries()
           
 String getQuery(ImmutableEndpoint endpoint, String stmt)
           
 org.apache.commons.dbutils.QueryRunner getQueryRunner()
           
 String[] getReadAndAckStatements(ImmutableEndpoint endpoint)
           
 org.apache.commons.dbutils.ResultSetHandler getResultSetHandler()
           
 SqlStatementStrategyFactory getSqlStatementStrategyFactory()
           
 String getStatement(ImmutableEndpoint endpoint)
           
 boolean isTransactionPerMessage()
           
 String parseStatement(String stmt, List params)
          Parse the given statement filling the parameter list and return the ready to use statement.
 void setDataSource(DataSource dataSource)
           
 void setPollingFrequency(long pollingFrequency)
           
 void setQueries(Map queries)
           
 void setQueryRunner(org.apache.commons.dbutils.QueryRunner queryRunner)
           
 void setResultSetHandler(org.apache.commons.dbutils.ResultSetHandler resultSetHandler)
           
 void setSqlStatementStrategyFactory(SqlStatementStrategyFactory sqlStatementStrategyFactory)
           
 void setTransactionPerMessage(boolean transactionPerMessage)
           
 RetryContext validateConnection(RetryContext retryContext)
          Verify that we are able to connect to the DataSource (needed for retry policies)
 
Methods inherited from class org.mule.transport.AbstractConnector
checkDisposed, connect, destroyReceiver, disconnect, dispatch, dispose, disposeDispatchers, disposeReceivers, disposeRequesters, disposeWorkManagers, exceptionThrown, fireNotification, getConnectEventId, getConnectionDescription, getDefaultInboundTransformers, getDefaultOutboundTransformers, getDefaultResponseTransformers, getDispatcherFactory, getDispatcherThreadingProfile, getDispatcherWorkManager, getExceptionListener, getMaxDispatchersActive, getMaxRequestersActive, getMessageAdapter, getMuleContext, getName, getNumberOfConcurrentTransactedReceivers, getOutputStream, getReceiver, getReceiverKey, getReceivers, getReceivers, getReceiverThreadingProfile, getReceiverWorkManager, getReplyToHandler, getRequesterFactory, getRequesterThreadingProfile, getRequesterWorkManager, getRetryPolicyTemplate, getScheduler, getServiceDescriptor, getServiceOverrides, getSessionHandler, getSupportedProtocols, handleException, handleException, handleWorkException, initFromServiceDescriptor, initialise, initialiseFromUrl, initWorkManagers, isConnected, isCreateMultipleTransactedReceivers, isDisposed, isEnableMessageEvents, isResponseEnabled, isStarted, isSyncEnabled, isValidateConnections, lookupReceiver, registerListener, registerSupportedProtocol, registerSupportedProtocolWithoutPrefix, request, request, send, setConnected, setCreateMultipleTransactedReceivers, setDispatcherFactory, setDispatcherThreadingProfile, setDynamicNotification, setExceptionListener, setMaxDispatchersActive, setMaxRequestersActive, setMuleContext, setName, setNumberOfConcurrentTransactedReceivers, setReceiverThreadingProfile, setRequesterFactory, setRequesterThreadingProfile, setRetryPolicyTemplate, setServiceOverrides, setSessionHandler, setSupportedProtocols, setupDispatchReturn, setupRequestReturn, setValidateConnections, start, stop, supportsProtocol, toString, unregisterListener, unregisterSupportedProtocol, updateCachedNotificationHandler, workAccepted, workCompleted, workRejected, workStarted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JDBC

public static final String JDBC
See Also:
Constant Field Values

PROPERTY_POLLING_FREQUENCY

public static final String PROPERTY_POLLING_FREQUENCY
See Also:
Constant Field Values

DEFAULT_POLLING_FREQUENCY

public static final long DEFAULT_POLLING_FREQUENCY
See Also:
Constant Field Values

pollingFrequency

protected long pollingFrequency

queries

protected Map queries

dataSource

protected DataSource dataSource

resultSetHandler

protected org.apache.commons.dbutils.ResultSetHandler resultSetHandler

queryRunner

protected org.apache.commons.dbutils.QueryRunner queryRunner

transactionPerMessage

protected boolean transactionPerMessage
Should each DB record be received in a separate transaction or should there be a single transaction for the entire ResultSet?

Constructor Detail

JdbcConnector

public JdbcConnector()
Method Detail

doInitialise

protected void doInitialise()
                     throws InitialisationException
Specified by:
doInitialise in class AbstractConnector
Throws:
InitialisationException

createReceiver

public MessageReceiver createReceiver(Service service,
                                      InboundEndpoint endpoint)
                               throws Exception
Description copied from class: AbstractConnector
Create a Message receiver for this connector

Overrides:
createReceiver in class AbstractConnector
Parameters:
service - the service that will receive events from this receiver, the listener
endpoint - the endpoint that defies this inbound communication
Returns:
an instance of the message receiver defined in this connectors' TransportServiceDescriptor initialised using the service and endpoint.
Throws:
Exception - if there is a problem creating the receiver. This exception really depends on the underlying transport, thus any exception could be thrown

getReadAndAckStatements

public String[] getReadAndAckStatements(ImmutableEndpoint endpoint)

getQuery

public String getQuery(ImmutableEndpoint endpoint,
                       String stmt)

getConnection

public Connection getConnection()
                         throws Exception
Throws:
Exception

isTransactionPerMessage

public boolean isTransactionPerMessage()

setTransactionPerMessage

public void setTransactionPerMessage(boolean transactionPerMessage)

parseStatement

public String parseStatement(String stmt,
                             List params)
Parse the given statement filling the parameter list and return the ready to use statement.

Parameters:
stmt -
params -
Returns:

getParams

public Object[] getParams(ImmutableEndpoint endpoint,
                          List paramNames,
                          MuleMessage message,
                          String query)
                   throws Exception
Throws:
Exception

getNameFromParam

protected String getNameFromParam(String param)

doDispose

protected void doDispose()
Description copied from class: AbstractConnector
Template method to perform any work when destroying the connectoe

Specified by:
doDispose in class AbstractConnector

doConnect

protected void doConnect()
                  throws Exception
Description copied from class: AbstractConnector
Template method where any connections should be made for the connector

Specified by:
doConnect in class AbstractConnector
Throws:
Exception

validateConnection

public RetryContext validateConnection(RetryContext retryContext)
Verify that we are able to connect to the DataSource (needed for retry policies)

Specified by:
validateConnection in interface Connectable
Overrides:
validateConnection in class AbstractConnector
Parameters:
retryContext -
Returns:
retry context with a success flag or failure details
See Also:
RetryContext.isOk(), RetryContext.getLastFailure()

doDisconnect

protected void doDisconnect()
                     throws Exception
Description copied from class: AbstractConnector
Template method where any connected resources used by the connector should be disconnected

Specified by:
doDisconnect in class AbstractConnector
Throws:
Exception

doStart

protected void doStart()
                throws MuleException
Description copied from class: AbstractConnector
Template method to perform any work when starting the connectoe

Specified by:
doStart in class AbstractConnector
Throws:
MuleException - if the method fails

doStop

protected void doStop()
               throws MuleException
Description copied from class: AbstractConnector
Template method to perform any work when stopping the connectoe

Specified by:
doStop in class AbstractConnector
Throws:
MuleException - if the method fails

getProtocol

public String getProtocol()
Returns:
the primary protocol name for endpoints of this connector

getDataSource

public DataSource getDataSource()

setDataSource

public void setDataSource(DataSource dataSource)

getResultSetHandler

public org.apache.commons.dbutils.ResultSetHandler getResultSetHandler()

setResultSetHandler

public void setResultSetHandler(org.apache.commons.dbutils.ResultSetHandler resultSetHandler)

getQueryRunner

public org.apache.commons.dbutils.QueryRunner getQueryRunner()

setQueryRunner

public void setQueryRunner(org.apache.commons.dbutils.QueryRunner queryRunner)

getPollingFrequency

public long getPollingFrequency()
Returns:
Returns the pollingFrequency.

setPollingFrequency

public void setPollingFrequency(long pollingFrequency)
Parameters:
pollingFrequency - The pollingFrequency to set.

getQueries

public Map getQueries()
Returns:
Returns the queries.

setQueries

public void setQueries(Map queries)
Parameters:
queries - The queries to set.

getSqlStatementStrategyFactory

public SqlStatementStrategyFactory getSqlStatementStrategyFactory()

setSqlStatementStrategyFactory

public void setSqlStatementStrategyFactory(SqlStatementStrategyFactory sqlStatementStrategyFactory)

getStatement

public String getStatement(ImmutableEndpoint endpoint)


Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.