Class SocketProductReceiverHandler

  • All Implemented Interfaces:
    java.lang.Runnable

    public class SocketProductReceiverHandler
    extends java.lang.Object
    implements java.lang.Runnable
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected BinaryIO io
      Protected Variable for BinaryIO
      static int PDL_PROTOCOL_BUFFER
      buffer for PDL protocol.
      protected java.lang.String protocolVersion
      Protected Variable for a string of protocolVersion
      protected SocketProductReceiver receiver
      Protected Variable for SocketProductReceiver
      protected java.net.Socket socket
      Protected Variable for Socket
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void acquireWriteLock​(ProductId id)
      Acquire write lock in receiver storage.
      java.lang.String readProtocolVersion​(java.io.InputStream in)
      Read PDL protocol version.
      void releaseWriteLock​(ProductId id)
      Release write lock in receiver storeage.
      void run()
      Process incoming socket connection.
      void sendException​(java.io.OutputStream out, java.lang.Exception e)
      Send an exception to the user.
      void sendString​(java.io.OutputStream out, java.lang.String str)
      Send a string to the user.
      • Methods inherited from class java.lang.Object

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

      • PDL_PROTOCOL_BUFFER

        public static final int PDL_PROTOCOL_BUFFER
        buffer for PDL protocol. Set to 1024
        See Also:
        Constant Field Values
      • io

        protected final BinaryIO io
        Protected Variable for BinaryIO
      • socket

        protected final java.net.Socket socket
        Protected Variable for Socket
      • protocolVersion

        protected java.lang.String protocolVersion
        Protected Variable for a string of protocolVersion
    • Constructor Detail

      • SocketProductReceiverHandler

        public SocketProductReceiverHandler​(SocketProductReceiver receiver,
                                            java.net.Socket socket)
        Constructor
        Parameters:
        receiver - SocketProductReceiver
        socket - Socket
    • Method Detail

      • acquireWriteLock

        public void acquireWriteLock​(ProductId id)
        Acquire write lock in receiver storage.
        Parameters:
        id - product to lock.
      • releaseWriteLock

        public void releaseWriteLock​(ProductId id)
        Release write lock in receiver storeage.
        Parameters:
        id - product to unlock.
      • readProtocolVersion

        public java.lang.String readProtocolVersion​(java.io.InputStream in)
                                             throws java.io.IOException
        Read PDL protocol version.
        Parameters:
        in - input stream to read
        Returns:
        version, or null if not the PDL protocol.
        Throws:
        java.io.IOException - if IO error occurs
      • run

        public void run()
        Process incoming socket connection.
        Specified by:
        run in interface java.lang.Runnable
      • sendException

        public void sendException​(java.io.OutputStream out,
                                  java.lang.Exception e)
        Send an exception to the user.
        Parameters:
        out - output stream where exception message is written
        e - exception to write
      • sendString

        public void sendString​(java.io.OutputStream out,
                               java.lang.String str)
                        throws java.io.IOException
        Send a string to the user.
        Parameters:
        out - output stream where exception message is written
        str - string to write
        Throws:
        java.io.IOException - if IO error occurs