Class CachedDriverManager
java.lang.Object
org.apache.plc4x.java.PlcDriverManager
org.apache.plc4x.java.utils.connectionpool2.CachedDriverManager
- All Implemented Interfaces:
CachedDriverManagerMBean
Driver Manager who Caches ONE Single Connection.
Usage Example:
PlcDriverManager manager = new PlcDriverManager();
PlcDriverManager cached = new CachedDriverManager(url, () -> manager.getConnection(url));
Now you can use "cached" everywhere you need the corresponding connection.
-
Field Summary
FieldsFields inherited from class org.apache.plc4x.java.PlcDriverManager
classLoader -
Constructor Summary
ConstructorsConstructorDescriptionCachedDriverManager(String url, PlcConnectionFactory connectionFactory) CachedDriverManager(String url, PlcConnectionFactory connectionFactory, int timeoutMillis) -
Method Summary
Modifier and TypeMethodDescriptiongetConnection(String url) This call now waits (with the timeout given in constructor) until it fails or returns a valid connection in this window.getConnection(String url, PlcAuthentication authentication) intintintintintorg.apache.plc4x.java.utils.connectionpool2.CachedDriverManager.ConnectionStategetState()voidused to signal, that the connection does not work and has to be re-established.booleanvoidreturnConnection(PlcConnection activeConnection) voidMethods inherited from class org.apache.plc4x.java.PlcDriverManager
getDriver, getDriverForUrl, listDrivers
-
Field Details
-
LONG_BORROW_WATCHDOG_TIMEOUT_MS
public static final int LONG_BORROW_WATCHDOG_TIMEOUT_MS- See Also:
-
-
Constructor Details
-
CachedDriverManager
-
CachedDriverManager
- Parameters:
url- Url that this connection is forconnectionFactory- Factory to create a suitable connection.timeoutMillis- Time out in milliseconds
-
-
Method Details
-
returnConnection
-
handleBrokenConnection
public void handleBrokenConnection()used to signal, that the connection does not work and has to be re-established. -
isConnectionAvailable
public boolean isConnectionAvailable() -
getConnection
This call now waits (with the timeout given in constructor) until it fails or returns a valid connection in this window.- Overrides:
getConnectionin classPlcDriverManager- Throws:
PlcConnectionException- if connection cannot be established
-
getConnection
public PlcConnection getConnection(String url, PlcAuthentication authentication) throws PlcConnectionException - Overrides:
getConnectionin classPlcDriverManager- Throws:
PlcConnectionException
-
getState
public org.apache.plc4x.java.utils.connectionpool2.CachedDriverManager.ConnectionState getState() -
getStateString
- Specified by:
getStateStringin interfaceCachedDriverManagerMBean
-
getNumberOfConnects
public int getNumberOfConnects()- Specified by:
getNumberOfConnectsin interfaceCachedDriverManagerMBean
-
getNumberOfBorrows
public int getNumberOfBorrows()- Specified by:
getNumberOfBorrowsin interfaceCachedDriverManagerMBean
-
getNumberOfRejections
public int getNumberOfRejections()- Specified by:
getNumberOfRejectionsin interfaceCachedDriverManagerMBean
-
getNumberOfWachtdogs
public int getNumberOfWachtdogs()- Specified by:
getNumberOfWachtdogsin interfaceCachedDriverManagerMBean
-
getQueueSize
public int getQueueSize()- Specified by:
getQueueSizein interfaceCachedDriverManagerMBean
-
triggerReconnect
public void triggerReconnect()- Specified by:
triggerReconnectin interfaceCachedDriverManagerMBean
-