Java tutorial
/** * This file is part of the Paxle project. * Visit http://www.paxle.net for more information. * Copyright 2007-2010 the original author or authors. * * Licensed under the terms of the Common Public License 1.0 ("CPL 1.0"). * Any use, reproduction or distribution of this program constitutes the recipient's acceptance of this agreement. * The full license text is available under http://www.opensource.org/licenses/cpl1.0.txt * or in the file LICENSE.txt in the root directory of the Paxle distribution. * * Unless required by applicable law or agreed to in writing, this software is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ package org.paxle.gui.impl.servlets; import java.util.Map; import javax.servlet.Servlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Properties; import org.apache.felix.scr.annotations.Property; import org.apache.felix.scr.annotations.Service; import org.apache.velocity.Template; import org.apache.velocity.context.Context; import org.apache.velocity.tools.view.VelocityLayoutServlet; @Component(metatype = false, immediate = true) @Service(Servlet.class) @Properties({ @Property(name = "org.paxle.servlet.path", value = "/threads"), @Property(name = "org.paxle.servlet.doUserAuth", boolValue = false) }) public class TheaddumpView extends VelocityLayoutServlet { private static final long serialVersionUID = 1L; /** * Logger */ protected Log logger = LogFactory.getLog(this.getClass()); @Override protected void fillContext(Context context, HttpServletRequest request) { try { // get the current dump Map<Thread, StackTraceElement[]> dumps = Thread.getAllStackTraces(); context.put("dumps", dumps); } catch (Exception e) { this.logger.error("Error", e); } } /** * Choosing the template to use */ @Override protected Template getTemplate(HttpServletRequest request, HttpServletResponse response) { return this.getTemplate("/resources/templates/ThreaddumpView.vm"); } }