Java 类javax.annotation.PreDestroy 实例源码

项目:Spring-Security-Third-Edition    文件:DataSourceConfig.java   
/**
     * DataSource PreDestroy call-back
     * @throws SQLException
     */
    @PreDestroy()
    public void dataSourceDestroy() throws SQLException {

//        SQLException sqlException = null;
//
//        try {
//            applicationContext.getBean(DataSource.class)
//                    .getConnection()
//                    .close();
//        } catch (SQLException e){
//            sqlException = e;
//            e.printStackTrace();
//        }

        if (database != null) {
            database.shutdown();
        }

//        if(sqlException != null){
//            throw sqlException;
//        }
    }
项目:OpenJSharp    文件:WSEndpointImpl.java   
public synchronized void dispose() {
    if (disposed) {
        return;
    }
    disposed = true;

    masterTubeline.preDestroy();

    for (Handler handler : binding.getHandlerChain()) {
        for (Method method : handler.getClass().getMethods()) {
            if (method.getAnnotation(PreDestroy.class) == null) {
                continue;
            }
            try {
                method.invoke(handler);
            } catch (Exception e) {
                logger.log(Level.WARNING, HandlerMessages.HANDLER_PREDESTROY_IGNORE(e.getMessage()), e);
            }
            break;
        }
    }
    closeManagedObjectManager();
    LazyMOMProvider.INSTANCE.unregisterEndpoint(this);
}
项目:spring-boot-data-source-decorator    文件:P6SpyConfiguration.java   
@PreDestroy
public void destroy() {
    P6SpyProperties p6spy = dataSourceDecoratorProperties.getP6spy();
    if (!initialP6SpyOptions.containsKey("modulelist")) {
        System.clearProperty("p6spy.config.modulelist");
    }
    if (!initialP6SpyOptions.containsKey("logMessageFormat")) {
        if (p6spy.getLogFormat() != null) {
            System.clearProperty("p6spy.config.logMessageFormat");
            System.clearProperty("p6spy.config.customLogMessageFormat");
        }
        else if (p6spy.isMultiline()) {
            System.clearProperty("p6spy.config.logMessageFormat");
        }
    }
    if (!initialP6SpyOptions.containsKey("appender")) {
        System.clearProperty("p6spy.config.appender");
    }
    if (!initialP6SpyOptions.containsKey("logfile")) {
        System.clearProperty("p6spy.config.logfile");
    }
    P6ModuleManager.getInstance().reload();
}
项目:id_center    文件:ZKSnowflakeIDGenerator.java   
/**
 * Spring容器关闭前先停止ID生成器的工作,并关闭ZK管理器
 */
@Override
@PreDestroy
public void close() throws IOException {
    log.info("close zkManager before shutdown...");
    suspend();
    CloseableUtils.closeQuietly(zkManager);
}
项目:Spring-Security-Third-Edition    文件:DataSourceConfig.java   
/**
 * DataSource PreDestroy call-back
 * @throws SQLException
 */
@PreDestroy()
public void dataSourceDestroy() throws SQLException {

    if (database != null) {
        database.shutdown();
    }
}
项目:iotplatform    文件:MsgProducer.java   
@PreDestroy
public void destroy() {
  log.info("Stopping Kafka Producer....");
  try {
    this.producer.close();
  } catch (Exception e) {
    log.error("Failed to close producer during destroy()", e);
    throw new RuntimeException(e);
  }
  log.info("Kafka Producer is stopped now....");
}
项目:easyhbase    文件:CollectorMetric.java   
@PreDestroy
private void shutdown() {
    if (reporter == null) {
        return;
    }
    reporter.stop();
    reporter = null;
}
项目:testee.fi    文件:PostgresConnectionFactory.java   
@PreDestroy
public void release() {
    databases.values().forEach(dbName -> {
        try {
            dropDB(dbName);
        } catch (final RuntimeException e) {
            // Don't stop dropping DBs if one of them fails. Notify the user, though.
            LOG.error("Failed to cleanup PostgreSQL database {}", dbName, e);
        }
    });
}
项目:testee.fi    文件:H2PostgresConnectionFactory.java   
@PreDestroy
public void release() {
    dbNames.forEach(dbName -> execute(
            () -> {
                LOG.debug("Cleaning up H2 database: {}", dbName);
                connect(dbName, 0).close();
                return null;
            },
            e -> "Failed to close H2 database"
    ));
}
项目:testee.fi    文件:TransactionalContext.java   
@PreDestroy
public void shutdown() {
    LOG.debug("Shutting down transactional context");
    if (ejbContainer != null) {
        ejbContainer.shutdown();
    }
    if (realm != null) {
        realm.shutdown();
    }
}
项目:Spring-Security-Third-Edition    文件:DataSourceConfig.java   
/**
 * DataSource PreDestroy call-back
 * @throws SQLException
 */
@PreDestroy()
public void dataSourceDestroy() throws SQLException {
    if (database != null) {
        database.shutdown();
    }
}
项目:springboot-shiro-cas-mybatis    文件:SimpleHttpClientFactoryBean.java   
/**
 * Destroy.
 */
@PreDestroy
public void destroy() {
    if (this.executorService != null) {
        this.executorService.shutdownNow();
        this.executorService = null;
    }
}
项目:Biliomi    文件:SocketSession.java   
@Override
@PreDestroy
public void stop() {
  if (clientWebSocket != null && clientWebSocket.isOpen()) {
    clientWebSocket.disconnect();
  }
}
项目:xm-ms-timeline    文件:TimelineApp.java   
@PreDestroy
public void destroyApplication() {
    log.info("\n----------------------------------------------------------\n\t"
            + "Application {} is closing"
            + "\n----------------------------------------------------------",
        env.getProperty("spring.application.name"));
}
项目:cas-server-4.2.1    文件:CouchbaseTicketRegistry.java   
/**
 * Stops the couchbase client.
 */
@PreDestroy
public void destroy() {
    try {
        couchbase.shutdown();
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
项目:cas-server-4.2.1    文件:CouchbaseServiceRegistryDao.java   
/**
 * Stops the couchbase client and cancels the initialization task if uncompleted.
 */
@PreDestroy
public void destroy() {
    try {
        couchbase.shutdown();
    } catch (final Exception e) {
        throw new RuntimeException(e);
    }
}
项目:cas-5.1.0    文件:MemCacheTicketRegistry.java   
/**
 * Destroy the client and shut down.
 */
@PreDestroy
public void destroy() {
    if (this.client == null) {
        return;
    }
    this.client.shutdown();
}
项目:cas-5.1.0    文件:InMemoryTestLdapDirectoryServer.java   
@Override
@PreDestroy
public void close() {
    LOGGER.debug("Shutting down LDAP server...");
    this.directoryServer.closeAllConnections(true);
    this.directoryServer.shutDown(true);
    LOGGER.debug("Shut down LDAP server.");
}
项目:cas-server-4.2.1    文件:SimpleHttpClientFactoryBean.java   
/**
 * Destroy.
 */
@PreDestroy
public void destroy() {
    if (this.executorService != null) {
        this.executorService.shutdownNow();
        this.executorService = null;
    }
}
项目:loom    文件:BaseAdapter.java   
@Override
@PreDestroy
public void onUnload() {
    // close down thread
    synchronized (this) {
        open = false;
        notifyAll();
    }
}
项目:cas-server-4.2.1    文件:PoolingLdaptiveResourceCRLFetcher.java   
/**
 * Close connection pull and shut down the executor.
 */
@PreDestroy
public void destroy() {
    logger.debug("Shutting down connection pools...");
    for (final PooledConnectionFactory factory : connectionPoolMap.values()) {
        factory.getConnectionPool().close();
    }
}
项目:iothub    文件:MqttTransportService.java   
@PreDestroy
public void shutdown() throws InterruptedException {
  log.info("Stopping MQTT transport!");
  try {
    serverChannel.close().sync();
  } finally {
    bossGroup.shutdownGracefully();
    workerGroup.shutdownGracefully();
  }
  log.info("MQTT transport stopped!");
}
项目:buenojo    文件:CacheConfiguration.java   
@PreDestroy
public void destroy() {
    log.info("Remove Cache Manager metrics");
    SortedSet<String> names = metricRegistry.getNames();
    names.forEach(metricRegistry::remove);
    log.info("Closing Cache Manager");
    cacheManager.shutdown();
}
项目:Your-Microservice    文件:YourMicroserviceToken_nimbus_Impl.java   
/**
 * Pre-Destroy TearDown of Container.
 * Here we Destroy our SecretKey and JWS Signer.
 */
@PreDestroy
public void shutdown() {
    /**
     * Shutdown Component
     */
    LOGGER.info("{}YourMicroserviceToken Component Shutdown commencing...",
            LOGGING_HEADER);
    secretKey = null;
    jwsSigner = null;
    LOGGER.info("{}YourMicroserviceToken Component Shutdown Completed, ready for Bean Removal.",
            LOGGING_HEADER);
}
项目:kubernetes-client    文件:PortForwarder.java   
@PreDestroy
public void done() {

    Thread t = connectionHandler;
    if (t != null)
        t.interrupt();
}
项目:beadledom    文件:LifecycleProvisionListener.java   
private <T> List<InvokableLifecycleMethod> findPreDestroyMethods(T injectee, Class<?> type) {
  List<InvokableLifecycleMethod> preDestroyMethods = new ArrayList<InvokableLifecycleMethod>();
  for (Method method : getAllMethods(type)) {
    if (method.isAnnotationPresent(PreDestroy.class)) {
      preDestroyMethods.add(new InvokableLifecycleMethodImpl(injectee, method, PreDestroy.class));
    }
  }

  return preDestroyMethods;
}
项目:simple-hostel-management    文件:SystemTrayComponent.java   
/**
 * This method will be called when Spring app is destroyed
 */
@PreDestroy
public void removeSystemTray() {
    if (trayIcon != null) {
        final SystemTray tray = SystemTray.getSystemTray();
        tray.remove(trayIcon);
    }
}
项目:xsharing-services-router    文件:BatchManagerBean.java   
@PreDestroy
public void destroy() {
    JobOperator jo = BatchRuntime.getJobOperator();
    stashList.stream()
             .map(HashMap::keySet)
             .flatMap(Collection::stream) // join multiple sets together
             .forEach(jo::stop); // signal every job that we are going down and they should stop
}
项目:Spring-Security-Third-Edition    文件:DataSourceConfig.java   
/**
 * DataSource PreDestroy call-back
 * @throws SQLException
 */
@PreDestroy()
public void dataSourceDestroy() throws SQLException {
    if (database != null) {
        database.shutdown();
    }
}
项目:GoPush    文件:MonitorDataCenterService.java   
@PreDestroy
public void destory() {
    monitorDataCenterPool.clear();
    zkUtils.destory();
}
项目:iothub    文件:CoapTransportService.java   
@PreDestroy
public void shutdown() {
  log.info("Stopping CoAP transport!");
  this.server.destroy();
  log.info("CoAP transport stopped!");
}
项目:jdg-lab    文件:CacheResources.java   
@PreDestroy
private void cleanup() {
    if (cacheManager != null)
        cacheManager.stop();
}
项目:iotplatform    文件:CoapTransportService.java   
@PreDestroy
public void shutdown() {
  log.info("Stopping CoAP transport!");
  this.server.destroy();
  log.info("CoAP transport stopped!");
}
项目:tomcat7    文件:TesterServletWithLifeCycleMethods.java   
@PreDestroy
protected void preDestroy() {
    result = "preDestroy()";
}
项目:accs-javaee8    文件:Broadcaster.java   
@PreDestroy
public void free(){
    broadcaster.close();
    System.out.println("broadcaster closed");
}
项目:iot-edge-greengrass    文件:DefaultFileTailService.java   
@PreDestroy
public void preDestroy() {
    if (brokers != null) {
        brokers.forEach(FileMonitor::stop);
    }
}
项目:scalable-coffee-shop    文件:BaristaUpdateConsumer.java   
@PreDestroy
public void close() {
    eventConsumer.stop();
}
项目:maildump    文件:SmtpServerLauncher.java   
@PreDestroy
public void stop() {
    log.info("****** Stopping SMTP Server for domain " + smtpServer.getHostName() + " on port "
            + smtpServer.getPort());
    smtpServer.stop();
}
项目:Code4Health-Platform    文件:CacheConfiguration.java   
@PreDestroy
public void destroy() {
    log.info("Closing Cache Manager");
    Hazelcast.shutdownAll();
}
项目:flow-platform    文件:AppConfig.java   
@PreDestroy
protected void destroy() throws IOException {
    FileUtils.deleteDirectory(folder.toFile());
}