public class XsltBuilder extends ServiceSupport implements Processor, CamelContextAware
XsltBuilder
its recommended
to inject the CamelContext
using the setCamelContext(org.apache.camel.CamelContext)
and call ServiceSupport.start()
to properly initialize the builder before using.shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
Constructor and Description |
---|
XsltBuilder() |
XsltBuilder(Templates templates) |
Modifier and Type | Method and Description |
---|---|
protected void |
addParameters(Transformer transformer,
Map<String,Object> map) |
XsltBuilder |
allowStAX()
Enables to allow using StAX.
|
protected void |
configureTransformer(Transformer transformer,
Exchange exchange)
Configures the transformer with exchange specific parameters
|
protected Transformer |
createTransformer() |
XsltBuilder |
deleteOutputFile()
Should the output file be deleted when the
Exchange is done. |
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
XsltBuilder |
errorListener(ErrorListener errorListener)
Uses a custom
ErrorListener . |
CamelContext |
getCamelContext()
Get the
CamelContext |
XmlConverter |
getConverter() |
ErrorListener |
getErrorListener() |
Map<String,Object> |
getParameters() |
ResultHandlerFactory |
getResultHandlerFactory() |
protected Source |
getSource(Exchange exchange,
Object body)
|
Templates |
getTemplate() |
URIResolver |
getUriResolver() |
boolean |
isAllowStAX() |
boolean |
isDeleteOutputFile() |
boolean |
isFailOnNullBody() |
protected boolean |
isInputStreamNeeded(Exchange exchange)
Checks whether we need an
InputStream to access the message body. |
XsltBuilder |
outputBytes()
Sets the output as being a byte[]
|
XsltBuilder |
outputDOM()
Sets the output as being a DOM
|
XsltBuilder |
outputFile()
Sets the output as being a File where the filename
must be provided in the
Exchange.XSLT_FILE_NAME header. |
XsltBuilder |
outputString()
Sets the output as being a String
|
XsltBuilder |
parameter(String name,
Object value) |
void |
process(Exchange exchange)
Processes the message exchange
|
void |
setAllowStAX(boolean allowStAX) |
void |
setCamelContext(CamelContext camelContext)
Injects the
CamelContext |
void |
setConverter(XmlConverter converter) |
void |
setDeleteOutputFile(boolean deleteOutputFile) |
void |
setErrorListener(ErrorListener errorListener) |
void |
setFailOnNullBody(boolean failOnNullBody) |
void |
setParameters(Map<String,Object> parameters) |
void |
setResultHandlerFactory(ResultHandlerFactory resultHandlerFactory) |
void |
setTemplate(Templates template) |
void |
setTransformerFile(File xslt)
Sets the XSLT transformer from a File
|
void |
setTransformerInputStream(InputStream in)
Sets the XSLT transformer from the given input stream
|
void |
setTransformerSource(Source source)
Sets the XSLT transformer from a Source
|
void |
setTransformerURL(URL url)
Sets the XSLT transformer from a URL
|
void |
setUriResolver(URIResolver uriResolver) |
String |
toString() |
XsltBuilder |
transformerCacheSize(int numberToCache)
Used for caching
Transformer s. |
XsltBuilder |
uriResolver(URIResolver uriResolver)
Sets a custom URI resolver to be used
|
static XsltBuilder |
xslt(File xslt)
Creates an XSLT processor using the given XSLT source
|
static XsltBuilder |
xslt(InputStream xslt)
Creates an XSLT processor using the given XSLT source
|
static XsltBuilder |
xslt(Source xslt)
Creates an XSLT processor using the given XSLT source
|
static XsltBuilder |
xslt(Templates templates)
Creates an XSLT processor using the given templates instance
|
static XsltBuilder |
xslt(URL xslt)
Creates an XSLT processor using the given XSLT source
|
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public XsltBuilder()
public XsltBuilder(Templates templates)
public void process(Exchange exchange) throws Exception
Processor
public static XsltBuilder xslt(Templates templates)
public static XsltBuilder xslt(Source xslt) throws TransformerConfigurationException
public static XsltBuilder xslt(File xslt) throws TransformerConfigurationException
public static XsltBuilder xslt(URL xslt) throws TransformerConfigurationException, IOException
public static XsltBuilder xslt(InputStream xslt) throws TransformerConfigurationException, IOException
public XsltBuilder outputBytes()
public XsltBuilder outputString()
public XsltBuilder outputDOM()
public XsltBuilder outputFile()
Exchange.XSLT_FILE_NAME
header.public XsltBuilder deleteOutputFile()
Exchange
is done.
This option should only be used if you use outputFile()
as well.public XsltBuilder parameter(String name, Object value)
public XsltBuilder uriResolver(URIResolver uriResolver)
public XsltBuilder allowStAX()
Source
.public XsltBuilder transformerCacheSize(int numberToCache)
Transformer
s.
By default no caching is in use.numberToCache
- the maximum number of transformers to cachepublic XsltBuilder errorListener(ErrorListener errorListener)
ErrorListener
.public Map<String,Object> getParameters()
public void setParameters(Map<String,Object> parameters)
public void setTemplate(Templates template)
public Templates getTemplate()
public boolean isFailOnNullBody()
public void setFailOnNullBody(boolean failOnNullBody)
public ResultHandlerFactory getResultHandlerFactory()
public void setResultHandlerFactory(ResultHandlerFactory resultHandlerFactory)
public boolean isAllowStAX()
public void setAllowStAX(boolean allowStAX)
public void setTransformerSource(Source source) throws TransformerConfigurationException
source
- the sourceTransformerConfigurationException
- is thrown if creating a XSLT transformer failed.public void setTransformerFile(File xslt) throws TransformerConfigurationException
public void setTransformerURL(URL url) throws TransformerConfigurationException, IOException
public void setTransformerInputStream(InputStream in) throws TransformerConfigurationException, IOException
public XmlConverter getConverter()
public void setConverter(XmlConverter converter)
public URIResolver getUriResolver()
public void setUriResolver(URIResolver uriResolver)
public boolean isDeleteOutputFile()
public void setDeleteOutputFile(boolean deleteOutputFile)
public ErrorListener getErrorListener()
public void setErrorListener(ErrorListener errorListener)
protected Transformer createTransformer() throws Exception
Exception
protected boolean isInputStreamNeeded(Exchange exchange)
InputStream
to access the message body.
Depending on the content in the message body, we may not need to convert
to InputStream
.exchange
- the current exchangeInputStream
beforehand converting to Source
afterwards.protected void configureTransformer(Transformer transformer, Exchange exchange) throws Exception
Exception
protected void addParameters(Transformer transformer, Map<String,Object> map)
public CamelContext getCamelContext()
CamelContextAware
CamelContext
getCamelContext
in interface CamelContextAware
public void setCamelContext(CamelContext camelContext)
CamelContextAware
CamelContext
setCamelContext
in interface CamelContextAware
camelContext
- the Camel contextprotected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
Apache Camel