package twopm.tech.bench.jaxrs;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;

public class Bench {

	public static final String BASE_URI = "http://0.0.0.0:8080";
	
	public static void main(String[] args) throws IOException, InterruptedException {
		JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean();
		factoryBean.setResourceClasses(TestResource.class);
		factoryBean.setAddress(BASE_URI);
		Server server = factoryBean.create();
		Runtime.getRuntime().addShutdownHook(new Thread(() -> {
			try {
				server.stop();
			} catch (Exception ex) {
				Logger.getLogger(Bench.class.getName()).log(Level.SEVERE, null, ex);
			}
		}));
		Thread.currentThread().join();
	}
}
