Package org.openehealth.ipf.commons.xml
Class AbstractCachingXmlProcessor<T>
java.lang.Object
org.openehealth.ipf.commons.xml.AbstractCachingXmlProcessor<T>
- Type Parameters:
- T- resource type.
- Direct Known Subclasses:
- XqjTransmogrifier,- XsdValidator,- XsltTransmogrifier
Abstract parent class for XML validators, transmogrifiers, and other classes
 which cache static external resources in memory.
 
On the basis of validator/transmogrifier parameters (
On the basis of validator/transmogrifier parameters (
Object... params),
 instances of this class determine:
 - Location of the raw resource (i.e. an unparsed XSLT document as opposed
 to its compiled representation in memory) — method resourceLocation(Object...),
- Parameters of resource instantiation (compilation) and execution (application) —
 method resourceParameters(Object...),
- Key to store the compiled resource in the cache —
 method resourceCacheKey(Object...).
resource(Object...),
 which takes over instantiation, initialization, caching, and other aspects of resource
 lifecycle.  For resource instantiation step, it calls the createResource(Object...)
 method, which is truly resource-type specific and thus declared as abstract
 in the given base class.- 
Nested Class SummaryNested Classes
- 
Field SummaryFields
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractCachingXmlProcessor(ClassLoader classLoader) Constructor.
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract TcreateResource(Object... params) Creates a ready-to-use resource (e.g. an XML Schema instance) for the given key.protected abstract ConcurrentMap<String, AbstractCachingXmlProcessor.Loader<T>> getCache()protected TRetrieves from the cache and returns the resource with the given location and further attributes.protected StringresourceCacheKey(Object... params) Extracts (constructs) resource cache key validator/transmogrifier parameters.protected StreamSourceresourceContent(Object... params) Loads the resource into memory and returns it as a Stream.protected StringresourceLocation(Object... params) Extracts (constructs) resource location from validator/transmogrifier parameters.resourceParameters(Object... params) Extracts (constructs) resource creation/application parameters from validator/transmogrifier parameters.
- 
Field Details- 
RESOURCE_LOCATION- See Also:
 
 
- 
- 
Constructor Details- 
AbstractCachingXmlProcessorConstructor.- Parameters:
- classLoader- class loader, may be- null.
 
 
- 
- 
Method Details- 
getCache- Returns:
- static cache for the configured resource type. Note that the returned Map is not necessarily synchronized.
 
- 
resourceLocationExtracts (constructs) resource location from validator/transmogrifier parameters.- Parameters:
- params- validator/transmogrifier parameters.
- Returns:
- resource location as a String.
 
- 
resourceCacheKeyExtracts (constructs) resource cache key validator/transmogrifier parameters. Per default, the key equals to the resource location.- Parameters:
- params- validator/transmogrifier parameters.
- Returns:
- cache key as a String.
 
- 
resourceParametersExtracts (constructs) resource creation/application parameters from validator/transmogrifier parameters.- Parameters:
- params- validator/transmogrifier parameters.
- Returns:
- resource creation/application parameters as a Map,
 or nullif not found.
 
- 
resourceRetrieves from the cache and returns the resource with the given location and further attributes. If necessary, creates the resource by means ofcreateResource(Object...)and stores it into the cache. The cache key is a combination of the location and further attributes. This method MUST be re-entrant, its result MUST be thread-safe.- Parameters:
- params- validator/transmogrifier parameters.
- Returns:
- resource instance.
- Throws:
- Exception- exception
 
- 
createResourceCreates a ready-to-use resource (e.g. an XML Schema instance) for the given key. Insertion into the cache will happen externally, this method's purpose is only to instantiate the resource to be cached. This method does not need to be re-entrant, but its result MUST be thread-safe.- Parameters:
- params- validator/transmogrifier parameters.
- Returns:
- resource of the configured type.
 
- 
resourceContentLoads the resource into memory and returns it as a Stream. This method does not need to be re-entrant.- Parameters:
- params- validator/transmogrifier parameters.
- Returns:
- resource of the configured type.
 
 
-