|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.milyn.cdr.SmooksResourceConfiguration
public class SmooksResourceConfiguration
Smooks Resource Targeting Configuration.
A Content Delivery Resource is anything that can be used by Smooks in the process of analysing or transforming a data stream. They could be pieces of Java logic (DOMElementVisitor,
SerializationUnit), some text or script resource, or perhaps
simply a configuration parameter (see ParameterAccessor).
SmooksResourceConfigurationSortComparator).
Note you don't have to use message profiling. You can simply create a set of configurations
that are only targeted at message fragments (no profiling info), supply them to a
Smooks instance and then use an ExecutionContext
instance that's not based on a profile (see Smooks.createExecutionContext()). This is
definitely the easiest way to start using Smooks.
<?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 "*").
SmooksXMLReader at a specific profile.ContentHandlers at XML elements from a
specific XML namespace e.g. "http://www.w3.org/2002/xforms". If not defined, the resource
is targeted at all namespces.
SmooksResourceConfigurationSortComparator| Field Summary | |
|---|---|
static String |
DOCUMENT_FRAGMENT_SELECTOR
A special selector for resource targeted at the document as a whole (the roor element). |
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 |
XML_DEF_PREFIX
XML selector type definition prefix |
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
Object |
clone()
Perform a shallow clone of this configuration. |
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()
Get the contextual selector definition for this SmooksResourceConfiguration. |
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 |
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. |
String |
getStringParameter(String name)
Get the named SmooksResourceConfiguration parameter. |
String |
getStringParameter(String name,
String defaultVal)
Get the named SmooksResourceConfiguration parameter. |
String |
getTargetElement()
Get the name of the target element where the selector
is targeting the resource at an XML element. |
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 ContentHandler resource. |
boolean |
isJavaResource()
Does this resource configuration refer to a Java Class resource. |
boolean |
isSelectorContextual()
Is the resource selector contextual. |
boolean |
isTargetedAtElement(Element element)
Is this configuration targeted at the supplied DOM element. |
boolean |
isTargetedAtElement(SAXElement element)
Is this configuration targeted at the supplied SAX element. |
boolean |
isTargetedAtElementContext(Element element)
Is this resource configuration targeted at the specified DOM element in context. |
boolean |
isTargetedAtElementContext(SAXElement element)
Is this resource configuration targeted at the specified SAX element in context. |
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. |
static String[] |
parseSelector(String selector)
|
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 |
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 |
setTargetProfile(String targetProfile)
Set the configs "target profile". |
Class |
toJavaResource()
Returns the resource as a Java Class instance. |
String |
toString()
|
String |
toXML()
Generate an XML'ified description of this resource. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String PARAM_RESTYPE
public static final String PARAM_RESDATA
public static final String XML_DEF_PREFIX
public static final String DOCUMENT_FRAGMENT_SELECTOR
| Constructor Detail |
|---|
public SmooksResourceConfiguration()
setSelector(String),
setSelectorNamespaceURI(String),
setTargetProfile(String),
setResource(String),
setResourceType(String),
setParameter(String, String)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)| Method Detail |
|---|
public Object clone()
clone in class Objectpublic void setSelector(String selector)
selector - The selector definition.public static String[] parseSelector(String selector)
public void setSelectorNamespaceURI(String namespaceURI)
namespaceURI - Selector namespace.public void setResource(String resource)
resource - The 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 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 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()
Parameter or parameter list (List<Parameter>).public List getParameterList()
parameter values set on this configuration.
Parameter value List, or null if not set.public List getParameters(String name)
parameter List.
name - Name of parameter to get.
Parameter value List, or null if not set.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 String toString()
toString in class Objectpublic 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()
ContentHandler resource.
ContentHandler class, otherwise false.public boolean isTargetedAtNamespace(String namespace)
namespace - The element to check against.
public boolean isSelectorContextual()
public boolean isTargetedAtElementContext(Element element)
element - The element to check against.
public boolean isTargetedAtElementContext(SAXElement element)
element - The element to check against.
public boolean isTargetedAtElement(Element element)
element - The element to be checked.
public boolean isTargetedAtElement(SAXElement element)
element - The element to be checked.
public String toXML()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||