Module net.shibboleth.ext.spring
Class ConditionalResource
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
-
- net.shibboleth.ext.spring.resource.ConditionalResource
-
- All Implemented Interfaces:
Component,DestructableComponent,IdentifiedComponent,InitializableComponent,Resource,Aware,BeanNameAware,InputStreamSource,Resource
public class ConditionalResource extends AbstractIdentifiedInitializableComponent implements Resource, BeanNameAware, Resource
A wrapper that guards aResourcethat may be absent by returning an empty bean file instead.- Since:
- 5.4.0
-
-
Field Summary
Fields Modifier and Type Field Description private static StringEMPTY_RESOURCEDummy content.private org.slf4j.LoggerlogLogger.private StringlogPrefixCached log prefix.private ResourcewrappedResourceResource to wrap.
-
Constructor Summary
Constructors Constructor Description ConditionalResource(Resource wrapped)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longcontentLength()ResourcecreateRelative(String relativePath)ResourcecreateRelativeResource(String relativePath)booleanexists()StringgetDescription()FilegetFile()StringgetFilename()InputStreamgetInputStream()protected StringgetLogPrefix()Return a prefix for logging messages for this component.URIgetURI()URLgetURL()booleanisOpen()booleanisReadable()longlastModified()voidsetBeanName(String name)voidsetId(String id)-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
doInitialize, getId
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.springframework.core.io.Resource
isFile, readableChannel
-
-
-
-
Field Detail
-
EMPTY_RESOURCE
@Nonnull @NotEmpty private static final String EMPTY_RESOURCE
Dummy content.- See Also:
- Constant Field Values
-
log
@Nonnull private final org.slf4j.Logger log
Logger.
-
logPrefix
@Nullable private String logPrefix
Cached log prefix.
-
wrappedResource
@Nonnull private final Resource wrappedResource
Resource to wrap.
-
-
Constructor Detail
-
ConditionalResource
public ConditionalResource(@Nonnull Resource wrapped)Constructor.- Parameters:
wrapped- the resource to wrap
-
-
Method Detail
-
setId
public void setId(@Nonnull @NotEmpty String id)
- Overrides:
setIdin classAbstractIdentifiedInitializableComponent
-
getInputStream
@Nonnull public InputStream getInputStream() throws IOException
- Specified by:
getInputStreamin interfaceInputStreamSource- Specified by:
getInputStreamin interfaceResource- Throws:
IOException
-
createRelativeResource
public Resource createRelativeResource(String relativePath) throws IOException
- Specified by:
createRelativeResourcein interfaceResource- Throws:
IOException
-
setBeanName
public void setBeanName(String name)
- Specified by:
setBeanNamein interfaceBeanNameAware
-
exists
public boolean exists()
-
isReadable
public boolean isReadable()
- Specified by:
isReadablein interfaceResource- Specified by:
isReadablein interfaceResource
-
isOpen
public boolean isOpen()
-
getURL
public URL getURL() throws IOException
- Specified by:
getURLin interfaceResource- Specified by:
getURLin interfaceResource- Throws:
IOException
-
getURI
public URI getURI() throws IOException
- Specified by:
getURIin interfaceResource- Specified by:
getURIin interfaceResource- Throws:
IOException
-
getFile
public File getFile() throws IOException
- Specified by:
getFilein interfaceResource- Specified by:
getFilein interfaceResource- Throws:
IOException
-
contentLength
public long contentLength() throws IOException- Specified by:
contentLengthin interfaceResource- Specified by:
contentLengthin interfaceResource- Throws:
IOException
-
lastModified
public long lastModified() throws IOException- Specified by:
lastModifiedin interfaceResource- Specified by:
lastModifiedin interfaceResource- Throws:
IOException
-
createRelative
public Resource createRelative(String relativePath) throws IOException
- Specified by:
createRelativein interfaceResource- Throws:
IOException
-
getFilename
public String getFilename()
- Specified by:
getFilenamein interfaceResource- Specified by:
getFilenamein interfaceResource
-
getDescription
public String getDescription()
- Specified by:
getDescriptionin interfaceResource- Specified by:
getDescriptionin interfaceResource
-
-