Hi everyone !
i have a problem using the class ReloadableResourceBundleMessageSource...
i'll explain my problem. I want to use Messages on server Side, and i' trying to use ReloadableResourceBundleMessageSource.
i have define this in my Spring file :
and SoftCuStrings is my *.properties fileCode:<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basenames"> <list> <value>WEB-INF/content/SoftCuStrings</value> </list> </property> <property name="defaultEncoding" value="UTF-8"/> </bean>
i have created a Listener :
which is defined in my web.xml :Code:public class CmiServletListener implements ServletContextListener { @Override public void contextInitialized(ServletContextEvent sce) { ServerMessageResourceFactory serverMessageResourceFactory = (ServerMessageResourceFactory) WebApplicationContextUtils .getWebApplicationContext(sce.getServletContext()).getBean("serverMessageResourceFactory"); SoftCuMessageTest.SERVER_GLOBAL_RES = serverMessageResourceFactory.getSoftCuStrings(); } @Override public void contextDestroyed(ServletContextEvent sce) { } }
the bean in this code is define in my spring file :Code:<listener> <listener-class>com.francetelecom.softcu.app.impl.listener.CmiServletListener</listener-class> </listener>
and here is my serverMessageResourceFactory file :Code:<bean id="serverMessageResourceFactory" class="com.francetelecom.softcu.app.impl.listener.ServerMessageResourceFactory"/>
to be quick, when i'm using my serverMessageResourceFactory, my messageResource is null...Code:public class ServerMessageResourceFactory { InvocationHandler handler = new InvocationHandler() { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return messageSource.getMessage(method.getAnnotation(LocalizableResource.Key.class).value(), args, null); } }; private ReloadableResourceBundleMessageSource messageSource; public SoftCuStrings getSoftCuStrings() { return (SoftCuStrings) Proxy.newProxyInstance(SoftCuStrings.class.getClassLoader(), new Class[] { SoftCuStrings.class }, handler); } public void setMessageResource(ReloadableResourceBundleMessageSource messageSource) { this.messageSource = messageSource; } }
i thought that my classpath is wrong, but, i don't think so...
someone can help me ? beacause i'm completely stuck :/
thx !!


Reply With Quote