Class BaSyxConnector
- java.lang.Object
-
- de.iip_ecosphere.platform.support.aas.basyx.basyx.BaSyxConnector
-
- All Implemented Interfaces:
org.eclipse.basyx.vab.protocol.api.IBaSyxConnector
public class BaSyxConnector extends java.lang.Object implements org.eclipse.basyx.vab.protocol.api.IBaSyxConnectorBaSyx connector class. Taken over from BaSyx to get rid of logging.- Author:
- kuhn, pschorn, schnicke
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.channels.SocketChannelchannelToProviderprivate booleankeepOpenprivate org.slf4j.Loggerloggerprivate java.net.InetSocketAddressserverSocketAddress
-
Constructor Summary
Constructors Constructor Description BaSyxConnector(java.lang.String hostName, int port)Constructor that creates a connection.BaSyxConnector(java.lang.String hostName, int port, boolean keepOpen)Constructor that creates a connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcloseConnection()Close connection.private byte[]createCall(java.lang.String servicePath, byte callType)Create non-parameterized call that can be used as an argument to the invokeBaSyx function.private byte[]createCall(java.lang.String servicePath, java.lang.String newValue, byte callType)Create parameterized byte call that can be used as an argument to the invokeBaSyx function.java.lang.StringcreateValue(java.lang.String servicePath, java.lang.String newValue)java.lang.StringdeleteValue(java.lang.String servicePath)java.lang.StringdeleteValue(java.lang.String servicePath, java.lang.String jsonObject)java.lang.StringgetEndpointRepresentation(java.lang.String path)Get string representation of endpoint for given path for debugging.java.lang.StringgetValue(java.lang.String servicePath)protected java.lang.StringinvokeBaSyx(byte[] call)Invoke a BaSyx operation in a remote provider.java.lang.StringinvokeOperation(java.lang.String servicePath, java.lang.String parameters)protected voidreadBytes(java.nio.ByteBuffer bytes, int expectedBytes)Read a number of bytes.java.lang.StringsetValue(java.lang.String servicePath, java.lang.String newValue)
-
-
-
Constructor Detail
-
BaSyxConnector
public BaSyxConnector(java.lang.String hostName, int port)Constructor that creates a connection. This constructor connects to port at name.- Parameters:
hostName- the name of the target hostport- the port number
-
BaSyxConnector
public BaSyxConnector(java.lang.String hostName, int port, boolean keepOpen)Constructor that creates a connection. This constructor connects to port at name.- Parameters:
hostName- the name of the target hostport- the port numberkeepOpen- whether the connection shall be kept open or terminated per request
-
-
Method Detail
-
closeConnection
private void closeConnection()
Close connection.
-
invokeBaSyx
protected java.lang.String invokeBaSyx(byte[] call)
Invoke a BaSyx operation in a remote provider.- Parameters:
call- the serialized call- Returns:
- the call result
-
readBytes
protected void readBytes(java.nio.ByteBuffer bytes, int expectedBytes)Read a number of bytes.- Parameters:
bytes- the buffer to read fromexpectedBytes- the number of bytes to read
-
getValue
public java.lang.String getValue(java.lang.String servicePath)
- Specified by:
getValuein interfaceorg.eclipse.basyx.vab.protocol.api.IBaSyxConnector
-
setValue
public java.lang.String setValue(java.lang.String servicePath, java.lang.String newValue)- Specified by:
setValuein interfaceorg.eclipse.basyx.vab.protocol.api.IBaSyxConnector
-
createValue
public java.lang.String createValue(java.lang.String servicePath, java.lang.String newValue) throws org.eclipse.basyx.vab.exception.provider.ProviderException- Specified by:
createValuein interfaceorg.eclipse.basyx.vab.protocol.api.IBaSyxConnector- Throws:
org.eclipse.basyx.vab.exception.provider.ProviderException
-
invokeOperation
public java.lang.String invokeOperation(java.lang.String servicePath, java.lang.String parameters) throws org.eclipse.basyx.vab.exception.provider.ProviderException- Specified by:
invokeOperationin interfaceorg.eclipse.basyx.vab.protocol.api.IBaSyxConnector- Throws:
org.eclipse.basyx.vab.exception.provider.ProviderException
-
deleteValue
public java.lang.String deleteValue(java.lang.String servicePath) throws org.eclipse.basyx.vab.exception.provider.ProviderException- Specified by:
deleteValuein interfaceorg.eclipse.basyx.vab.protocol.api.IBaSyxConnector- Throws:
org.eclipse.basyx.vab.exception.provider.ProviderException
-
deleteValue
public java.lang.String deleteValue(java.lang.String servicePath, java.lang.String jsonObject) throws org.eclipse.basyx.vab.exception.provider.ProviderException- Specified by:
deleteValuein interfaceorg.eclipse.basyx.vab.protocol.api.IBaSyxConnector- Throws:
org.eclipse.basyx.vab.exception.provider.ProviderException
-
createCall
private byte[] createCall(java.lang.String servicePath, byte callType)Create non-parameterized call that can be used as an argument to the invokeBaSyx function.- Parameters:
servicePath- the path to the servicecallType- the call type- Returns:
- the call result
-
createCall
private byte[] createCall(java.lang.String servicePath, java.lang.String newValue, byte callType)Create parameterized byte call that can be used as an argument to the invokeBaSyx function.- Parameters:
servicePath- the path to the servicenewValue- the valuecallType- the call type- Returns:
- the result of the call
-
getEndpointRepresentation
public java.lang.String getEndpointRepresentation(java.lang.String path)
Get string representation of endpoint for given path for debugging.- Specified by:
getEndpointRepresentationin interfaceorg.eclipse.basyx.vab.protocol.api.IBaSyxConnector- Parameters:
path- Requested path- Returns:
- String representing requested endpoint
-
-