當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。