Class 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.IBaSyxConnector
    BaSyx connector class. Taken over from BaSyx to get rid of logging.
    Author:
    kuhn, pschorn, schnicke
    • 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 void closeConnection()
      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.String createValue​(java.lang.String servicePath, java.lang.String newValue)  
      java.lang.String deleteValue​(java.lang.String servicePath)  
      java.lang.String deleteValue​(java.lang.String servicePath, java.lang.String jsonObject)  
      java.lang.String getEndpointRepresentation​(java.lang.String path)
      Get string representation of endpoint for given path for debugging.
      java.lang.String getValue​(java.lang.String servicePath)  
      protected java.lang.String invokeBaSyx​(byte[] call)
      Invoke a BaSyx operation in a remote provider.
      java.lang.String invokeOperation​(java.lang.String servicePath, java.lang.String parameters)  
      protected void readBytes​(java.nio.ByteBuffer bytes, int expectedBytes)
      Read a number of bytes.
      java.lang.String setValue​(java.lang.String servicePath, java.lang.String newValue)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        private org.slf4j.Logger logger
      • serverSocketAddress

        private java.net.InetSocketAddress serverSocketAddress
      • channelToProvider

        private java.nio.channels.SocketChannel channelToProvider
      • keepOpen

        private boolean keepOpen
    • 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 host
        port - 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 host
        port - the port number
        keepOpen - 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 from
        expectedBytes - the number of bytes to read
      • getValue

        public java.lang.String getValue​(java.lang.String servicePath)
        Specified by:
        getValue in interface org.eclipse.basyx.vab.protocol.api.IBaSyxConnector
      • setValue

        public java.lang.String setValue​(java.lang.String servicePath,
                                         java.lang.String newValue)
        Specified by:
        setValue in interface org.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:
        createValue in interface org.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:
        invokeOperation in interface org.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:
        deleteValue in interface org.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:
        deleteValue in interface org.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 service
        callType - 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 service
        newValue - the value
        callType - 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:
        getEndpointRepresentation in interface org.eclipse.basyx.vab.protocol.api.IBaSyxConnector
        Parameters:
        path - Requested path
        Returns:
        String representing requested endpoint