Created
February 25, 2012 22:20
-
-
Save eugenp/1911163 to your computer and use it in GitHub Desktop.
RestTemplate with Authentication in Spring 3.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
public class RestTemplateFactory implements | |
FactoryBean< RestTemplate >, InitializingBean{ | |
private RestTemplate restTemplate; | |
public RestTemplate getObject(){ | |
return restTemplate; | |
} | |
public Class< RestTemplate > getObjectType(){ | |
return RestTemplate.class; | |
} | |
public boolean isSingleton(){ | |
return true; | |
} | |
public void afterPropertiesSet(){ | |
restTemplate = new RestTemplate( | |
new HttpComponentsClientHttpRequestFactory( new DefaultHttpClient() ){ | |
{ | |
setReadTimeout( 15000 ); | |
} | |
} ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment