Example usage for org.springframework.context.support AbstractApplicationContext registerShutdownHook

List of usage examples for org.springframework.context.support AbstractApplicationContext registerShutdownHook

Introduction

In this page you can find the example usage for org.springframework.context.support AbstractApplicationContext registerShutdownHook.

Prototype

@Override
public void registerShutdownHook() 

Source Link

Document

Register a shutdown hook with the JVM runtime, closing this context on JVM shutdown unless it has already been closed at that time.

Usage

From source file:com.checkup.hadoop.Main.java

public static void main(String[] args) {

    AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml");
    ctx.registerShutdownHook();
}

From source file:org.powertac.logtool.Logtool.java

/**
 * Sets up the logtool, delegates everything to a LogtoolCore instance.
 *//*from   w  w w .j a v a  2 s  . c o  m*/
public static void main(String[] args) {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("logtool.xml");
    context.registerShutdownHook();

    // find the LogtoolCore bean
    LogtoolCore lc = (LogtoolCore) context.getBeansOfType(LogtoolCore.class).values().toArray()[0];
    lc.processCmdLine(args);

    // if we get here, it's time to exit
    System.exit(0);
}

From source file:samples.ProducerApplication.java

public static void main(String[] args) {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    context.registerShutdownHook();

    SpringJmsProducer producer = (SpringJmsProducer) context.getBean("springJmsProducer");
    producer.run();/*from w w  w .j  ava  2s . c  om*/

    ((org.springframework.jms.connection.CachingConnectionFactory) context.getBean("connectionFactory"))
            .resetConnection();
}

From source file:com.ushahidi.swiftriver.core.dropqueue.DropQueueProcessor.java

@SuppressWarnings("resource")
public static void main(String[] args) {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("appContext.xml");
    context.registerShutdownHook();

    DropFilterPublisher dropFilterPublisher = context.getBean(DropFilterPublisher.class);
    dropFilterPublisher.start();//from w ww.  ja v  a  2 s  .  c o m

    logger.info("Drop queue processor started");
}

From source file:com.parivero.jenkins.speech.App.java

public static void main(String[] args) throws InterruptedException {

    AbstractApplicationContext context = new ClassPathXmlApplicationContext(
            "classpath:spring/jenkins-speech-integration.xml");
    context.registerShutdownHook();

}

From source file:samples.ConsumerApplication.java

public static void main(String[] args) {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    context.registerShutdownHook();

    boolean sync = true;
    if (args != null && args.length > 0) {
        sync = Boolean.valueOf(args[0]);
    }/*from  w  w  w. jav a  2  s . co m*/

    if (sync == true) {
        //Example of a sync consumer with Spring JMS
        SpringJmsConsumer consumer = (SpringJmsConsumer) context.getBean("springJmsConsumer");
        consumer.run();
        ((org.springframework.jms.connection.CachingConnectionFactory) context.getBean("connectionFactory"))
                .resetConnection();
    } else {
        //Example of an async consumer with Spring JMS (autoStartup is normally set to true)
        AbstractJmsListeningContainer listenerContainer = (AbstractJmsListeningContainer) context
                .getBean("listenerContainer");
        listenerContainer.start();
    }
}

From source file:com.artivisi.biller.simulator.gateway.pln.Launcher.java

public static void main(String[] args) {
    AbstractApplicationContext ctx = new ClassPathXmlApplicationContext(
            "classpath*:com/artivisi/**/applicationContext.xml");
    ctx.registerShutdownHook();
}

From source file:com.ushahidi.swiftriver.core.rules.RulesProcessor.java

@SuppressWarnings("resource")
public static void main(String[] args) {
    AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "applicationContext.xml");

    applicationContext.registerShutdownHook();

}

From source file:org.powertac.server.PowerTacServer.java

/**
 * Sets up the container, sets up logging, and starts the
 * CompetitionControl service.//from   ww w  .  ja  v  a2  s.  co m
 * <p>
 * A simple script file can be used in lieu of a web interface to
 * configure and run games. Each line in the file must be in one of two
 * forms:<br/>
 * <code>&nbsp;&nbsp;bootstrap [--config boot-config]</code><br/>
 * <code>&nbsp;&nbsp;sim [--config sim-config] broker1 broker2 ...</code><br/>
 * where 
 * <dl>
 *  <dt><code>boot-config</code></dt>
 *  <dd>is the optional name of a properties file that specifies the
 *    bootstrap setup. If not provided, then the default
 *    server.properties will be used.</dd>
 *  <dt><code>sim-config</code></dt>
 *  <dd>is the optional name of a properties file that specifies the
 *    simulation setup. If not provided, then the default server.properties
 *    file will be used. It is possible for the sim-config to be different
 *    from the boot-config that produced the bootstrap data file used
 *    in the sim, but many properties will be carried over from the
 *    bootstrap session regardless of the contents of sim-config.</dd>
 *  <dt><code>brokern</code></dt>
 *  <dd>are the broker usernames of the brokers that will be logged in
 *    before the simulation starts. They must attempt to log in after the
 *    server starts.</dd>
 * </dl>
 * To use a configuration file, simply give the filename as a command-line
 * argument.
 *  
 */
public static void main(String[] args) {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("powertac.xml");
    context.registerShutdownHook();

    // find the CompetitionControl and ServerProperties beans
    css = (CompetitionSetupService) context.getBeansOfType(CompetitionSetupService.class).values().toArray()[0];

    css.processCmdLine(args);
    // if we get here, it's time to exit
    System.exit(0);
}

From source file:org.openflamingo.uploader.Starter.java

public static void main(String[] args) {
    AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "classpath:applicationContext.xml");
    applicationContext.registerShutdownHook();
}