Example usage for org.springframework.context ConfigurableApplicationContext close

List of usage examples for org.springframework.context ConfigurableApplicationContext close

Introduction

In this page you can find the example usage for org.springframework.context ConfigurableApplicationContext close.

Prototype

@Override
void close();

Source Link

Document

Close this application context, releasing all resources and locks that the implementation might hold.

Usage

From source file:com.all.ultrapeer.UltrapeerService.java

public static void runInteractiveMode(ConfigurableApplicationContext applicationContext,
        UltrapeerService ultraPeerService, ServiceInvoker monitorable, BufferedReader in) throws IOException {
    while (true) {
        LOG.info(" $ ");
        String line = in.readLine();
        line = line.trim();//  ww  w  .  j  a  va2  s .  c  o m
        if (line.equals("")) {
            continue;
        }
        try {
            if (line.indexOf("shutdown") >= 0) {
                applicationContext.close();
                break;
            } else {
                executeCommand(ultraPeerService, monitorable, line);
            }
        } catch (Exception e) {
            LOG.error(e, e);
        }
    }
}

From source file:org.jboss.spring.deployers.ApplicationContextDeployer.java

protected DeploymentVisitor<SpringMetaData> createDeploymentVisitor() {
    return new SpringDeploymentVisitor() {
        protected ConfigurableApplicationContext doCreate(SpringContextDescriptor metaData) {
            return new NamedXmlApplicationContext(metaData.getDefaultName(), metaData.getResource());
        }/*w w w  .j  a  v  a 2 s  .  c o  m*/

        protected void doClose(ConfigurableApplicationContext beanFactory) {
            beanFactory.close();
        }
    };
}

From source file:org.echocat.jomon.spring.testing.environments.BeanEnvironment.java

@Override
public void close() {
    final ConfigurableApplicationContext applicationContext = _applicationContext;
    if (applicationContext != null) {
        applicationContext.close();
    }/*from  w w  w . j  av a2s  .c  om*/
}

From source file:com.payu.ratel.tests.HeartBeatServiceUnregisterTest.java

@Test
public void shouldUnregisterServiceWhenHeartBeatIsMissed() throws InterruptedException {
    //given/* w  ww. ja v a 2 s. co  m*/
    ratelTestContext.waitForServicesRegistration(2);

    //when
    ConfigurableApplicationContext secondCtx = ratelTestContext.startService(TestServiceConfiguration.class);

    //then
    ratelTestContext.waitForServicesRegistration(4);

    //when
    secondCtx.close();

    //then
    ratelTestContext.waitForServicesRegistration(4);

}

From source file:com.provenance.cloudprovenance.policycontroller.utility.test.XPathUtilityTest.java

@Before
public void setUp() throws XMLDBException, URISyntaxException {
    ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { "beans.xml" });

    xpathUtility = (XPathProvenanceConditionUtility) ctx.getBean("xPathProvenanceConditionUtility");
    ctx.close();

    // initilizeStore();
}

From source file:de.olivergierke.samples.datanucleus.SpringTestCase.java

@Test
public void bootstrapJpa() {

    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
    EntityManagerFactory factory = context.getBean(EntityManagerFactory.class);

    SimpleTestCase.executeTestWith(factory);

    context.close();
}

From source file:org.cleverbus.core.conf.ConfigurationChecker.java

/**
 * Checks configuration./*  w  w w  .ja  va  2s.  c  o m*/
 *
 * @param context the application context
 */
void checkConfiguration(ApplicationContext context) {
    Log.debug("Checking configuration validity ...");

    Assert.state(context.getParent() != null, "ConfigurationChecker must be initialized in child context");

    try {
        if (checkUrl) {
            checkLocalhostUri();
        }

        checkPatterns();

        // go through "local" checks
        if (checks != null) {
            for (ConfCheck check : checks) {
                check.check();
            }
        }
    } catch (ConfigurationException ex) {
        Log.error("Configuration error", ex);

        // stop parent context (I don't know how to stop it in other way)
        ConfigurableApplicationContext rootContext = (ConfigurableApplicationContext) context.getParent();
        rootContext.close();
    }
}

From source file:org.copperengine.core.test.persistent.DerbyDbSpringTxnPersistentWorkflowTest.java

@Override
protected void closeContext(final ConfigurableApplicationContext context) {
    try {/*from   w ww  .j  av a2  s .  com*/
        Thread.sleep(100);
    } catch (InterruptedException e) {
        // ignore
    }
    context.close();
}

From source file:org.testng.spring.test.AbstractSpringContextTests.java

/**
  * Mark the context with the given key as dirty. This will cause the
  * cached context to be reloaded before the next test case is executed.
  * <p>Call this method only if you change the state of a singleton
  * bean, potentially affecting future tests.
 *///from  w  w  w  .jav  a2 s  . com
protected final void setDirty(Object contextKey) {
    String keyString = contextKeyString(contextKey);
    ConfigurableApplicationContext ctx = (ConfigurableApplicationContext) contextKeyToContextMap
            .remove(keyString);
    if (ctx != null) {
        ctx.close();
    }
}

From source file:com.griddynamics.banshun.ContextParentBean.java

public void destroy() throws Exception {
    Collections.reverse(children);
    for (ConfigurableApplicationContext child : children) {
        child.close();
    }//ww  w .j a v a  2 s.c o  m
}