org.mule.module.xml.transformer
Class XQueryTransformer

java.lang.Object
  extended by org.mule.transformer.AbstractTransformer
      extended by org.mule.transformer.AbstractMessageTransformer
          extended by org.mule.module.xml.transformer.AbstractXmlTransformer
              extended by org.mule.module.xml.transformer.XQueryTransformer
All Implemented Interfaces:
AnnotatedObject, MuleContextAware, Disposable, Initialisable, NameableObject, NamedObject, MessageProcessor, MessageTransformer, Transformer, EndpointAware

public class XQueryTransformer
extends AbstractXmlTransformer
implements Disposable

The XQuery Module gives users the ability to perform XQuery transformations on XML messages in Mule


Nested Class Summary
protected  class XQueryTransformer.PooledXQueryTransformerFactory
           
 
Nested classes/interfaces inherited from class org.mule.module.xml.transformer.AbstractXmlTransformer
AbstractXmlTransformer.ResultHolder
 
Field Summary
protected  net.sf.saxon.Configuration configuration
           
static String SOURCE_DOCUMENT_NAMESPACE
           
protected  org.apache.commons.pool.impl.GenericObjectPool transformerPool
           
 
Fields inherited from class org.mule.transformer.AbstractTransformer
encoding, endpoint, logger, mimeType, MULE_MESSAGE_DATA_TYPE, muleContext, name, returnType, sourceTypes
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.AnnotatedObject
PROPERTY_NAME
 
Constructor Summary
XQueryTransformer()
           
XQueryTransformer(String xqueryFile)
           
 
Method Summary
protected  void bindDocument(Object src, javax.xml.xquery.XQPreparedExpression transformer)
          Returns the InputSource corresponding to xqueryFile or xquery
protected  void bindParameters(javax.xml.xquery.XQPreparedExpression transformer, MuleMessage message)
           
 Object clone()
           
 void dispose()
          Template method where deriving classes can do any clean up any resources or state before the object is disposed.
protected  Object evaluateTransformParameter(String name, Object value, MuleMessage message)
           Returns the value to be set for the parameter.
 net.sf.saxon.Configuration getConfiguration()
           
 Map<String,Object> getContextProperties()
          Gets the parameters to be used when applying the transformation
 int getMaxActiveTransformers()
           
 int getMaxIdleTransformers()
           
 String getXquery()
           
 String getXqueryFile()
           
 void initialise()
          Template method where deriving classes can do any initialisation after the properties have been set on this transformer
 void setConfiguration(net.sf.saxon.Configuration configuration)
           
 void setContextProperties(Map<String,Object> contextProperties)
          Sets the parameters to be used when applying the transformation
 void setMaxActiveTransformers(int maxActiveTransformers)
          Sets the the current maximum number of active transformer objects allowed in the pool
 void setMaxIdleTransformers(int maxIdleTransformers)
          Sets the the current maximum number of idle transformer objects allowed in the pool
 void setXquery(String xquery)
           
 void setXqueryFile(String xqueryFile)
           
 Object transformMessage(MuleMessage message, String outputEncoding)
          Transform the message
protected  void unbindParameters(javax.xml.xquery.XQPreparedExpression transformer)
          Removes any parameter bindings from the transformer, replacing them with empty strings
 
Methods inherited from class org.mule.module.xml.transformer.AbstractXmlTransformer
convertToBytes, convertToText, convertToText, getOutputEncoding, getResultHolder, getXMLInputFactory, getXMLOutputFactory, isUseStaxSource, setOutputEncoding, setUseStaxSource, setXMLInputFactory, setXMLOutputFactory, writeToStream
 
Methods inherited from class org.mule.transformer.AbstractMessageTransformer
checkReturnClass, doTransform, isSourceDataTypeSupported, transform, transform, transform
 
Methods inherited from class org.mule.transformer.AbstractTransformer
generateTransformerName, getAnnotation, getAnnotations, getEncoding, getEncoding, getEndpoint, getMimeType, getName, getReturnClass, getReturnDataType, getSourceDataTypes, getSourceTypes, isAcceptNull, isAllowNullReturn, isConsumed, isIgnoreBadInput, isSourceDataTypeSupported, isSourceTypeSupported, isSourceTypeSupported, process, registerSourceType, registerSourceType, setAllowNullReturn, setAnnotations, setEncoding, setEndpoint, setIgnoreBadInput, setMimeType, setMuleContext, setName, setReturnClass, setReturnDataType, toString, transform, unregisterSourceType, unregisterSourceType
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mule.api.transformer.Transformer
getEncoding, getEndpoint, getMimeType, getReturnClass, getReturnDataType, getSourceDataTypes, getSourceTypes, isAcceptNull, isIgnoreBadInput, isSourceDataTypeSupported, isSourceTypeSupported, setReturnClass, setReturnDataType, transform
 
Methods inherited from interface org.mule.api.processor.MessageProcessor
process
 
Methods inherited from interface org.mule.api.NameableObject
setName
 
Methods inherited from interface org.mule.api.NamedObject
getName
 
Methods inherited from interface org.mule.api.context.MuleContextAware
setMuleContext
 
Methods inherited from interface org.mule.endpoint.EndpointAware
setEndpoint
 

Field Detail

SOURCE_DOCUMENT_NAMESPACE

public static final String SOURCE_DOCUMENT_NAMESPACE
See Also:
Constant Field Values

transformerPool

protected final org.apache.commons.pool.impl.GenericObjectPool transformerPool

configuration

protected net.sf.saxon.Configuration configuration
Constructor Detail

XQueryTransformer

public XQueryTransformer()

XQueryTransformer

public XQueryTransformer(String xqueryFile)
Method Detail

initialise

public void initialise()
                throws InitialisationException
Description copied from class: AbstractTransformer
Template method where deriving classes can do any initialisation after the properties have been set on this transformer

Specified by:
initialise in interface Initialisable
Overrides:
initialise in class AbstractTransformer
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

dispose

public void dispose()
Description copied from class: AbstractTransformer
Template method where deriving classes can do any clean up any resources or state before the object is disposed.

Specified by:
dispose in interface Disposable
Overrides:
dispose in class AbstractTransformer

transformMessage

public Object transformMessage(MuleMessage message,
                               String outputEncoding)
                        throws TransformerException
Description copied from class: AbstractMessageTransformer
Transform the message

Specified by:
transformMessage in class AbstractMessageTransformer
Throws:
TransformerException

bindParameters

protected void bindParameters(javax.xml.xquery.XQPreparedExpression transformer,
                              MuleMessage message)
                       throws javax.xml.xquery.XQException,
                              TransformerException
Throws:
javax.xml.xquery.XQException
TransformerException

unbindParameters

protected void unbindParameters(javax.xml.xquery.XQPreparedExpression transformer)
                         throws javax.xml.xquery.XQException
Removes any parameter bindings from the transformer, replacing them with empty strings

Parameters:
transformer - the transformer to remove properties from
Throws:
javax.xml.xquery.XQException

bindDocument

protected void bindDocument(Object src,
                            javax.xml.xquery.XQPreparedExpression transformer)
                     throws Exception
Returns the InputSource corresponding to xqueryFile or xquery

Parameters:
src -
transformer -
Throws:
javax.xml.xquery.XQException
Exception

getConfiguration

public net.sf.saxon.Configuration getConfiguration()

setConfiguration

public void setConfiguration(net.sf.saxon.Configuration configuration)

getXqueryFile

public String getXqueryFile()
Returns:
Returns the xqueryFile.

setXqueryFile

public void setXqueryFile(String xqueryFile)
Parameters:
xqueryFile - The xqueryFile to set.

getXquery

public String getXquery()

setXquery

public void setXquery(String xquery)

getMaxActiveTransformers

public int getMaxActiveTransformers()
Returns:
The current maximum number of allowable active transformer objects in the pool

setMaxActiveTransformers

public void setMaxActiveTransformers(int maxActiveTransformers)
Sets the the current maximum number of active transformer objects allowed in the pool

Parameters:
maxActiveTransformers - New maximum size to set

getMaxIdleTransformers

public int getMaxIdleTransformers()
Returns:
The current maximum number of allowable idle transformer objects in the pool

setMaxIdleTransformers

public void setMaxIdleTransformers(int maxIdleTransformers)
Sets the the current maximum number of idle transformer objects allowed in the pool

Parameters:
maxIdleTransformers - New maximum size to set

getContextProperties

public Map<String,Object> getContextProperties()
Gets the parameters to be used when applying the transformation

Returns:
a map of the parameter names and associated values
See Also:
Transformer.setParameter(java.lang.String, java.lang.Object)

setContextProperties

public void setContextProperties(Map<String,Object> contextProperties)
Sets the parameters to be used when applying the transformation

Parameters:
contextProperties - a map of the parameter names and associated values
See Also:
Transformer.setParameter(java.lang.String, java.lang.Object)

evaluateTransformParameter

protected Object evaluateTransformParameter(String name,
                                            Object value,
                                            MuleMessage message)
                                     throws TransformerException

Returns the value to be set for the parameter. This method is called for each parameter before it is set on the transformer. The purpose of this method is to allow dynamic parameters related to the event (usually message properties) to be used. Any expression using the Mule expression syntax can be used.

For example: If the current event's message has a property named "myproperty", to pass this in you would set the transform parameter's value to be "#[mule.message:header(myproperty)]".

This method may be overloaded by a sub class to provide a different dynamic parameter implementation.

Parameters:
name - the name of the parameter
value - the value of the paramter
Returns:
the object to be set as the parameter value
Throws:
TransformerException

clone

public Object clone()
             throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException


Copyright © 2003-2014 MuleSoft, Inc.. All Rights Reserved.