List of usage examples for org.springframework.context ConfigurableApplicationContext close
@Override
void close();
From source file:com.gaodashang.demo.SampleWebSocketsApplicationTests.java
@Test public void echoEndpoint() throws Exception { ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class) .properties("websocket.uri:ws://localhost:" + this.port + "/echo/websocket") .run("--spring.main.web_environment=false"); long count = context.getBean(ClientConfiguration.class).latch.getCount(); AtomicReference<String> messagePayloadReference = context.getBean(ClientConfiguration.class).messagePayload; context.close(); assertEquals(0, count);// w w w. ja v a 2 s . com assertEquals("Did you say \"Hello world!\"?", messagePayloadReference.get()); }
From source file:com.gaodashang.demo.echo.CustomContainerWebSocketsApplicationTests.java
@Test public void reverseEndpoint() throws Exception { ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class) .properties("websocket.uri:ws://localhost:" + PORT + "/ws/reverse") .run("--spring.main.web_environment=false"); long count = context.getBean(ClientConfiguration.class).latch.getCount(); AtomicReference<String> messagePayloadReference = context.getBean(ClientConfiguration.class).messagePayload; context.close(); assertEquals(0, count);//from ww w . j a va 2 s. c om assertEquals("Reversed: !dlrow olleH", messagePayloadReference.get()); }
From source file:com.gaodashang.demo.echo.CustomContainerWebSocketsApplicationTests.java
@Test public void echoEndpoint() throws Exception { ConfigurableApplicationContext context = new SpringApplicationBuilder(ClientConfiguration.class, PropertyPlaceholderAutoConfiguration.class) .properties("websocket.uri:ws://localhost:" + PORT + "/ws/echo/websocket") .run("--spring.main.web_environment=false"); long count = context.getBean(ClientConfiguration.class).latch.getCount(); AtomicReference<String> messagePayloadReference = context.getBean(ClientConfiguration.class).messagePayload; context.close(); assertEquals(0, count);/* ww w.j a va2 s . c om*/ assertEquals("Did you say \"Hello world!\"?", messagePayloadReference.get()); }
From source file:org.kew.rmf.reconciliation.service.ReconciliationService.java
/** * Unloads a single configuration./*from w ww. j a v a 2s . c o m*/ */ public void unloadConfiguration(String configFileName) throws ReconciliationServiceException { synchronized (configurationStatuses) { ConfigurationStatus status = configurationStatuses.get(configFileName); if (status == ConfigurationStatus.LOADING) { throw new ReconciliationServiceException( "Match configuration " + configFileName + " is loading, wait until it has completed."); } else if (status == null) { throw new ReconciliationServiceException( "Match configuration " + configFileName + " is not loaded."); } StopWatch sw = new Slf4JStopWatch(timingLogger); logger.info("{}: Unloading configuration", configFileName); ConfigurableApplicationContext context = contexts.get(configFileName); String configName = configFileName.substring(0, configFileName.length() - 4); totals.remove(configName); matchers.remove(configName); contexts.remove(configFileName); context.close(); configurationStatuses.remove(configFileName); sw.stop("UnloadConfiguration:" + configFileName + ".success"); } }
From source file:com.intelligrated.ftp.services.FtpOutboundGatewayService.java
public void testLsGetRm() throws Exception { ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext( "classpath:/META-INF/spring/integration/FtpOutboundGatewaySample-context.xml"); final ToFtpFlowGateway toFtpFlow = ctx.getBean(ToFtpFlowGateway.class); // execute the flow (ls, get, rm, aggregate results) List<Boolean> rmResults = toFtpFlow.lsGetAndRmFiles("/"); //Check everything went as expected, and clean up assertEquals("Was expecting the collection 'rmResults' to contain 2 elements.", 2, rmResults.size()); for (Boolean result : rmResults) { assertTrue(result);//w w w.jav a 2 s . co m } //assertTrue("Expected FTP remote directory to be empty", new File(TestSuite.FTP_ROOT_DIR).delete()); ctx.close(); }
From source file:org.copperengine.core.test.persistent.BasePersistentWorkflowTest.java
protected void closeContext(final ConfigurableApplicationContext context) { context.close(); }
From source file:org.echocat.jomon.spring.application.DefaultApplicationGenerator.java
@Nonnull @Override// w w w . j av a 2 s. c o m public Application generate(@Nonnull ApplicationRequirement requirement) { final ApplicationInformation information = generateApplicationInformationFor(requirement); final LoggingEnvironment loggingEnvironment = generateLoggingEnvironmentFor(requirement); final StopWatch stopWatch = new StopWatch(); displayBannerIfNeeded(information); final Logger logger = loggingEnvironment.getLogger(DefaultApplicationGenerator.class); logger.info("Starting " + information.getTitle() + "..."); final ConfigurableApplicationContext applicationContext = getApplicationContextGenerator() .generate(requirement.getApplicationContextRequirement()); boolean success = false; boolean applicationContextStarted = false; try { final Application application = new DefaultApplication(applicationContext, information, loggingEnvironment); application.init(); applicationContextStarted = true; waitForContextLoadThreads(applicationContext); logger.info("Starting " + information.getTitle() + "... DONE! (after: " + stopWatch.toCurrentPattern(MILLISECONDS) + ")"); notifyApplicationSuccessfulInitiated(application); success = true; return application; } finally { if (applicationContextStarted && !success) { applicationContext.close(); } } }
From source file:org.metis.cassandra.CqlComponent.java
private void initComponent() throws Exception { if (LOG.isTraceEnabled()) { LOG.trace("initComponent: Component has not yet been initialized"); LOG.trace("initComponent: Using this context file name: " + dfltContextFileName); }/* w ww . ja va 2s . c o m*/ ConfigurableApplicationContext cassandraContext = null; // load the spring application context, which should be somewhere // in the application's classpath if (myContextFileName == null) { myContextFileName = dfltContextFileName; } try { cassandraContext = new ClassPathXmlApplicationContext(myContextFileName); setClients(cassandraContext.getBeansOfType(Client.class)); } catch (BeansException exc) { LOG.error("initComponent: caught this exception while " + "attempting to load spring context file: " + exc.toString()); throw exc; } if (getClients() == null || getClients().isEmpty()) { cassandraContext.close(); throw new Exception("there are no beans of type Client in the Spring XML file"); } // now that the context has been successfully loaded, create a new // profile and continue the init process setComponentProfile(new ComponentProfile(cassandraContext, myContextFileName, this)); initClientMapper(cassandraContext); initProfileMonitor(); }