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 a
Resource that may be absent by returning an empty bean file instead.- Since:
- 5.4.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcreateRelative(String relativePath) createRelativeResource(String relativePath) booleanexists()getFile()protected StringReturn a prefix for logging messages for this component.getURI()getURL()booleanisOpen()booleanlongvoidsetBeanName(String name) voidsetDefaultContent(String content) Set the default content to return if the underlying resource is absent.voidMethods inherited from class net.shibboleth.utilities.java.support.component.AbstractIdentifiedInitializableComponent
doInitialize, getIdMethods 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
-
DEFAULT_CONTENT
Dummy content.- See Also:
-
log
@Nonnull private final org.slf4j.Logger logLogger. -
logPrefix
Cached log prefix. -
wrappedResource
Resource to wrap. -
defaultContent
Content to return if the resource is missing.
-
-
Constructor Details
-
ConditionalResource
Constructor.- Parameters:
wrapped- the resource to wrap
-
-
Method Details
-
setId
- Overrides:
setIdin classAbstractIdentifiedInitializableComponent
-
setDefaultContent
Set the default content to return if the underlying resource is absent.- Parameters:
content- default "empty" content- Since:
- 6.1.0
-
getInputStream
- Specified by:
getInputStreamin interfaceInputStreamSource- Specified by:
getInputStreamin interfaceResource- Throws:
IOException
-
createRelativeResource
- Specified by:
createRelativeResourcein interfaceResource- Throws:
IOException
-
setBeanName
- 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
- Specified by:
getURLin interfaceResource- Specified by:
getURLin interfaceResource- Throws:
IOException
-
getURI
- Specified by:
getURIin interfaceResource- Specified by:
getURIin interfaceResource- Throws:
IOException
-
getFile
- Specified by:
getFilein interfaceResource- Specified by:
getFilein interfaceResource- Throws:
IOException
-
contentLength
- Specified by:
contentLengthin interfaceResource- Specified by:
contentLengthin interfaceResource- Throws:
IOException
-
lastModified
- Specified by:
lastModifiedin interfaceResource- Specified by:
lastModifiedin interfaceResource- Throws:
IOException
-
createRelative
- Specified by:
createRelativein interfaceResource- Throws:
IOException
-
getFilename
- Specified by:
getFilenamein interfaceResource- Specified by:
getFilenamein interfaceResource
-
getDescription
- Specified by:
getDescriptionin interfaceResource- Specified by:
getDescriptionin interfaceResource
-
getLogPrefix
Return a prefix for logging messages for this component.- Returns:
- a string for insertion at the beginning of any log messages
-