[jboss-cvs] jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet ...
Takuro Okada
t2-okada at nri.co.jp
Mon Nov 6 02:35:10 EST 2006
User: tokada
Date: 06/11/06 02:35:10
Added: java/src/expansion/org/jboss/profiler/exp/view/servlet Tag:
JBossProfiler_Expansion Initializer.java
Log:
Revision Changes Path
No revision
No revision
1.1.2.1 +114 -0 jboss-profiler/java/src/expansion/org/jboss/profiler/exp/view/servlet/Attic/Initializer.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Initializer.java
===================================================================
RCS file: Initializer.java
diff -N Initializer.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ Initializer.java 6 Nov 2006 07:35:10 -0000 1.1.2.1
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profiler.exp.view.servlet;
+
+import java.io.IOException;
+
+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 javolution.xml.stream.XMLOutputFactory;
+import javolution.xml.stream.XMLStreamException;
+import javolution.xml.stream.XMLStreamWriter;
+
+import org.apache.log4j.Logger;
+
+/**
+ * The servlet class to initialize the application.
+ *
+ * @author Takuro Okada (Nomura Research Institute, Ltd.)
+ * Copyright 2006 Nomura Research Institute, Ltd. All Rights Reserved.
+ * Copyright(c) Information-technology Promotion Agency, Japan. All rights reserved 2006.
+ * Result of Open Source Software Development Activities of Information-technology Promotion Agency, Japan.
+ */
+public class Initializer extends HttpServlet {
+
+ private static Logger logger = Logger.getLogger(Initializer.class);
+
+ /*
+ * Request parameters for setting
+ */
+ protected static final String RPK_ES_METRIC_NAME = "org.jboss.profiler.exp.view.setting.EsMetricName";
+ protected static final String RPK_WA_METRIC_NAME = "org.jboss.profiler.exp.view.setting.WaMetricName";
+ protected static final String RPK_FROM_DATE = "org.jboss.profiler.exp.view.setting.FromDate";
+ protected static final String RPK_TO_DATE = "org.jboss.profiler.exp.view.setting.ToDate";
+ protected static final String RPK_FILTER = "org.jboss.profiler.exp.view.setting.Filter";
+
+ /*
+ * Request parameters for request
+ */
+ protected static final String RPK_CATEGORIES = "org.jboss.profiler.exp.view.request.Categories";
+ protected static final String RPK_THREAD_ID = "org.jboss.profiler.exp.view.request.ThreadId";
+ protected static final String RPK_CALLER = "org.jboss.profiler.exp.view.request.Caller";
+
+ private final String XML_ROOT = "initialization";
+
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ // Gets request parameters
+ String esMetricName = request.getParameter(RPK_ES_METRIC_NAME);
+ String waMetricName = request.getParameter(RPK_WA_METRIC_NAME);
+ String fromDate = request.getParameter(RPK_FROM_DATE);
+ String toDate = request.getParameter(RPK_TO_DATE);
+ String filterStrings = request.getParameter(RPK_FILTER);
+
+ // Sets request parameters to session
+ HttpSession session = request.getSession();
+ if(!session.isNew()) {
+ session.removeAttribute(RPK_ES_METRIC_NAME);
+ session.removeAttribute(RPK_WA_METRIC_NAME);
+ session.removeAttribute(RPK_FROM_DATE);
+ session.removeAttribute(RPK_TO_DATE);
+ session.removeAttribute(RPK_FILTER);
+ }
+ if(esMetricName!=null) session.setAttribute(RPK_ES_METRIC_NAME, esMetricName);
+ if(waMetricName!=null) session.setAttribute(RPK_WA_METRIC_NAME, waMetricName);
+ if(fromDate!=null) session.setAttribute(RPK_FROM_DATE, fromDate);
+ if(toDate!=null) session.setAttribute(RPK_TO_DATE, toDate);
+ if(filterStrings!=null) session.setAttribute(RPK_FILTER, filterStrings.split(","));
+
+ // Writes xml to response
+ response.setContentType("text/plain; charset=UTF-8");
+ XMLOutputFactory factory = XMLOutputFactory.newInstance();
+ factory.setProperty(XMLOutputFactory.INDENTATION, " ");
+ XMLStreamWriter writer = null;
+ try {
+ writer = factory.createXMLStreamWriter(response.getWriter());
+ writer.writeStartDocument();
+ writer.writeEmptyElement(XML_ROOT);
+ writer.writeAttribute("status", "ok");
+ writer.writeEndDocument();
+ } catch (XMLStreamException e) {
+ logger.error("failed to write xml.");
+ } finally {
+ try {
+ if(writer!=null) writer.close();
+ } catch (XMLStreamException e) {
+ logger.error("failed to write xml.");
+ }
+ }
+ }
+
+}
More information about the jboss-cvs-commits
mailing list