java.lang.Object
org.mule.sdk.api.runtime.source.Source<T,A>
com.mulesoft.connectors.mcp.internal.server.source.AbstractRequestListener<ResourceRequest,RequestAttributes>
com.mulesoft.connectors.mcp.internal.server.source.resource.ResourceListener

@DisplayName("MCP Server - Resource listener") @EmitsResponse public class ResourceListener extends AbstractRequestListener<ResourceRequest,RequestAttributes>
Exposes a resource which content is generated by the execution of the owning flow.

The flow will be executed for every received resources/read request. The user can choose to implement the flow so that the resource content is static or to make it dynamic.

For instance, a dynamic resource could be a expenses.csv file, that is actually the result of executing a live DB query. Or a static resource could be a file obtained through Amazon S3 and locally cached using the <ee:cache> component.

Since:
0.1.0
  • Constructor Details

    • ResourceListener

      public ResourceListener()
  • Method Details

    • doStart

      protected void doStart(org.mule.sdk.api.runtime.source.SourceCallback<ResourceRequest,RequestAttributes> sourceCallback) throws org.mule.runtime.api.exception.MuleException
      Specified by:
      doStart in class AbstractRequestListener<ResourceRequest,RequestAttributes>
      Throws:
      org.mule.runtime.api.exception.MuleException
    • onSuccess

      @OnSuccess public void onSuccess(@Expression(NOT_SUPPORTED) @ParameterDsl(allowReferences=false) Resource resourceListenerContent, org.mule.sdk.api.runtime.source.SourceCallbackContext context)
      Parameters:
      resourceListenerContent - Defines the resource content and type. These parameters will be evaluated when the flow finishes successfully (payload and variables available)
      context - the callback context
    • onError

      @OnError public void onError(org.mule.runtime.api.message.Error error, org.mule.sdk.api.runtime.source.SourceCallbackContext context)
    • onTerminate

      @OnTerminate public void onTerminate(org.mule.sdk.api.runtime.source.SourceResult sourceResult)
    • doStop

      protected void doStop()
      Specified by:
      doStop in class AbstractRequestListener<ResourceRequest,RequestAttributes>