org.springframework.beans.factory.support
Class BeanDefinitionResource

java.lang.Object
  extended by org.springframework.core.io.AbstractResource
      extended by org.springframework.beans.factory.support.BeanDefinitionResource
All Implemented Interfaces:
InputStreamSource, Resource

 class BeanDefinitionResource
extends AbstractResource

Descriptive Resource wrapper for a BeanDefinition.

Since:
2.5.2
Author:
Juergen Hoeller
See Also:
DescriptiveResource

Field Summary
private  BeanDefinition beanDefinition
           
 
Constructor Summary
BeanDefinitionResource(BeanDefinition beanDefinition)
          Create a new BeanDefinitionResource.
 
Method Summary
 boolean equals(java.lang.Object obj)
          This implementation compares the underlying BeanDefinition.
 boolean exists()
          This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened.
 BeanDefinition getBeanDefinition()
          Return the wrapped BeanDefinition object.
 java.lang.String getDescription()
          Return a description for this resource, to be used for error output when working with the resource.
 java.io.InputStream getInputStream()
          Return an InputStream.
 int hashCode()
          This implementation returns the hash code of the underlying BeanDefinition.
 boolean isReadable()
          This implementation always returns true.
 
Methods inherited from class org.springframework.core.io.AbstractResource
contentLength, createRelative, getFile, getFileForLastModifiedCheck, getFilename, getURI, getURL, isOpen, lastModified, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

beanDefinition

private final BeanDefinition beanDefinition
Constructor Detail

BeanDefinitionResource

public BeanDefinitionResource(BeanDefinition beanDefinition)
Create a new BeanDefinitionResource.

Parameters:
beanDefinition - the BeanDefinition objectto wrap
Method Detail

getBeanDefinition

public final BeanDefinition getBeanDefinition()
Return the wrapped BeanDefinition object.


exists

public boolean exists()
Description copied from class: AbstractResource
This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened. This will cover both directories and content resources.

Specified by:
exists in interface Resource
Overrides:
exists in class AbstractResource

isReadable

public boolean isReadable()
Description copied from class: AbstractResource
This implementation always returns true.

Specified by:
isReadable in interface Resource
Overrides:
isReadable in class AbstractResource

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Description copied from interface: InputStreamSource
Return an InputStream.

It is expected that each call creates a fresh stream.

This requirement is particularly important when you consider an API such as JavaMail, which needs to be able to read the stream multiple times when creating mail attachments. For such a use case, it is required that each getInputStream() call returns a fresh stream.

Throws:
java.io.IOException - if the stream could not be opened
See Also:
MimeMessageHelper.addAttachment(String, InputStreamSource)

getDescription

public java.lang.String getDescription()
Description copied from interface: Resource
Return a description for this resource, to be used for error output when working with the resource.

Implementations are also encouraged to return this value from their toString method.

See Also:
Object.toString()

equals

public boolean equals(java.lang.Object obj)
This implementation compares the underlying BeanDefinition.

Overrides:
equals in class AbstractResource
See Also:
Resource.getDescription()

hashCode

public int hashCode()
This implementation returns the hash code of the underlying BeanDefinition.

Overrides:
hashCode in class AbstractResource
See Also:
Resource.getDescription()