Separate application (Operator) from controller.
This commit is contained in:
parent
c74d48f8af
commit
8f5bec1311
2 changed files with 49 additions and 11 deletions
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* VM-Operator
|
||||
* Copyright (C) 2023 Michael N. Lipp
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.jdrupes.vmoperator.manager;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.jgrapes.core.Channel;
|
||||
import org.jgrapes.core.Component;
|
||||
|
||||
/**
|
||||
* The application class.
|
||||
*/
|
||||
public class Controller extends Component {
|
||||
|
||||
/**
|
||||
* Instantiates a new manager.
|
||||
*
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public Controller(Channel componentChannel) {
|
||||
super(componentChannel);
|
||||
// Prepare component tree
|
||||
attach(new VmWatcher(channel()));
|
||||
attach(new Reconciler(channel()));
|
||||
}
|
||||
}
|
||||
|
|
@ -33,22 +33,19 @@ import org.jgrapes.io.NioDispatcher;
|
|||
/**
|
||||
* The application class.
|
||||
*/
|
||||
public class Manager extends Component {
|
||||
public class Operator extends Component {
|
||||
|
||||
/** The Constant APP_NAME. */
|
||||
public static final String APP_NAME = "vmoperator";
|
||||
private static Manager app;
|
||||
private static Operator app;
|
||||
|
||||
/**
|
||||
* Instantiates a new manager.
|
||||
*
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
public Manager() throws IOException {
|
||||
public Operator() throws IOException {
|
||||
// Prepare component tree
|
||||
attach(new NioDispatcher());
|
||||
attach(new VmWatcher(channel()));
|
||||
attach(new Reconciler(channel()));
|
||||
attach(new Controller(channel()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -64,12 +61,12 @@ public class Manager extends Component {
|
|||
static {
|
||||
try {
|
||||
InputStream props;
|
||||
var path = FsdUtils.findConfigFile(Manager.APP_NAME,
|
||||
var path = FsdUtils.findConfigFile(Constants.APP_NAME,
|
||||
"logging.properties");
|
||||
if (path.isPresent()) {
|
||||
props = Files.newInputStream(path.get());
|
||||
} else {
|
||||
props = Manager.class.getResourceAsStream("logging.properties");
|
||||
props = Operator.class.getResourceAsStream("logging.properties");
|
||||
}
|
||||
LogManager.getLogManager().readConfiguration(props);
|
||||
} catch (IOException e) {
|
||||
|
|
@ -85,8 +82,8 @@ public class Manager extends Component {
|
|||
*/
|
||||
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
|
||||
public static void main(String[] args) throws Exception {
|
||||
// The Manager is the root component
|
||||
app = new Manager();
|
||||
// The Operator is the root component
|
||||
app = new Operator();
|
||||
|
||||
// Prepare Stop
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||
Loading…
Add table
Add a link
Reference in a new issue