public abstract class AbstractMessageHandler extends Object implements ManagementMessageHandler, ManagementChannelShutdownHandle, org.jboss.remoting3.CloseHandler<org.jboss.remoting3.Channel>
ManagementMessageHandler implementations.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractMessageHandler(ExecutorService executorService) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitCompletion(long timeout,
TimeUnit unit)
Await the completion of all currently active operations.
|
protected List<Integer> |
cancelAllActiveOperations()
Cancel all currently active operations.
|
protected <T,A> org.jboss.threads.AsyncFuture<T> |
executeRequest(ManagementRequest<T,A> request,
org.jboss.remoting3.Channel channel,
ActiveOperation<T,A> support)
Execute a request.
|
protected <T,A> ActiveOperation<T,A> |
getActiveOperation(Integer id)
Get the active operation.
|
protected <T,A> ActiveOperation<T,A> |
getActiveOperation(ManagementRequestHeader header)
Get an active operation.
|
protected ExecutorService |
getExecutor()
Get the executor
|
protected static <T,A> ManagementRequestHandler<T,A> |
getFallbackHandler(ManagementRequestHeader header)
Get a fallback handler.
|
protected ManagementRequestHandler<?,?> |
getRequestHandler(ManagementRequestHeader header)
Get the request handler.
|
void |
handleChannelClosed(org.jboss.remoting3.Channel closed,
IOException e)
Receive a notification that the channel was closed.
|
void |
handleClose(org.jboss.remoting3.Channel closed,
IOException exception) |
void |
handleMessage(org.jboss.remoting3.Channel channel,
DataInput input,
ManagementProtocolHeader header)
Handle a message.
|
protected <T,A> void |
handleMessage(org.jboss.remoting3.Channel channel,
DataInput message,
ManagementProtocolHeader header,
ActiveOperation<T,A> support,
ManagementRequestHandler<T,A> handler)
Handle a message.
|
protected <T,A> void |
handleMessage(org.jboss.remoting3.Channel channel,
DataInput message,
ManagementRequestHeader header,
ManagementRequestHandler<T,A> handler)
Handle a message.
|
protected <T,A> void |
handleRequest(org.jboss.remoting3.Channel channel,
DataInput message,
ManagementProtocolHeader header,
org.jboss.as.protocol.mgmt.AbstractMessageHandler.ActiveRequest<T,A> activeRequest)
Handle a message.
|
protected boolean |
isShutdown()
Is shutdown.
|
protected <T,A> ActiveOperation<T,A> |
registerActiveOperation(A attachment)
Register an active operation.
|
protected <T,A> ActiveOperation<T,A> |
registerActiveOperation(A attachment,
ActiveOperation.CompletedCallback<T> callback)
Register an active operation.
|
protected <T,A> ActiveOperation<T,A> |
registerActiveOperation(Integer id,
A attachment)
Register an active operation with a specific operation id.
|
protected <T,A> ActiveOperation<T,A> |
registerActiveOperation(Integer id,
A attachment,
ActiveOperation.CompletedCallback<T> callback)
Register an active operation with a specific operation id.
|
protected <T,A> ActiveOperation<T,A> |
removeActiveOperation(Integer id)
Remove an active operation.
|
protected static void |
safeWriteErrorResponse(org.jboss.remoting3.Channel channel,
ManagementProtocolHeader header,
Throwable error)
Safe write error response.
|
void |
shutdown()
Prevent new active operations get registered.
|
void |
shutdownNow()
This will attempt to cancel all active operations, without waiting for their completion.
|
protected ManagementRequestHeader |
validateRequest(ManagementProtocolHeader header)
Validate whether the request can be handled.
|
protected static void |
writeErrorResponse(org.jboss.remoting3.Channel channel,
ManagementRequestHeader header,
Throwable error)
Write an error response.
|
protected static FlushableDataOutput |
writeHeader(ManagementProtocolHeader header,
OutputStream os)
Write the management protocol header.
|
protected AbstractMessageHandler(ExecutorService executorService)
public void handleChannelClosed(org.jboss.remoting3.Channel closed,
IOException e)
ManagementClientChannelStrategy.Establishing since it might use multiple channels.closed - the closed resourcee - the exception which occurred during close, if anyprotected boolean isShutdown()
true if the shutdown method was called, false otherwisepublic void shutdown()
shutdown in interface ManagementChannelShutdownHandlepublic void shutdownNow()
shutdownNow in interface ManagementChannelShutdownHandlepublic boolean awaitCompletion(long timeout,
TimeUnit unit)
throws InterruptedException
awaitCompletion in interface ManagementChannelShutdownHandletimeout - the timeoutunit - the time unitInterruptedExceptionprotected ExecutorService getExecutor()
protected ManagementRequestHandler<?,?> getRequestHandler(ManagementRequestHeader header)
header - the request headerprotected ManagementRequestHeader validateRequest(ManagementProtocolHeader header) throws IOException
header - the protocol headerIOExceptionpublic void handleMessage(org.jboss.remoting3.Channel channel,
DataInput input,
ManagementProtocolHeader header)
throws IOException
handleMessage in interface ManagementMessageHandlerchannel - the channelinput - the messageheader - the management protocol headerIOExceptionprotected <T,A> org.jboss.threads.AsyncFuture<T> executeRequest(ManagementRequest<T,A> request, org.jboss.remoting3.Channel channel, ActiveOperation<T,A> support)
request - the requestchannel - the channelsupport - the request supportprotected <T,A> void handleRequest(org.jboss.remoting3.Channel channel,
DataInput message,
ManagementProtocolHeader header,
org.jboss.as.protocol.mgmt.AbstractMessageHandler.ActiveRequest<T,A> activeRequest)
channel - the channelmessage - the messageheader - the protocol headeractiveRequest - the active requestprotected <T,A> void handleMessage(org.jboss.remoting3.Channel channel,
DataInput message,
ManagementRequestHeader header,
ManagementRequestHandler<T,A> handler)
throws IOException
channel - the channelmessage - the messageheader - the protocol headerhandler - the request handlerIOExceptionprotected <T,A> void handleMessage(org.jboss.remoting3.Channel channel,
DataInput message,
ManagementProtocolHeader header,
ActiveOperation<T,A> support,
ManagementRequestHandler<T,A> handler)
channel - the channelmessage - the messageheader - the protocol headersupport - the request supporthandler - the request handlerpublic void handleClose(org.jboss.remoting3.Channel closed,
IOException exception)
handleClose in interface org.jboss.remoting3.CloseHandler<org.jboss.remoting3.Channel>protected <T,A> ActiveOperation<T,A> registerActiveOperation(A attachment)
attachment - the shared attachmentprotected <T,A> ActiveOperation<T,A> registerActiveOperation(A attachment, ActiveOperation.CompletedCallback<T> callback)
attachment - the shared attachmentcallback - the completed callbackprotected <T,A> ActiveOperation<T,A> registerActiveOperation(Integer id, A attachment)
id - the operation idattachment - the shared attachmentIllegalStateException - if an operation with the same id is already registeredprotected <T,A> ActiveOperation<T,A> registerActiveOperation(Integer id, A attachment, ActiveOperation.CompletedCallback<T> callback)
id - the operation idattachment - the shared attachmentcallback - the completed callbackIllegalStateException - if an operation with the same id is already registeredprotected <T,A> ActiveOperation<T,A> getActiveOperation(ManagementRequestHeader header)
header - the request headernull if if there is no registered operationprotected <T,A> ActiveOperation<T,A> getActiveOperation(Integer id)
id - the active operation idnull if if there is no registered operationprotected List<Integer> cancelAllActiveOperations()
protected <T,A> ActiveOperation<T,A> removeActiveOperation(Integer id)
id - the operation idnull if there was no registered operationprotected static void safeWriteErrorResponse(org.jboss.remoting3.Channel channel,
ManagementProtocolHeader header,
Throwable error)
channel - the channelheader - the request headererror - the exceptionprotected static void writeErrorResponse(org.jboss.remoting3.Channel channel,
ManagementRequestHeader header,
Throwable error)
throws IOException
channel - the channelheader - the requesterror - the errorIOExceptionprotected static FlushableDataOutput writeHeader(ManagementProtocolHeader header, OutputStream os) throws IOException
header - the mgmt protocol headeros - the output streamIOExceptionprotected static <T,A> ManagementRequestHandler<T,A> getFallbackHandler(ManagementRequestHeader header)
header - the protocol headerCopyright © 2020 JBoss by Red Hat. All rights reserved.