Example usage for org.apache.commons.pool2 KeyedObjectPool close

List of usage examples for org.apache.commons.pool2 KeyedObjectPool close

Introduction

In this page you can find the example usage for org.apache.commons.pool2 KeyedObjectPool close.

Prototype

void close();

Source Link

Document

Close this pool, and free any resources associated with it.

Usage

From source file:org.openhab.io.transport.modbus.internal.ModbusManagerImpl.java

@Deactivate
protected void deactivate() {
    synchronized (this) {
        KeyedObjectPool<ModbusSlaveEndpoint, ModbusSlaveConnection> connectionPool = this.connectionPool;
        if (connectionPool != null) {
            Set<@NonNull PollTask> polls = getRegisteredRegularPolls();
            for (PollTask task : polls) {
                unregisterRegularPoll(task);
            }/*from  www  .java 2  s. c  om*/

            connectionPool.close();
            this.connectionPool = connectionPool = null;
        }

        if (monitorFuture != null) {
            monitorFuture.cancel(true);
            monitorFuture = null;
        }
        // Note that it is not allowed to shutdown the executor, since they will be reused when
        // when pool is received from ThreadPoolManager is called
        scheduledThreadPoolExecutor = null;
        connectionFactory = null;
        logger.debug("Modbus manager deactivated");
    }
}