Class ProtonLink<L extends Link<L>>

    • Constructor Detail

      • ProtonLink

        protected ProtonLink​(ProtonSession session,
                             String name,
                             ProtonLinkCreditState creditState)
        Create a new link instance with the given parent session.
        Parameters:
        session - The Session that this link resides within.
        name - The name assigned to this Link
        creditState - The link credit state used to track credit for the link.
    • Method Detail

      • getName

        public String getName()
        Specified by:
        getName in interface Link<L extends Link<L>>
        Returns:
        the link name that is assigned to this Link
      • isSender

        public boolean isSender()
        Specified by:
        isSender in interface Link<L extends Link<L>>
        Returns:
        true if this link is acting in a sender Role.
      • isReceiver

        public boolean isReceiver()
        Specified by:
        isReceiver in interface Link<L extends Link<L>>
        Returns:
        true if this link is acting in a receiver Role.
      • self

        protected abstract L self()
      • getRemoteState

        public LinkState getRemoteState()
        Specified by:
        getRemoteState in interface Link<L extends Link<L>>
        Returns:
        the remote link state (as last communicated)
      • open

        public L open()
        Description copied from interface: Endpoint
        Open the end point locally, sending the Open performative immediately if possible or holding it until SASL negotiations or the AMQP header exchange and other required performative exchanges has completed. The end point will signal any registered handler of the remote opening the Connection once the remote performative that signals open completion arrives.
        Specified by:
        open in interface Endpoint<L extends Link<L>>
        Returns:
        this Endpoint instance.
      • detach

        public L detach()
        Description copied from interface: Link
        Detach this end of the link.
        Specified by:
        detach in interface Link<L extends Link<L>>
        Returns:
        this Link.
      • close

        public L close()
        Description copied from interface: Endpoint
        Close the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it. If the engine encounters an error writing the performative or the engine is in a failed state from a previous error then this method will throw an exception. If the engine has been shutdown then this method will close out the local end of the Endpoint and clean up any local resources before returning normally.
        Specified by:
        close in interface Endpoint<L extends Link<L>>
        Returns:
        this Endpoint instance.
      • setSenderSettleMode

        public L setSenderSettleMode​(SenderSettleMode senderSettleMode)
        Description copied from interface: Link
        Sets the sender settle mode.

        Should only be called during link set-up, i.e. before calling Endpoint.open(). If this endpoint is the initiator of the link, this method can be used to set a value other than the default.

        If this endpoint is not the initiator, this method should be used to set a local value. According to the AMQP spec, the application may choose to accept the sender's suggestion (accessed by calling Link.getRemoteSenderSettleMode()) or choose another value. The value has no effect on Proton, but may be useful to the application at a later point.

        In order to be AMQP compliant the application is responsible for honoring the settlement mode. See Link.

        Specified by:
        setSenderSettleMode in interface Link<L extends Link<L>>
        Parameters:
        senderSettleMode - The SenderSettleMode that will be set on the local end of this link.
        Returns:
        this Link.
      • setSource

        public L setSource​(Source source)
        Description copied from interface: Link
        Sets the Source to assign to the local end of this Link.

        Must be called during link setup, i.e. before calling the Endpoint.open() method.

        Specified by:
        setSource in interface Link<L extends Link<L>>
        Parameters:
        source - The Source that will be set on the local end of this link.
        Returns:
        this Link.
      • setTarget

        public L setTarget​(Target target)
        Description copied from interface: Link
        Sets the Target to assign to the local end of this Link. Must be called during link setup, i.e. before calling the Endpoint.open() method.
        Specified by:
        setTarget in interface Link<L extends Link<L>>
        Parameters:
        target - The Target that will be set on the local end of this link.
        Returns:
        this Link.
      • getTarget

        public <T extends Terminus> T getTarget()
        Description copied from interface: Link
        Returns the currently set Target for this Link. A link target can be either a Target type for a Sender or Receiver link or if the link is to be transaction resource then the target type will be a Coordinator instance.
        Specified by:
        getTarget in interface Link<L extends Link<L>>
        Type Parameters:
        T - The terminus type that the target should be cast to on return.
        Returns:
        the link target Terminus for the local end of this link.
      • setProperties

        public L setProperties​(Map<Symbol,​Object> properties)
        Description copied from interface: Endpoint
        Sets the properties to be sent to the remote when this Endpoint is Opened. The Endpoint properties value can only be modified prior to a call to Endpoint.open(), once the Endpoint has been opened locally an error will be thrown if this method is called.
        Specified by:
        setProperties in interface Endpoint<L extends Link<L>>
        Parameters:
        properties - The properties that will be sent to the remote when this Connection is opened.
        Returns:
        this Endpoint instance.
      • getProperties

        public Map<Symbol,​Object> getProperties()
        Specified by:
        getProperties in interface Endpoint<L extends Link<L>>
        Returns:
        the configured properties sent to the remote when this Connection is opened.
      • setOfferedCapabilities

        public L setOfferedCapabilities​(Symbol... capabilities)
        Description copied from interface: Endpoint
        Sets the capabilities to be offered on to the remote when this Endpoint is opened. The offered capabilities value can only be modified prior to a call to Endpoint.open(), once the Endpoint has been opened locally an error will be thrown if this method is called.
        Specified by:
        setOfferedCapabilities in interface Endpoint<L extends Link<L>>
        Parameters:
        capabilities - The capabilities to be offered to the remote when the Endpoint is opened.
        Returns:
        this Endpoint instance.
      • setDesiredCapabilities

        public L setDesiredCapabilities​(Symbol... capabilities)
        Description copied from interface: Endpoint
        Sets the capabilities that are desired from the remote when this Endpoint is opened. The desired capabilities value can only be modified prior to a call to Endpoint.open(), once the Endpoint has been opened locally an error will be thrown if this method is called.
        Specified by:
        setDesiredCapabilities in interface Endpoint<L extends Link<L>>
        Parameters:
        capabilities - The capabilities desired from the remote when the Endpoint is opened.
        Returns:
        this Endpoint instance.
      • getDesiredCapabilities

        public Symbol[] getDesiredCapabilities()
        Specified by:
        getDesiredCapabilities in interface Endpoint<L extends Link<L>>
        Returns:
        the configured desired capabilities that are sent to the remote when the Connection is opened.
      • setMaxMessageSize

        public L setMaxMessageSize​(UnsignedLong maxMessageSize)
        Description copied from interface: Link
        Sets the local link max message size, to be conveyed to the peer via the Attach frame when attaching the link to the session. Null or 0 means no limit.

        Must be called during link setup, i.e. before calling the Endpoint.open() method.

        Specified by:
        setMaxMessageSize in interface Link<L extends Link<L>>
        Parameters:
        maxMessageSize - the local max message size value, or null to clear. 0 also means no limit.
        Returns:
        this Link.
      • getRemoteTarget

        public <T extends Terminus> T getRemoteTarget()
        Description copied from interface: Link
        Returns the remote target Terminus cast to the given type. This can be used when the underlying type is known by the caller or as a control to validate the assumption of the underlying type.

        the currently set Target for this Link. A link target can be either a Target type for a Sender or Receiver link or if the link is to be transaction resource then the target type will be a Coordinator instance.

        Specified by:
        getRemoteTarget in interface Link<L extends Link<L>>
        Type Parameters:
        T - The type that the remote Terminus will be cast to on return.
        Returns:
        the source Terminus for the remote end of this link.
      • getRemoteMaxMessageSize

        public UnsignedLong getRemoteMaxMessageSize()
        Description copied from interface: Link
        Gets the remote link max message size, as conveyed from the peer via the Attach frame when attaching the link to the session.
        Specified by:
        getRemoteMaxMessageSize in interface Link<L extends Link<L>>
        Returns:
        the remote max message size conveyed by the peer, or null if none was set. 0 also means no limit.
      • localDetachHandler

        public L localDetachHandler​(EventHandler<L> localDetachHandler)
        Description copied from interface: Link
        Sets a EventHandler for when an this link is detached locally via a call to Link.detach() This is a convenience event that supplements the normal Endpoint.localCloseHandler(EventHandler) event point if set. If no local detached event handler is set the endpoint will route the detached event to the local closed event handler if set and allow it to process the event in one location.

        Typically used by clients for logging or other state update event processing. Clients should not perform any blocking calls within this context. It is an error for the handler to throw an exception and the outcome of doing so is undefined.

        Specified by:
        localDetachHandler in interface Link<L extends Link<L>>
        Parameters:
        localDetachHandler - The EventHandler to notify when this link is locally detached.
        Returns:
        the link for chaining.
      • detachHandler

        public L detachHandler​(EventHandler<L> remoteDetachHandler)
        Description copied from interface: Link
        Sets a EventHandler for when an AMQP Detach frame is received from the remote peer for this Link which would have been locally opened previously, the Detach from would have been marked as not having been closed.

        This is a convenience event that supplements the normal Endpoint.closeHandler(EventHandler) event point if set. If no detached event handler is set the endpoint will route the detached event to the closed event handler if set and allow it to process the event in one location.

        Specified by:
        detachHandler in interface Link<L extends Link<L>>
        Parameters:
        remoteDetachHandler - The EventHandler to notify when this link is remotely closed.
        Returns:
        the Link for chaining.
      • parentEndpointClosedHandler

        public L parentEndpointClosedHandler​(EventHandler<L> handler)
        Description copied from interface: Link
        Sets a EventHandler for when the parent Session or Connection of this link is locally closed.

        Typically used by clients for logging or other state update event processing. Clients should not perform any blocking calls within this context. It is an error for the handler to throw an exception and the outcome of doing so is undefined.

        Specified by:
        parentEndpointClosedHandler in interface Link<L extends Link<L>>
        Parameters:
        handler - The EventHandler to notify when this link's parent Session is locally closed.
        Returns:
        the link for chaining.
      • transitionedToLocallyOpened

        protected void transitionedToLocallyOpened()
      • transitionedToLocallyDetached

        protected void transitionedToLocallyDetached()
      • transitionedToLocallyClosed

        protected void transitionedToLocallyClosed()
      • transitionToRemotelyOpenedState

        protected void transitionToRemotelyOpenedState()
      • transitionToRemotelyDetached

        protected void transitionToRemotelyDetached()
      • transitionToRemotelyClosed

        protected void transitionToRemotelyClosed()
      • transitionToParentLocallyClosed

        protected void transitionToParentLocallyClosed()
      • transitionToParentRemotelyClosed

        protected void transitionToParentRemotelyClosed()
      • handleRemoteAttach

        protected abstract L handleRemoteAttach​(Attach attach)
      • handleRemoteDetach

        protected abstract L handleRemoteDetach​(Detach detach)
      • handleRemoteFlow

        protected abstract L handleRemoteFlow​(Flow flow)
      • decorateOutgoingFlow

        protected abstract L decorateOutgoingFlow​(Flow flow)
      • checkLinkOperable

        protected void checkLinkOperable​(String failurePrefix)
      • areDeliveriesStillActive

        protected boolean areDeliveriesStillActive()
      • checkNotOpened

        protected void checkNotOpened​(String errorMessage)
      • checkNotClosed

        protected void checkNotClosed​(String errorMessage)