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 Details

  • Constructor Details

    • AmqpResourceBuilder

      public AmqpResourceBuilder(PARENT parent, INFO resourceInfo)
  • Method Details

    • 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: AmqpEventSink
      Event handler for remote peer open of this resource.
      Specified by:
      processRemoteOpen in interface AmqpEventSink
      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: AmqpEventSink
      Event handler for remote peer close of this resource.
      Specified by:
      processRemoteClose in interface AmqpEventSink
      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: AmqpEventSink
      Event handler for remote peer detach of this resource.
      Specified by:
      processRemoteDetach in interface AmqpEventSink
      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: AmqpEventSink
      Called when the Proton Engine signals an Delivery related event has been triggered for the given endpoint.
      Specified by:
      processDeliveryUpdates in interface AmqpEventSink
      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: AmqpEventSink
      Called when the Proton Engine signals an Flow related event has been triggered for the given endpoint.
      Specified by:
      processFlowUpdates in interface AmqpEventSink
      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: AmqpExceptionBuilder
      Creates an exception appropriate to some failure condition
      Specified by:
      createException in interface AmqpExceptionBuilder
      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 resource
      resourceInfo - 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()