visualization/visualization-spi-doclet/src/main/java/se/jguru/nazgul/tools/visualization/spi/doclet/graphviz/AbstractExecutableFacade.java
protected boolean initialize(final RootDoc rootDoc) {

        // #0) Don't initialize twice, unless required to.
        if (isInitializedOK) {
            return true;
        }

        // #1) Output the discovery log.
        for (String current : discoveryLog) {
            rootDoc.printNotice(current);
        }

        rootDoc.printNotice("GraphViz home: " + getHomeDirectory().getAbsolutePath());
        rootDoc.printNotice("Executable   : " + getExecutableNameOrPath());

        // #2) Create a ProcessBuilder which synthesizes a call to the executable and determine its version.
        //
        final ProcessBuilder pb = new ProcessBuilder(getExecutableNameOrPath(), "-V");
        pb.redirectErrorStream(true);
        if (homeDirectory != null) {
            pb.directory(homeDirectory);
        }

        Process p;
        try {

            // Launch the executable
            p = pb.start();
        } catch (IOException e) {

            rootDoc.printWarning(e.getMessage());
            return false;
        }

        try (BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
             OutputStream out = p.getOutputStream();) {

            // We don't need to send any more commands to the process, so close the output stream.
            out.close();

            // Read all input from the process, searching for the pattern "graphviz" ignoring case.
            String line = null;
            while ((line = in.readLine()) != null) {

                if (line.matches(GRAPHVIZ_EXECUTABLE_FIRST_LINE_CHECK)) {

                    // We found the expected output from the executable.
                    rootDoc.printNotice("GraphViz Version: " + line);
                    isInitializedOK = true;
                    return true;

                } else {

                    // Unknown output. Printout a warning and die.
                    rootDoc.printWarning("Unknown GraphViz output: " + line);
                }
            }

            // Cache the result.
            isInitializedOK = false;
            return false;

        } catch (IOException e) {

            // Nopes.
            rootDoc.printWarning("Problem detecting GraphViz: " + e.getMessage());
            isInitializedOK = false;
            return false;

        } finally {

            for (; ; ) {
                try {
                    p.waitFor();
                    break;
                } catch (InterruptedException e) {
                    // Ignore this
                }
            }
        }
    }
protected boolean initialize(final RootDoc rootDoc) {

        // #0) Don't initialize twice, unless required to.
        if (isInitializedOK) {
            return true;
        }

        // #1) Output the discovery log.
        for (String current : discoveryLog) {
            rootDoc.printNotice(current);
        }

        rootDoc.printNotice("GraphViz home: " + getHomeDirectory().getAbsolutePath());
        rootDoc.printNotice("Executable   : " + getExecutableNameOrPath());

        // #2) Create a ProcessBuilder which synthesizes a call to the executable and determine its version.
        //
        final ProcessBuilder pb = new ProcessBuilder(getExecutableNameOrPath(), "-V");
        pb.redirectErrorStream(true);
        if (homeDirectory != null) {
            pb.directory(homeDirectory);
        }

        Process p;
        try {

            // Launch the executable
            p = pb.start();
        } catch (IOException e) {

            rootDoc.printWarning(e.getMessage());
            return false;
        }

        try (BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
             OutputStream out = p.getOutputStream();) {

            // We don't need to send any more commands to the process, so close the output stream.
            out.close();

            // Read all input from the process, searching for the pattern "graphviz" ignoring case.
            String line = null;
            while ((line = in.readLine()) != null) {

                if (line.matches(GRAPHVIZ_EXECUTABLE_FIRST_LINE_CHECK)) {

                    // We found the expected output from the executable.
                    rootDoc.printNotice("GraphViz Version: " + line);
                    isInitializedOK = true;
                    return true;

                } else {

                    // Unknown output. Printout a warning and die.
                    rootDoc.printWarning("Unknown GraphViz output: " + line);
                }
            }

            // Cache the result.
            isInitializedOK = false;
            return false;

        } catch (IOException e) {

            // Nopes.
            rootDoc.printWarning("Problem detecting GraphViz: " + e.getMessage());
            isInitializedOK = false;
            return false;

        } finally {

            for (; ; ) {
                try {
                    p.waitFor();
                    break;
                } catch (InterruptedException e) {
                    // Ignore this
                }
            }
        }
    }
<p>This method should be invoked from within subclasses' worker methods, to validate that the executable found
is actually a GraphViz program.</p>
<p>The method fires the command <b><code><i>executableNameOrPath</i> -V</code></b>, capturing the output to determine
if it contains the pattern {@link #GRAPHVIZ_EXECUTABLE_FIRST_LINE_CHECK}, in which case it is deemed to be a
proper GraphViz executable. For instance, the two executables dot and neato responds as follows:</p>
<ul>
<li><i>dot -V</i>: <code>dot - graphviz version 2.36.0 (20140111.2315)</code></li>
<li><i>neato -V</i>: <code>neato - graphviz version 2.36.0 (20140111.2315)</code></li>
</ul>

@param rootDoc The non-null RootDoc received from the JavaDoc execution context.
@return {@link true} if this {@link AbstractExecutableFacade} is properly initialized and can accept commands.