in uimaj-as-core/src/main/java/org/apache/uima/aae/handler/input/ProcessRequestHandler_impl.java [1038:1129]
public void handle(Object anObjectToHandle) // throws AsynchAEException
{
try {
super.validate(anObjectToHandle);
MessageContext messageContext = (MessageContext) anObjectToHandle;
if (isHandlerForMessage(messageContext, AsynchAEMessage.Request, AsynchAEMessage.Process)
|| isHandlerForMessage(messageContext, AsynchAEMessage.Request,
AsynchAEMessage.CollectionProcessComplete)
|| isHandlerForMessage(messageContext, AsynchAEMessage.Request,
AsynchAEMessage.ReleaseCAS)
|| isHandlerForMessage(messageContext, AsynchAEMessage.Request, AsynchAEMessage.Stop)) {
int payload = messageContext.getMessageIntProperty(AsynchAEMessage.Payload);
int command = messageContext.getMessageIntProperty(AsynchAEMessage.Command);
CacheEntry ce = null;
if (AsynchAEMessage.CASRefID == payload) {
String cid = null;
// Fetch id of the CAS from the message.
if ((cid = getCasReferenceId(messageContext)) == null) {
return; // Invalid message. Nothing to do
}
ce = getController().getInProcessCache().getCacheEntryForCAS(cid);
}
if ( ce == null || !ce.isWarmUp() ) {
getController().getControllerLatch().waitUntilInitialized();
}
// If a Process Request, increment number of CASes processed
if (messageContext.getMessageIntProperty(AsynchAEMessage.MessageType) == AsynchAEMessage.Request
&& command == AsynchAEMessage.Process
&& !messageContext.propertyExists(AsynchAEMessage.CasSequence)) {
// Increment number of CASes processed by this service
getController().getServicePerformance().incrementNumberOfCASesProcessed();
}
if (getController().isStopped()) {
return;
}
if (AsynchAEMessage.CASRefID == payload) {
// Fetch id of the CAS from the message.
if (getCasReferenceId(messageContext) == null) {
return; // Invalid message. Nothing to do
}
handleProcessRequestWithCASReference(messageContext);
} else if (AsynchAEMessage.XMIPayload == payload
|| AsynchAEMessage.BinaryPayload == payload) {
// Fetch id of the CAS from the message.
if (getCasReferenceId(messageContext) == null) {
return; // Invalid message. Nothing to do
}
handleProcessRequestFromRemoteClient(messageContext);
}
// else if (AsynchAEMessage.XCASPayload == payload) {
// // Fetch id of the CAS from the message.
// if (getCasReferenceId(messageContext) == null) {
// return; // Invalid message. Nothing to do
// }
// handleProcessRequestWithXCAS(messageContext);
// }
else if (AsynchAEMessage.None == payload
&& AsynchAEMessage.CollectionProcessComplete == command) {
handleCollectionProcessCompleteRequest(messageContext);
} else if (AsynchAEMessage.None == payload && AsynchAEMessage.ReleaseCAS == command) {
handleReleaseCASRequest(messageContext);
} else if (AsynchAEMessage.None == payload && AsynchAEMessage.Stop == command) {
handleStopRequest(messageContext);
} else if (AsynchAEMessage.None == payload && AsynchAEMessage.Ping == command) {
handlePingRequest(messageContext);
}
// Handled Request
return;
}
// Not a Request nor Command. Delegate to the next handler in the chain
super.delegate(messageContext);
} catch (Exception e) {
if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) {
if ( getController() != null ) {
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, CLASS_NAME.getName(),
"handle", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_service_exception_WARNING", getController().getComponentName());
}
UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(),
"handle", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE,
"UIMAEE_exception__WARNING", e);
}
getController().getErrorHandlerChain().handle(e,
HandlerBase.populateErrorContext((MessageContext) anObjectToHandle), getController());
}
}