Class XmlSchemaValidatorImpl
- java.lang.Object
-
- com.adaptris.core.transform.MessageValidatorImpl
-
- com.adaptris.core.transform.schema.XmlSchemaValidatorImpl
-
- All Implemented Interfaces:
ComponentLifecycle
,ComponentLifecycleExtension
,MessageValidator
- Direct Known Subclasses:
BasicXmlSchemaValidator
public abstract class XmlSchemaValidatorImpl extends MessageValidatorImpl
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.transform.MessageValidatorImpl
log
-
-
Constructor Summary
Constructors Constructor Description XmlSchemaValidatorImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the component.java.lang.String
getSchema()
Returns the schema to validate against.AdaptrisConnection
getSchemaCache()
void
init()
Initialises the component.void
prepare()
Prepare for initialisation.protected javax.xml.validation.Schema
resolveFromCache(java.lang.String urlString)
protected javax.xml.validation.Schema
resolveSchema(AdaptrisMessage msg)
void
setSchema(java.lang.String s)
Sets the schema to validate against.void
setSchemaCache(AdaptrisConnection cache)
Configure the internal cache for schemas.void
start()
Starts the component.void
stop()
Stop the component<T extends XmlSchemaValidatorImpl>
TwithSchema(java.lang.String c)
<T extends XmlSchemaValidatorImpl>
TwithSchemaCache(AdaptrisConnection c)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.transform.MessageValidator
validate
-
-
-
-
Method Detail
-
prepare
public void prepare() throws CoreException
Description copied from interface:ComponentLifecycleExtension
Prepare for initialisation.- Specified by:
prepare
in interfaceComponentLifecycleExtension
- Overrides:
prepare
in classMessageValidatorImpl
- Throws:
CoreException
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Throws:
CoreException
- wrapping any underlyingException
s
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.- Throws:
CoreException
- wrapping any underlyingException
s
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing aRuntimeException
may cause unintended consequences
-
close
public void close()
Description copied from interface:ComponentLifecycle
Closes the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeException
may cause unintended consequences
-
resolveSchema
protected javax.xml.validation.Schema resolveSchema(AdaptrisMessage msg) throws java.lang.Exception
- Throws:
java.lang.Exception
-
resolveFromCache
protected javax.xml.validation.Schema resolveFromCache(java.lang.String urlString) throws java.lang.Exception
- Throws:
java.lang.Exception
-
setSchema
public void setSchema(java.lang.String s)
Sets the schema to validate against. May not be null or empty.- Parameters:
s
- the schema to validate against, normally a URL.
-
getSchema
public java.lang.String getSchema()
Returns the schema to validate against.- Returns:
- the schema to validate against
-
getSchemaCache
public AdaptrisConnection getSchemaCache()
-
setSchemaCache
public void setSchemaCache(AdaptrisConnection cache)
Configure the internal cache for schemas.While it is possible to configure a distributed cache (a-la ehcache or JSR107) the
Schema
object isn't serializable, so you may run into issues. It will be best to stick withExpiringMapCache
if you want to enable caching. The default behaviour is to cache 16 schemas for a max of 2 hours (last-access) if you don't explicitly configure it differently.- Parameters:
cache
- the cache, generally aCacheConnection
orSharedConnection
.
-
withSchemaCache
public <T extends XmlSchemaValidatorImpl> T withSchemaCache(AdaptrisConnection c)
-
withSchema
public <T extends XmlSchemaValidatorImpl> T withSchema(java.lang.String c)
-
-