Class AmqpResourceBuilder<TARGET extends AmqpResource,PARENT extends AmqpResourceParent,INFO extends JmsResource,ENDPOINT extends org.apache.qpid.proton.engine.Endpoint>
java.lang.Object
org.apache.qpid.jms.provider.amqp.builders.AmqpResourceBuilder<TARGET,PARENT,INFO,ENDPOINT>
- Type Parameters:
TARGET- The Type of resource that will be created.PARENT- The Type of this resource's parent.INFO- The Type of JmsResource used to describe the target resource.ENDPOINT- The AMQP Endpoint that the target resource encapsulates.
- All Implemented Interfaces:
AmqpEventSink,AmqpExceptionBuilder
- Direct Known Subclasses:
AmqpConnectionBuilder,AmqpConsumerBuilder,AmqpProducerBuilder,AmqpSessionBuilder,AmqpTemporaryDestinationBuilder,AmqpTransactionCoordinatorBuilder
public abstract class AmqpResourceBuilder<TARGET extends AmqpResource,PARENT extends AmqpResourceParent,INFO extends JmsResource,ENDPOINT extends org.apache.qpid.proton.engine.Endpoint>
extends Object
implements AmqpEventSink, AmqpExceptionBuilder
Base for all AmqpResource builders.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ENDPOINTprotected final PARENTprotected final AmqpProviderprotected AsyncResultprotected ScheduledFuture<?>protected TARGETprotected final INFO -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterClosed(TARGET resource, INFO resourceInfo) Called if endpoint opening process fails in order to give the subclasses a place to perform any follow-on processing or teardown steps before the operation is deemed to have been completed and failure is signalled.protected voidCalled once an endpoint has been opened and validated to give the subclasses a place to perform any follow-on processing or setup steps before the operation is deemed to have been completed and success is signaled.voidbuildResource(AsyncResult request) Called to initiate the process of building the resource type that is managed by this builder.protected abstract ENDPOINTcreateEndpoint(INFO resourceInfo) Given the resource information provided create and configure the local endpoint whose open phase is managed by this builder.Creates an exception appropriate to some failure conditionprotected abstract TARGETcreateResource(PARENT parent, INFO resourceInfo, ENDPOINT endpoint) Create the managed resource instance.protected ProviderExceptionWhen aborting the open operation, and there isn't an error condition, provided by the peer, the returned exception will be used instead.protected ProviderExceptionWhen aborting the open operation, this method will attempt to create an appropriate exception from the remote error condition if one is set and will revert to creating the default variant if not.protected longReturns the configured time before the open of the resource is considered to have failed.protected final voidhandleClosed(AmqpProvider provider, ProviderException cause) protected final voidhandleOpened(AmqpProvider provider) protected booleanprotected abstract booleanIf the resource was opened but its current state indicates a close is pending then we do no need to proceed further into the resource creation process.protected booleanFollowing the open of the endpoint implementations of this method should validate that the endpoint properties match what was requested.voidprocessDeliveryUpdates(AmqpProvider provider, org.apache.qpid.proton.engine.Delivery delivery) Called when the Proton Engine signals an Delivery related event has been triggered for the given endpoint.voidprocessFlowUpdates(AmqpProvider provider) Called when the Proton Engine signals an Flow related event has been triggered for the given endpoint.voidprocessRemoteClose(AmqpProvider provider) Event handler for remote peer close of this resource.voidprocessRemoteDetach(AmqpProvider provider) Event handler for remote peer detach of this resource.voidprocessRemoteOpen(AmqpProvider provider) Event handler for remote peer open of this resource.
-
Field Details
-
request
-
requestTimeoutTask
-
resource
-
endpoint
-
parent
-
resourceInfo
-
provider
-
-
Constructor Details
-
AmqpResourceBuilder
-
-
Method Details
-
buildResource
Called to initiate the process of building the resource type that is managed by this builder. The resource is created and the open process occurs asynchronously. If the resource is successfully opened it will added to its parent resource for use.- Parameters:
request- The request that initiated the resource creation.
-
processRemoteOpen
Description copied from interface:AmqpEventSinkEvent handler for remote peer open of this resource.- Specified by:
processRemoteOpenin interfaceAmqpEventSink- Parameters:
provider- the AmqpProvider instance for easier access to fire events.- Throws:
ProviderException- if an error occurs while processing the update.
-
processRemoteClose
Description copied from interface:AmqpEventSinkEvent handler for remote peer close of this resource.- Specified by:
processRemoteClosein interfaceAmqpEventSink- Parameters:
provider- the AmqpProvider instance for easier access to fire events.- Throws:
ProviderException- if an error occurs while processing the update.
-
processRemoteDetach
Description copied from interface:AmqpEventSinkEvent handler for remote peer detach of this resource.- Specified by:
processRemoteDetachin interfaceAmqpEventSink- Parameters:
provider- the AmqpProvider instance for easier access to fire events.- Throws:
ProviderException- if an error occurs while processing the update.
-
processDeliveryUpdates
public void processDeliveryUpdates(AmqpProvider provider, org.apache.qpid.proton.engine.Delivery delivery) throws ProviderException Description copied from interface:AmqpEventSinkCalled when the Proton Engine signals an Delivery related event has been triggered for the given endpoint.- Specified by:
processDeliveryUpdatesin interfaceAmqpEventSink- Parameters:
provider- the AmqpProvider instance for easier access to fire events.delivery- the Delivery that has an update to its state which needs handled.- Throws:
ProviderException- if an error occurs while processing the update.
-
processFlowUpdates
Description copied from interface:AmqpEventSinkCalled when the Proton Engine signals an Flow related event has been triggered for the given endpoint.- Specified by:
processFlowUpdatesin interfaceAmqpEventSink- Parameters:
provider- the AmqpProvider instance for easier access to fire events.- Throws:
ProviderException- if an error occurs while processing the update.
-
handleOpened
-
handleClosed
-
createException
Description copied from interface:AmqpExceptionBuilderCreates an exception appropriate to some failure condition- Specified by:
createExceptionin interfaceAmqpExceptionBuilder- Returns:
- a new Exception instance that describes a failure condition.
-
createEndpoint
Given the resource information provided create and configure the local endpoint whose open phase is managed by this builder.- Returns:
- a new endpoint to be managed.
-
createResource
Create the managed resource instance.- Parameters:
parent- The parent of the newly created resource.resourceInfo- The resource information used to configure the resource.endpoint- The local endpoint for the managed resource to wrap.- Returns:
- the resource instance who open life-cycle is managed by this builder.
-
isClosePending
protected abstract boolean isClosePending()If the resource was opened but its current state indicates a close is pending then we do no need to proceed further into the resource creation process. Each endpoint build must implement this and examine the opened endpoint to determine if a close frame will follow the open.- Returns:
- true if the resource state indicates it will be immediately closed.
-
isOpenedEndpointValid
protected boolean isOpenedEndpointValid()Following the open of the endpoint implementations of this method should validate that the endpoint properties match what was requested.- Returns:
- true if the endpoint is valid based on what was requested.
-
afterOpened
protected void afterOpened()Called once an endpoint has been opened and validated to give the subclasses a place to perform any follow-on processing or setup steps before the operation is deemed to have been completed and success is signaled. -
afterClosed
Called if endpoint opening process fails in order to give the subclasses a place to perform any follow-on processing or teardown steps before the operation is deemed to have been completed and failure is signalled.- Parameters:
resource- the resourceresourceInfo- the resourceInfo
-
hasRemoteError
protected boolean hasRemoteError() -
getDefaultOpenAbortException
When aborting the open operation, and there isn't an error condition, provided by the peer, the returned exception will be used instead. A subclass may override this method to provide alternative behavior.- Returns:
- an Exception to describes the open failure for this resource.
-
getOpenAbortExceptionFromRemote
When aborting the open operation, this method will attempt to create an appropriate exception from the remote error condition if one is set and will revert to creating the default variant if not.- Returns:
- an Exception to describes the open failure for this resource.
-
getRequestTimeout
protected long getRequestTimeout()Returns the configured time before the open of the resource is considered to have failed. Subclasses can override this method to provide a value more appropriate to the resource being built.- Returns:
- the configured timeout before the open of the resource fails.
-
getEndpoint
-
getRequest
-
getResource
-
getParent
-
getResourceInfo
-