public interface ProcessingContext extends ResourceResolver
ProcessingContext provides contextual information concerning the processing of content in an xml document.
ProcessingContexts additionally provide mechanisms to:
XmlElements.ResourceRegistry provided to the DocumentProcessor associated with the XmlDocument being processed.ParameterResolver provided to the DocumentProcessor associated with the XmlDocument being processed.ElementProcessors and AttributeProcessors that may be used for processing and injecting beans in the ProcessingContext.| Modifier and Type | Method and Description |
|---|---|
<T> void |
addCookie(Class<T> clzCookie, String sCookieName, T cookie)
Adds the specified named and typed cookie to the
ProcessingContext. |
<T> void |
addCookie(Class<T> clzCookie, T cookie)
Adds the specified cookie to the
ProcessingContext. |
void |
definePropertyPath(String sBeanPropertyName, String sXmlPath)
Defines the xml path to locate a specific Java Bean property with in an
XmlElement in the ProcessingContext. |
NamespaceHandler |
ensureNamespaceHandler(String sPrefix, NamespaceHandler handler)
Ensures that the specified
NamespaceHandler for the specified prefix is defined in this ProcessingContext. |
NamespaceHandler |
ensureNamespaceHandler(String sPrefix, URI uri)
Ensures that an
NamespaceHandler with the specified URI is available for use in the ProcessingContext with the specified prefix. |
ClassLoader |
getContextClassLoader()
Obtains the
ClassLoader to use for loading classes in the ProcessingContext. |
<T> T |
getCookie(Class<T> clzCookie)
Locates and returns the cookie with the specified type.
|
<T> T |
getCookie(Class<T> clzCookie, String sCookieName)
Locates and returns the cookie with the specified type and name.
|
com.tangosol.config.expression.ParameterResolver |
getDefaultParameterResolver()
Obtains the
ParameterResolver to use for resolving parameters defined externally to the document being processed (ie: the operating system or container) |
com.tangosol.config.expression.ExpressionParser |
getExpressionParser()
Obtains the configured
ExpressionParser for this ProcessingContext. |
<T> T |
getMandatoryProperty(String sPath, Type typeProperty, XmlElement xmlElement)
Obtains the strongly typed value for the property defined at the path relative to the specified
XmlElement. |
NamespaceHandler |
getNamespaceHandler(String sPrefix)
Obtains the
NamespaceHandler which is capable of processing the namespace with the specified prefix. |
NamespaceHandler |
getNamespaceHandler(URI uri)
Obtains the
NamespaceHandler that is capable of processing the namespace defined with the specified URI. |
Iterable<NamespaceHandler> |
getNamespaceHandlers()
Obtains the
NamespaceHandlers that are currently in scope for this ProcessingContext. |
URI |
getNamespaceURI(String sPrefix)
Obtains the
URI that is associated with the specified prefix. |
<T> T |
getOptionalProperty(String sPath, Type typeProperty, T defaultValue, XmlElement xmlElement)
Obtains the strongly typed value for the property defined at the path relative to the specified
XmlElement. |
ResourceRegistry |
getResourceRegistry()
Obtains the
ResourceRegistry associated with the ProcessingContext. |
<B> B |
inject(B bean, XmlElement xmlElement)
Given the information available in the
ProcessingContext, including the cookies, the ResourceRegistry the XmlElement, its XmlAttributes and/or children, inject appropriately named and typed values into the specified bean (using setter injection). |
boolean |
isPropertyDefined(String sPath, XmlElement xmlElement)
Determines if the specified property is defined at the path relative to the specified
XmlElement. |
Object |
processDocument(String sXml)
Request that the specified xml string (representing an xml document) be processed with appropriate
NamespaceHandlers. |
Object |
processDocument(XmlElement xmlElement)
Request that the specified
XmlElement (representing the root of an XmlDocument) be processed with appropriate NamespaceHandlers. |
Object |
processDocumentAt(String sLocation)
Request that the document specified by the URI/filename (containing the root of an XmlDocument) be processed with appropriate
NamespaceHandlers. |
Object |
processDocumentAt(URI uri)
Request that the document specified by the URI/filename (containing the root of an XmlDocument) be processed with appropriate
NamespaceHandlers. |
Object |
processElement(String sXml)
Request the specified xml string be processed with an appropriate
NamespaceHandler known by the ProcessingContext. |
Object |
processElement(XmlElement xmlElement)
Request the specified
XmlElement to be processed with an appropriate NamespaceHandler known by the ProcessingContext or outer ProcessingContexts. |
Map<String,?> |
processElementsOf(XmlElement xmlElement)
Request that all of the child elements contained with in the specified
XmlElement be processed using appropriate NamespaceHandlers known by the ProcessingContext. |
Map<String,?> |
processForeignElementsOf(XmlElement xmlElement)
Request that all of the child elements contained within the specified
XmlElement that do not belong to the namespace of the said XmlElement are processed using appropriate processes. |
<T> T |
processOnlyElementOf(XmlElement xmlElement)
Request that the only child element contained within the
XmlElement is processed using an appropriate NamespaceHandler known by the ProcessingContext. |
<T> T |
processRemainingElementOf(XmlElement xmlElement)
Request that the last remaining unprocessed child element contained within the specified
XmlElement is processed using an appropriate ElementProcessor. |
Map<String,?> |
processRemainingElementsOf(XmlElement xmlElement)
Request that the last remaining unprocessed children contained within the specified
XmlElement are processed using appropriate ElementProcessors. |
<T> void |
registerAttributeType(Class<T> clzType)
Automatically creates and registers an
AttributeProcessor for the specified type. |
<T> void |
registerElementType(Class<T> clzType)
Automatically creates and registers an
ElementProcessor for the specified type. |
<T> void |
registerProcessor(Class<T> clzType, AttributeProcessor<T> processor)
Registers an
AttributeProcessor that may be used to process specific types of values contained in XmlAttributes with in the ProcessingContext. |
<T> void |
registerProcessor(Class<T> clzType, ElementProcessor<T> processor)
Registers an
ElementProcessor that may be used to process specific types of values contained in XmlElements with in the ProcessingContext. |
getResource, getResourceResourceRegistry getResourceRegistry()
ResourceRegistry associated with the ProcessingContext.ResourceRegistryClassLoader getContextClassLoader()
ClassLoader to use for loading classes in the ProcessingContext.ClassLoadercom.tangosol.config.expression.ParameterResolver getDefaultParameterResolver()
ParameterResolver to use for resolving parameters defined externally to the document being processed (ie: the operating system or container)ParameterResolver.<T> void addCookie(Class<T> clzCookie, String sCookieName, T cookie)
ProcessingContext.
If a cookie with the same name and type exists in the ProcessingContext, it will be replaced by the specified cookie. If a cookie with the same name and type has been defined in an outer ProcessingContext, the specified cookie will hide the cookie defined in the outer ProcessingContext.
T - the type of the cookieclzCookie - the class of the cookiesCookieName - the name of the cookiecookie - the cookie value<T> void addCookie(Class<T> clzCookie, T cookie)
ProcessingContext.
If a cookie of the same type and name (being the name of the class of the said cookie) is already registered with the ProcessingContext, it will be replaced by the specified cookie.
If a cookie of the same type and name has been defined in an outer ProcessingContext, the specified cookie will hide the cookie defined in the outer ProcessingContext.
This method is equivalent to calling: addCookie(clz, clz.getName(), cookie);
T - the type of the cookieclzCookie - the class of the cookiecookie - the cookie value<T> T getCookie(Class<T> clzCookie, String sCookieName)
Locating the cookie involves searching the current ProcessingContext for a matching cookie. If one is not found, the search continues with outer ProcessingContexts until a cookie is either located or there are no more ProcessingContexts, in which case null is returned.
T - the type of the cookieclzCookie - the class of the cookiesCookieName - the name of the cookienull if not defined<T> T getCookie(Class<T> clzCookie)
Locating the cookie involves searching the current ProcessingContext for a matching cookie. If one is not found, the search continues with outer ProcessingContexts until a cookie is either located or there are no more ProcessingContexts, in which case null is returned.
This method is equivalent to calling: getCookie(clz, clz.getName());
T - the type of the cookieclzCookie - the class of the cookienull if not definedvoid definePropertyPath(String sBeanPropertyName, String sXmlPath)
XmlElement in the ProcessingContext.
This method allows "alias" paths for Java Bean properties to be defined so that inject(Object, XmlElement) calls may resolve property values correctly.
This is an advanced feature. Typically this is only used when:
XmlElement or XmlAttribute with in a ProcessingContext.ProcessingContext.sBeanPropertyName - the property name of the beansXmlPath - the xmlPath to the property value<T> void registerProcessor(Class<T> clzType, AttributeProcessor<T> processor)
AttributeProcessor that may be used to process specific types of values contained in XmlAttributes with in the ProcessingContext.
When an AttributeProcessor isn't provided by the associated NamespaceHandler for an XmlAttribute, an attempt is made to use a type specific AttributeProcessor to process an XmlAttribute for injection (with inject(Object, XmlElement)).
T - the typeclzType - the Class typeprocessor - the AttributeProcessor for the type<T> void registerProcessor(Class<T> clzType, ElementProcessor<T> processor)
ElementProcessor that may be used to process specific types of values contained in XmlElements with in the ProcessingContext.
When an ElementProcessor isn't provided by the associated NamespaceHandler for an XmlElement, an attempt is made to use a type specific ElementProcessor to process an XmlElement for injection (with inject(Object, XmlElement)).
T - the typeclzType - the Class typeprocessor - the ElementProcessor for the type<T> void registerAttributeType(Class<T> clzType)
AttributeProcessor for the specified type.
Note: This assumes the type supports a String-based or XmlAttribute-based constructor.
clzType - the type for which to create and register an AttributeProcessor<T> void registerElementType(Class<T> clzType)
ElementProcessor for the specified type.
Note: This assumes the type supports a String-based or XmlElement-based constructor.
clzType - the type for which to create and register an ElementProcessorcom.tangosol.config.expression.ExpressionParser getExpressionParser()
ExpressionParser for this ProcessingContext.ExpressionParserNamespaceHandler ensureNamespaceHandler(String sPrefix, URI uri)
NamespaceHandler with the specified URI is available for use in the ProcessingContext with the specified prefix. If a NamespaceHandler with the specified prefix and URI is not defined by the ProcessingContext, one is instantiated, registered and returned.sPrefix - the prefix of the Xml Namespace to use for the NamespaceHandleruri - the URI detailing the location of the NamespaceHandler. Typically this will be a java class URI, specified as "class://fully.qualified.class.name"NamespaceHandler that is suitable for processing the prefix and URIConfigurationException - when a configuration problem was encounteredNamespaceHandler ensureNamespaceHandler(String sPrefix, NamespaceHandler handler)
NamespaceHandler for the specified prefix is defined in this ProcessingContext.
If a NamespaceHandler for the prefix does not exist in the ProcessingContext, it is added. Otherwise the existing NamespaceHandler for the prefix is returned.
sPrefix - the prefix of the xml Namespace to be associated with the NamespaceHandlerhandler - the NamespaceHandlerNamespaceHandler for the ProcessingContextNamespaceHandler getNamespaceHandler(URI uri)
NamespaceHandler that is capable of processing the namespace defined with the specified URI.uri - the Xml Namespace URI of the NamespaceHandler to locatenull if a NamespaceHandler could not be located for the specified URINamespaceHandler getNamespaceHandler(String sPrefix)
NamespaceHandler which is capable of processing the namespace with the specified prefix.sPrefix - the prefix of the xml namespacenull if a NamespaceHandler could not be located for the specified prefixURI getNamespaceURI(String sPrefix)
URI that is associated with the specified prefix.Iterable<NamespaceHandler> getNamespaceHandlers()
NamespaceHandlers that are currently in scope for this ProcessingContext.Iterable over the NamespaceHandlers in scope.Object processDocumentAt(URI uri) throws ConfigurationException
NamespaceHandlers.
Should the document root contain any unrecognized xml namespaces, an attempt will be made to load appropriate NamespaceHandlers that of which will be used to process said elements in the document.
uri - the URI of the XmlDocument to processConfigurationException - when a configuration problem was encounteredObject processDocumentAt(String sLocation) throws ConfigurationException
NamespaceHandlers.
Should the document root contain any unrecognized xml namespaces, an attempt will be made to load appropriate NamespaceHandlers that of which will be used to process said elements in the document.
sLocation - the URI/filename of the XmlDocument to processConfigurationException - when a configuration problem was encounteredObject processDocument(XmlElement xmlElement) throws ConfigurationException
XmlElement (representing the root of an XmlDocument) be processed with appropriate NamespaceHandlers.
Should the document root contain any unrecognized xml namespaces, an attempt will be made to load appropriate NamespaceHandlers that of which will be used to process said elements in the document.
xmlElement - the root XmlElement of the XmlDocument to processXmlElementConfigurationException - when a configuration problem was encounteredObject processDocument(String sXml) throws ConfigurationException
NamespaceHandlers.
Should the document root contain any unrecognized xml namespaces, an attempt will be made to load appropriate NamespaceHandlers that of which will be used to process said elements in the document.
sXml - a string containing an xml document to processConfigurationException - when a configuration problem was encounteredObject processElement(XmlElement xmlElement) throws ConfigurationException
XmlElement to be processed with an appropriate NamespaceHandler known by the ProcessingContext or outer ProcessingContexts.
Note: Should the element contain any unrecognized xml namespaces, an attempt will be made to load appropriate NamespaceHandlers that of which will be used to process said elements.
xmlElement - the XmlElement to processXmlElement with an appropriate ElementProcessorConfigurationException - when a configuration problem was encounteredObject processElement(String sXml) throws ConfigurationException
NamespaceHandler known by the ProcessingContext.
Note: Should the element contain any unrecognized xml namespaces, an attempt will be made to load appropriate NamespaceHandlers that of which will be used to process said elements.
sXml - the xml to processConfigurationException - when a configuration problem was encounteredMap<String,?> processElementsOf(XmlElement xmlElement) throws ConfigurationException
XmlElement be processed using appropriate NamespaceHandlers known by the ProcessingContext.
This is a convenience method to aid in the processing of all children of an XmlElement. The keys of the returned Map represent the id attributes each child XmlElement. If an XmlElement does not have a specified id attribute, a UUID is generated in it's place.
xmlElement - the parent XmlElement of the children to processMap from identifiable child XmlElements (with id="O___" attributes) and their corresponding processed valuesConfigurationException - when a configuration problem was encounteredMap<String,?> processForeignElementsOf(XmlElement xmlElement) throws ConfigurationException
XmlElement that do not belong to the namespace of the said XmlElement are processed using appropriate processes.
This is a convenience method to aid in the processing of all children of an XmlElement. The keys of the returned Map represent the id attributes each child XmlElement. If an XmlElement does not have a specified id attribute, a UUID is generated in it's place.
xmlElement - the parent XmlElement of the children to processMap from identifiable child XmlElements (with attributes) and their corresponding processed valuesConfigurationException - when a configuration problem was encountered<T> T processOnlyElementOf(XmlElement xmlElement) throws ConfigurationException
XmlElement is processed using an appropriate NamespaceHandler known by the ProcessingContext.xmlElement - the XmlElement in which the child is definedConfigurationException - when a configuration problem was encountered, especially if there is zero or more than one child<T> T processRemainingElementOf(XmlElement xmlElement) throws ConfigurationException
XmlElement is processed using an appropriate ElementProcessor.
This is a convenience method to aid in the processing of an unprocessed child XmlElement of an element.
xmlElement - the parent XmlElement of the unprocessed child to processConfigurationException - if there are zero or more than one unprocessed child in the element, or if some other ConfigurationException occurredMap<String,?> processRemainingElementsOf(XmlElement xmlElement) throws ConfigurationException
XmlElement are processed using appropriate ElementProcessors.
This is a convenience method to aid in the processing of an unprocessed child XmlElements of an element. The keys of the returned Map represent the id attributes each child XmlElement. If an XmlElement does not have a specified id attribute, a UUID is generated in it's place.
xmlElement - the parent XmlElement of the unprocessed children to processMap from identifiable child XmlElements (with attributes) and their corresponding processed valuesConfigurationException - when a configuration problem was encountered
<B> B inject(B bean,
XmlElement xmlElement)
throws ConfigurationException
ProcessingContext, including the cookies, the ResourceRegistry the XmlElement, its XmlAttributes and/or children, inject appropriately named and typed values into the specified bean (using setter injection).
The order in which values are located for injection is as follows; attributed defined by the element, child elements defined by the element, alternative paths to values defined in the ProcessingContext, cookies defined by the ProcessingContext and finally the ResourceRegistry associated with the ProcessingContext.
bean - the bean to be injectedxmlElement - the XmlElement from which values will be derived for injection into the beanProcessingContextConfigurationException - if a configuration is not validboolean isPropertyDefined(String sPath, XmlElement xmlElement) throws ConfigurationException
XmlElement.sPath - the path to the propertyxmlElement - the XmlElement in which the property should be searchedtrue if the property is defined, false otherwiseConfigurationException - if a configuration is not valid<T> T getMandatoryProperty(String sPath, Type typeProperty, XmlElement xmlElement) throws ConfigurationException
XmlElement. If the property is not defined or is of the incorrect type, a ConfigurationException is thrown.T - the type of the propertysPath - the path to the propertytypeProperty - the type of the propertyxmlElement - the XmlElement containing the properties for the objectConfigurationException - if a configuration is not valid, the property can't be located or is of the wrong type<T> T getOptionalProperty(String sPath, Type typeProperty, T defaultValue, XmlElement xmlElement) throws ConfigurationException
XmlElement. If the property is not defined, the defaultValue is returned.T - the type of the propertysPath - the path to the propertytypeProperty - the type of the propertydefaultValue - the value to return if the property is not foundxmlElement - the XmlElement containing the properties for the objectConfigurationException - if a configuration is not valid