- java.lang.Object
-
- org.apache.qpid.protonj2.client.impl.ClientLinkType<LinkType,ProtonType>
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,Link<LinkType>
- Direct Known Subclasses:
ClientReceiverLinkType
,ClientSenderLinkType
public abstract class ClientLinkType<LinkType extends Link<LinkType>,ProtonType extends Link<ProtonType>> extends java.lang.Object implements Link<LinkType>
Base type used by client resources that represent an AMQP link type.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
closed
protected static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<ClientLinkType>
CLOSED_UPDATER
protected ClientFuture<LinkType>
closeFuture
protected java.util.concurrent.ScheduledExecutorService
executor
protected ClientException
failureCause
protected java.lang.String
linkId
protected java.util.function.Consumer<LinkType>
linkRemotelyClosedHandler
protected ClientFuture<LinkType>
openFuture
protected LinkOptions<?>
options
protected Source
remoteSource
protected Target
remoteTarget
protected ClientSession
session
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.String
address()
Returns the address that theLink
instance will be subscribed to.protected void
checkClosedOrFailed()
ClientInstance
client()
void
close()
Requests a close of theLink
at the remote and waits until the Link has been fully closed or until the configured close timeout is exceeded.void
close(ErrorCondition error)
Requests a close of theLink
at the remote and waits until the Link has been fully closed or until the configuredLinkOptions.closeTimeout()
is exceeded.ClientFuture<LinkType>
closeAsync()
Requests a close of theLink
link at the remote and returns aFuture
that will be completed once the link has been closed.ClientFuture<LinkType>
closeAsync(ErrorCondition error)
Requests a close of theLink
link at the remote and returns aFuture
that will be completed once the link has been closed.ClientConnection
connection()
java.lang.String[]
desiredCapabilities()
Returns the desired capabilities that the remote provided upon successfully opening theLink
.void
detach()
Requests a detach of theLink
at the remote and waits until the Link has been fully detached or until the configuredLinkOptions.closeTimeout()
is exceeded.void
detach(ErrorCondition error)
Requests a detach of theLink
at the remote and waits until the Link has been fully detached or until the configuredLinkOptions.closeTimeout()
is exceeded.ClientFuture<LinkType>
detachAsync()
Requests a detach of theLink
link at the remote and returns aFuture
that will be completed once the link has been detached.ClientFuture<LinkType>
detachAsync(ErrorCondition error)
Requests a detach of theLink
link at the remote and returns aFuture
that will be completed once the link has been detached.protected void
handleEngineShutdown(Engine engine)
protected void
handleLocalCloseOrDetach(ProtonType link)
protected void
handleLocalOpen(ProtonType link)
protected void
handleParentEndpointClosed(ProtonType link)
protected void
handleRemoteCloseOrDetach(ProtonType link)
protected void
handleRemoteOpen(ProtonType link)
protected void
immediateLinkShutdown(ClientException failureCause)
protected abstract void
linkSpecificCleanupHandler(ClientException failureCause)
protected abstract void
linkSpecificLocalCloseHandler()
protected abstract void
linkSpecificLocalOpenHandler()
protected abstract void
linkSpecificRemoteCloseHandler()
protected abstract void
linkSpecificRemoteOpenHandler()
protected boolean
notClosedOrFailed(ClientFuture<?> request)
protected boolean
notClosedOrFailed(ClientFuture<?> request, ProtonType protonLink)
java.lang.String[]
offeredCapabilities()
Returns the offered capabilities that the remote provided upon successfully opening theLink
.ClientFuture<LinkType>
openFuture()
java.util.Map<java.lang.String,java.lang.Object>
properties()
Returns the properties that the remote provided upon successfully opening theLink
.protected abstract ProtonType
protonLink()
protected abstract void
recreateLinkForReconnect()
protected abstract LinkType
self()
ClientSession
session()
Source
source()
Returns an immutable view of the remoteSource
object assigned to this link.Target
target()
Returns an immutable view of the remoteTarget
object assigned to this sender link.protected void
waitForOpenToComplete()
-
-
-
Field Detail
-
CLOSED_UPDATER
protected static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<ClientLinkType> CLOSED_UPDATER
-
openFuture
protected final ClientFuture<LinkType extends Link<LinkType>> openFuture
-
closeFuture
protected final ClientFuture<LinkType extends Link<LinkType>> closeFuture
-
closed
protected volatile int closed
-
failureCause
protected ClientException failureCause
-
session
protected final ClientSession session
-
executor
protected final java.util.concurrent.ScheduledExecutorService executor
-
linkId
protected final java.lang.String linkId
-
options
protected final LinkOptions<?> options
-
remoteSource
protected volatile Source remoteSource
-
remoteTarget
protected volatile Target remoteTarget
-
-
Method Detail
-
self
protected abstract LinkType self()
-
protonLink
protected abstract ProtonType protonLink()
-
close
public void close()
Description copied from interface:Link
Requests a close of theLink
at the remote and waits until the Link has been fully closed or until the configured close timeout is exceeded.
-
close
public void close(ErrorCondition error)
Description copied from interface:Link
Requests a close of theLink
at the remote and waits until the Link has been fully closed or until the configuredLinkOptions.closeTimeout()
is exceeded.
-
detach
public void detach()
Description copied from interface:Link
Requests a detach of theLink
at the remote and waits until the Link has been fully detached or until the configuredLinkOptions.closeTimeout()
is exceeded.
-
detach
public void detach(ErrorCondition error)
Description copied from interface:Link
Requests a detach of theLink
at the remote and waits until the Link has been fully detached or until the configuredLinkOptions.closeTimeout()
is exceeded.
-
closeAsync
public ClientFuture<LinkType> closeAsync()
Description copied from interface:Link
Requests a close of theLink
link at the remote and returns aFuture
that will be completed once the link has been closed.
-
closeAsync
public ClientFuture<LinkType> closeAsync(ErrorCondition error)
Description copied from interface:Link
Requests a close of theLink
link at the remote and returns aFuture
that will be completed once the link has been closed.- Specified by:
closeAsync
in interfaceLink<LinkType extends Link<LinkType>>
- Parameters:
error
- TheErrorCondition
to transmit to the remote along with the close operation.- Returns:
- a
Future
that will be completed when the remote closes thisLink
link.
-
detachAsync
public ClientFuture<LinkType> detachAsync()
Description copied from interface:Link
Requests a detach of theLink
link at the remote and returns aFuture
that will be completed once the link has been detached.
-
detachAsync
public ClientFuture<LinkType> detachAsync(ErrorCondition error)
Description copied from interface:Link
Requests a detach of theLink
link at the remote and returns aFuture
that will be completed once the link has been detached.- Specified by:
detachAsync
in interfaceLink<LinkType extends Link<LinkType>>
- Parameters:
error
- TheErrorCondition
to transmit to the remote along with the detach operation.- Returns:
- a
Future
that will be completed when the remote detaches thisLink
link.
-
address
public java.lang.String address() throws ClientException
Description copied from interface:Link
Returns the address that theLink
instance will be subscribed to. This method can block based on the type of link and how it was configured.- If the link is a Sender and it was configured as an anonymous sender then this method returns null as the link has no address.
- If a link was created with the dynamic node value enabled then the method will return the dynamically created address once the remote has attached its end of the opened link. Due to the need to await the remote peer to populate the dynamic address this method will block until the open of the link has completed.
- If not a dynamic link then the address returned is the address passed to the original link creation method.
-
source
public Source source() throws ClientException
Description copied from interface:Link
-
target
public Target target() throws ClientException
Description copied from interface:Link
-
properties
public java.util.Map<java.lang.String,java.lang.Object> properties() throws ClientException
Description copied from interface:Link
Returns the properties that the remote provided upon successfully opening theLink
. If the attach has not completed yet this method will block to await the attach response which carries the remote properties. If the remote provides no properties this method will return null.- Specified by:
properties
in interfaceLink<LinkType extends Link<LinkType>>
- Returns:
- any properties provided from the remote once the sender has successfully opened.
- Throws:
ClientException
- if an error occurs while obtaining theLink
remote properties.
-
offeredCapabilities
public java.lang.String[] offeredCapabilities() throws ClientException
Description copied from interface:Link
Returns the offered capabilities that the remote provided upon successfully opening theLink
. If the attach has not completed yet this method will block to await the attach response which carries the remote offered capabilities. If the remote provides no capabilities this method will return null.- Specified by:
offeredCapabilities
in interfaceLink<LinkType extends Link<LinkType>>
- Returns:
- any capabilities provided from the remote once the sender has successfully opened.
- Throws:
ClientException
- if an error occurs while obtaining theLink
remote offered capabilities.
-
desiredCapabilities
public java.lang.String[] desiredCapabilities() throws ClientException
Description copied from interface:Link
Returns the desired capabilities that the remote provided upon successfully opening theLink
. If the attach has not completed yet this method will block to await the attach response which carries the remote desired capabilities. If the remote provides no capabilities this method will return null.- Specified by:
desiredCapabilities
in interfaceLink<LinkType extends Link<LinkType>>
- Returns:
- any desired capabilities provided from the remote once the sender has successfully opened.
- Throws:
ClientException
- if an error occurs while obtaining theLink
remote desired capabilities.
-
client
public ClientInstance client()
-
connection
public ClientConnection connection()
- Specified by:
connection
in interfaceLink<LinkType extends Link<LinkType>>
- Returns:
- the
Connection
instance that holds this session'sLink
-
session
public ClientSession session()
-
openFuture
public ClientFuture<LinkType> openFuture()
-
handleLocalOpen
protected final void handleLocalOpen(ProtonType link)
-
handleLocalCloseOrDetach
protected final void handleLocalCloseOrDetach(ProtonType link)
-
handleRemoteOpen
protected final void handleRemoteOpen(ProtonType link)
-
handleRemoteCloseOrDetach
protected final void handleRemoteCloseOrDetach(ProtonType link)
-
handleParentEndpointClosed
protected final void handleParentEndpointClosed(ProtonType link)
-
handleEngineShutdown
protected final void handleEngineShutdown(Engine engine)
-
immediateLinkShutdown
protected final void immediateLinkShutdown(ClientException failureCause)
-
linkSpecificLocalOpenHandler
protected abstract void linkSpecificLocalOpenHandler()
-
linkSpecificLocalCloseHandler
protected abstract void linkSpecificLocalCloseHandler()
-
linkSpecificRemoteOpenHandler
protected abstract void linkSpecificRemoteOpenHandler()
-
linkSpecificRemoteCloseHandler
protected abstract void linkSpecificRemoteCloseHandler()
-
linkSpecificCleanupHandler
protected abstract void linkSpecificCleanupHandler(ClientException failureCause)
-
recreateLinkForReconnect
protected abstract void recreateLinkForReconnect()
-
notClosedOrFailed
protected boolean notClosedOrFailed(ClientFuture<?> request)
-
notClosedOrFailed
protected boolean notClosedOrFailed(ClientFuture<?> request, ProtonType protonLink)
-
checkClosedOrFailed
protected void checkClosedOrFailed() throws ClientException
- Throws:
ClientException
-
waitForOpenToComplete
protected void waitForOpenToComplete() throws ClientException
- Throws:
ClientException
-
-