Package com.adaptris.core.services.jdbc
Class JdbcDataQueryService
- java.lang.Object
-
- com.adaptris.core.ServiceImp
-
- com.adaptris.core.jdbc.JdbcService
-
- com.adaptris.core.services.jdbc.JdbcServiceWithParameters
-
- com.adaptris.core.services.jdbc.JdbcDataQueryService
-
- All Implemented Interfaces:
AdaptrisComponent
,ComponentLifecycle
,ComponentLifecycleExtension
,ConnectedService
,DynamicPollingTemplate.TemplateProvider
,MessageEventGenerator
,Service
,StateManagedComponent
@ComponentProfile(summary="Query a database and store the results in the message", tag="service,jdbc", recommended=DatabaseConnection.class) public class JdbcDataQueryService extends JdbcServiceWithParameters implements DynamicPollingTemplate.TemplateProvider
Perform a triggered JDBC query and the results of this query that can be stored in the AdaptrisMessage.In the adapter configuration file this class is aliased as jdbc-data-query-service which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.ServiceImp
log
-
-
Constructor Summary
Constructors Constructor Description JdbcDataQueryService()
JdbcDataQueryService(JdbcStatementCreator creator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
closeJdbcService()
Close the service.void
doService(AdaptrisMessage msg)
The main service method, which sees the specified query executed and the results returned in an XML message.java.lang.Boolean
getIgnoreExecuteQueryErrors()
KeyValuePairSet
getNamespaceContext()
ResultSetTranslator
getResultSetTranslator()
JdbcStatementCreator
getStatementCreator()
DocumentBuilderFactoryBuilder
getXmlDocumentFactoryConfig()
protected void
initJdbcService()
protected void
prepareService()
void
setIgnoreExecuteQueryErrors(java.lang.Boolean b)
Whether or not to ignore the SQL Exception when executingPreparedStatement.executeQuery()
.void
setNamespaceContext(KeyValuePairSet kvps)
Set the namespace context for resolving namespaces.void
setResultSetTranslator(ResultSetTranslator outputTranslator)
Set the implementation that will be used to parse the result set.void
setStatementCreator(JdbcStatementCreator statementCreator)
Set the SQL Query statement creator.void
setXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)
void
startService()
Start the service.void
stopService()
Stop the service.-
Methods inherited from class com.adaptris.core.services.jdbc.JdbcServiceWithParameters
addStatementParameter, getParameterApplicator, getStatementParameters, setParameterApplicator, setStatementParameters
-
Methods inherited from class com.adaptris.core.jdbc.JdbcService
applyTimeout, closeService, createStatement, getConnection, getConnection, getStatementTimeout, initService, prepare, prepareStatement, prepareStatement, setConnection, setStatementTimeout, start, stop
-
Methods inherited from class com.adaptris.core.ServiceImp
changeState, close, continueOnFailure, createName, createQualifier, getContinueOnFail, getIsTrackingEndpoint, getUniqueId, init, isBranching, isTrackingEndpoint, requestClose, requestInit, requestStart, requestStop, retrieveComponentState, setContinueOnFail, setIsTrackingEndpoint, setUniqueId
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.ComponentLifecycle
close, init, start, stop
-
Methods inherited from interface com.adaptris.core.ComponentLifecycleExtension
prepare
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
Methods inherited from interface com.adaptris.core.Service
continueOnFailure, isBranching, setUniqueId
-
Methods inherited from interface com.adaptris.core.StateManagedComponent
changeState, requestClose, requestInit, requestStart, requestStop, retrieveComponentState
-
-
-
-
Constructor Detail
-
JdbcDataQueryService
public JdbcDataQueryService()
-
JdbcDataQueryService
public JdbcDataQueryService(JdbcStatementCreator creator)
-
-
Method Detail
-
initJdbcService
protected void initJdbcService() throws CoreException
- Specified by:
initJdbcService
in classJdbcService
- Throws:
CoreException
-
prepareService
protected void prepareService() throws CoreException
- Specified by:
prepareService
in classJdbcService
- Throws:
CoreException
-
startService
public void startService() throws CoreException
Description copied from class:JdbcService
Start the service.This is called after the connection is started
- Specified by:
startService
in classJdbcService
- Throws:
CoreException
-
closeJdbcService
protected void closeJdbcService()
Description copied from class:JdbcService
Close the service.This is called before the connection is closed
- Specified by:
closeJdbcService
in classJdbcService
-
stopService
public void stopService()
Description copied from class:JdbcService
Stop the service.This is called after before the connection is stopped
- Specified by:
stopService
in classJdbcService
-
doService
public void doService(AdaptrisMessage msg) throws ServiceException
The main service method, which sees the specified query executed and the results returned in an XML message.- Specified by:
doService
in interfaceService
- Parameters:
msg
- theAdaptrisMessage
to process- Throws:
ServiceException
- wrapping any underlyingException
s- See Also:
Service.doService(com.adaptris.core.AdaptrisMessage)
-
getResultSetTranslator
public ResultSetTranslator getResultSetTranslator()
- Returns:
- the output translator implementation.
-
setResultSetTranslator
public void setResultSetTranslator(ResultSetTranslator outputTranslator)
Set the implementation that will be used to parse the result set.- Parameters:
outputTranslator
- the implementation to use.
-
getNamespaceContext
public KeyValuePairSet getNamespaceContext()
- Returns:
- the namespaceContext
-
setNamespaceContext
public void setNamespaceContext(KeyValuePairSet kvps)
Set the namespace context for resolving namespaces.- The key is the namespace prefix
- The value is the namespace uri
- Parameters:
kvps
- the namespace context- See Also:
SimpleNamespaceContext.create(KeyValuePairSet)
-
getXmlDocumentFactoryConfig
public DocumentBuilderFactoryBuilder getXmlDocumentFactoryConfig()
-
setXmlDocumentFactoryConfig
public void setXmlDocumentFactoryConfig(DocumentBuilderFactoryBuilder xml)
-
getStatementCreator
public JdbcStatementCreator getStatementCreator()
-
setStatementCreator
public void setStatementCreator(JdbcStatementCreator statementCreator)
Set the SQL Query statement creator. If set, a StatementCreator will override the configured statement, if any.- Parameters:
statementCreator
- The statement creator to set.
-
getIgnoreExecuteQueryErrors
public java.lang.Boolean getIgnoreExecuteQueryErrors()
- Returns:
- the ignoreExecuteQueryErrors
-
setIgnoreExecuteQueryErrors
public void setIgnoreExecuteQueryErrors(java.lang.Boolean b)
Whether or not to ignore the SQL Exception when executingPreparedStatement.executeQuery()
.If set to true this means is that the
PreparedStatement.executeQuery()
is treated as successful, but with an empty result set.- Parameters:
b
- the ignoreExecuteQueryErrors to set
-
-