package com.lgx8.gateway.admin.servlet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.lgx8.common.entities.GatewayConfig;
import com.lgx8.gateway.entities.AreaCategory;
import com.lgx8.gateway.entities.Category;
import freemarker.template.Configuration;
/**
* Servlet implementation class GatewayAdminBaseServlet
*/
public class GatewayAdminBaseServlet extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 3462806037512737936L;
private Configuration configuration;
public Map<Object, Object> root = new HashMap<Object, Object>();
/**
* @see HttpServlet#HttpServlet()
*/
public GatewayAdminBaseServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
public Configuration getConfiguration() {
return configuration;
}
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}
@Override
public void destroy() {
super.destroy();
configuration = null;
}
@SuppressWarnings("unchecked")
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
configuration = new Configuration();
configuration.setServletContextForTemplateLoading(getServletContext(), "ftl/gateway/admin");
configuration.setDefaultEncoding("UTF-8");
configuration.setNumberFormat("0.##########");
GatewayConfig gatewayConfig = (GatewayConfig) getServletContext().getAttribute("gatewayConfig");
root.put("gatewayConfig", gatewayConfig);
List<AreaCategory> areaCategorys = (List<AreaCategory>) getServletContext().getAttribute("areaCategorys");
root.put("areaCategorys", areaCategorys);
List<Category> categorys = (List<Category>) getServletContext().getAttribute("categorys");
root.put("categorys", categorys);
Map<Long, Category> categoryMap = (Map<Long, Category>) getServletContext().getAttribute("categoryMap");
root.put("categoryMap", categoryMap);
}
}