Package com.tangosol.config.xml
Class AbstractNamespaceHandler
- java.lang.Object
-
- com.tangosol.config.xml.AbstractNamespaceHandler
-
- All Implemented Interfaces:
NamespaceHandler
- Direct Known Subclasses:
CacheConfigNamespaceHandler
,CdiNamespaceHandler
,JCacheExtendNamespace
,JCacheNamespace
,OperationalConfigNamespaceHandler
public abstract class AbstractNamespaceHandler extends Object implements NamespaceHandler
AnAbstractNamespaceHandler
provides a base implementation of aNamespaceHandler
with support for implicit and explicit registration ofElementProcessor
s andAttributeProcessor
s for those xml attributes and elements occurring in the associated xml namespace.- Since:
- Coherence 12.1.2
- Author:
- bo 2011.06.20
-
-
Constructor Summary
Constructors Constructor Description AbstractNamespaceHandler()
Construct anAbstractNamespaceHandler
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributeProcessor<?>
getAttributeProcessor(XmlAttribute attribute)
Obtains theAttributeProcessor
that is suitable for processing the specifiedXmlAttribute
in the xml namespace associated with thisNamespaceHandler
.AttributeProcessor<?>
getAttributeProcessor(String localName)
Obtains theAttributeProcessor
registered with the specified localName (in the namespace).DocumentPreprocessor
getDocumentPreprocessor()
Obtains theDocumentPreprocessor
that must be applied to theXmlElement
(ie: document) in which theNamespaceHandler
is defined, prior toXmlElement
s andXmlAttribute
s being processed defined by thisNamespaceHandler
.ElementProcessor<?>
getElementProcessor(XmlElement element)
Obtains theElementProcessor
that is suitable for processing the specifiedXmlElement
in the xml namespace associated with thisNamespaceHandler
.ElementProcessor<?>
getElementProcessor(String localName)
Obtains theElementProcessor
registered with the specified localName (in the namespace).void
onEndNamespace(ProcessingContext context, XmlElement element, String prefix, URI uri)
Called when the xml namespace associated with theNamespaceHandler
is last encountered in an xml document.void
onStartNamespace(ProcessingContext context, XmlElement element, String prefix, URI uri)
Called when the xml namespace associated with theNamespaceHandler
is first encountered in an xml document.protected AttributeProcessor<?>
onUnknownAttribute(XmlAttribute attribute)
A call-back to handle when anXmlAttribute
is unknown to theNamespaceHandler
.protected ElementProcessor<?>
onUnknownElement(XmlElement element)
A call-back to handle when anXmlElement
is unknown to theNamespaceHandler
.<T> void
registerAttributeType(String sLocalName, Class<T> clzType)
Registers (internally creates) an appropriateAttributeProcessor
forXmlAttribute
s with the specified local name so that they produce the specified type of value when processed.<T> void
registerElementType(String sLocalName, Class<T> clzType)
Registers (internally creates) an appropriateElementProcessor
forXmlElement
s with the specified local name so that they produce the specified type of value when processed.void
registerProcessor(Class<?> clzProcessor)
Registers the specified processor as anElementProcessor
orAttributeProcessor
(based on the interfaces it implements) using theXmlSimpleName
annotation to determine the localName of the said processor.void
registerProcessor(String sLocalName, AttributeProcessor<?> processor)
Registers anAttributeProcessor
forXmlAttribute
s with the specified name.void
registerProcessor(String sLocalName, ElementProcessor<?> processor)
Registers anElementProcessor
forXmlElement
s with a name with in the context of theNamespaceHandler
namespace.void
setDocumentPreprocessor(DocumentPreprocessor preprocessor)
Sets theDocumentPreprocessor
for theNamespaceHandler
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.tangosol.config.xml.NamespaceHandler
getOverrideProcessor
-
-
-
-
Constructor Detail
-
AbstractNamespaceHandler
public AbstractNamespaceHandler()
Construct anAbstractNamespaceHandler
.
-
-
Method Detail
-
getDocumentPreprocessor
public DocumentPreprocessor getDocumentPreprocessor()
Obtains theDocumentPreprocessor
that must be applied to theXmlElement
(ie: document) in which theNamespaceHandler
is defined, prior toXmlElement
s andXmlAttribute
s being processed defined by thisNamespaceHandler
.- Specified by:
getDocumentPreprocessor
in interfaceNamespaceHandler
- Returns:
- the
DocumentPreprocessor
ornull
if one is not required or defined for theNamespaceHandler
-
getAttributeProcessor
public AttributeProcessor<?> getAttributeProcessor(XmlAttribute attribute)
Obtains theAttributeProcessor
that is suitable for processing the specifiedXmlAttribute
in the xml namespace associated with thisNamespaceHandler
.- Specified by:
getAttributeProcessor
in interfaceNamespaceHandler
- Parameters:
attribute
- theXmlAttribute
- Returns:
- the
AttributeProcessor
ornull
if a suitableAttributeProcessor
could not be found
-
getElementProcessor
public ElementProcessor<?> getElementProcessor(XmlElement element)
Obtains theElementProcessor
that is suitable for processing the specifiedXmlElement
in the xml namespace associated with thisNamespaceHandler
.- Specified by:
getElementProcessor
in interfaceNamespaceHandler
- Parameters:
element
- theXmlElement
- Returns:
- the
ElementProcessor
ornull
if a suitableElementProcessor
could not be found
-
onStartNamespace
public void onStartNamespace(ProcessingContext context, XmlElement element, String prefix, URI uri)
Called when the xml namespace associated with theNamespaceHandler
is first encountered in an xml document.- Specified by:
onStartNamespace
in interfaceNamespaceHandler
- Parameters:
context
- the documentProcessingContext
in which the xml namespace was encounteredelement
- theXmlElement
in which the xml namespace was encounteredprefix
- the prefix of the declared xml namespaceuri
- theURI
of the declared xml namespace
-
onEndNamespace
public void onEndNamespace(ProcessingContext context, XmlElement element, String prefix, URI uri)
Called when the xml namespace associated with theNamespaceHandler
is last encountered in an xml document.- Specified by:
onEndNamespace
in interfaceNamespaceHandler
- Parameters:
context
- the documentProcessingContext
in which the xml namespace was encounteredelement
- theXmlElement
in which the xml namespace was encounteredprefix
- the prefix of the declared xml namespaceuri
- theURI
of the declared xml namespace
-
setDocumentPreprocessor
public void setDocumentPreprocessor(DocumentPreprocessor preprocessor)
Sets theDocumentPreprocessor
for theNamespaceHandler
.- Parameters:
preprocessor
- theDocumentPreprocessor
-
registerProcessor
public void registerProcessor(Class<?> clzProcessor)
Registers the specified processor as anElementProcessor
orAttributeProcessor
(based on the interfaces it implements) using theXmlSimpleName
annotation to determine the localName of the said processor.Note: The specified class must have a no-args constructor.
- Parameters:
clzProcessor
- A class that implements either (or both)ElementProcessor
orAttributeProcessor
that is annotated with @XmlSimpleName
to specify it's localName.
-
registerProcessor
public void registerProcessor(String sLocalName, ElementProcessor<?> processor)
Registers anElementProcessor
forXmlElement
s with a name with in the context of theNamespaceHandler
namespace.- Parameters:
sLocalName
- The local name of theXmlElement
to be processed with theElementProcessor
processor
- TheElementProcessor
-
registerProcessor
public void registerProcessor(String sLocalName, AttributeProcessor<?> processor)
Registers anAttributeProcessor
forXmlAttribute
s with the specified name.- Parameters:
sLocalName
- The local name of theXmlAttribute
to be processed with theAttributeProcessor
processor
- TheAttributeProcessor
-
registerElementType
public <T> void registerElementType(String sLocalName, Class<T> clzType)
Registers (internally creates) an appropriateElementProcessor
forXmlElement
s with the specified local name so that they produce the specified type of value when processed.- Type Parameters:
T
- the type of value the registeredElementProcessor
will produce- Parameters:
sLocalName
- The local name of theXmlElement
s to be associated with the typeclzType
- TheClass
of value that should be produced for theXmlElement
-
registerAttributeType
public <T> void registerAttributeType(String sLocalName, Class<T> clzType)
Registers (internally creates) an appropriateAttributeProcessor
forXmlAttribute
s with the specified local name so that they produce the specified type of value when processed.- Type Parameters:
T
- the type of value the registeredAttributeProcessor
will produce- Parameters:
sLocalName
- The local name of theXmlElement
s to be associated with the typeclzType
- TheClass
of value that should be produced for theXmlAttribute
-
onUnknownAttribute
protected AttributeProcessor<?> onUnknownAttribute(XmlAttribute attribute)
A call-back to handle when anXmlAttribute
is unknown to theNamespaceHandler
.Override this method to provide specialized foreign
XmlAttribute
processing. By default,null
will be returned for unknownXmlAttribute
s.- Parameters:
attribute
- TheXmlAttribute
that was unknown.- Returns:
- An appropriate
AttributeProcessor
that may be used to process the unknownXmlAttribute
ornull
if no special processing should occur.
-
onUnknownElement
protected ElementProcessor<?> onUnknownElement(XmlElement element)
A call-back to handle when anXmlElement
is unknown to theNamespaceHandler
.Override this method to provide specialized foreign
XmlElement
processing. By default, unknownXmlElement
will return anElementProcessor
that when attempting to process the said element, will throw aConfigurationException
.- Parameters:
element
- TheXmlElement
that was unknown.- Returns:
- An appropriate
ElementProcessor
that may be used to process the unknownXmlElement
ornull
if no special processing should occur.
-
getAttributeProcessor
public AttributeProcessor<?> getAttributeProcessor(String localName)
Obtains theAttributeProcessor
registered with the specified localName (in the namespace).- Parameters:
localName
- the name of theAttributeProcessor
to return- Returns:
- the
AttributeProcessor
ornull
if not found
-
getElementProcessor
public ElementProcessor<?> getElementProcessor(String localName)
Obtains theElementProcessor
registered with the specified localName (in the namespace).- Parameters:
localName
- the name of theElementProcessor
to return- Returns:
- the
ElementProcessor
ornull
if not found
-
-