Class ProtonLink<L extends Link<L>>
- Direct Known Subclasses:
ProtonReceiver
,ProtonSender
-
Field Summary
Modifier and TypeFieldDescriptionprotected final ProtonConnection
protected final Attach
protected Attach
protected final ProtonSession
Fields inherited from class org.apache.qpid.protonj2.engine.impl.ProtonEndpoint
engine
-
Constructor Summary
ModifierConstructorDescriptionprotected
ProtonLink
(ProtonSession session, String name, ProtonLinkCreditState creditState) Create a new link instance with the given parent session. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
protected void
checkLinkOperable
(String failurePrefix) protected void
checkNotClosed
(String errorMessage) protected void
checkNotOpened
(String errorMessage) close()
Close the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it.protected abstract L
decorateOutgoingFlow
(Flow flow) detach()
Detach this end of the link.detachHandler
(EventHandler<L> remoteDetachHandler) Sets aEventHandler
for when an AMQP Detach frame is received from the remote peer for thisLink
which would have been locally opened previously, the Detach from would have been marked as not having been closed.Symbol[]
Gets the local link max message size.getName()
Symbol[]
Gets the parent of thisEndpoint
which can be itself forConnection
instance.Gets the local link receiver settlement mode.Symbol[]
Gets the remote link max message size, as conveyed from the peer via the Attach frame when attaching the link to the session.Symbol[]
Gets the remote link receiver settlement mode, as conveyed from the peer via the Attach frame when attaching the link to the session.Gets the remote link sender settlement mode, as conveyed from the peer via the Attach frame when attaching the link to the session.<T extends Terminus>
TReturns the remote targetTerminus
cast to the given type.Gets the local link sender settlement mode.getState()
<T extends Terminus>
TReturns the currently set Target for thisLink
.protected abstract L
handleRemoteAttach
(Attach attach) protected abstract L
handleRemoteDetach
(Detach detach) protected abstract L
handleRemoteDisposition
(Disposition disposition, ProtonIncomingDelivery delivery) protected abstract L
handleRemoteDisposition
(Disposition disposition, ProtonOutgoingDelivery delivery) protected abstract L
handleRemoteFlow
(Flow flow) protected abstract ProtonIncomingDelivery
handleRemoteTransfer
(Transfer transfer, ProtonBuffer payload) boolean
Returns true if thisEndpoint
is currently locally closed meaning that a call to theEndpoint.close()
method has occurred.boolean
Returns true if thisLink
is currently locally detached or locally closed meaning the state returned fromLink.getState()
is equal toLinkState.DETACHED
orLinkState.CLOSED
.boolean
Returns true if thisLink
is currently locally detached meaning the state returned fromLink.getState()
is equal toLinkState.DETACHED
.boolean
Returns true if thisEndpoint
is currently locally open meaning that theEndpoint.open()
has been called but theEndpoint.close()
has not.boolean
boolean
Returns true if thisLink
is currently remotely closed meaning the state returned fromLink.getRemoteState()
is equal toLinkState.CLOSED
.boolean
Returns true if thisLink
is currently remotely detached or closed meaning the state returned fromLink.getRemoteState()
is equal toLinkState.DETACHED
orLinkState.CLOSED
.boolean
Returns true if thisLink
is currently remotely detached meaning the state returned fromLink.getRemoteState()
is equal toLinkState.DETACHED
.boolean
Returns true if thisLink
is currently remotely open meaning the state returned fromLink.getRemoteState()
is equal toLinkState.ACTIVE
.boolean
isSender()
localDetachHandler
(EventHandler<L> localDetachHandler) Sets aEventHandler
for when an this link is detached locally via a call toLink.detach()
This is a convenience event that supplements the normalEndpoint.localCloseHandler(EventHandler)
event point if set.open()
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.parentEndpointClosedHandler
(EventHandler<L> handler) protected abstract L
self()
setDesiredCapabilities
(Symbol... capabilities) Sets the capabilities that are desired from the remote when thisEndpoint
is opened.setMaxMessageSize
(UnsignedLong maxMessageSize) Sets the local link max message size, to be conveyed to the peer via the Attach frame when attaching the link to the session.setOfferedCapabilities
(Symbol... capabilities) Sets the capabilities to be offered on to the remote when thisEndpoint
is opened.setProperties
(Map<Symbol, Object> properties) Sets the properties to be sent to the remote when thisEndpoint
is Opened.setReceiverSettleMode
(ReceiverSettleMode receiverSettleMode) Sets the receiver settle mode.setSenderSettleMode
(SenderSettleMode senderSettleMode) Sets the sender settle mode.setTarget
(Coordinator coordinator) Sets theCoordinator
target to assign to the local end of thisLink
.protected void
protected void
protected void
protected void
protected void
protected void
protected void
protected void
Methods inherited from class org.apache.qpid.protonj2.engine.impl.ProtonEndpoint
closeHandler, engineShutdownHandler, getAttachments, getCondition, getEngine, getLinkedResource, getLinkedResource, getRemoteCondition, localCloseHandler, localOpenHandler, openHandler, setCondition, setLinkedResource
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.qpid.protonj2.engine.Endpoint
closeHandler, engineShutdownHandler, getAttachments, getCondition, getEngine, getLinkedResource, getLinkedResource, getRemoteCondition, localCloseHandler, localOpenHandler, openHandler, setCondition, setLinkedResource
Methods inherited from interface org.apache.qpid.protonj2.engine.Link
creditStateUpdateHandler, getCredit, getRole, isDraining
-
Field Details
-
connection
-
session
-
localAttach
-
remoteAttach
-
-
Constructor Details
-
Method Details
-
getConnection
- Specified by:
getConnection
in interfaceLink<L extends Link<L>>
- Returns:
- the parent
Connection
for theLink
-
getSession
-
getParent
Description copied from interface:Endpoint
Gets the parent of thisEndpoint
which can be itself forConnection
instance. -
getName
-
isSender
public boolean isSender() -
isReceiver
public boolean isReceiver() -
self
-
getState
-
getRemoteState
- Specified by:
getRemoteState
in interfaceLink<L extends Link<L>>
- Returns:
- the remote link state (as last communicated)
-
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. -
detach
Description copied from interface:Link
Detach this end of the link. -
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 theEndpoint
and clean up any local resources before returning normally. -
setSenderSettleMode
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 interfaceLink<L extends Link<L>>
- Parameters:
senderSettleMode
- TheSenderSettleMode
that will be set on the local end of this link.- Returns:
- this Link.
-
getSenderSettleMode
Description copied from interface:Link
Gets the local link sender settlement mode.- Specified by:
getSenderSettleMode
in interfaceLink<L extends Link<L>>
- Returns:
- the local sender settlement mode, or null if none was set.
- See Also:
-
setReceiverSettleMode
Description copied from interface:Link
Sets the receiver 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. Used in analogous way toLink.setSenderSettleMode(SenderSettleMode)
- Specified by:
setReceiverSettleMode
in interfaceLink<L extends Link<L>>
- Parameters:
receiverSettleMode
- TheReceiverSettleMode
that will be set on the local end of this link.- Returns:
- this Link.
-
getReceiverSettleMode
Description copied from interface:Link
Gets the local link receiver settlement mode.- Specified by:
getReceiverSettleMode
in interfaceLink<L extends Link<L>>
- Returns:
- the local receiver settlement mode, or null if none was set.
- See Also:
-
setSource
Description copied from interface:Link
Sets theSource
to assign to the local end of thisLink
.Must be called during link setup, i.e. before calling the
Endpoint.open()
method. -
getSource
-
setTarget
Description copied from interface:Link
Sets theTarget
to assign to the local end of thisLink
. Must be called during link setup, i.e. before calling theEndpoint.open()
method. -
setTarget
Description copied from interface:Link
Sets theCoordinator
target to assign to the local end of thisLink
.Must be called during link setup, i.e. before calling the
Endpoint.open()
method.- Specified by:
setTarget
in interfaceLink<L extends Link<L>>
- Parameters:
coordinator
- TheCoordinator
target that will be set on the local end of this link.- Returns:
- this Link.
- Throws:
IllegalStateException
- if theLink
has already been opened.
-
getTarget
Description copied from interface:Link
Returns the currently set Target for thisLink
. A link target can be either aTarget
type for aSender
orReceiver
link or if the link is to be transaction resource then the target type will be aCoordinator
instance. -
setProperties
Description copied from interface:Endpoint
Sets the properties to be sent to the remote when thisEndpoint
is Opened. TheEndpoint
properties value can only be modified prior to a call toEndpoint.open()
, once theEndpoint
has been opened locally an error will be thrown if this method is called. -
getProperties
- Specified by:
getProperties
in interfaceEndpoint<L extends Link<L>>
- Returns:
- the configured properties sent to the remote when this Connection is opened.
-
setOfferedCapabilities
Description copied from interface:Endpoint
Sets the capabilities to be offered on to the remote when thisEndpoint
is opened. The offered capabilities value can only be modified prior to a call toEndpoint.open()
, once theEndpoint
has been opened locally an error will be thrown if this method is called. -
getOfferedCapabilities
-
setDesiredCapabilities
Description copied from interface:Endpoint
Sets the capabilities that are desired from the remote when thisEndpoint
is opened. The desired capabilities value can only be modified prior to a call toEndpoint.open()
, once theEndpoint
has been opened locally an error will be thrown if this method is called. -
getDesiredCapabilities
- Specified by:
getDesiredCapabilities
in interfaceEndpoint<L extends Link<L>>
- Returns:
- the configured desired capabilities that are sent to the remote when the Connection is opened.
-
setMaxMessageSize
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 interfaceLink<L extends Link<L>>
- Parameters:
maxMessageSize
- the local max message size value, or null to clear. 0 also means no limit.- Returns:
- this Link.
-
getMaxMessageSize
Description copied from interface:Link
Gets the local link max message size.- Specified by:
getMaxMessageSize
in interfaceLink<L extends Link<L>>
- Returns:
- the local max message size, or null if none was set. 0 also means no limit.
- See Also:
-
isLocallyOpen
public boolean isLocallyOpen()Description copied from interface:Endpoint
Returns true if thisEndpoint
is currently locally open meaning that theEndpoint.open()
has been called but theEndpoint.close()
has not. -
isLocallyClosed
public boolean isLocallyClosed()Description copied from interface:Endpoint
Returns true if thisEndpoint
is currently locally closed meaning that a call to theEndpoint.close()
method has occurred. -
isLocallyDetached
public boolean isLocallyDetached()Description copied from interface:Link
Returns true if thisLink
is currently locally detached meaning the state returned fromLink.getState()
is equal toLinkState.DETACHED
. A link is locally detached after a call toLink.detach()
.- Specified by:
isLocallyDetached
in interfaceLink<L extends Link<L>>
- Returns:
- true if the link is locally closed.
- See Also:
-
isLocallyClosedOrDetached
public boolean isLocallyClosedOrDetached()Description copied from interface:Link
Returns true if thisLink
is currently locally detached or locally closed meaning the state returned fromLink.getState()
is equal toLinkState.DETACHED
orLinkState.CLOSED
. A link is locally detached after a call toLink.detach()
and is locally closed after a call toEndpoint.close()
.- Specified by:
isLocallyClosedOrDetached
in interfaceLink<L extends Link<L>>
- Returns:
- true if the link is locally closed or detached.
- See Also:
-
isRemotelyOpen
public boolean isRemotelyOpen()Description copied from interface:Link
Returns true if thisLink
is currently remotely open meaning the state returned fromLink.getRemoteState()
is equal toLinkState.ACTIVE
. A link is remotely opened after anAttach
has been received from the remote and before aDetach
has been received from the remote.- Specified by:
isRemotelyOpen
in interfaceEndpoint<L extends Link<L>>
- Specified by:
isRemotelyOpen
in interfaceLink<L extends Link<L>>
- Returns:
- true if the link is remotely open.
- See Also:
-
isRemotelyClosed
public boolean isRemotelyClosed()Description copied from interface:Link
Returns true if thisLink
is currently remotely closed meaning the state returned fromLink.getRemoteState()
is equal toLinkState.CLOSED
. A link is remotely closed after anDetach
has been received from the remote with the close flag equal to true.- Specified by:
isRemotelyClosed
in interfaceEndpoint<L extends Link<L>>
- Specified by:
isRemotelyClosed
in interfaceLink<L extends Link<L>>
- Returns:
- true if the link is remotely closed.
- See Also:
-
isRemotelyDetached
public boolean isRemotelyDetached()Description copied from interface:Link
Returns true if thisLink
is currently remotely detached meaning the state returned fromLink.getRemoteState()
is equal toLinkState.DETACHED
. A link is remotely detached after anDetach
has been received from the remote with the close flag equal to false.- Specified by:
isRemotelyDetached
in interfaceLink<L extends Link<L>>
- Returns:
- true if the link is remotely detached.
- See Also:
-
isRemotelyClosedOrDetached
public boolean isRemotelyClosedOrDetached()Description copied from interface:Link
Returns true if thisLink
is currently remotely detached or closed meaning the state returned fromLink.getRemoteState()
is equal toLinkState.DETACHED
orLinkState.CLOSED
. A link is remotely detached or closed after aDetach
has been received from the remote.- Specified by:
isRemotelyClosedOrDetached
in interfaceLink<L extends Link<L>>
- Returns:
- true if the link is remotely detached or closed.
- See Also:
-
getRemoteSenderSettleMode
Description copied from interface:Link
Gets the remote link sender settlement mode, as conveyed from the peer via the Attach frame when attaching the link to the session.- Specified by:
getRemoteSenderSettleMode
in interfaceLink<L extends Link<L>>
- Returns:
- the sender settlement mode conveyed by the peer, or null if there was none.
- See Also:
-
getRemoteReceiverSettleMode
Description copied from interface:Link
Gets the remote link receiver settlement mode, as conveyed from the peer via the Attach frame when attaching the link to the session.- Specified by:
getRemoteReceiverSettleMode
in interfaceLink<L extends Link<L>>
- Returns:
- the sender receiver mode conveyed by the peer, or null if there was none.
- See Also:
-
getRemoteSource
-
getRemoteTarget
Description copied from interface:Link
Returns the remote targetTerminus
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 aTarget
type for aSender
orReceiver
link or if the link is to be transaction resource then the target type will be aCoordinator
instance. -
getRemoteOfferedCapabilities
-
getRemoteDesiredCapabilities
-
getRemoteProperties
-
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 interfaceLink<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
Description copied from interface:Link
Sets aEventHandler
for when an this link is detached locally via a call toLink.detach()
This is a convenience event that supplements the normalEndpoint.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 interfaceLink<L extends Link<L>>
- Parameters:
localDetachHandler
- TheEventHandler
to notify when this link is locally detached.- Returns:
- the link for chaining.
-
detachHandler
Description copied from interface:Link
Sets aEventHandler
for when an AMQP Detach frame is received from the remote peer for thisLink
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 interfaceLink<L extends Link<L>>
- Parameters:
remoteDetachHandler
- TheEventHandler
to notify when this link is remotely closed.- Returns:
- the
Link
for chaining.
-
parentEndpointClosedHandler
Description copied from interface:Link
Sets aEventHandler
for when the parentSession
orConnection
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 interfaceLink<L extends Link<L>>
- Parameters:
handler
- TheEventHandler
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
-
handleRemoteDetach
-
handleRemoteFlow
-
handleRemoteDisposition
protected abstract L handleRemoteDisposition(Disposition disposition, ProtonOutgoingDelivery delivery) -
handleRemoteDisposition
protected abstract L handleRemoteDisposition(Disposition disposition, ProtonIncomingDelivery delivery) -
handleRemoteTransfer
protected abstract ProtonIncomingDelivery handleRemoteTransfer(Transfer transfer, ProtonBuffer payload) -
decorateOutgoingFlow
-
checkLinkOperable
-
areDeliveriesStillActive
protected boolean areDeliveriesStillActive() -
checkNotOpened
-
checkNotClosed
-