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 theManagementRequestContextis 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceManagementRequestContext.AsyncTask<A>A task that can be executed asynchronously by aManagementRequestContextstatic interfaceManagementRequestContext.MultipleResponseAsyncTask<A>Deprecated.this is a bit of a hack, plus we can move this method into AsyncTask with a default impl once this module no longer requires JDK 6 source level
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanexecuteAsync(ManagementRequestContext.AsyncTask<A> task)Execute a cancellable task at some point in the future, using this object's internalExecutor.booleanexecuteAsync(ManagementRequestContext.AsyncTask<A> task, boolean cancellable)Execute a possibly cancellable task at some point in the future, using this object's internalExecutor.booleanexecuteAsync(ManagementRequestContext.AsyncTask<A> task, boolean cancellable, Executor executor)Execute a possibly cancellable task at some point in the future, using the givenExecutor.booleanexecuteAsync(ManagementRequestContext.AsyncTask<A> task, Executor executor)Execute a cancellable task at some point in the future, using the givenExecutor.AgetAttachment()Get any attachment used to maintain shared state across possibly multiple requests associated with a larger overall operation.org.jboss.remoting3.ChannelgetChannel()Get the underlying channel.IntegergetOperationId()Get the current batch id for the overall operation.ManagementProtocolHeadergetRequestHeader()Get the protocol header.FlushableDataOutputwriteMessage(ManagementProtocolHeader header)Initiates writing a new message to the remote side, using the given header.
-
-
-
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
-
getRequestHeader
ManagementProtocolHeader getRequestHeader()
Get the protocol header.- Returns:
- the protocol header
-
executeAsync
boolean executeAsync(ManagementRequestContext.AsyncTask<A> task)
Execute a cancellable task at some point in the future, using this object's internalExecutor. Equivalent toexecuteAsync(task, true).If the executor
rejectsthe task, or if the task itself throws an exception during execution, thefailed methodof theResultHanderassociated with the request will be invoked, and if it returnstruea failure message will be sent to the remote client.- Parameters:
task- the task- Returns:
trueif the task was accepted for execution;falseif 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 internalExecutor.If the executor
rejectsthe task, or if the task itself throws an exception during execution, thefailed methodof theResultHanderassociated with the request will be invoked, and if it returnstruea failure message will be sent to the remote client.- Parameters:
task- the taskcancellable-trueif the task can be cancelled as part of overall request cancellation- Returns:
trueif the task was accepted for execution;falseif 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 givenExecutor. Equivalent toexecuteAsync(task, true, executor).If the executor
rejectsthe task, or if the task itself throws an exception during execution, thefailed methodof theResultHanderassociated with the request will be invoked, and if it returnstruea failure message will be sent to the remote client.- Parameters:
task- the taskexecutor- the executor- Returns:
trueif the task was accepted for execution;falseif 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 givenExecutor. Equivalent toexecuteAsync(task, true, executor).If the executor
rejectsthe task, or if the task itself throws an exception during execution, thefailed methodof theResultHanderassociated with the request will be invoked, and if it returnstruea failure message will be sent to the remote client.- Parameters:
task- the taskcancellable-trueif the task can be cancelled as part of overall request cancellationexecutor- the executor- Returns:
trueif the task was accepted for execution;falseif 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
-
-