/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.com.mx.dda.msjb;

/**
 *
 * @author albarranoi
 */
import java.io.*;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import javax.servlet.*;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import mx.com.amx.mx.dda.crn.DDAExhibicion;
import mx.com.amx.mx.dda.crn.bo.DDAExhibicionBO;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

@WebServlet(name="service", urlPatterns={"/servicio"})
public class service extends HttpServlet {

    private DDAExhibicion ex;
    private DDAExhibicionBO bo;

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        response.setContentType("application/json");
        PrintWriter out = response.getWriter();
        String msg = ejec();
        out.write("{\"rows\":\"" + msg + "\"}");
    }

    public String ejec() {

        ApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
        setEx((DDAExhibicion) context.getBean("exhibicion_DDA"));

        getEx().ejecutaProceso();
        return "OK";
    }

    /**
     * @return the ex
     */
    public DDAExhibicion getEx() {
        return ex;
    }

    /**
     * @param ex the ex to set
     */
    public void setEx(DDAExhibicion ex) {
        this.ex = ex;
    }

}
