public abstract class AbstractMessageHandler extends Object implements ManagementMessageHandler, org.jboss.remoting3.CloseHandler<org.jboss.remoting3.Channel>
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 <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)
protected ExecutorService getExecutor()
protected ManagementRequestHandler<?,?> getRequestHandler(ManagementRequestHeader header)
header
- the request headerprotected ManagementRequestHeader validateRequest(ManagementProtocolHeader header) throws IOException
header
- the protocol headerIOException
public void handleMessage(org.jboss.remoting3.Channel channel, DataInput input, ManagementProtocolHeader header) throws IOException
handleMessage
in interface ManagementMessageHandler
channel
- the channelinput
- the messageheader
- the management protocol headerIOException
protected <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 handlerIOException
protected <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 shutdown()
shutdown
in interface ManagementChannelInitialization.ManagementChannelShutdownHandle
public void shutdownNow()
shutdownNow
in interface ManagementChannelInitialization.ManagementChannelShutdownHandle
public boolean awaitCompletion(long timeout, TimeUnit unit) throws InterruptedException
awaitCompletion
in interface ManagementChannelInitialization.ManagementChannelShutdownHandle
timeout
- the timeoutunit
- the time unitInterruptedException
public 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> 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 errorIOException
protected static FlushableDataOutput writeHeader(ManagementProtocolHeader header, OutputStream os) throws IOException
header
- the mgmt protocol headeros
- the output streamIOException
protected <T,A> ManagementRequestHandler<T,A> getFallbackHandler(ManagementRequestHeader header)
header
- the protocol headerprotected <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 operationpublic 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 List<Integer> cancelAllActiveOperations()
protected boolean isShutdown()
true
if the shutdown method was called, false
otherwiseCopyright © 2023 JBoss by Red Hat. All rights reserved.