Package org.apache.qpid.protonj2.engine
Interface Endpoint<E extends Endpoint<E>>
- Type Parameters:
E- TheEndpointtype
- 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 anEventHandlerthat is invoked when the engine that supports thisEndpointis shutdown via a call toEngine.shutdown()which indicates a desire to terminate all engine operations.Symbol[]<T> T<T> TgetLinkedResource(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 thisEndpointwhich can be itself forConnectioninstance.If the remote has closed thisEndpointand provided anErrorConditionas part of the closing AMQP performative then this method will return it.Symbol[]Symbol[]booleanbooleanbooleanbooleanlocalCloseHandler(EventHandler<E> localCloseHandler) Sets aEventHandlerfor when an thisEndpointis closed locally via a call toclose()Typically used by clients for logging or other state update event processing.localOpenHandler(EventHandler<E> localOpenHandler) Sets aEventHandlerfor when an thisEndpointis 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 localErrorConditionto be applied to aEndpointclose.setDesiredCapabilities(Symbol... capabilities) Sets the capabilities that are desired from the remote when thisEndpointis opened.setLinkedResource(Object resource) Links a given resource to thisEndpoint.setOfferedCapabilities(Symbol... capabilities) Sets the capabilities to be offered on to the remote when thisEndpointis opened.setProperties(Map<Symbol, Object> properties) Sets the properties to be sent to the remote when thisEndpointis 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
Endpointinstance. - 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 theEndpointand clean up any local resources before returning normally.- Returns:
- this
Endpointinstance. - Throws:
EngineFailedException- if an error occurs closing the end point or the Engine is in a failed state.
-
getAttachments
Attachments getAttachments()- Returns:
- the
Attachmentsinstance that is associated with thisEndpoint
-
getEngine
Engine getEngine() -
getParent
Endpoint<?> getParent()Gets the parent of thisEndpointwhich can be itself forConnectioninstance.- Returns:
- the parent of this
Endpointor 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
Endpointinstance.
-
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
Endpointerror, or null if there is none
-
setCondition
Sets the localErrorConditionto be applied to aEndpointclose.- Parameters:
condition- The error condition to convey to the remote peer on close of this end point.- Returns:
- this
Endpointinstance.
-
isLocallyOpen
boolean isLocallyOpen()Returns true if thisEndpointis currently locally open meaning that theopen()has been called but theclose()has not.- Returns:
trueif theEndpointis locally open.- See Also:
-
isLocallyClosed
boolean isLocallyClosed()Returns true if thisEndpointis currently locally closed meaning that a call to theclose()method has occurred.- Returns:
trueif theEndpointis locally closed.- See Also:
-
setOfferedCapabilities
Sets the capabilities to be offered on to the remote when thisEndpointis opened. The offered capabilities value can only be modified prior to a call toopen(), once theEndpointhas been opened locally an error will be thrown if this method is called.- Parameters:
capabilities- The capabilities to be offered to the remote when theEndpointis opened.- Returns:
- this
Endpointinstance. - Throws:
IllegalStateException- if theEndpointhas already been opened.
-
getOfferedCapabilities
Symbol[] getOfferedCapabilities()- Returns:
- the configured capabilities that are offered to the remote when the
Endpointis opened.
-
setDesiredCapabilities
Sets the capabilities that are desired from the remote when thisEndpointis opened. The desired capabilities value can only be modified prior to a call toopen(), once theEndpointhas been opened locally an error will be thrown if this method is called.- Parameters:
capabilities- The capabilities desired from the remote when theEndpointis opened.- Returns:
- this
Endpointinstance. - Throws:
IllegalStateException- if theEndpointhas 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 thisEndpointis Opened. TheEndpointproperties value can only be modified prior to a call toopen(), once theEndpointhas 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
Endpointinstance. - Throws:
IllegalStateException- if theEndpointhas already been opened.
-
getProperties
- Returns:
- the configured properties sent to the remote when this Connection is opened.
-
isRemotelyOpen
boolean isRemotelyOpen()Returns true if thisEndpointis 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:
trueif theEndpointis remotely open.- See Also:
-
isRemotelyClosed
boolean isRemotelyClosed()Returns true if thisEndpointis currently remotely closed meaning that the AMQP performative that completes the close phase of thisEndpoint's lifetime has arrived.- Returns:
trueif theEndpointis remotely closed.- See Also:
-
getRemoteCondition
ErrorCondition getRemoteCondition()If the remote has closed thisEndpointand provided anErrorConditionas 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 aEventHandlerfor when an thisEndpointis 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- TheEventHandlerto notify when thisEndpointis locally opened.- Returns:
- this
Endpointinstance.
-
localCloseHandler
Sets aEventHandlerfor when an thisEndpointis 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- TheEventHandlerto notify when thisEndpointis locally closed.- Returns:
- this
Endpointinstance.
-
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 theEndpointonce 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 anEventHandlerthat is invoked when the engine that supports thisEndpointis shutdown via a call toEngine.shutdown()which indicates a desire to terminate all engine operations. AnyEndpointthat 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 closedEndpointthat 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.
-