@SuppressWarnings("unchecked")
public static void main(String[] args) {
try {
CommandLine cl = parseComandLine(args);
Device device = new Device("stgcmtscu");
Connection conn = new Connection();
device.addConnection(conn);
ApplicationEntity ae = new ApplicationEntity("STGCMTSCU");
device.addApplicationEntity(ae);
ae.addConnection(conn);
final StgCmtSCU stgcmtscu = new StgCmtSCU(ae);
CLIUtils.configureConnect(stgcmtscu.remote, stgcmtscu.rq, cl);
CLIUtils.configureBind(conn, stgcmtscu.ae, cl);
CLIUtils.configure(conn, cl);
stgcmtscu.remote.setTlsProtocols(conn.getTlsProtocols());
stgcmtscu.remote.setTlsCipherSuites(conn.getTlsCipherSuites());
stgcmtscu.setTransferSyntaxes(CLIUtils.transferSyntaxesOf(cl));
stgcmtscu.setStatus(CLIUtils.getIntOption(cl, "status", 0));
stgcmtscu.setSplitTag(getSplitTag(cl));
stgcmtscu.setKeepAlive(cl.hasOption("keep-alive"));
stgcmtscu.setStorageDirectory(getStorageDirectory(cl));
stgcmtscu.setAttributes(new Attributes());
CLIUtils.addAttributes(stgcmtscu.attrs, cl.getOptionValues("s"));
stgcmtscu.setUIDSuffix(cl.getOptionValue("uid-suffix"));
List<String> argList = cl.getArgList();
boolean echo = argList.isEmpty();
if (!echo) {
LOG.info(rb.getString("scanning"));
DicomFiles.scan(argList, new DicomFiles.Callback() {
@Override
public boolean dicomFile(File f, Attributes fmi, long dsPos,
Attributes ds) {
return stgcmtscu.addInstance(ds);
}
});
}
ExecutorService executorService =
Executors.newCachedThreadPool();
ScheduledExecutorService scheduledExecutorService =
Executors.newSingleThreadScheduledExecutor();
device.setExecutor(executorService);
device.setScheduledExecutor(scheduledExecutorService);
device.bindConnections();
try {
stgcmtscu.open();
if (echo)
stgcmtscu.echo();
else
stgcmtscu.sendRequests();
} finally {
stgcmtscu.close();
if (conn.isListening()) {
device.waitForNoOpenConnections();
device.unbindConnections();
}
executorService.shutdown();
scheduledExecutorService.shutdown();
}
} catch (ParseException e) {