Example usage for org.springframework.context Lifecycle Lifecycle

List of usage examples for org.springframework.context Lifecycle Lifecycle

Introduction

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

Prototype

Lifecycle

Source Link

Usage

From source file:edu.dfci.cccb.mev.web.configuration.PersistenceConfiguration.java

@Bean
@Profile("!test")
public Lifecycle h2ConsoleServer() {
    return new Lifecycle() {

        private Server server;
        private final int port = environment.getProperty("h2.console.port", Integer.class, 18043);

        /* (non-Javadoc)
         * @see org.springframework.context.Lifecycle#start() */
        @Override/*  w ww . j  ava  2 s .  c  o  m*/
        @Synchronized
        @PostConstruct
        public void start() {
            try {
                (server = createWebServer("-webPort", valueOf(port))).start();
                log.info("Started H2 console on port " + port);
            } catch (SQLException e) {
                log.warn("Failed to start H2 console on port " + port, e);
            }
        }

        /* (non-Javadoc)
         * @see org.springframework.context.Lifecycle#stop() */
        @Override
        @Synchronized
        public void stop() {
            server.stop();
            log.info("Stopped H2 console");
            server = null;
        }

        /* (non-Javadoc)
         * @see org.springframework.context.Lifecycle#isRunning() */
        @Override
        @Synchronized
        public boolean isRunning() {
            return server != null;
        }
    };
}

From source file:org.springframework.integration.smpp.session.ExtendedSmppSessionAdaptingDelegate.java

/**
 * noops for the {@link Lifecycle} arg in {@link ExtendedSmppSessionAdaptingDelegate#ExtendedSmppSessionAdaptingDelegate(org.jsmpp.session.SMPPSession, org.springframework.context.Lifecycle)}
 *
 * @param session the session//  www.  j av a 2s  . c  o  m
 */
public ExtendedSmppSessionAdaptingDelegate(SMPPSession session) {
    this(session, new Lifecycle() {
        public void start() {
        }

        public void stop() {
        }

        public boolean isRunning() {
            return true;
        }
    });
}