/*
* Copyright 2011 PA Consulting Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.prodeagle.java.servlets;
import java.io.IOException;
import java.util.logging.Logger;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.prodeagle.java.MemCacheManager;
import com.prodeagle.java.counters.BatchCounter;
import com.prodeagle.java.counters.Counter;
public class ExampleServlet extends HttpServlet {
/**
* Auto-generated for Serializable
*/
private static final long serialVersionUID = -2254847938021058718L;
private static final Logger _logger = Logger.getLogger(ExampleServlet.class.getName());
public void doGet(HttpServletRequest req, HttpServletResponse resp) {
if (null != req.getParameter("clearMemcache")) {
MemCacheManager.clearMemCache();
try {
resp.getWriter().print("Cleared memcache");
} catch (IOException e) {
_logger.severe("Failure to write response");
}
} else {
Counter.increment("Counter_Singular");
_logger.info("Counter_Singular incremented");
BatchCounter counters = new BatchCounter();
counters.increment("Counter A");
counters.increment("Counter B");
counters.increment("Counter C");
counters.commit();
_logger.info("Counters A, B and C incremented");
try {
resp.getWriter().print("4 counters incremented");
} catch (IOException e) {
_logger.severe("Failure to write response");
}
}
}
}