Interface ManagementRequestContext<A>
- Type Parameters:
A- the type of the attachment that can be retrieved from the context
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
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA task that can be executed asynchronously by aManagementRequestContextstatic interfaceDeprecated.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
Modifier and TypeMethodDescriptionbooleanExecute 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.Get any attachment used to maintain shared state across possibly multiple requests associated with a larger overall operation.org.jboss.remoting3.ChannelGet the underlying channel.Get the current batch id for the overall operation.Get the protocol header.writeMessage(ManagementProtocolHeader header) Initiates writing a new message to the remote side, using the given header.
-
Method Details
-
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.- 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
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
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
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
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
-