This commit is contained in:
Michael Lipp 2023-08-08 14:18:17 +02:00
parent 010b6fdce6
commit 85dca0cb80

View file

@ -45,9 +45,9 @@ import org.jgrapes.util.events.WatchFile;
/** /**
* The application class. * The application class.
*/ */
public class Operator extends Component { public class Manager extends Component {
private static Operator app; private static Manager app;
/** /**
* Instantiates a new manager. * Instantiates a new manager.
@ -55,7 +55,7 @@ public class Operator extends Component {
* *
* @throws IOException Signals that an I/O exception has occurred. * @throws IOException Signals that an I/O exception has occurred.
*/ */
public Operator(CommandLine cmdLine) throws IOException { public Manager(CommandLine cmdLine) throws IOException {
// Prepare component tree // Prepare component tree
attach(new NioDispatcher()); attach(new NioDispatcher());
attach(new FileSystemWatcher(channel())); attach(new FileSystemWatcher(channel()));
@ -92,7 +92,7 @@ public class Operator extends Component {
props = Files.newInputStream(path.get()); props = Files.newInputStream(path.get());
} else { } else {
props props
= Operator.class.getResourceAsStream("logging.properties"); = Manager.class.getResourceAsStream("logging.properties");
} }
LogManager.getLogManager().readConfiguration(props); LogManager.getLogManager().readConfiguration(props);
} catch (IOException e) { } catch (IOException e) {
@ -109,9 +109,9 @@ public class Operator extends Component {
@SuppressWarnings("PMD.SignatureDeclareThrowsException") @SuppressWarnings("PMD.SignatureDeclareThrowsException")
public static void main(String[] args) { public static void main(String[] args) {
try { try {
Logger.getLogger(Operator.class.getName()) Logger.getLogger(Manager.class.getName())
.fine(() -> "Version: " .fine(() -> "Version: "
+ Operator.class.getPackage().getImplementationVersion()); + Manager.class.getPackage().getImplementationVersion());
CommandLineParser parser = new DefaultParser(); CommandLineParser parser = new DefaultParser();
// parse the command line arguments // parse the command line arguments
final Options options = new Options(); final Options options = new Options();
@ -119,7 +119,7 @@ public class Operator extends Component {
+ "tion file (defaults to /etc/opt/vmoperator/config.yaml).")); + "tion file (defaults to /etc/opt/vmoperator/config.yaml)."));
CommandLine cmd = parser.parse(options, args); CommandLine cmd = parser.parse(options, args);
// The Operator is the root component // The Operator is the root component
app = new Operator(cmd); app = new Manager(cmd);
// Prepare Stop // Prepare Stop
Runtime.getRuntime().addShutdownHook(new Thread(() -> { Runtime.getRuntime().addShutdownHook(new Thread(() -> {
@ -135,7 +135,7 @@ public class Operator extends Component {
Components.start(app); Components.start(app);
} catch (IOException | InterruptedException } catch (IOException | InterruptedException
| org.apache.commons.cli.ParseException e) { | org.apache.commons.cli.ParseException e) {
Logger.getLogger(Operator.class.getName()).log(Level.SEVERE, e, Logger.getLogger(Manager.class.getName()).log(Level.SEVERE, e,
() -> "Failed to start runner: " + e.getMessage()); () -> "Failed to start runner: " + e.getMessage());
} }
} }