Example of Java Application

Last modified: Jul 5, 2019 @ 06:40

The following is an example of a Java application implementing a gateway.

public class SimpleGateway {
    private final Logger logger = Logger.getLogger(this.getClass().getName());
    private AppIoTListener appIoTListener;
    private AppIoTGateway appIoTGateway;

    public static void main(String[] args) {
        SimpleGateway application = new SimpleGateway();
        application.start();
    }

    private void start() {
        logger.log(Level.INFO, "Simple Gateway starting up.");
        appIoTListener = new MyAppIoTListener();
        appIoTGateway = new AppIoTGateway(appIoTListener);
        appIoTGateway.start();
        logger.log(Level.INFO, "Simple Gateway started. Type quit to shut down.");
        Scanner scanner = new Scanner(System.in);
        while(!scanner.nextLine().equalsIgnoreCase("quit")) {
        }
        scanner.close();
        logger.log(Level.INFO, "Simple Gateway shut down.");
    }
}