Class ClientContext

  • All Implemented Interfaces:
    Encodable, Serializable

    public final class ClientContext
    extends Object
    implements Serializable, Encodable
    The ClientContext class holds the data related to a connection context. Contexts are only reloaded during a broker restart to allow them to be cleaned up, they are then immediately deleted.
    See Also:
    Serialized Form
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        define serialVersionUID for interoperability
        See Also:
        Constant Field Values
      • logger

        public static final Logger logger
        logger
      • DEBUG

        private static final boolean DEBUG
      • id

        private int id
        Context identifier.
      • tempDestinations

        private Vector<AgentId> tempDestinations
        Vector of temporary destinations.
      • deliveringQueues

        private Hashtable<AgentId,​AgentId> deliveringQueues
        Identifiers of queues delivering messages.
      • transactionsTable

        private Hashtable<Xid,​XACnxPrepare> transactionsTable
        Prepared transactions objects waiting for commit.
      • started

        private transient boolean started
        true if the context is activated.
      • cancelledRequestId

        private transient int cancelledRequestId
        Identifier of a cancelled "receive" request, set when a PTP listener has been unset.
      • activeSubs

        private transient Vector<String> activeSubs
        Vector of active subscriptions' names.
      • repliesBuffer

        private transient Vector<AbstractJmsReply> repliesBuffer
        Pending replies waiting for the context to be activated.
      • proxyId

        private AgentId proxyId
        The proxy's agent identifier
      • proxy

        private transient ProxyAgentItf proxy
        An handle to proxy Agent
      • txName

        private transient String txName
      • modified

        private transient boolean modified
      • first

        private transient boolean first
    • Constructor Detail

      • ClientContext

        ClientContext()
      • ClientContext

        ClientContext​(AgentId proxyId,
                      int id)
        Constructs a ClientContext instance.
        Parameters:
        proxyId - The proxy's agent identifier.
        id - Identifier of the context.
    • Method Detail

      • getId

        int getId()
        Returns the identifier of the context.
      • addTemporaryDestination

        void addTemporaryDestination​(AgentId destId)
        Adds a temporary destination identifier.
      • removeTemporaryDestination

        void removeTemporaryDestination​(AgentId destId)
        Removes a temporary destination identifier.
      • addDeliveringQueue

        void addDeliveringQueue​(AgentId queueId)
        Adds, if not already, the identifier of a delivering queue.
      • getDeliveringQueues

        Iterator<AgentId> getDeliveringQueues()
        Returns the identifiers of the delivering queues.
      • setActivated

        void setActivated​(boolean started)
        Sets the activation status of the context.
      • isActivated

        boolean isActivated()
        Returns true if the context is activated.
      • cancelReceive

        void cancelReceive​(int cancelledRequestId)
        Cancels a "receive" request.
      • getCancelledReceive

        int getCancelledReceive()
        Returns the cancelled "receive" request identifier.
      • addSubName

        void addSubName​(String subName)
        Adds an active subscription name.
      • getActiveSubs

        Iterator<String> getActiveSubs()
        Returns the active subscriptions' names.
      • removeSubName

        void removeSubName​(String subName)
        Removes an active subscription name.
      • addPendingDelivery

        void addPendingDelivery​(AbstractJmsReply reply)
        Adds a pending delivery.
      • clearPendingDeliveries

        void clearPendingDeliveries()
        Clears the pending deliveries buffer.
      • addMultiReplyContext

        void addMultiReplyContext​(int requestId,
                                  int asyncReplyCount)
        Some requests may require to wait for several SendReplyNot notifications before replying to the client.
        Parameters:
        requestId -
        asyncReplyCount -
      • getProxyId

        public AgentId getProxyId()
      • setModified

        private final void setModified()
      • setReply

        int setReply​(int requestId)
        Called by UserAgent when a SendReplyNot arrived.
        Parameters:
        requestId -
        Returns:
        > 0 if there are still some pending replies, 0 if all the replies arrived (the context is removed) or if the context doesn't exist
      • getTxPrepare

        XACnxPrepare getTxPrepare​(Object key)
        Returns and deletes a given transaction "prepare".
      • isPrepared

        public boolean isPrepared​(Object key)
        Parameters:
        key - XID
        Returns:
        true if prepared transation.
      • getTxIds

        Iterator<Xid> getTxIds()
        Returns the identifiers of the prepared transactions.
      • getEncodableClassId

        public int getEncodableClassId()
        Description copied from interface: Encodable
        Returns a unique class identifier.
        Specified by:
        getEncodableClassId in interface Encodable
        Returns:
        a unique class identifier
      • getEncodedSize

        public int getEncodedSize()
                           throws Exception
        Description copied from interface: Encodable
        Returns the size of the byte array that results from the encoding of this object.
        Specified by:
        getEncodedSize in interface Encodable
        Returns:
        the size of the encoded byte array
        Throws:
        Exception - if an error occurs
      • encode

        public void encode​(Encoder encoder)
                    throws Exception
        Description copied from interface: Encodable
        Encodes the content of this object
        Specified by:
        encode in interface Encodable
        Parameters:
        encoder - the encoder to be used for the encoding
        Throws:
        Exception - if an error occurs
      • decode

        public void decode​(Decoder decoder)
                    throws Exception
        Description copied from interface: Encodable
        Decodes the content of this object
        Specified by:
        decode in interface Encodable
        Parameters:
        decoder - the decoder to be used for the decoding
        Throws:
        Exception - if an error occurs
      • getTransactionPrefix

        public static String getTransactionPrefix​(AgentId proxyId)
      • getTxName

        public final String getTxName()
      • save

        public final void save()
      • delete

        public void delete()
      • getActiveSubList

        List<String> getActiveSubList()
      • getTempDestinationList

        List<AgentId> getTempDestinationList()