Nov 30th, 2010, 09:33 PM
DataSource backed Resource implementation?
The Resource interface is a fundamental building block of making effective use of the Spring framework. Incredibly powerful and flexible, the JavaDoc describes a Resource as an "Interface for a resource descriptor that abstracts from the actual type of underlying resource, such as a file or class path resource. An InputStream can be opened for every resource if it exists in physical form, but a URL or File handle can just be returned for certain resources. The actual behavior is implementation-specific."
Out of the box, Spring provides six implementations: UrlResource, ClassPathResource, FileSystemResource, ServletContextResource, InputStreamResource, and ByteArrayResource.
While these implementations serve their purposes quite well, I was wondering if the community felt there was a need and/or was interested in a DataSource backed Resource implementation -- an implementation that, through configuration, loaded content from a DataSource and populated a ByteArrayResource, for example. I have created such a subclass of the ByteArrayResource backed by the JdbcTempalte and it has worked quite well for numerous projects. One of the main benefits is the storage and retrieval of application configuration (as well as any other type of Resource, such as Velocity templates, XDS definitions, etc) from the database which could be updated without requiring a new build or the deployment of new files within a specific environment.
Does the community have any interest in such an implementation becoming part of the out of the box Spring framework?