use of org.apache.meecrowave.runner.Cli in project component-runtime by Talend.
the class WebServer method run.
@Override
public void run() {
final String originalCompSystProp = setSystemProperty("talend.component.server.component.coordinates", componentGav);
final String skipClasspathSystProp = setSystemProperty("component.manager.classpath.skip", "true");
final String skipCallersSystProp = setSystemProperty("component.manager.callers.skip", "true");
final AtomicReference<Meecrowave> ref = new AtomicReference<>();
try {
final CountDownLatch latch = new CountDownLatch(1);
final Cli cli = new Cli(buildArgs()) {
@Override
protected void doWait(final Meecrowave meecrowave, final CommandLine line) {
ref.set(meecrowave);
latch.countDown();
super.doWait(meecrowave, line);
}
};
new Thread(() -> {
try {
cli.run();
} catch (final RuntimeException re) {
latch.countDown();
log.error(re.getMessage());
throw re;
}
}, getClass().getName() + '_' + findPort()).start();
try {
latch.await(2, MINUTES);
} catch (final InterruptedException e) {
Thread.interrupted();
return;
}
final Scanner scanner = new Scanner(System.in);
do {
log.info("Enter 'exit' to quit");
} while (!shouldQuit(scanner.nextLine()));
} finally {
reset("talend.component.server.component.coordinates", originalCompSystProp);
reset("component.manager.classpath.skip", skipClasspathSystProp);
reset("component.manager.callers.skip", skipCallersSystProp);
ofNullable(ref.get()).ifPresent(mw -> StandardServer.class.cast(mw.getTomcat().getServer()).stopAwait());
}
}
Aggregations