[OLINGO-317] Store DataProvider per HttpSession

This commit is contained in:
Michael Bolz 2014-07-08 15:41:00 +02:00
parent 9fa6773d70
commit cbd2b3c991
1 changed files with 8 additions and 5 deletions

View File

@ -32,6 +32,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
public class TechnicalServlet extends HttpServlet {
@ -39,20 +40,22 @@ public class TechnicalServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(TechnicalServlet.class);
private DataProvider dataProvider;
// private DataProvider dataProvider;
@Override
protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException,
IOException {
protected void service(final HttpServletRequest req, final HttpServletResponse resp)
throws ServletException, IOException {
try {
OData odata = OData.newInstance();
Edm edm = odata.createEdm(new EdmTechProvider());
HttpSession session = req.getSession(true);
DataProvider dataProvider = (DataProvider) session.getAttribute(DataProvider.class.getName());
if (dataProvider == null) {
dataProvider = new JefDataProvider(edm);
session.setAttribute(DataProvider.class.getName(), dataProvider);
LOG.info("Created new data provider.");
}
dataProvider.reset();
ODataHttpHandler handler = odata.createHandler(edm);