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
Fields Modifier and Type Field Description protected ENDPOINTendpointprotected PARENTparentprotected AmqpProviderproviderprotected AsyncResultrequestprotected ScheduledFuture<?>requestTimeoutTaskprotected TARGETresourceprotected INFOresourceInfo
-
Constructor Summary
Constructors Constructor Description AmqpResourceBuilder(PARENT parent, INFO resourceInfo)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected 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 voidafterOpened()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.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.ProviderExceptioncreateException()Creates an exception appropriate to some failure conditionprotected abstract TARGETcreateResource(PARENT parent, INFO resourceInfo, ENDPOINT endpoint)Create the managed resource instance.protected ProviderExceptiongetDefaultOpenAbortException()When aborting the open operation, and there isn't an error condition, provided by the peer, the returned exception will be used instead.ENDPOINTgetEndpoint()protected ProviderExceptiongetOpenAbortExceptionFromRemote()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.PARENTgetParent()AsyncResultgetRequest()protected longgetRequestTimeout()Returns the configured time before the open of the resource is considered to have failed.TARGETgetResource()INFOgetResourceInfo()protected voidhandleClosed(AmqpProvider provider, ProviderException cause)protected voidhandleOpened(AmqpProvider provider)protected booleanhasRemoteError()protected abstract booleanisClosePending()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.protected booleanisOpenedEndpointValid()Following 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 Detail
-
request
protected AsyncResult request
-
requestTimeoutTask
protected ScheduledFuture<?> requestTimeoutTask
-
resource
protected TARGET extends AmqpResource resource
-
endpoint
protected ENDPOINT extends org.apache.qpid.proton.engine.Endpoint endpoint
-
parent
protected final PARENT extends AmqpResourceParent parent
-
resourceInfo
protected final INFO extends JmsResource resourceInfo
-
provider
protected final AmqpProvider provider
-
-
Method Detail
-
buildResource
public void buildResource(AsyncResult request)
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
public void processRemoteOpen(AmqpProvider provider) throws ProviderException
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
public void processRemoteClose(AmqpProvider provider) throws ProviderException
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
public void processRemoteDetach(AmqpProvider provider) throws ProviderException
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
public void processFlowUpdates(AmqpProvider provider) throws ProviderException
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
protected final void handleOpened(AmqpProvider provider)
-
handleClosed
protected final void handleClosed(AmqpProvider provider, ProviderException cause)
-
createException
public ProviderException 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
protected abstract ENDPOINT createEndpoint(INFO resourceInfo)
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
protected abstract TARGET createResource(PARENT parent, INFO resourceInfo, ENDPOINT endpoint)
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
protected void afterClosed(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.- Parameters:
resource- the resourceresourceInfo- the resourceInfo
-
hasRemoteError
protected boolean hasRemoteError()
-
getDefaultOpenAbortException
protected ProviderException 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
protected ProviderException 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
public ENDPOINT getEndpoint()
-
getRequest
public AsyncResult getRequest()
-
getResource
public TARGET getResource()
-
getParent
public PARENT getParent()
-
getResourceInfo
public INFO getResourceInfo()
-
-