package net.pimpas.tests;

import java.io.IOException;

import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(urlPatterns={"/*"})
public class TestServlet extends HttpServlet {

	private static final long serialVersionUID = -7558142452250757990L;
	
	@Inject
	private Instance<Pojo> pojoInstance;
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		Pojo pojo = pojoInstance.get();
		resp.setContentType("text/html");
		resp.getWriter().print("POJO Instance: "+pojo);
		if(null != pojo) resp.getWriter().print("POJO message: "+pojo.sayHi());
		resp.getOutputStream().flush();
	}
}
