
org.springframework.daemon.SpringBootDaemon Maven / Gradle / Ivy
package org.springframework.daemon;
import java.util.Arrays;
import org.apache.commons.daemon.Daemon;
import org.apache.commons.daemon.DaemonContext;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.util.ClassUtils;
public class SpringBootDaemon implements Daemon {
private Class> springBootApp;
private ConfigurableApplicationContext content;
public void init(DaemonContext context) throws Exception {
System.out.println("Daemon initialized with arguments [" + Arrays.toString(context.getArguments()) + "]");
this.springBootApp = ClassUtils.resolveClassName(context.getArguments()[0], SpringBootDaemon.class.getClassLoader());
}
public void start() throws Exception {
System.out.println("Starting Spring Boot application [" + this.springBootApp.getName() + "]");
this.content = SpringApplication.run(springBootApp);
}
public void stop() throws Exception {
System.out.println("Stopping Spring Boot application [" + this.springBootApp.getName() + "]");
this.content.close();
}
public void destroy() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy