May 10th, 2010, 09:49 AM
Creating a custom core.io.Resource for HTTPClient
I have written a Resource implementation that uses Apache HTTPClient instead of java.net.URL (as used by UrlResource).
Because DefaultResourceLoader explicitly constructs a UrlResource, I wrote an extension of ClassPathXMLApplicationContext overriding getResource as appropriate. This seems clumsy as there are many ways to get a Context and I cannot be sure to have intercepted all ways we may choose to define our application (see (c) below).
a) Is there a better way to achieve this goal? My worst-case scenario is to patch DefaultResourceLoader itself.
b) If I wanted to register a new uri type (e.g. "scp://") would I be looking to do the same thing?
c) How do I integrate the solution with Spring Testframework @ContextConfiguration as I am not directly in control of the class-to-construct in this circumstance.
I hope to be told of some kind of PluggableResourceLoader that would answer all three of these.