Interface ManagementRequestContext<A>

  • Type Parameters:
    A - the type of the attachment that can be retrieved from the context

    public interface ManagementRequestContext<A>
    The context for handling a management request. Besides providing basic state associated with the request, one of the primary purposes of the ManagementRequestContext is to support asynchronous task execution by request handlers. Handlers should avoid doing blocking tasks in the remoting threads that invoke them, so the asynchronous task execution facilities of this class allow that work to be offloaded to other threads. Handlers also should be careful about performing IO writes using threads that have invoked management operations, as those threads may be interrupted if the caller cancels the operation, and if that interruption happens during IO the remote channel will be incorrectly closed. The asynchronous task execution facilities of this class allow the IO writes to be done in a separate thread.
    Author:
    Emanuel Muckenhuber
    • Method Detail

      • getOperationId

        Integer getOperationId()
        Get the current batch id for the overall operation.
        Returns:
        the batch id
      • getAttachment

        A getAttachment()
        Get any attachment used to maintain shared state across possibly multiple requests associated with a larger overall operation. {@see org.jboss.as.protocol.mgmt.ActiveOperation#getAttachment()}
        Returns:
        the attachment, can be null
      • getChannel

        org.jboss.remoting3.Channel getChannel()
        Get the underlying channel.
        Returns:
        the channel
      • executeAsync

        boolean executeAsync​(ManagementRequestContext.AsyncTask<A> task)
        Execute a cancellable task at some point in the future, using this object's internal Executor. Equivalent to executeAsync(task, true).

        If the executor rejects the task, or if the task itself throws an exception during execution, the failed method of the ResultHander associated with the request will be invoked, and if it returns true a failure message will be sent to the remote client.

        Parameters:
        task - the task
        Returns:
        true if the task was accepted for execution; false if the executor rejected it
      • executeAsync

        boolean executeAsync​(ManagementRequestContext.AsyncTask<A> task,
                             boolean cancellable)
        Execute a possibly cancellable task at some point in the future, using this object's internal Executor.

        If the executor rejects the task, or if the task itself throws an exception during execution, the failed method of the ResultHander associated with the request will be invoked, and if it returns true a failure message will be sent to the remote client.

        Parameters:
        task - the task
        cancellable - true if the task can be cancelled as part of overall request cancellation
        Returns:
        true if the task was accepted for execution; false if the executor rejected it
      • executeAsync

        boolean executeAsync​(ManagementRequestContext.AsyncTask<A> task,
                             Executor executor)
        Execute a cancellable task at some point in the future, using the given Executor. Equivalent to executeAsync(task, true, executor).

        If the executor rejects the task, or if the task itself throws an exception during execution, the failed method of the ResultHander associated with the request will be invoked, and if it returns true a failure message will be sent to the remote client.

        Parameters:
        task - the task
        executor - the executor
        Returns:
        true if the task was accepted for execution; false if the executor rejected it
      • executeAsync

        boolean executeAsync​(ManagementRequestContext.AsyncTask<A> task,
                             boolean cancellable,
                             Executor executor)
        Execute a possibly cancellable task at some point in the future, using the given Executor. Equivalent to executeAsync(task, true, executor).

        If the executor rejects the task, or if the task itself throws an exception during execution, the failed method of the ResultHander associated with the request will be invoked, and if it returns true a failure message will be sent to the remote client.

        Parameters:
        task - the task
        cancellable - true if the task can be cancelled as part of overall request cancellation
        executor - the executor
        Returns:
        true if the task was accepted for execution; false if the executor rejected it
      • writeMessage

        FlushableDataOutput writeMessage​(ManagementProtocolHeader header)
                                  throws IOException
        Initiates writing a new message to the remote side, using the given header.
        Parameters:
        header - the protocol header
        Returns:
        the message output stream to use for writing further data associated with the message
        Throws:
        IOException