public class CachingJaxbLoaderImpl<T> extends java.lang.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 java.lang.Class<T> |
loadedType |
protected org.springframework.core.io.Resource |
mappedXmlResource |
protected long |
noLastModifiedReloadPeriod |
protected T |
unmarshalledObject |
| Constructor and Description |
|---|
CachingJaxbLoaderImpl(java.lang.Class<T> loadedType) |
| Modifier and Type | Method and Description |
|---|---|
protected javax.xml.bind.JAXBContext |
getJAXBContext() |
protected java.lang.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 javax.xml.bind.Unmarshaller |
getUnmarshaller(javax.xml.bind.JAXBContext jaxbContext) |
protected java.io.InputStream |
getXmlInputStream() |
protected boolean |
isCacheValid(java.lang.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(java.io.InputStream xmlInputStream,
javax.xml.bind.Unmarshaller unmarshaller) |
protected final java.lang.Class<T> loadedType
protected long noLastModifiedReloadPeriod
protected org.springframework.core.io.Resource mappedXmlResource
protected T unmarshalledObject
protected long lastModifiedTime
public CachingJaxbLoaderImpl(java.lang.Class<T> loadedType)
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 java.lang.Long getLastModified()
protected boolean isCacheValid(java.lang.Long lastModified)
lastModified - last modified timestamp of the resource, null if not known.protected java.io.InputStream getXmlInputStream()
protected javax.xml.bind.JAXBContext getJAXBContext()
protected javax.xml.bind.Unmarshaller getUnmarshaller(javax.xml.bind.JAXBContext jaxbContext)
jaxbContext - The context to get an unmarshaller forprotected T unmarshal(java.io.InputStream xmlInputStream, javax.xml.bind.Unmarshaller unmarshaller)
xmlInputStream - InputStream to read the XML fromunmarshaller - Unmarshaller to generate the object from the XML withCopyright © 2005-2018. All Rights Reserved.