public class SmooksResourceConfiguration extends Object
Visitor
implementations), some text or script resource, or perhaps
simply a configuration parameter (see ParameterAccessor
).
Visitor
resources at message fragments.
This typically means targeting a piece of tranformation logic (XSLT, Java, Groovy etc)
at a specific fragment of that message. The fragment may
include as much or as little of the document as required. Smooks also allows you to target multilpe
resources at the same fragment.
<?xml version='1.0'?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
<resource-config selector="order/order-header">
<resource type="xsl">/com/acme/transform/OrderHeaderTransformer.xsl</resource>
</resource-config>
<resource-config selector="order-items/order-item">
<resource>com.acme.transform.MyJavaOrderItemTransformer
</resource>
</resource-config>
</smooks-resource-list>
A more complex sample, using profiling. So resource 1 is targeted at both "message-exchange-1" and "message-exchange-2",
whereas resource 2 is only targeted at "message-exchange-1" and resource 3 at "message-exchange-2" (see Smooks.createExecutionContext(String)
).
<?xml version='1.0'?> <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd"> <profiles> <profile base-profile="message-exchange-1" sub-profiles="message-producer-A, message-consumer-B" /> <profile base-profile="message-exchange-2" sub-profiles="message-producer-A, message-consumer-C" /> </profiles> (1) <resource-config selector="order/order-header" target-profile="message-producer-A"> <resource>com.acme.transform.AddIdentityInfo</resource> </resource-config> (2) <resource-config selector="order-items/order-item" target-profile="message-consumer-B"> <resource>com.acme.transform.MyJavaOrderItemTransformer</resource> <param name="execution-param-X">param-value-forB</param> </resource-config> (3) <resource-config selector="order-items/order-item" target-profile="message-consumer-C"> <resource>com.acme.transform.MyJavaOrderItemTransformer</resource> <param name="execution-param-X">param-value-forC</param> </resource-config> </smooks-resource-list>
profile targeting expressions
.
(supports wildcards "*").
Visitor
implementation, the selector
is treated as an XPath expression (full XPath spec not supported), otherwise the selector value is treated as an opaque value.
Visitor
implementation, use the target fragment name e.g. "order", "address", "address/name", "item[2]/price[text() = 99.99]" etc.
Also supports wildcard based fragment selection ("*"). See the User Guide for more details on setting selectors for Visitor
type
resources.
SmooksXMLReader
at a specific profile.Visitor
implementations at fragments from a
specific XML namespace e.g. "http://www.w3.org/2002/xforms". If not defined, the resource
is targeted at all namespces.
Note that since Smooks v1.3, namespace URI-to-prefix mappings can be configured through the "smooks-core" configuration namespace. Then,
selectors can be configured with namespace prefixes, removing the need to use the "selector-namespace" configuration.
SmooksResourceConfigurationSortComparator
Modifier and Type | Field and Description |
---|---|
static String |
DOCUMENT_FRAGMENT_SELECTOR
A special selector for resource targeted at the document as a whole (the roor element).
|
static String |
DOCUMENT_VOID_SELECTOR
A special selector for resource targeted at the document as a whole (the roor element).
|
static String |
LEGACY_DOCUMENT_FRAGMENT_SELECTOR |
static String |
PARAM_RESDATA
Deprecated.
Resource now specified on <resource> element.
Since Configuration DTD v2.0.
|
static String |
PARAM_RESTYPE
Deprecated.
Resource type now specified on "type" attribute of <resource> element.
Since Configuration DTD v2.0.
|
static String |
SELECTOR_NONE |
static String |
XML_DEF_PREFIX
XML selector type definition prefix
|
Constructor and Description |
---|
SmooksResourceConfiguration()
Public default constructor.
|
SmooksResourceConfiguration(String selector)
Public constructor.
|
SmooksResourceConfiguration(String selector,
String resource)
Public constructor.
|
SmooksResourceConfiguration(String selector,
String targetProfile,
String resource)
Public constructor.
|
SmooksResourceConfiguration(String selector,
String selectorNamespaceURI,
String targetProfile,
String resource)
Public constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(SmooksResourceConfigurationChangeListener listener)
Add the specified change listener to the list of change listeners.
|
void |
addParameters(SmooksResourceConfiguration config) |
void |
attachGlobalParameters(ApplicationContext appContext) |
Object |
clone()
Perform a shallow clone of this configuration.
|
boolean |
equals(Object obj) |
static String |
extractTargetAttribute(String[] selectorTokens) |
boolean |
getBoolParameter(String name,
boolean defaultVal)
Get the named SmooksResourceConfiguration parameter as a boolean.
|
byte[] |
getBytes()
Get the resource as a byte array.
|
ExpressionEvaluator |
getConditionEvaluator()
Get the condition evaluator used in targeting of this resource.
|
String[] |
getContextualSelector()
Deprecated.
Use {#link #getSelectorSteps}.
|
String |
getExtendedConfigNS()
Get the extended config namespace from which this configuration was created.
|
Object |
getJavaResourceObject()
Get the Java resource object instance associated with this resource, if one exists and
it has been create.
|
Parameter |
getParameter(String name)
Get the named SmooksResourceConfiguration
parameter . |
int |
getParameterCount()
Get the SmooksResourceConfiguration parameter count.
|
List |
getParameterList()
Get all
parameter values set on this configuration. |
Map<String,Object> |
getParameters()
Get the param map associated with this configuration.
|
List<Parameter> |
getParameters(String name)
Get the named SmooksResourceConfiguration
parameter List. |
ProfileTargetingExpression[] |
getProfileTargetingExpressions()
Get the profile targeting expressions for this SmooksResourceConfiguration.
|
String |
getResource()
Get the resource for this SmooksResourceConfiguration.
|
String |
getResourceType()
Get the resource "type" for this resource.
|
String |
getSelector()
Get the selector definition for this SmooksResourceConfiguration.
|
String |
getSelectorNamespaceURI()
The the selector namespace URI.
|
SelectorStep |
getSelectorStep()
Get the targeting selector step.
|
SelectorStep[] |
getSelectorSteps()
Get the selector steps.
|
String |
getStringParameter(String name)
Get the named SmooksResourceConfiguration parameter.
|
String |
getStringParameter(String name,
String defaultVal)
Get the named SmooksResourceConfiguration parameter.
|
String |
getTargetAttribute()
Get the name of the attribute specified on the selector, if one was
specified.
|
QName |
getTargetAttributeQName()
Get the name of the attribute specified on the selector, if one was
specified.
|
String |
getTargetElement()
Get the name of the target element where the
selector
is targeting the resource at an XML element. |
QName |
getTargetElementQName()
|
String |
getTargetProfile()
Get the target profile string as set in the configuration.
|
boolean |
isDefaultResource()
Is this resource config a default applied resource.
|
boolean |
isInline()
Is this resource defined inline in the configuration, or is it
referenced through a URI.
|
boolean |
isJavaContentHandler()
Is this resource a Java Class.
|
boolean |
isJavaResource()
Does this resource configuration refer to a Java Class resource.
|
boolean |
isSelectorContextual()
Is the resource selector contextual.
|
boolean |
isTargetedAtElement(Element element,
ExecutionContext executionContext)
Is this configuration targeted at the supplied DOM element.
|
boolean |
isTargetedAtElement(SAXElement element,
ExecutionContext executionContext)
Is this configuration targeted at the supplied SAX element.
|
boolean |
isTargetedAtNamespace(String namespace)
Is this resource configuration targets at the same namespace as the
specified elemnt.
|
boolean |
isXmlDef()
Is this selector defininition an XML based definition.
|
SmooksResourceConfiguration |
merge(SmooksResourceConfiguration config) |
static String[] |
parseSelector(String selector) |
void |
removeChangeListener(SmooksResourceConfigurationChangeListener listener)
Remove the specified change listener from the list of change listeners.
|
void |
removeParameter(String name)
Remove the named parameter.
|
void |
setConditionEvaluator(ExpressionEvaluator expressionEvaluator)
Set the condition evaluator to be used in targeting of this resource.
|
void |
setDefaultResource(boolean defaultResource)
Set this resource config as a default applied resource.
|
void |
setExtendedConfigNS(String extendedConfigNS)
Set the extended config namespace from which this configuration was created.
|
void |
setJavaResourceObject(Object javaResourceObject)
Set the Java resource object instance associated with this resource.
|
void |
setParameter(Parameter parameter) |
Parameter |
setParameter(String name,
String value)
Set the named SmooksResourceConfiguration parameter value (default type - String).
|
Parameter |
setParameter(String name,
String type,
String value)
Set the named SmooksResourceConfiguration parameter value (with type).
|
void |
setResource(String resource)
Set the configs "resource".
|
void |
setResourceType(String resourceType)
Explicitly set the resource type.
|
void |
setSelector(String selector)
Set the config selector.
|
void |
setSelectorNamespaceURI(String namespaceURI)
Set the namespace URI to which the selector is associated.
|
void |
setSelectorSteps(SelectorStep[] selectorSteps)
Set the selector steps.
|
void |
setTargetProfile(String targetProfile)
Set the configs "target profile".
|
Class |
toJavaResource()
Returns the resource as a Java Class instance.
|
Properties |
toProperties()
Create a
Properties instance from this supplied SmooksResourceConfiguration |
String |
toString() |
String |
toXML()
Generate an XML'ified description of this resource.
|
public static final String PARAM_RESTYPE
public static final String PARAM_RESDATA
public static final String XML_DEF_PREFIX
public static final String SELECTOR_NONE
public static final String DOCUMENT_FRAGMENT_SELECTOR
public static final String LEGACY_DOCUMENT_FRAGMENT_SELECTOR
public static final String DOCUMENT_VOID_SELECTOR
public SmooksResourceConfiguration()
public SmooksResourceConfiguration(String selector)
selector
- The selector definition.setSelectorNamespaceURI(String)
,
setTargetProfile(String)
,
setResource(String)
,
setResourceType(String)
,
setParameter(String, String)
public SmooksResourceConfiguration(String selector, String resource)
selector
- The selector definition.resource
- The resource.setSelectorNamespaceURI(String)
,
setTargetProfile(String)
,
setResourceType(String)
,
setParameter(String, String)
public SmooksResourceConfiguration(String selector, String targetProfile, String resource)
selector
- The selector definition.targetProfile
- Target Profile(s). Comma separated list of
ProfileTargetingExpressions
.resource
- The resource.setSelectorNamespaceURI(String)
,
setResourceType(String)
,
setParameter(String, String)
public SmooksResourceConfiguration(String selector, String selectorNamespaceURI, String targetProfile, String resource)
selector
- The selector definition.selectorNamespaceURI
- The selector namespace URI.targetProfile
- Target Profile(s). Comma separated list of
ProfileTargetingExpressions
.resource
- The resource.setResourceType(String)
,
setParameter(String, String)
public Object clone()
public String getExtendedConfigNS()
public void setExtendedConfigNS(String extendedConfigNS)
extendedConfigNS
- The extended config namespace from which this configuration was created.public void attachGlobalParameters(ApplicationContext appContext)
public SmooksResourceConfiguration merge(SmooksResourceConfiguration config)
public void addParameters(SmooksResourceConfiguration config)
public void setSelector(String selector)
selector
- The selector definition.public void setSelectorNamespaceURI(String namespaceURI)
namespaceURI
- Selector namespace.public void setResource(String resource)
resource
- The resource.public Object getJavaResourceObject()
public void setJavaResourceObject(Object javaResourceObject)
javaResourceObject
- The Java resource object instance associated with this resource.public boolean isInline()
public String getTargetProfile()
public void setTargetProfile(String targetProfile)
targetProfile
- Target Profile(s). Comma separated list of
ProfileTargetingExpressions
.public void setResourceType(String resourceType)
resourceType
- The resource type.public String getSelector()
public String[] getContextualSelector()
public void setSelectorSteps(SelectorStep[] selectorSteps)
selectorSteps
- The selector steps.public SelectorStep[] getSelectorSteps()
public SelectorStep getSelectorStep()
public String getTargetElement()
selector
is targeting the resource at an XML element.
Accomodates the fact that element based selectors can be contextual. This method
is not relevant where the selector is not targeting an XML element.
See details about the "selector" attribute in the
Attribute Definitions section.public QName getTargetElementQName()
QName
of the target element where the selector
is targeting the resource at an XML element.
Accomodates the fact that element based selectors can be contextual. This method
is not relevant where the selector is not targeting an XML element.
See details about the "selector" attribute in the
Attribute Definitions section.QName
.public String getTargetAttribute()
public QName getTargetAttributeQName()
public String getSelectorNamespaceURI()
public ProfileTargetingExpression[] getProfileTargetingExpressions()
public String getResource()
public void setConditionEvaluator(ExpressionEvaluator expressionEvaluator)
expressionEvaluator
- The ExpressionEvaluator
, or null if no condition is to be used.public ExpressionEvaluator getConditionEvaluator()
ExpressionEvaluator
, or null if no condition is specified.public boolean isDefaultResource()
DefaultSerializationUnit
or
DefaultSAXElementSerializer
) are applied by default when no other
resources are targeted at an element.public void setDefaultResource(boolean defaultResource)
DefaultSerializationUnit
or
DefaultSAXElementSerializer
) are applied by default when no other
resources are targeted at an element.defaultResource
- True if this is a default applied resource, otherwise false.public String getResourceType()
isJavaResource()
. If it is, return "class".public Parameter setParameter(String name, String value)
name
- Parameter name.value
- Parameter value.public Parameter setParameter(String name, String type, String value)
name
- Parameter name.type
- Parameter type.value
- Parameter value.public void setParameter(Parameter parameter)
public Parameter getParameter(String name)
parameter
.
If there is more than one of the named parameters defined, the first
defined value is returned.name
- Name of parameter to get.public Map<String,Object> getParameters()
public List<Parameter> getParameters(String name)
parameter
List.public String getStringParameter(String name)
name
- Name of parameter to get.public String getStringParameter(String name, String defaultVal)
name
- Name of parameter to get.defaultVal
- The default value to be returned if there are no
parameters on the this SmooksResourceConfiguration instance, or the parameter is not defined.public boolean getBoolParameter(String name, boolean defaultVal)
name
- Name of parameter to get.defaultVal
- The default value to be returned if there are no
parameters on the this SmooksResourceConfiguration instance, or the parameter is not defined.public int getParameterCount()
public void removeParameter(String name)
name
- The name of the parameter to be removed.public boolean isXmlDef()
public byte[] getBytes()
URIResourceLocator
i.e. the path will be enterpretted as a URI
.
If the resource doesn't resolve to a stream producing URI, the resource string will be converted to
bytes and returned.public Class toJavaResource()
public boolean isJavaResource()
public boolean isJavaContentHandler()
public boolean isTargetedAtNamespace(String namespace)
namespace
- The element to check against.public boolean isSelectorContextual()
public boolean isTargetedAtElement(Element element, ExecutionContext executionContext)
element
- The element to be checked.executionContext
- The current execution context.public boolean isTargetedAtElement(SAXElement element, ExecutionContext executionContext)
element
- The element to be checked.executionContext
- The current execution context.public void addChangeListener(SmooksResourceConfigurationChangeListener listener)
listener
- The listener instance.public void removeChangeListener(SmooksResourceConfigurationChangeListener listener)
listener
- The listener instance.public String toXML()
public Properties toProperties()
Properties
instance from this supplied SmooksResourceConfiguration
Properties
instance.Copyright © 2020. All rights reserved.