*
*/
public synchronized Transportable eval(Transportable in) throws ServiceException {
try {
VinciFrame input = (VinciFrame) in;
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger().log(Level.FINEST, input.toXML());
}
String cmd = input.fgetString("vinci:COMMAND");
if (cmd.equals("shutdown")) {
if (UIMAFramework.getLogger().isLoggable(Level.INFO)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.INFO, this.getClass().getName(),
"initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_deactivating_vns_port__INFO",
new Object[] { Thread.currentThread().getName() });
}
this.cleanExit();
return input;
} else if (cmd.equals("serveon")) {
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
"initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_vns_process_serveon__FINEST",
new Object[] { Thread.currentThread().getName() });
}
// String serviceName = input.fgetString("SERVICE");
int port = getPort();
input.fdrop("vinci:COMMAND");
input.fadd("IP", "127.0.0.1");
input.fadd("PORT", port);
try {
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
"initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_assign_service_port__FINEST",
new Object[] { Thread.currentThread().getName(), String.valueOf(port) });
}
portQueue.enqueue(String.valueOf(port));
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
"initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_assign_service_port_complete__FINEST",
new Object[] { Thread.currentThread().getName(), String.valueOf(port) });
}
} catch (Exception e) {
e.printStackTrace();
}
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).log(Level.FINEST, input.toXML());
UIMAFramework.getLogger().log(Level.FINEST, input.toXML());
}
return input;
} else if (cmd.equals("resolve")) {
String publicVNSHost = System.getProperty("PVNS_HOST");
String publicVNSPort = System.getProperty("PVNS_PORT");
if (publicVNSHost == null || publicVNSHost.trim().length() == 0 || publicVNSPort == null
|| publicVNSPort.trim().length() == 0) {
if (UIMAFramework.getLogger().isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.WARNING,
this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_unknown_vns_command__WARNING",
new Object[] { Thread.currentThread().getName() });
}
VinciFrame rtn = new VinciFrame();
rtn
.fadd("vinci:EXCEPTION",
"CPM Reply:Public VNS not known. Verify CPMs startup param include -DVNS_HOST and -DVNS_PORT");
return rtn;
}
int pvnsPort = -1;
try {
pvnsPort = Integer.parseInt(publicVNSPort);
} catch (NumberFormatException e) {
if (UIMAFramework.getLogger().isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.WARNING,
this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_unknown_vns_command__WARNING",
new Object[] { Thread.currentThread().getName() });
}
VinciFrame rtn = new VinciFrame();
rtn.fadd("vinci:EXCEPTION", "CPM Reply: Invalid VNS Port value::" + publicVNSPort);
return rtn;
}
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
"initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_vns_redirect__FINEST",
new Object[] { Thread.currentThread().getName(), publicVNSHost, publicVNSPort });
}
BaseClient client = new BaseClient(publicVNSHost, pvnsPort);
return client.sendAndReceive(in);
} else {
if (UIMAFramework.getLogger().isLoggable(Level.WARNING)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.WARNING, this.getClass().getName(),
"initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_unknown_vns_command__WARNING",
new Object[] { Thread.currentThread().getName() });
}
VinciFrame rtn = new VinciFrame();
rtn.fadd("vinci:EXCEPTION", "Unknown command");
return rtn;
}
} catch (Exception ex) {
ex.printStackTrace();
throw new ServiceException(ex.getMessage());