Class ServiceFromDatabase
- java.lang.Object
-
- com.adaptris.core.services.dynamic.ServiceExtractorImpl
-
- com.adaptris.core.services.dynamic.ExtractorWithConnection
-
- com.adaptris.core.services.dynamic.ServiceFromDatabase
-
- All Implemented Interfaces:
ComponentLifecycle
,ServiceExtractor
@ComponentProfile(summary="Extract the service to execute from a database", recommended=DatabaseConnection.class, since="3.8.4") public class ServiceFromDatabase extends ExtractorWithConnection
Extract the service to execute from a databaseThis executes the configured query, takes the first column of the first ResultSet and uses that as the source for the dynamic service.
Since it supports the expression syntax; this is perfectly acceptable; It is up to you to protect against SQL injection attacks.
SELECT dynamicService FROM services WHERE src='%message{source}' AND dest='%message{destination}' AND msgType='%message{messageType}'
The alternative to this would be to use
JdbcDataQueryService
with aFirstRowMetadataTranslator
and subsequently aServiceFromDataInputParameter
(from metadata). That might be more performant as you would benefit from prepared statement caching and mitigate against SQL injection style attacks.- See Also:
DynamicServiceExecutor
In the adapter configuration file this class is aliased as dynamic-service-from-database which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.services.dynamic.ServiceExtractorImpl
log
-
-
Constructor Summary
Constructors Constructor Description ServiceFromDatabase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStream
getInputStream(AdaptrisMessage m)
java.lang.String
getQuery()
void
setQuery(java.lang.String query)
ServiceFromDatabase
withQuery(java.lang.String q)
-
Methods inherited from class com.adaptris.core.services.dynamic.ExtractorWithConnection
close, getConnection, init, setConnection, start, stop, withConnection
-
Methods inherited from class com.adaptris.core.services.dynamic.ServiceExtractorImpl
getService
-
-
-
-
Method Detail
-
getInputStream
public java.io.InputStream getInputStream(AdaptrisMessage m) throws java.lang.Exception
- Specified by:
getInputStream
in classServiceExtractorImpl
- Throws:
java.lang.Exception
-
getQuery
public java.lang.String getQuery()
-
setQuery
public void setQuery(java.lang.String query)
-
withQuery
public ServiceFromDatabase withQuery(java.lang.String q)
-
-