In my configuration's spring/resources.xml file, I define a bean like this :
<bean id="myService" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
<property name="serviceUrl" value="http://${remote.host}:8080/MyAgent/remoting/MyService"/>
<property name="serviceInterface" value="services.MyService"/>
</bean>
In my Config.groovy file I have : remote.host = "someipaddress"
Now I'd like to change this placeholder's value at runtime. In a regular spring app, I do this through a PropertyPlaceHolderConfigurer, then I refresh the context and it works.
In Grails, how can I refresh the context ?
Regards,
Philippe
Ok I give up the refreshing approach. As a workaround, I created a grails service that looks like this :
class myService {
def myRemoteService
static transactional = false
private MyRemoteService getService(String remoteServiceURL) {
HessianProxyFactory factory = new HessianProxyFactory();
try {
return (MyRemoteService) factory.create(MyRemoteService.class, url);
}
catch (MalformedURLException e) {
e.printStackTrace()
}
return null
}
def someRemoteMethod(String remoteServiceURL) {
getService(remoteServiceURL).myRemoteMethod()
}
}
This allows me to invoke the remote service on any distant machine dinamically.
I'm still interested in a cleaner solution as this makes me rewrite a wrapper method for each remote method :-S
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With