at.spardat.xma.datasource.TabularServletServer Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* s IT Solutions AT Spardat GmbH - initial API and implementation
*******************************************************************************/
// @(#) $Id: TabularServletServer.java 2089 2007-11-28 13:56:13Z s3460 $
package at.spardat.xma.datasource;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Enumeration;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import at.spardat.enterprise.exc.SysException;
import at.spardat.properties.XProperties;
import at.spardat.xma.RuntimeDefaults;
import at.spardat.xma.exception.Codes;
import at.spardat.xma.monitoring.TimeingEvent;
import at.spardat.xma.plugins.PluginManagerServer;
import at.spardat.xma.session.Transform;
import at.spardat.xma.session.XMASessionServer;
/**
* This servlets task is to serve tabular data sources at the XMA server. It must
* be registered under the servlet mapping tabular in the applications
* web.xml-file.
*
* @author YSD, 17.06.2003 12:25:43
*/
public class TabularServletServer extends HttpServlet {
/**
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
TimeingEvent ev = new TimeingEvent (getMeasurementPraefix(request) + "tabular"); // measurement for imcmonitor
try {
doGet0 (request, response);
ev.success();
} finally {
ev.failure();
}
}
/**
* Called by doGet.
*/
protected void doGet0 (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String measurePraefix = getMeasurementPraefix(request);
/**
* Measurement that indicates the time when the servlet returns the complete table to the client
*/
TimeingEvent evLoaded = new TimeingEvent (measurePraefix + "tabularLoaded");
/**
* Measurement that indicates the execution time when the servlet returns a not-modified.
* Either evLoaded or evNotModified is also closed.
*/
TimeingEvent evNotModified = new TimeingEvent (measurePraefix + "tabularNotModified");
/**
* Iterate over request parameters and construct a TableSpec object
*/
TableSpec tableSpec = new TableSpec();
Enumeration paramNames = request.getParameterNames();
while (paramNames.hasMoreElements()) {
String key = (String) paramNames.nextElement();
String val = request.getParameter(key);
tableSpec.setProperty (key, val);
}
// ensure that the necessary properties are specified
String [] required = new String[] { "type", "_loc", "_man", "_env" };
for (int i=0; isize should be
* gzip compressed.
*/
private static boolean doCompress (int size) {
XProperties node = XProperties.getNodeOfPackage("at.spardat.xma.datasource");
int threshold = node.getInt("compressionThreshold", RuntimeDefaults.compressionThreshold);
if (threshold != -1 && size > threshold) return true;
return false;
}
/**
* Returns the praefix of a measurement variable name that contains
* the context path of the web application.
*/
private static String getMeasurementPraefix (HttpServletRequest req) {
String contextPath = req.getContextPath();
if (contextPath.length() == 0) return "app:";
if (contextPath.charAt(0) == '/') contextPath = contextPath.substring(1);
return "app<" + contextPath + ">:";
}
// http://localhost:8080/demo/tabular?type=rsc&_loc=de_AT&_man=188&_env=p&bundle=at.spardat.xma.datasource.test
}