Setting System properties using Spring January 22, 2013 Posted by Unknown Spring 2 comments Approach 1 : Approach 2 : Suggested by Sam Mohamed Email ThisBlogThis!Share to XShare to Facebook
Another approach using @Configuration:
ReplyDelete@Bean
public Properties retrieveSystemProperties(){
return System.getProperties();
}
private Properties systemProperties;
public Properties getSystemProperties() {
return systemProperties;
}
@Resource(name="retrieveSystemProperties")
public void setSystemProperties(Properties systemProperties) {
this.systemProperties = systemProperties;
}
@Bean
public MethodInvokingFactoryBean methodInvokingFactoryBean() {
MethodInvokingFactoryBean methodInvokingFactoryBean = new MethodInvokingFactoryBean();
methodInvokingFactoryBean.setStaticMethod("java.lang.System.setProperties");
systemProperties.setProperty("http.keepAlive", "false");
methodInvokingFactoryBean.setArguments(new Object[]{systemProperties});
return methodInvokingFactoryBean;
}
Thanks, nice post
ReplyDelete