List of usage examples for org.springframework.context.support AbstractApplicationContext getResource
@Override
public Resource getResource(String location)
From source file:org.rivetlogic.export.components.XmlExtractRequestProcessor.java
private void initializeCMSCreds(Ticket ticketParam) throws IOException, AuthenticationFailure, CmaRuntimeException { // set up the bean factory if (beanFactory == null) { PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); AbstractApplicationContext context = new ClassPathXmlApplicationContext("application-context.xml"); Resource resource = context.getResource("classpath:core/cma-cfg.properties"); Properties properties = new Properties(); properties.load(resource.getInputStream()); configurer.setProperties(properties); context.addBeanFactoryPostProcessor(configurer); context.refresh();//from ww w. j av a 2s . c o m beanFactory = context.getBeanFactory(); authService = (AuthenticationService) beanFactory.getBean("authenticationService", AuthenticationServiceImpl.class); } // get a ticket if (this.ticket == null) { if (ticketParam != null) { this.ticket = ticketParam; } else { this.ticket = authService.authenticate(cmaUrl, cmaUsername, cmaPassword.toCharArray()); } } try { authService.validate(ticket); } catch (InvalidTicketException e) { log.debug("ticket invalid, getting a new one."); ticket = authService.authenticate(cmaUrl, cmaUsername, cmaPassword.toCharArray()); } }
From source file:org.rivetlogic.export.components.AbstractXMLProcessor.java
private void initialize() throws AuthenticationFailure, CmaRuntimeException, IOException { if (ticket == null) { if (beanFactory == null) { PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer(); AbstractApplicationContext context = new ClassPathXmlApplicationContext("application-context.xml"); Resource resource = context.getResource("classpath:core/cma-cfg.properties"); Properties properties = new Properties(); properties.load(resource.getInputStream()); configurer.setProperties(properties); context.addBeanFactoryPostProcessor(configurer); context.refresh();//from ww w . j a va2 s .co m beanFactory = context.getBeanFactory(); } authService = (AuthenticationService) beanFactory.getBean("authenticationService", AuthenticationServiceImpl.class); ticket = authService.authenticate(cmaUrl, cmaUsername, cmaPassword.toCharArray()); nodeService = (NodeService) beanFactory.getBean("nodeService", NodeServiceImpl.class); searchService = (SearchService) beanFactory.getBean("searchService", SearchServiceImpl.class); contentService = (ContentServiceImpl) beanFactory.getBean("contentService", ContentServiceImpl.class); } try { authService.validate(ticket); } catch (InvalidTicketException e) { logger.debug("ticket invalid, getting a new one."); ticket = authService.authenticate(cmaUrl, cmaUsername, cmaPassword.toCharArray()); } }