Haifisch7734

Factory

Aug 21st, 2015
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. public class MSExchangeConfig implements FactoryBean<ExchangeService> {
  2.  
  3. .
  4. .
  5. .
  6.  
  7. @Override
  8.     public ExchangeService getObject() throws Exception {
  9.         ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
  10.         ExchangeCredentials credentials = new WebCredentials(getUsername(), getPassword());
  11.         service.setCredentials(credentials);
  12.         try {
  13.             service.setUrl(new URI(getUri()));
  14.         } catch (URISyntaxException ex) {
  15.             logger.error("URL problem when connecting to Exchange");
  16.             logger.trace("{}", ex);
  17.             throw new ExchangeServiceNotBuiltException();
  18.         }
  19.         return service;
  20.     }
  21.  
  22.     @Override
  23.     public Class<ExchangeService> getObjectType() {
  24.         return ExchangeService.class;
  25.     }
  26.  
  27.     @Override
  28.     public boolean isSingleton() {
  29.         return false;
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment