Package org.apache.plc4x.java
Class DefaultPlcDriverManager
- java.lang.Object
-
- org.apache.plc4x.java.DefaultPlcDriverManager
-
- All Implemented Interfaces:
PlcConnectionManager
,PlcDriverManager
public class DefaultPlcDriverManager extends Object implements PlcDriverManager, PlcConnectionManager
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassLoader
classLoader
-
Constructor Summary
Constructors Constructor Description DefaultPlcDriverManager()
DefaultPlcDriverManager(ClassLoader classLoader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PlcConnection
getConnection(String url)
Connects to a PLC using the given plc connection string.PlcConnection
getConnection(String url, PlcAuthentication authentication)
Connects to a PLC using the given plc connection string using given authentication credentials.PlcConnectionManager
getConnectionManager()
PlcDriver
getDriver(String protocolCode)
Returns suitable driver for protocol or throws an Exception.PlcDriver
getDriverForUrl(String url)
Returns suitable driver for a given plc4x connection url or throws an Exception.Set<String>
getProtocolCodes()
Returns the codes of all the drivers which are currently registered at the PlcDriverManager
-
-
-
Field Detail
-
classLoader
protected final ClassLoader classLoader
-
-
Constructor Detail
-
DefaultPlcDriverManager
public DefaultPlcDriverManager()
-
DefaultPlcDriverManager
public DefaultPlcDriverManager(ClassLoader classLoader)
-
-
Method Detail
-
getConnection
public PlcConnection getConnection(String url) throws PlcConnectionException
Connects to a PLC using the given plc connection string.- Specified by:
getConnection
in interfacePlcConnectionManager
- Parameters:
url
- plc connection string.- Returns:
- PlcConnection object.
- Throws:
PlcConnectionException
- an exception if the connection attempt failed.
-
getConnection
public PlcConnection getConnection(String url, PlcAuthentication authentication) throws PlcConnectionException
Connects to a PLC using the given plc connection string using given authentication credentials.- Specified by:
getConnection
in interfacePlcConnectionManager
- Parameters:
url
- plc connection string.authentication
- authentication credentials.- Returns:
- PlcConnection object.
- Throws:
PlcConnectionException
- an exception if the connection attempt failed.
-
getProtocolCodes
public Set<String> getProtocolCodes()
Returns the codes of all the drivers which are currently registered at the PlcDriverManager- Specified by:
getProtocolCodes
in interfacePlcDriverManager
- Returns:
- Set of driver codes for all drivers registered
-
getDriver
public PlcDriver getDriver(String protocolCode) throws PlcConnectionException
Returns suitable driver for protocol or throws an Exception.- Specified by:
getDriver
in interfacePlcDriverManager
- Parameters:
protocolCode
- protocol code identifying the driver- Returns:
- Driver instance for the given protocol
- Throws:
PlcConnectionException
- If no Suitable Driver can be found
-
getDriverForUrl
public PlcDriver getDriverForUrl(String url) throws PlcConnectionException
Returns suitable driver for a given plc4x connection url or throws an Exception.- Specified by:
getDriverForUrl
in interfacePlcDriverManager
- Parameters:
url
- Uri to use- Returns:
- Driver instance for the given url
- Throws:
PlcConnectionException
- If no Suitable Driver can be found
-
getConnectionManager
public PlcConnectionManager getConnectionManager()
- Specified by:
getConnectionManager
in interfacePlcDriverManager
-
-