public class CachingJaxbLoaderImpl<T> extends Object implements CachingJaxbLoader<T>
Resource to determine when to reload. If that fails
the resource is reloaded periodically as specified by the setNoLastModifiedReloadPeriod(long) property.
The class determines the return type and the base package to use for the JAXBContext.newInstance(String) call
via the loadedType parameter provided to the constructor.CachingJaxbLoader.UnmarshallingCallback<T>| Modifier and Type | Field and Description |
|---|---|
protected long |
lastModifiedTime |
protected Class<T> |
loadedType |
protected org.springframework.core.io.Resource |
mappedXmlResource |
protected long |
noLastModifiedReloadPeriod |
protected T |
unmarshalledObject |
| Constructor and Description |
|---|
CachingJaxbLoaderImpl(Class<T> loadedType) |
| Modifier and Type | Method and Description |
|---|---|
protected JAXBContext |
getJAXBContext() |
protected Long |
getLastModified() |
org.springframework.core.io.Resource |
getMappedXmlResource() |
long |
getNoLastModifiedReloadPeriod() |
T |
getUnmarshalledObject()
Loads and unmarshalls the XML as needed, returning the unmarshalled object
|
T |
getUnmarshalledObject(CachingJaxbLoader.UnmarshallingCallback<T> callback) |
protected Unmarshaller |
getUnmarshaller(JAXBContext jaxbContext) |
protected InputStream |
getXmlInputStream() |
protected boolean |
isCacheValid(Long lastModified)
Determines if the cached unmarshalled object is still valid
|
void |
setMappedXmlResource(org.springframework.core.io.Resource mappedXmlResource)
The XML resource to load.
|
void |
setNoLastModifiedReloadPeriod(long noLastModifiedReloadPeriod)
Period between reloads if last-modified of the
Resource cannot be determined |
protected T |
unmarshal(InputStream xmlInputStream,
Unmarshaller unmarshaller) |
protected long noLastModifiedReloadPeriod
protected org.springframework.core.io.Resource mappedXmlResource
protected T unmarshalledObject
protected long lastModifiedTime
public long getNoLastModifiedReloadPeriod()
public void setNoLastModifiedReloadPeriod(long noLastModifiedReloadPeriod)
Resource cannot be determinednoLastModifiedReloadPeriod - period between reloadspublic org.springframework.core.io.Resource getMappedXmlResource()
public void setMappedXmlResource(org.springframework.core.io.Resource mappedXmlResource)
mappedXmlResource - XML resource to loadpublic T getUnmarshalledObject()
CachingJaxbLoadergetUnmarshalledObject in interface CachingJaxbLoader<T>public T getUnmarshalledObject(CachingJaxbLoader.UnmarshallingCallback<T> callback)
getUnmarshalledObject in interface CachingJaxbLoader<T>callback - Callback that will be executed after the object is unmarshalled (if it needs to be) but before it is returnedCachingJaxbLoader.getUnmarshalledObject()protected Long getLastModified()
protected boolean isCacheValid(Long lastModified)
lastModified - last modified timestamp of the resource, null if not known.protected InputStream getXmlInputStream()
protected JAXBContext getJAXBContext()
protected Unmarshaller getUnmarshaller(JAXBContext jaxbContext)
jaxbContext - The context to get an unmarshaller forprotected T unmarshal(InputStream xmlInputStream, Unmarshaller unmarshaller)
xmlInputStream - InputStream to read the XML fromunmarshaller - Unmarshaller to generate the object from the XML withCopyright © 2015 Jasig. All Rights Reserved.