public interface ToolProvider
Tool providers are normally located using the service-provider
loading facility defined by ServiceLoader
.
Each provider must provide a name, and a method to run
an instance of the corresponding tool. When a tool is run,
it will be provided with an array of string arguments, and a
pair of streams: one for normal (or expected) output and the other
for reporting any errors that may occur.
The interpretation of the string arguments will normally be defined by
each individual tool provider, but will generally correspond to the
arguments that could be provided to the tool when invoking the tool
from the command line.
Modifier and Type | Method | Description |
---|---|---|
static Optional<ToolProvider> |
findFirst(String name) |
Returns the first instance of a
ToolProvider with the given name,
as loaded by ServiceLoader using the system class loader. |
String |
name() |
Returns the name of this tool provider.
|
default int |
run(PrintStream out,
PrintStream err,
String... args) |
Runs an instance of the tool, returning zero for a successful run.
|
int |
run(PrintWriter out,
PrintWriter err,
String... args) |
Runs an instance of the tool, returning zero for a successful run.
|
String name()
int run(PrintWriter out, PrintWriter err, String... args)
out
- a stream to which "expected" output should be writtenerr
- a stream to which any error messages should be writtenargs
- the command-line arguments for the toolNullPointerException
- if any of the arguments are null
,
or if there are any null
values in the args
arraydefault int run(PrintStream out, PrintStream err, String... args)
out
and err
streams within PrintWriter
s, and then calls
run(PrintWriter, PrintWriter, String[])
.out
- a stream to which "expected" output should be writtenerr
- a stream to which any error messages should be writtenargs
- the command-line arguments for the toolNullPointerException
- if any of the arguments are null
,
or if there are any null
values in the args
arraystatic Optional<ToolProvider> findFirst(String name)
ToolProvider
with the given name,
as loaded by ServiceLoader
using the system class loader.name
- the name of the desired tool providerOptional<ToolProvider>
of the first instance foundNullPointerException
- if name
is null
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.
DRAFT 9-internal+0-adhoc.mlchung.jdk9-jdeps