PDA

View Full Version : Implementing a new protocol on org.springframework.core.io



danilo_lr
Sep 30th, 2004, 02:16 PM
I am testing the script groovy support.
I know it use the org.springframework.core.io Resource support to be able to load the resouces from the filesystem or the classpath.
But I need make possible to load the script files from a database. So I need to create database protocol :

<constructor-arg index="0"><value>database:/tmp/CalculoSub.groovy</value></constructor-arg>

How I will implement this generic resource support ?

Colin Sampaleanu
Oct 1st, 2004, 11:04 AM
The Resource interface is generic, but the classes in Spring are not set up such that this is a pluggable protocol setup similar to the way URLs are handled for example. The actual text strings you entrer in an appcontext get converted to a Resoure via a ResourceEditor PropertyEditor that gets registered automatically, and this will ultimately end up using DefaultResourceLoader, which ends up creating Resources of type ClassPathResource or UrlResource. If you can register a standrd type URL handler in your environment which can handle a custom database prefix, that might be one approach.

I would instead however first look at basing something off JdbcBeanDefinitionReader, for reading bean definitions from a db...