Search in sources :

Example 1 with ModbusSlaveConnectionFactoryImpl

use of org.openhab.binding.modbus.internal.pooling.ModbusSlaveConnectionFactoryImpl in project openhab1-addons by openhab.

the class ModbusBinding method reconstructConnectionPool.

private static void reconstructConnectionPool() {
    connectionFactory = new ModbusSlaveConnectionFactoryImpl();
    GenericKeyedObjectPool<ModbusSlaveEndpoint, ModbusSlaveConnection> genericKeyedObjectPool = new GenericKeyedObjectPool<ModbusSlaveEndpoint, ModbusSlaveConnection>(connectionFactory, poolConfig);
    genericKeyedObjectPool.setSwallowedExceptionListener(new SwallowedExceptionListener() {

        @Override
        public void onSwallowException(Exception e) {
            logger.error("Connection pool swallowed unexpected exception: {}", e.getMessage());
        }
    });
    connectionPool = genericKeyedObjectPool;
}
Also used : GenericKeyedObjectPool(org.apache.commons.pool2.impl.GenericKeyedObjectPool) ModbusSlaveEndpoint(org.openhab.binding.modbus.internal.pooling.ModbusSlaveEndpoint) SwallowedExceptionListener(org.apache.commons.pool2.SwallowedExceptionListener) ModbusSlaveConnection(net.wimpi.modbus.net.ModbusSlaveConnection) ModbusSlaveConnectionFactoryImpl(org.openhab.binding.modbus.internal.pooling.ModbusSlaveConnectionFactoryImpl) ConfigurationException(org.osgi.service.cm.ConfigurationException) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

NoSuchElementException (java.util.NoSuchElementException)1 ModbusSlaveConnection (net.wimpi.modbus.net.ModbusSlaveConnection)1 SwallowedExceptionListener (org.apache.commons.pool2.SwallowedExceptionListener)1 GenericKeyedObjectPool (org.apache.commons.pool2.impl.GenericKeyedObjectPool)1 ModbusSlaveConnectionFactoryImpl (org.openhab.binding.modbus.internal.pooling.ModbusSlaveConnectionFactoryImpl)1 ModbusSlaveEndpoint (org.openhab.binding.modbus.internal.pooling.ModbusSlaveEndpoint)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1