Class FileBackedHTTPResource
java.lang.Object
net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
net.shibboleth.ext.spring.resource.HTTPResource
net.shibboleth.ext.spring.resource.FileBackedHTTPResource
- All Implemented Interfaces:
Component,DestructableComponent,IdentifiedComponent,InitializableComponent,Resource,Aware,BeanNameAware,InitializingBean,InputStreamSource,Resource
A resource representing a file read from an HTTP(S) location. Every time the file is successfully read from the URL
location it is written to a backing file. If the file can not be read from the URL it is read from this backing file,
if available.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ResourceBacking resource file.private final org.slf4j.LoggerLogger. -
Constructor Summary
ConstructorsConstructorDescriptionFileBackedHTTPResource(String backingFile, org.apache.http.client.HttpClient client, String url) Constructor.FileBackedHTTPResource(String backingFile, org.apache.http.client.HttpClient client, URL url) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionlongcreateRelative(String relativePath) Based onUrlResource.booleanexists()longprotected InputStreamsaveAndClone(InputStream input) saveAndClone.Methods inherited from class net.shibboleth.ext.spring.resource.HTTPResource
afterPropertiesSet, buildHttpClientContext, closeResponse, createRelativeResource, getFile, getFilename, getResourceHeaders, getResponseHeader, getURI, getURL, isOpen, isReadable, reportCachingStatus, setBeanName, setHttpClientContextHandlerMethods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
doInitialize, getId, setIdMethods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.core.io.Resource
isFile, readableChannel
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logLogger. -
backingResource
Backing resource file.
-
-
Constructor Details
-
FileBackedHTTPResource
public FileBackedHTTPResource(@Nonnull @ParameterName(name="backingFile") String backingFile, @Nonnull @ParameterName(name="client") org.apache.http.client.HttpClient client, @NotEmpty @Nonnull @ParameterName(name="url") String url) throws IOException Constructor.- Parameters:
backingFile- the file to use as backing storeclient- the client we use to connect with.url- URL to the remote data- Throws:
IOException- if the URL was badly formed
-
FileBackedHTTPResource
public FileBackedHTTPResource(@Nonnull @ParameterName(name="backingFile") String backingFile, @Nonnull @ParameterName(name="client") org.apache.http.client.HttpClient client, @Nonnull @ParameterName(name="url") URL url) throws IOException Constructor.- Parameters:
backingFile- the file to use as backing storeclient- the client we use to connect with.url- URL to the remote data- Throws:
IOException- if the URL was badly formed
-
-
Method Details
-
saveAndClone
saveAndClone. Read the contents into memory and then write out to the backing file. Finally- Parameters:
input- the input stream- Returns:
- the cloned stream.
- Throws:
IOException- if an error happens. If the backing file might have been corrupted we delete it.
-
getInputStream
- Specified by:
getInputStreamin interfaceInputStreamSource- Specified by:
getInputStreamin interfaceResource- Overrides:
getInputStreamin classHTTPResource- Throws:
IOException
-
exists
public boolean exists() -
contentLength
- Specified by:
contentLengthin interfaceResource- Specified by:
contentLengthin interfaceResource- Overrides:
contentLengthin classHTTPResource- Throws:
IOException
-
lastModified
- Specified by:
lastModifiedin interfaceResource- Specified by:
lastModifiedin interfaceResource- Overrides:
lastModifiedin classHTTPResource- Throws:
IOException
-
createRelative
Based onUrlResource.- Specified by:
createRelativein interfaceResource- Overrides:
createRelativein classHTTPResource- Throws:
IOException
-
getDescription
- Specified by:
getDescriptionin interfaceResource- Specified by:
getDescriptionin interfaceResource- Overrides:
getDescriptionin classHTTPResource
-