当前位置: 首页>>代码示例>>Java>>正文


Java PreDestroy类代码示例

本文整理汇总了Java中javax.annotation.PreDestroy的典型用法代码示例。如果您正苦于以下问题:Java PreDestroy类的具体用法?Java PreDestroy怎么用?Java PreDestroy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PreDestroy类属于javax.annotation包,在下文中一共展示了PreDestroy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dataSourceDestroy

import javax.annotation.PreDestroy; //导入依赖的package包/类
/**
     * 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;
//        }
    }
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:27,代码来源:DataSourceConfig.java

示例2: dispose

import javax.annotation.PreDestroy; //导入依赖的package包/类
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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:WSEndpointImpl.java

示例3: destroy

import javax.annotation.PreDestroy; //导入依赖的package包/类
@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:gavlyukovskiy,项目名称:spring-boot-data-source-decorator,代码行数:24,代码来源:P6SpyConfiguration.java

示例4: close

import javax.annotation.PreDestroy; //导入依赖的package包/类
/**
 * Spring容器关闭前先停止ID生成器的工作,并关闭ZK管理器
 */
@Override
@PreDestroy
public void close() throws IOException {
    log.info("close zkManager before shutdown...");
    suspend();
    CloseableUtils.closeQuietly(zkManager);
}
 
开发者ID:zhongmingmao,项目名称:id_center,代码行数:11,代码来源:ZKSnowflakeIDGenerator.java

示例5: dataSourceDestroy

import javax.annotation.PreDestroy; //导入依赖的package包/类
/**
 * DataSource PreDestroy call-back
 * @throws SQLException
 */
@PreDestroy()
public void dataSourceDestroy() throws SQLException {

    if (database != null) {
        database.shutdown();
    }
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:12,代码来源:DataSourceConfig.java

示例6: shutdown

import javax.annotation.PreDestroy; //导入依赖的package包/类
@PreDestroy
private void shutdown() {
    if (reporter == null) {
        return;
    }
    reporter.stop();
    reporter = null;
}
 
开发者ID:fchenxi,项目名称:easyhbase,代码行数:9,代码来源:CollectorMetric.java

示例7: release

import javax.annotation.PreDestroy; //导入依赖的package包/类
@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);
        }
    });
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:12,代码来源:PostgresConnectionFactory.java

示例8: release

import javax.annotation.PreDestroy; //导入依赖的package包/类
@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"
    ));
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:12,代码来源:H2PostgresConnectionFactory.java

示例9: shutdown

import javax.annotation.PreDestroy; //导入依赖的package包/类
@PreDestroy
public void shutdown() {
    LOG.debug("Shutting down transactional context");
    if (ejbContainer != null) {
        ejbContainer.shutdown();
    }
    if (realm != null) {
        realm.shutdown();
    }
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:11,代码来源:TransactionalContext.java

示例10: dataSourceDestroy

import javax.annotation.PreDestroy; //导入依赖的package包/类
/**
 * DataSource PreDestroy call-back
 * @throws SQLException
 */
@PreDestroy()
public void dataSourceDestroy() throws SQLException {
    if (database != null) {
        database.shutdown();
    }
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:11,代码来源:DataSourceConfig.java

示例11: destroy

import javax.annotation.PreDestroy; //导入依赖的package包/类
/**
 * Destroy.
 */
@PreDestroy
public void destroy() {
    if (this.executorService != null) {
        this.executorService.shutdownNow();
        this.executorService = null;
    }
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:11,代码来源:SimpleHttpClientFactoryBean.java

示例12: stop

import javax.annotation.PreDestroy; //导入依赖的package包/类
@Override
@PreDestroy
public void stop() {
  if (clientWebSocket != null && clientWebSocket.isOpen()) {
    clientWebSocket.disconnect();
  }
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:8,代码来源:SocketSession.java

示例13: destroyApplication

import javax.annotation.PreDestroy; //导入依赖的package包/类
@PreDestroy
public void destroyApplication() {
    log.info("\n----------------------------------------------------------\n\t"
            + "Application {} is closing"
            + "\n----------------------------------------------------------",
        env.getProperty("spring.application.name"));
}
 
开发者ID:xm-online,项目名称:xm-ms-timeline,代码行数:8,代码来源:TimelineApp.java

示例14: destroy

import javax.annotation.PreDestroy; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:12,代码来源:CouchbaseServiceRegistryDao.java

示例15: destroy

import javax.annotation.PreDestroy; //导入依赖的package包/类
/**
 * Destroy the client and shut down.
 */
@PreDestroy
public void destroy() {
    if (this.client == null) {
        return;
    }
    this.client.shutdown();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:11,代码来源:MemCacheTicketRegistry.java


注:本文中的javax.annotation.PreDestroy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。