List of usage examples for org.springframework.context.support FileSystemXmlApplicationContext FileSystemXmlApplicationContext
public FileSystemXmlApplicationContext(String... configLocations) throws BeansException
From source file:edu.du.penrose.systems.fedoraApp.tests.ECTD_IngestControllerTest.java
private ApplicationContext getApplicationContext() { // page 706 String[] paths = new String[] { "./WebContent/WEB-INF/fedoraApp-servlet.xml" }; return new FileSystemXmlApplicationContext(paths); }
From source file:de.uzk.hki.da.action.ActionRegistryTests.java
/** * Sets the up./*from ww w . jav a 2 s . co m*/ * @throws IOException */ @Before public void setUp() throws IOException { FileUtils.copyFile(new File("src/main/conf/config.properties.dev"), new File("conf/config.properties")); context = new FileSystemXmlApplicationContext( "src/test/resources/action/ActionRegistryTests/action-definitions.xml"); registry = (ActionRegistry) context.getBean("actionRegistry"); }
From source file:com.taobao.ad.es.common.datasource.DataSourceFactory.java
public Connection getConnection(String contextPath, int dsType, String dataSource) throws BeansException, SQLException, NamingException { Connection connection = null; switch (dsType) { case JobData.JOBDATA_DATA_DATASOURCE_TYPE_DYNAMIC: // BeanFactoryLocator sysCtxLocator = // SingletonBeanFactoryLocator.getInstance(WebAgentConstants.DATASOURCE_CONTEXT); // BeanFactoryReference brf = // sysCtxLocator.useBeanFactory(WebAgentConstants.DATASOURCE_CONTEXT_KEY); // connection = ((DataSource) // brf.getFactory().getBean(dataSource)).getConnection(); AbstractXmlApplicationContext context = null; if (StringUtils.isEmpty(contextPath)) { context = new ClassPathXmlApplicationContext("classpath:es-agent-ds.xml"); } else {/* ww w. j a v a2 s. c om*/ context = new FileSystemXmlApplicationContext(contextPath); } connection = ((DataSource) context.getBean(dataSource)).getConnection(); break; default: Context cxt = new InitialContext(); Context envCtx = (Context) cxt.lookup("java:comp/env"); DataSource ds = (DataSource) envCtx.lookup("jdbc/" + dataSource); connection = ds.getConnection(); break; } return connection; }
From source file:org.jinglenodes.Main.java
public static void start(final String springFile) { try {//from ww w .jav a2 s. c om long init = System.currentTimeMillis(); log.info("Using home directory: " + appDir); Properties p = System.getProperties(); p.setProperty("sipgateway.home", appDir); PropertyConfigurator.configure(appDir + "/conf/log4j.xml"); DOMConfigurator.configureAndWatch(appDir + "/conf/log4j.xml"); ApplicationContext appContext = new FileSystemXmlApplicationContext("file:" + appDir + springFile); BeanFactory factory = appContext; sipGatewayApplication = (SIPGatewayApplication) factory.getBean("sip"); double time = (double) (System.currentTimeMillis() - init) / 1000.0; addShutdownHook(); log.info("Started Sip Gateway in " + time + " seconds"); Thread.currentThread().wait(); } catch (Exception e) { log.error(e); e.printStackTrace(); } }
From source file:org.hbird.business.validation.ValidatorTest.java
public ValidatorTest() throws Exception { // Between tests the Camel context stays the same, so routes may not // be added during the initialization phase of further tests. if (thisIsTheFirstRun) { // Load contexts ApplicationContext temp;/* w ww.jav a2s . c o m*/ temp = new FileSystemXmlApplicationContext( "file:src/main/resources/parameterValidator/parameter-validator.xml"); validatorContext = (CamelContext) temp.getBean("validatorContext"); validatorContext.start(); // Add routes to access activemq topics via via mock endpoints. validatorContext.addRoutes(new RouteBuilder() { public void configure() throws Exception { from("activemq:topic:ParametersWarning").to("mock:ResultsWarning"); from("activemq:topic:ParametersError").to("mock:ResultsError"); from("activemq:topic:ParametersSwitch").to("mock:ResultsSwitch"); from("activemq:topic:Parameters").to("mock:ResultsParameter"); } }); thisIsTheFirstRun = false; } // Prepare producer producer = validatorContext.createProducerTemplate(); // Prepare access to mock components resultsWarning = validatorContext.getEndpoint("mock:ResultsWarning", MockEndpoint.class); resultsError = validatorContext.getEndpoint("mock:ResultsError", MockEndpoint.class); resultsSwitch = validatorContext.getEndpoint("mock:ResultsSwitch", MockEndpoint.class); resultsParameters = validatorContext.getEndpoint("mock:ResultsParameter", MockEndpoint.class); // In case that there are still old parameters left in the parameters topic, wait until // all have been routed to the 'results' components, so that they don't disturb the testing. int oldCount = -1; int newCount = 0; while (oldCount < newCount) { Thread.sleep(250); oldCount = newCount; newCount = resultsSwitch.getReceivedCounter() + resultsWarning.getReceivedCounter() + resultsError.getReceivedCounter() + resultsParameters.getReceivedCounter(); } // Reset Mock endpoints so that they don't contain any messages. resultsSwitch.reset(); resultsWarning.reset(); resultsError.reset(); resultsParameters.reset(); }
From source file:org.atmars.action.BaseAction.java
protected void InitAction() { webRootPath = ServletActionContext.getServletContext().getRealPath("/"); String xmlPath = webRootPath + "WEB-INF\\applicationContext.xml"; ApplicationContext appContext = new FileSystemXmlApplicationContext(xmlPath); //Resource res = new FileSystemResource(webRootPath // + "WEB-INF\\applicationContext.xml"); //XmlBeanFactory factory = new XmlBeanFactory(res); BeanFactory factory = appContext;/*from w w w. j av a 2s .c o m*/ mService = (MessageService) factory.getBean("messageService"); uService = (UserService) factory.getBean("userService"); jMail = (Jmail) factory.getBean("jmail"); mailServiceMdp = (MailServiceMdp) factory.getBean("mailServiceMdp"); factory.getBean("listnerContainer"); ActionContext ctx = ActionContext.getContext(); Map<String, Object> session = ctx.getSession(); currentUserFromSession = (User) session.get("user"); }
From source file:org.openscada.da.server.exporter.spring.SpringHiveFactory.java
protected ApplicationContext getApplicationContext(final String file) { ApplicationContext ctx = this.ctxMap.get(file); if (ctx == null) { ctx = new FileSystemXmlApplicationContext(file); this.ctxMap.put(file, ctx); }//www .ja va 2 s . c o m return ctx; }
From source file:de.uzk.hki.da.at.AcceptanceTest.java
private static void instantiateNode() { AbstractApplicationContext context = new FileSystemXmlApplicationContext("conf/beans.xml"); localNode = (Node) context.getBean("localNode"); Session session = HibernateUtil.openSession(); session.beginTransaction();/*from ww w . j a v a2 s.c o m*/ session.refresh(localNode); session.close(); context.close(); }
From source file:com.glaf.core.context.ContextFactory.java
public static void reload() { logger.info("?......"); if (ctx == null) { try {//w w w . j a va 2s . c o m if (StringUtils.isNotEmpty(conf.get("spring-config"))) { String filename = SystemProperties.getConfigRootPath() + conf.get("spring-config"); logger.info("load custom spring config:" + filename); if (filename.startsWith("/")) { filename = "/" + filename;// For linux } ctx = new FileSystemXmlApplicationContext(filename); } else if (StringUtils.isNotEmpty(conf.get("spring-config-file"))) { String filename = conf.get("spring-config-file"); logger.info("load custom spring config:" + filename); if (filename.startsWith("/")) { filename = "/" + filename;// For linux } ctx = new FileSystemXmlApplicationContext(filename); } else if (StringUtils.isNotEmpty(System.getProperty("spring-config-file"))) { String filename = System.getProperty("spring-config-file"); logger.info("load custom spring config:" + filename); if (filename.startsWith("/")) { filename = "/" + filename;// For linux } ctx = new FileSystemXmlApplicationContext(filename); } else { String filename = SystemProperties.getConfigRootPath() + Constants.SPRING_APPLICATION_CONTEXT; logger.info("load default spring config:" + filename); ctx = new FileSystemXmlApplicationContext(filename); } } catch (Exception ex) { ex.printStackTrace(); logger.error(ex); } } }
From source file:com.china317.gmmp.gmmp_report_analysis.cache.LineDenoterCache.java
/** * ????// w w w. j av a 2s. c om * @param yyyyMMdd */ public void LineDenoterRm(String yyyyMMdd) { try { denoterMap.clear(); ApplicationContext context = new FileSystemXmlApplicationContext( "//home/gmmp/repAnalysis/bin/applicationcontext.xml"); LineDenoterDao dao = (LineDenoterDao) context.getBean("lineDenoterDao"); List<LineDenoter> list = dao.getLineDenoterByDate(yyyyMMdd); for (LineDenoter denoter : list) { String mapKey = LineDenoterCodeUtil.getVehicleCode(denoter.getLicenseCard(), denoter.getColor()); denoterMap.put(mapKey, denoter); } } catch (Exception e) { e.printStackTrace(); } }