Package org.smooks.api.resource.config
Interface ResourceConfig
-
- All Known Implementing Classes:
DefaultResourceConfig
public interface ResourceConfig
A configuration for a Smooks resource.ResourceConfig
controls the behaviour of a Smooks resource, including:- which event/s from the input stream target the resource
- the parameters injected into the resource
- the type of resource that is instantiated
A
ResourceConfig
can be configured through Java code but it is easier to configure through XML. The following are a few sample configurations. Explanations follow the samples.Basic Sample
<?xml version='1.0'?> <smooks-resource-list xmlns="https://www.smooks.org/xsd/smooks-2.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>
The resource-config XML element maps directly to an instance ofcom.acme.transform.MyJavaOrderItemTransformer
</resource> </resource-config> </smooks-resource-list>ResourceConfig
.More Complex Sample with Profiling
<?xml version='1.0'?> <smooks-resource-list xmlns="https://www.smooks.org/xsd/smooks-2.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>
The first resource is targeted for both "message-exchange-1" and "message-exchange-2" profiles. The second resource is only targeted for "message-exchange-1" profile and the third resource only for "message-exchange-2" profile (see
Smooks.createExecutionContext(String)
).Attribute Definitions
- target-profile: a list of one or more
profile targeting expressions
(supports wildcards "*"). - selector: selector string. Used by Smooks to lookup a resource config.
This is typically an input fragment name (partial XPath support). This attribute supports a list of comma separated selectors,
allowing you to target a single resource at multiple selector (e.g. fragments). Where the resource is a
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.Example selectors:
- For a
Visitor
, use the target fragment name e.g. "order", "address", "address/name", "item[2]/price[text() = 99.99]" etc. Also supports wildcard based fragment selection (i.e., "*"). See the User Guide for more details on setting selectors forVisitor
type resources. - "#document" is a special selector that targets a resource at the "document" fragment i.e. the whole document, or document root node fragment.
- Targeting a specific
SmooksXMLReader
at a specific profile.
- For a
-
-
Field Summary
Fields Modifier and Type Field Description static String
DOCUMENT_FRAGMENT_SELECTOR
A special selector for resource targeted at the document as a whole (the root element).static String
SELECTOR_NONE
static String
XML_DEF_PREFIX
XML selector type definition prefix
-
Method Summary
-
-
-
Field Detail
-
DOCUMENT_FRAGMENT_SELECTOR
static final String DOCUMENT_FRAGMENT_SELECTOR
A special selector for resource targeted at the document as a whole (the root element).- See Also:
- Constant Field Values
-
XML_DEF_PREFIX
static final String XML_DEF_PREFIX
XML selector type definition prefix- See Also:
- Constant Field Values
-
SELECTOR_NONE
static final String SELECTOR_NONE
- See Also:
- Constant Field Values
-
-
Method Detail
-
copy
ResourceConfig copy()
-
getExtendedConfigNS
@Deprecated String getExtendedConfigNS()
Deprecated.
-
setExtendedConfigNS
@Deprecated void setExtendedConfigNS(String extendedConfigNS)
Deprecated.
-
addParameters
void addParameters(ResourceConfig resourceConfig)
-
setSelector
void setSelector(String selector, Properties namespaces)
-
setResource
void setResource(String resource)
-
isInline
boolean isInline()
-
getTargetProfile
String getTargetProfile()
-
setTargetProfile
void setTargetProfile(String targetProfile)
-
setResourceType
void setResourceType(String resourceType)
-
setSelectorPath
void setSelectorPath(SelectorPath selectorPath)
-
getSelectorPath
SelectorPath getSelectorPath()
-
getProfileTargetingExpressions
ProfileTargetingExpression[] getProfileTargetingExpressions()
-
getResource
String getResource()
-
isDefaultResource
boolean isDefaultResource()
-
setDefaultResource
void setDefaultResource(boolean defaultResource)
-
getResourceType
String getResourceType()
-
setParameter
<T> void setParameter(Parameter<T> parameter)
-
getParameterValues
List<?> getParameterValues()
-
getParameterCount
int getParameterCount()
-
removeParameter
void removeParameter(String name)
-
isXmlDef
boolean isXmlDef()
-
getBytes
byte[] getBytes()
-
isJavaResource
boolean isJavaResource()
-
addChangeListener
void addChangeListener(ResourceConfigChangeListener listener)
-
removeChangeListener
void removeChangeListener(ResourceConfigChangeListener listener)
-
toXml
String toXml()
-
toProperties
Properties toProperties()
-
-