Sachin Handiekar

Sachin Handiekar


January 2013
M T W T F S S
« Dec   Aug »
 123456
78910111213
14151617181920
21222324252627
28293031  

Categories


Setting System properties using Spring

Sachin HandiekarSachin Handiekar
Approach 1 :

Approach 2 : Suggested by Sam Mohamed

Comments 2
  • Sam Mohamed
    Posted on

    Sam Mohamed Sam Mohamed

    Reply Author

    Another approach using @Configuration:

    @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;
    }


  • congdoan
    Posted on

    congdoan congdoan

    Reply Author

    Thanks, nice post


Leave a Reply