O'Reilly logo

Java 9: Building Robust Modular Applications by Jason Lee, Peter Verhas, Dr. Edward Lavieri

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The ControlDaemon class

The ControlDaemon class implements the Runnable interface and is started as a separate thread. The constructor gets the set of the parameters that were read from the properties files and converts them to a set of ParamsAndHandle objects:

    private final Set<ParamsAndHandle> handlers;    public ControlDaemon(Set<Parameters> params) {      handlers = params      .stream()      .map( s -> new ParamsAndHandle(s,null))      .collect(Collectors.toSet());    }

Because the processes are not started at this point, the handles are all null. The run() method starts the processes:

    @Override    public void run() {      try {        for (ParamsAndHandle pah : handlers) {          log.log(DEBUG, "Starting {0}", pah.params);          ProcessHandle handle = start(pah.params); pah.handle = ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required