Class PojoMessageHandlerWholeBase<T>

    • Field Detail

      • decoders

        protected final java.util.List<Decoder> decoders
        The list of decoders for this message handler.
    • Constructor Detail

      • PojoMessageHandlerWholeBase

        public PojoMessageHandlerWholeBase​(java.lang.Object pojo,
                                           java.lang.reflect.Method method,
                                           Session session,
                                           java.lang.Object[] params,
                                           int indexPayload,
                                           boolean convert,
                                           int indexSession,
                                           long maxMessageSize)
        Create a whole message handler.
        Parameters:
        pojo - POJO instance
        method - Method to invoke
        session - WebSocket session
        params - Pre-populated parameter array
        indexPayload - Index of the payload parameter
        convert - Convert the message before passing to the method
        indexSession - Index of the session parameter
        maxMessageSize - Maximum message size
    • Method Detail

      • createDecoderInstance

        protected Decoder createDecoderInstance​(java.lang.Class<? extends Decoder> clazz)
                                         throws java.lang.ReflectiveOperationException,
                                                javax.naming.NamingException
        Create an instance of the given decoder class.
        Parameters:
        clazz - Decoder class
        Returns:
        New decoder instance
        Throws:
        java.lang.ReflectiveOperationException - If the decoder cannot be instantiated
        javax.naming.NamingException - If the instance manager fails to create the decoder
      • onClose

        protected void onClose()
        Called when the WebSocket session is closed. Destroys all decoders.
      • convert

        protected java.lang.Object convert​(T message)
        Convert the message to the type expected by the target method.
        Parameters:
        message - Message to convert
        Returns:
        Converted message
      • decode

        protected abstract java.lang.Object decode​(T message)
                                            throws DecodeException
        Decode the message using the registered decoders.
        Parameters:
        message - Message to decode
        Returns:
        Decoded message or null if no decoder could decode it
        Throws:
        DecodeException - If the message cannot be decoded