2 * Copyright (c) 2010-2020 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.io.transport.modbus.internal.pooling;
15 import org.apache.commons.pool2.PooledObject;
16 import org.apache.commons.pool2.impl.EvictionConfig;
17 import org.apache.commons.pool2.impl.EvictionPolicy;
18 import org.openhab.io.transport.modbus.internal.pooling.ModbusSlaveConnectionFactoryImpl.PooledConnection;
20 import net.wimpi.modbus.net.ModbusSlaveConnection;
23 * Eviction policy, i.e. policy for deciding when to close idle, unused connections.
25 * Connections are evicted according to {@link PooledConnection} maybeResetConnection method.
27 * @author Sami Salonen - Initial contribution
29 public class ModbusSlaveConnectionEvictionPolicy implements EvictionPolicy<ModbusSlaveConnection> {
32 public boolean evict(EvictionConfig config, PooledObject<ModbusSlaveConnection> underTest, int idleCount) {
33 return ((PooledConnection) underTest).maybeResetConnection("evict");