Package org.apache.qpid.protonj2.engine
Interface Endpoint<E extends Endpoint<E>>
- Type Parameters:
E
- TheEndpoint
type
- All Known Subinterfaces:
Connection
,Link<L>
,Receiver
,Sender
,Session
,TransactionController
,TransactionManager
- All Known Implementing Classes:
ProtonConnection
,ProtonEndpoint
,ProtonLink
,ProtonReceiver
,ProtonSender
,ProtonSession
,ProtonTransactionController
,ProtonTransactionManager
public interface Endpoint<E extends Endpoint<E>>
Represents a conceptual endpoint type used to provide common operations that
all the endpoint types will share.
-
Method Summary
Modifier and TypeMethodDescriptionclose()
Close the end point locally and send the closing performative immediately if possible or holds it until the Connection / Engine state allows it.closeHandler
(EventHandler<E> remoteCloseEventHandler) Sets a EventHandler for when an AMQP Close frame is received from the remote peer.engineShutdownHandler
(EventHandler<Engine> engineShutdownEventHandler) Sets anEventHandler
that is invoked when the engine that supports thisEndpoint
is shutdown via a call toEngine.shutdown()
which indicates a desire to terminate all engine operations.Symbol[]
<T> T
<T> T
getLinkedResource
(Class<T> typeClass) Gets the linked resource (if set) and returns it using the type information provided to cast the returned value.Symbol[]
Endpoint<?>
Gets the parent of thisEndpoint
which can be itself forConnection
instance.If the remote has closed thisEndpoint
and provided anErrorCondition
as part of the closing AMQP performative then this method will return it.Symbol[]
Symbol[]
boolean
boolean
boolean
boolean
localCloseHandler
(EventHandler<E> localCloseHandler) Sets aEventHandler
for when an thisEndpoint
is closed locally via a call toclose()
Typically used by clients for logging or other state update event processing.localOpenHandler
(EventHandler<E> localOpenHandler) Sets aEventHandler
for when an thisEndpoint
is opened locally via a call toopen()
Typically used by clients for logging or other state update event processing.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.openHandler
(EventHandler<E> remoteOpenEventHandler) Sets a EventHandler for when an AMQP Open frame is received from the remote peer.setCondition
(ErrorCondition condition) Sets the localErrorCondition
to be applied to aEndpoint
close.setDesiredCapabilities
(Symbol... capabilities) Sets the capabilities that are desired from the remote when thisEndpoint
is opened.setLinkedResource
(Object resource) Links a given resource to thisEndpoint
.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.
-
Method Details
-
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. The end point will signal any registered handler of the remote opening the Connection once the remote performative that signals open completion arrives.- Returns:
- this
Endpoint
instance. - Throws:
EngineStateException
- if an error occurs opening the Connection or the Engine is shutdown.
-
close
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.- Returns:
- this
Endpoint
instance. - Throws:
EngineFailedException
- if an error occurs closing the end point or the Engine is in a failed state.
-
getAttachments
Attachments getAttachments()- Returns:
- the
Attachments
instance that is associated with thisEndpoint
-
getEngine
Engine getEngine() -
getParent
Endpoint<?> getParent()Gets the parent of thisEndpoint
which can be itself forConnection
instance.- Returns:
- the parent of this
Endpoint
or itself if this is aConnection
;
-
setLinkedResource
Links a given resource to thisEndpoint
. -
getLinkedResource
<T> T getLinkedResource()- Type Parameters:
T
- The type that the linked resource should be cast to on return.- Returns:
- the user set linked resource for this
Endpoint
instance.
-
getLinkedResource
Gets the linked resource (if set) and returns it using the type information provided to cast the returned value.- Type Parameters:
T
- The type to cast the linked resource to if one is set.- Parameters:
typeClass
- the type's Class which is used for casting the returned value.- Returns:
- the user set linked resource for this Context instance.
- Throws:
ClassCastException
- if the linked resource cannot be cast to the type requested.
-
getCondition
ErrorCondition getCondition()- Returns:
- the local
Endpoint
error, or null if there is none
-
setCondition
Sets the localErrorCondition
to be applied to aEndpoint
close.- Parameters:
condition
- The error condition to convey to the remote peer on close of this end point.- Returns:
- this
Endpoint
instance.
-
isLocallyOpen
boolean isLocallyOpen()Returns true if thisEndpoint
is currently locally open meaning that theopen()
has been called but theclose()
has not.- Returns:
true
if theEndpoint
is locally open.- See Also:
-
isLocallyClosed
boolean isLocallyClosed()Returns true if thisEndpoint
is currently locally closed meaning that a call to theclose()
method has occurred.- Returns:
true
if theEndpoint
is locally closed.- See Also:
-
setOfferedCapabilities
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 toopen()
, once theEndpoint
has been opened locally an error will be thrown if this method is called.- Parameters:
capabilities
- The capabilities to be offered to the remote when theEndpoint
is opened.- Returns:
- this
Endpoint
instance. - Throws:
IllegalStateException
- if theEndpoint
has already been opened.
-
getOfferedCapabilities
Symbol[] getOfferedCapabilities()- Returns:
- the configured capabilities that are offered to the remote when the
Endpoint
is opened.
-
setDesiredCapabilities
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 toopen()
, once theEndpoint
has been opened locally an error will be thrown if this method is called.- Parameters:
capabilities
- The capabilities desired from the remote when theEndpoint
is opened.- Returns:
- this
Endpoint
instance. - Throws:
IllegalStateException
- if theEndpoint
has already been opened.
-
getDesiredCapabilities
Symbol[] getDesiredCapabilities()- Returns:
- the configured desired capabilities that are sent to the remote when the Connection is opened.
-
setProperties
Sets the properties to be sent to the remote when thisEndpoint
is Opened. TheEndpoint
properties value can only be modified prior to a call toopen()
, once theEndpoint
has been opened locally an error will be thrown if this method is called.- Parameters:
properties
- The properties that will be sent to the remote when this Connection is opened.- Returns:
- this
Endpoint
instance. - Throws:
IllegalStateException
- if theEndpoint
has already been opened.
-
getProperties
- Returns:
- the configured properties sent to the remote when this Connection is opened.
-
isRemotelyOpen
boolean isRemotelyOpen()Returns true if thisEndpoint
is currently remotely open meaning that the AMQP performative that completes the open phase of thisEndpoint
's lifetime has arrived but the performative that closes it has not.- Returns:
true
if theEndpoint
is remotely open.- See Also:
-
isRemotelyClosed
boolean isRemotelyClosed()Returns true if thisEndpoint
is currently remotely closed meaning that the AMQP performative that completes the close phase of thisEndpoint
's lifetime has arrived.- Returns:
true
if theEndpoint
is remotely closed.- See Also:
-
getRemoteCondition
ErrorCondition getRemoteCondition()If the remote has closed thisEndpoint
and provided anErrorCondition
as part of the closing AMQP performative then this method will return it.- Returns:
- the remote supplied
ErrorCondition
, or null if there is none.
-
getRemoteOfferedCapabilities
Symbol[] getRemoteOfferedCapabilities()- Returns:
- the capabilities offered by the remote when it opened its end of the
Endpoint
.
-
getRemoteDesiredCapabilities
Symbol[] getRemoteDesiredCapabilities()- Returns:
- the capabilities desired by the remote when it opened its end of the
Endpoint
.
-
getRemoteProperties
- Returns:
- the properties sent by the remote when it opened its end of the
Endpoint
.
-
localOpenHandler
Sets aEventHandler
for when an thisEndpoint
is opened locally via a call toopen()
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.- Parameters:
localOpenHandler
- TheEventHandler
to notify when thisEndpoint
is locally opened.- Returns:
- this
Endpoint
instance.
-
localCloseHandler
Sets aEventHandler
for when an thisEndpoint
is closed locally via a call toclose()
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.- Parameters:
localCloseHandler
- TheEventHandler
to notify when thisEndpoint
is locally closed.- Returns:
- this
Endpoint
instance.
-
openHandler
Sets a EventHandler for when an AMQP Open frame is received from the remote peer. Used to process remotely initiated Connections. Locally initiated sessions have their own EventHandler invoked instead. This method is typically used by servers to listen for the remote peer to open itsEndpoint
, while a client would listen for the server to open its end of theEndpoint
once a local open has been performed. Typically used by clients as servers will typically listen to some parent resource event handler to determine if the remote is initiating a resource open. -
closeHandler
Sets a EventHandler for when an AMQP Close frame is received from the remote peer. -
engineShutdownHandler
Sets anEventHandler
that is invoked when the engine that supports thisEndpoint
is shutdown via a call toEngine.shutdown()
which indicates a desire to terminate all engine operations. AnyEndpoint
that has been both locally and remotely closed will not receive this event as it will no longer be tracked by the parent its parentEndpoint
. A typical use of this event would be from a locally closedEndpoint
that is awaiting response from the remote. If this event fires then there will never be a remote response to any pending operations and the client or server instance should react accordingly to clean up any related resources etc.
-