List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext destroy
@Deprecated public void destroy()
From source file:com.bt.aloha.batchtest.v2.Main.java
public static void main(String[] args) { int res = 256; try {//from ww w .j a va 2 s . com String appCtx = "com/bt/aloha/batchtest/v2/RobustnessV2.xml"; if (args.length != 0) appCtx = args[0]; // load app context ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(appCtx); // extracts TestRunner TestRunner testRunner = (TestRunner) appContext.getBean("testRunner"); // runs Test Runner ResultTotals resTotal = testRunner.run(); res = Long.valueOf(resTotal.getFailures()).intValue(); LOG.info("Results: " + resTotal); appContext.destroy(); } catch (Throwable t) { LOG.error("Exception cought in Main", t); } LOG.info("Returning code: " + res); if (res != 0) { res = 1; } // return code is calc module 256 System.exit(res); }
From source file:com.newlandframework.test.PojoCallTest.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:rpc-invoke-config-client.xml"); PersonManage manage = (PersonManage) context.getBean("personManage"); Person p = new Person(); p.setId(20150811);/*from w w w.j ava2 s .c om*/ p.setName("XiaoHaoBaby"); p.setAge(1); int result = manage.save(p); System.out.println("call pojo rpc result:" + result); context.destroy(); }
From source file:nl.mindef.c2sc.nbs.olsr.pud.uplink.server.Main.java
public static void main(String[] args) { logger.info("RelayServer starting"); try {//from ww w. ja v a2s . c om ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:META-INF/spring/application-context.xml"); logger.info("RelayServer started"); context.start(); UplinkReceiver uplinkReceiver = (UplinkReceiver) context.getBean("UplinkReceiver"); uplinkReceiver.join(); logger.info("RelayServer stopped"); context.stop(); context.close(); context.destroy(); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.newlandframework.test.RpcParallelTest.java
public static void main(String[] args) throws Exception { //1000//from w w w. j a va 2 s . co m int parallel = 1000; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:rpc-invoke-config-client.xml"); for (int i = 0; i < 1; i++) { addTask((AddCalculate) context.getBean("addCalc"), parallel); multiTask((MultiCalculate) context.getBean("multiCalc"), parallel); System.out.printf( "[author tangjie] Netty RPC Server ????[%d]???!\n\n", i); } context.destroy(); }
From source file:hu.vanio.jms.spring3.ibmmq.Start.java
public static void main(String[] args) throws IOException, InterruptedException { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:/application.xml"); // sending messages JmsQueueSender jqs = ctx.getBean(JmsQueueSender.class); String message = "Hello queue world!" + " National chars (see CCSID): \"--\"''<>&@# AE: "; // send five message and sleep half second for (int i = 1; i <= 5; i++) { Thread.sleep(500);//from w ww.j a va 2 s.c o m jqs.simpleSend(i + ". " + message); } // quit after 1 second Thread.sleep(1000); ctx.destroy(); }
From source file:com.himanshu.spring.context.loader.diffconfigpercontext.RunMe.java
public static void main(String[] args) { ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext( "classpath:/diff-config-per-context/context/applicationContext.xml"); ServiceFactoryDiffConfigPerContext svcRepo = appContext.getBean(ServiceFactoryDiffConfigPerContext.class); DummyBean dummyBean_Context1 = svcRepo.getBean(DummyBean.class, "context1"); logger.info("From Dummy Bean in ctx1 : " + dummyBean_Context1.getWelcomeMsg()); DummyBean dummyBean_Context2 = svcRepo.getBean(DummyBean.class, "context2"); logger.info("From Dummy Bean in ctx2 : " + dummyBean_Context2.getWelcomeMsg()); appContext.destroy(); }
From source file:com.himanshu.spring.context.loader.sameconfigallcontext.RunMe.java
public static void main(String[] args) { ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext( "classpath:/same-config-all-context/context/applicationContext.xml"); ServiceFactorySameConfigAllContext svcRepo = appContext.getBean(ServiceFactorySameConfigAllContext.class); DummyBean dummyBean_Context1 = svcRepo.getBean(DummyBean.class, "context1"); logger.info("From Dummy Bean in ctx1 : " + dummyBean_Context1.getWelcomeMsg()); DummyBean dummyBean_Context2 = svcRepo.getBean(DummyBean.class, "context2"); logger.info("From Dummy Bean in ctx2 : " + dummyBean_Context2.getWelcomeMsg()); appContext.destroy(); }
From source file:com.bt.aloha.batchtest.v2.scenarios.InboundCallScenario.java
public static void main(String[] args) { ClassPathXmlApplicationContext applicationContext = null; try {/*from w w w . ja va 2 s. c o m*/ InboundCallScenario scenario = new InboundCallScenario(); ScenarioRunResultListenerImpl listener = new ScenarioRunResultListenerImpl(); scenario.setScenarioRunResultListener(listener); applicationContext = new ClassPathXmlApplicationContext( new String[] { "core-ctx.xml", "memory-collections-ctx.xml", "com/bt/aloha/batchtest/v2/scenarios/inboundCallScenarioApplicationContext.xml" }); scenario.setApplicationContext(applicationContext); scenario.setTestEndpoint("sip:inbound@172.25.58.154:7072"); StackManagerSyncronizationSemaphore s = new StackManagerSyncronizationSemaphoreImpl(); s.initialize(1, 1); scenario.setStackManagerSyncronizationSemaphore(s); scenario.run("fred"); ResultLogger logger = new ResultLogger(); logger.setScenarioResults(listener.getResults()); logger.logResultEntries(); logger.logResultsSummary(); } finally { if (null != applicationContext) applicationContext.destroy(); } }
From source file:com.bt.aloha.batchtest.PerformanceBatchTest.java
public static void main(String[] args) throws Exception { MultistackApplicationContextManager manager = null; try {/*ww w . ja v a 2 s . c o m*/ manager = new MultistackApplicationContextManager(new String[] { "batchTestApplicationContext.xml", "propertyListenerApplicationContext.performance.xml" }, null); manager.injectManagerIntoApplicatonContext1Beans(); } catch (Exception e) { log.error(e); e.printStackTrace(); System.exit(1); } log.info("Loading application context"); boolean success = true; PerformanceMeasurmentDao dao = null; //ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("batchTestApplicationContext.xml"); ClassPathXmlApplicationContext applicationContext = manager.getApplicationContext1(); dao = (PerformanceMeasurmentDao) applicationContext.getBean("performanceMeasurementDaoBean"); PerformanceBatchTest performanceBatchTest = (PerformanceBatchTest) applicationContext .getBean("performanceBatchTestBean"); int start = performanceBatchTest.getNumberOfInitialConcurrentStarts(); int max = performanceBatchTest.getNumberOfMaxConcurrentStarts(); int inc = performanceBatchTest.getNumberOfConcurrentStartsIncrements(); long runId = dao.generateId(); performanceBatchTest.setApplicationContext(applicationContext); performanceBatchTest.resetDb(); for (int currNumberOfAppThreads = start; currNumberOfAppThreads <= max; currNumberOfAppThreads += inc) { performanceBatchTest.init(); performanceBatchTest.addBatchScenarios(); performanceBatchTest.setNumberOfConcurrentStarts(currNumberOfAppThreads); logSystemInformation(performanceBatchTest); performanceBatchTest.setExecutorService(Executors.newFixedThreadPool(currNumberOfAppThreads)); log.info("Running tests with " + currNumberOfAppThreads + " concurrent threads"); performanceBatchTest.run(); performanceBatchTest.currentMetrics .setThreadInfo(String.format(Metrics.TI_STRING, currNumberOfAppThreads, start, max, inc)); performanceBatchTest.currentMetrics.setTestType(performanceBatchTest.getTestType()); dao.record("Call", runId, performanceBatchTest.currentMetrics); performanceBatchTest.executorService.shutdownNow(); performanceBatchTest.results.clear(); success &= performanceBatchTest.overallSuccess; } applicationContext.destroy(); if (dao != null) { List<Metrics> metrics = dao.findMetricsByRunId(runId); Map<Long, List<Metrics>> m = new HashMap<Long, List<Metrics>>(); m.put(runId, metrics); Chart c = new Chart(m); //String xLabel = String.format("Runs - %s calls per thread, %s min threads, %s max theads, %s increment", cpt, start, max, inc); c.saveChart(new File("unitPerSecond.jpg"), "UPS with Std deviation", "threads", "units per second"); m = dao.findLastXMetricsForTestType(5, performanceBatchTest.getTestType()); c = new Chart(m); c.saveCombinedChart(new File("unitPerSecond-historical.jpg"), "Runs Per Second", "threads", "runs per second", "Standard Deviation", "threads", "std. deviation"); } try { // allow sipp to settle down (in terms of sending its responses and us being up to receive them) Thread.sleep(30000); } catch (Throwable tex) { } System.exit(success ? 0 : 1); }
From source file:org.fusesource.meshkeeper.MeshKeeperFactoryTest.java
public void testFactories() throws Exception { // Test out the spring factory.. ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("factory-test.xml"); MeshKeeper mk = (MeshKeeper) context.getBean("mk"); assertNotNull(mk.registry().getRegistryData(ControlServer.REMOTING_URI_PATH)); context.destroy(); // Test out the java factories. mk = MeshKeeperFactory.createMeshKeeper("zk:tcp://localhost:2101"); assertNotNull(mk.registry().getRegistryData(ControlServer.REMOTING_URI_PATH)); mk.destroy();/*w w w .jav a2s . co m*/ // Test out starting a launcher agent mk = MeshKeeperFactory.createMeshKeeper("zk:tcp://localhost:2101"); LaunchAgent agent = MeshKeeperFactory.createAgent(mk); assertNotNull(agent.getAgentId()); agent.stop(); }