package com.javahonk;

import javax.annotation.PostConstruct;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.eclipse.jetty.server.Server;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

@SuppressWarnings("restriction")
public class JettyService {

	@Value("${web.port}")
	private int port;

	@Autowired
	private MessageHandler handler; 

	private static final Logger logger = LogManager.getLogger(JettyService.class.getName());
	
	@PostConstruct
    public void init() throws Exception {
		logger.info("starting jetty server at port {}", port);
        Server server = new Server(port);
        server.setHandler(handler);
        server.start();
    }
	
}
