{
private static final boolean debug = false;
- /*
- * true: use REST API (recommended), false: use stdout/stdin (deprecated)
- */
- // TODO remove once definitely happy with using REST
- private static final boolean USE_REST = true;
-
private int chimeraRestPort;
private Process chimera;
modelNumbers[0], modelNumbers[1]);
currentModelsMap.put(modelNumber, newModel);
models.add(newModel);
+
+ //
// patch for Jalview - set model name in Chimera
+ //
sendChimeraCommand("setattr M name " + modelName + " #"
+ modelNumbers[0], false);
// end patch for Jalview
+
modelNumbers = null;
}
}
{
chimera = null;
currentModelsMap.clear();
- if (USE_REST)
- {
this.chimeraRestPort = 0;
- }
- else
- {
- chimeraListenerThread.requestStop();
- chimeraListenerThread = null;
- }
structureManager.clearOnChimeraExit();
}
List<String> args = new ArrayList<String>();
args.add(chimeraPath);
args.add("--start");
- args.add(USE_REST ? "RESTServer" : "ReadStdin");
+ args.add("RESTServer");
ProcessBuilder pb = new ProcessBuilder(args);
chimera = pb.start();
error = "";
workingPath = chimeraPath;
- logger.info("Starting " + chimeraPath + " with "
- + (USE_REST ? "REST API" : "stdin/stdout"));
break;
} catch (Exception e)
{
// If no error, then Chimera was launched successfully
if (error.length() == 0)
{
- if (USE_REST)
- {
- this.chimeraRestPort = getPortNumber();
- System.out.println("Chimera REST API on port " + chimeraRestPort);
- }
- else
- {
- // Initialize the listener threads
- chimeraListenerThread = new ListenerThreads(chimera,
- structureManager);
- chimeraListenerThread.start();
- }
+ this.chimeraRestPort = getPortNumber();
+ System.out.println("Chimera REST API started on port "
+ + chimeraRestPort);
// structureManager.initChimTable();
structureManager.setChimeraPathProperty(workingPath);
// TODO: [Optional] Check Chimera version and show a warning if below 1.8
} catch (InterruptedException q)
{
}
- ;
}
busy = true;
long startTime = System.currentTimeMillis();
try
{
- if (USE_REST)
- {
- return sendRestCommand(command);
- }
- else
- {
- return sendStdinCommand(command, reply);
- }
+ return sendRestCommand(command);
} finally
{
+ /*
+ * Make sure busy flag is reset come what may!
+ */
busy = false;
if (debug)
{