Tran, Khiet wrote:
> Hi,
>
>
>
> I successfully experimented Spring, everything works fine. I am using
> the ClasspathXmlApplicationContext.
>
> Now I am integrating Spring within Eclipse RCP, which causes me some
> headaches:
>
> -My spring application cannot see the spring configuration
> file. I manage to solve this problem by subclassing the
> ClasspathXmlApplicationContext and ClasspathResource classes. Now
> Spring cannot see ResourceBundleMessageSource.class!
>
>
>
> My question is then: how could I centralize all resource lookup or
> class lookup within Spring without subclassing all its classes. Spring
> uses the current Thread as its classloading mechanism, is there a way
> to change that globally? I want to define my way of class lookup globally.
>
I do not have a solution to your problem.
I am only sending this email to the Spring developers know I have the
same question.
I already had post a message about this on the forums :
http://forum.springframework.org/viewtopic.php?t=1089
I think the Spring components should access resouces using a interface
like this :
public interface ResourceLoader {
byte[] loadResource(String resourceName);
}
So any spring components with the need of acess resources will have a
setResourceLoader method and they will use a default implementation like
the current one.
Maybe will be useful to set the default resource loader on the
ApplicationContext :
ResourceLoader resourceLoader = new MyResourceLoaderImpl();
ClassPathXmlApplicationContext bf = new
ClassPathXmlApplicationContext(new String[] {"/spring.xml"},resourceLoader);
It will be easy to implement things like chains of resurce loaders
to create the support to new protocols.
I think this is a good idea. In Spring everything should be a
interface, so why not make this with the resource loader ?
Danilo.
|