public interface KeywordExecutable
ServiceLoader to auto-discover classes executable with a
convenient keyword on the command-line.
All implementing classes who have an entry in
META-INF/services/KeywordExecutable on the classpath will
be constructed by the ServiceLoader, so they should be lightweight and quickly
constructible with a mandatory no-argument constructor. Because of this, implementing classes
could simply be factories which execute a different class, if that class is expensive to
construct or cannot have a no-argument constructor.
One way to easily create META-INF/services files is to use the AutoService annotation.
If the implementing class also wishes to have a redundant main method, it may be useful to simply
implement main as:
new MyImplementingClass().execute(args);
| Modifier and Type | Method and Description |
|---|---|
void |
execute(String[] args)
Execute the item with the given arguments.
|
String |
keyword()
Provides access to the service's keyword.
|
String keyword()
Copyright © 2011–2018 The Apache Software Foundation. All rights reserved.