Class AmqpResourceBuilder<TARGET extends AmqpResource,​PARENT extends AmqpResourceParent,​INFO extends JmsResource,​ENDPOINT extends org.apache.qpid.proton.engine.Endpoint>

    • Constructor Detail

      • AmqpResourceBuilder

        public AmqpResourceBuilder​(PARENT parent,
                                   INFO resourceInfo)
    • 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.
      • 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)
      • 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()
      • getResource

        public TARGET getResource()
      • getParent

        public PARENT getParent()
      • getResourceInfo

        public INFO getResourceInfo()