@ComponentProfile(summary="Extract the service to execute from a database", recommended=DatabaseConnection.class, since="3.8.4") public class ServiceFromDatabase extends ExtractorWithConnection
This 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 a
FirstRowMetadataTranslator
and subsequently a ServiceFromDataInputParameter
(from
metadata). That might be more performant as you would benefit from prepared statement caching and
mitigate against SQL injection style attacks.
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.
log
Constructor and Description |
---|
ServiceFromDatabase() |
Modifier and Type | Method and Description |
---|---|
java.io.InputStream |
getInputStream(AdaptrisMessage m)
Get an
InputStream that can be unmarshalled into a service. |
java.lang.String |
getQuery() |
void |
setQuery(java.lang.String query) |
ServiceFromDatabase |
withQuery(java.lang.String q) |
close, getConnection, init, setConnection, start, stop, withConnection
getService
public java.io.InputStream getInputStream(AdaptrisMessage m) throws java.lang.Exception
ServiceExtractor
InputStream
that can be unmarshalled into a service.getInputStream
in interface ServiceExtractor
getInputStream
in class ServiceExtractorImpl
m
- the adaptris message.java.lang.Exception
public java.lang.String getQuery()
public void setQuery(java.lang.String query)
public ServiceFromDatabase withQuery(java.lang.String q)