org.apache.camel.processor.idempotent.jdbc
Class AbstractJdbcMessageIdRepository<T>
java.lang.Object
org.apache.camel.support.ServiceSupport
org.apache.camel.processor.idempotent.jdbc.AbstractJdbcMessageIdRepository<T>
- All Implemented Interfaces:
- org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.IdempotentRepository<T>, org.apache.camel.StatefulService, org.apache.camel.SuspendableService
- Direct Known Subclasses:
- JdbcMessageIdRepository
@ManagedResource(description="JDBC IdempotentRepository")
public abstract class AbstractJdbcMessageIdRepository<T>
- extends org.apache.camel.support.ServiceSupport
- implements org.apache.camel.spi.IdempotentRepository<T>
Base class for JDBC-based idempotent repositories that allows the schema to be changed.
Subclasses need only implement theses methods:
#queryForInt(T key)
#insert(T key)
#delete(T key)
These methods should perform the named database operation.
Fields inherited from class org.apache.camel.support.ServiceSupport |
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending |
Methods inherited from class org.apache.camel.support.ServiceSupport |
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.camel.Service |
start, stop |
jdbcTemplate
protected org.springframework.jdbc.core.JdbcTemplate jdbcTemplate
processorName
protected String processorName
transactionTemplate
protected org.springframework.transaction.support.TransactionTemplate transactionTemplate
dataSource
protected DataSource dataSource
log
protected org.slf4j.Logger log
AbstractJdbcMessageIdRepository
public AbstractJdbcMessageIdRepository()
AbstractJdbcMessageIdRepository
public AbstractJdbcMessageIdRepository(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
org.springframework.transaction.support.TransactionTemplate transactionTemplate)
AbstractJdbcMessageIdRepository
public AbstractJdbcMessageIdRepository(DataSource dataSource,
org.springframework.transaction.support.TransactionTemplate transactionTemplate,
String processorName)
AbstractJdbcMessageIdRepository
public AbstractJdbcMessageIdRepository(DataSource dataSource,
String processorName)
queryForInt
protected abstract int queryForInt(T key)
- Operation that returns the number of rows, if any, for the specified key
- Parameters:
key
- the key
- Returns:
- int number of rows
insert
protected abstract int insert(T key)
- Operation that inserts the key if it does not already exist
- Parameters:
key
- the key
- Returns:
- int number of rows inserted
delete
protected abstract int delete(T key)
- Operations that deletes the key if it exists
- Parameters:
key
- the key
- Returns:
- int number of rows deleted
createTransactionTemplate
protected static org.springframework.transaction.support.TransactionTemplate createTransactionTemplate(DataSource dataSource)
- Creates the transaction template
doStart
protected void doStart()
throws Exception
- Specified by:
doStart
in class org.apache.camel.support.ServiceSupport
- Throws:
Exception
doStop
protected void doStop()
throws Exception
- Specified by:
doStop
in class org.apache.camel.support.ServiceSupport
- Throws:
Exception
add
@ManagedOperation(description="Adds the key to the store")
public boolean add(T key)
- Specified by:
add
in interface org.apache.camel.spi.IdempotentRepository<T>
contains
@ManagedOperation(description="Does the store contain the given key")
public boolean contains(T key)
- Specified by:
contains
in interface org.apache.camel.spi.IdempotentRepository<T>
remove
@ManagedOperation(description="Remove the key from the store")
public boolean remove(T key)
- Specified by:
remove
in interface org.apache.camel.spi.IdempotentRepository<T>
confirm
public boolean confirm(T key)
- Specified by:
confirm
in interface org.apache.camel.spi.IdempotentRepository<T>
getJdbcTemplate
public org.springframework.jdbc.core.JdbcTemplate getJdbcTemplate()
setJdbcTemplate
public void setJdbcTemplate(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
getProcessorName
public String getProcessorName()
setProcessorName
public void setProcessorName(String processorName)
getTransactionTemplate
public org.springframework.transaction.support.TransactionTemplate getTransactionTemplate()
setTransactionTemplate
public void setTransactionTemplate(org.springframework.transaction.support.TransactionTemplate transactionTemplate)
getDataSource
public DataSource getDataSource()
setDataSource
public void setDataSource(DataSource dataSource)
Apache Camel