Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.hq.ui.servlet
Class ImageServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.hyperic.hq.ui.servlet.ParameterizedServlet
              extended by org.hyperic.hq.ui.servlet.ImageServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
ChartServlet, NavMapImageServlet

public abstract class ImageServlet
extends ParameterizedServlet

This servlet returns a response that contains the binary data of an image (JPEG or PNG) that can be viewed in a web browser.

The navigation map servlet takes the following parameters (any applicable defaults are in bold and required parameters are in italics):

key value
imageFormat (png | jpeg)
imageWidth <integer (700)>
imageHeight <integer (350)>

See Also:
Serialized Form

Field Summary
static java.lang.String IMAGE_FORMAT_JPEG
          Request parameter value representing a JPEG image.
static java.lang.String IMAGE_FORMAT_PARAM
          Request parameter for image format.
static java.lang.String IMAGE_FORMAT_PNG
          Request parameter value representing a PNG image.
static int IMAGE_HEIGHT_DEFAULT
          Default image height.
static java.lang.String IMAGE_HEIGHT_PARAM
          Request parameter for image height.
static int IMAGE_WIDTH_DEFAULT
          Default image width.
static java.lang.String IMAGE_WIDTH_PARAM
          Request parameter for image width.
 
Constructor Summary
ImageServlet()
           
 
Method Summary
protected abstract  java.lang.Object createImage(javax.servlet.http.HttpServletRequest request)
          Create the image being rendered.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  java.lang.String getDefaultImageFormat()
          Return the default imageFormat.
protected  int getDefaultImageHeight()
          Return the default imageHeight.
protected  int getDefaultImageWidth()
          Return the default imageWidth.
protected  int getImageHeight(javax.servlet.http.HttpServletRequest request)
          Return the image height.
protected  int getImageWidth(javax.servlet.http.HttpServletRequest request)
          Return the image width.
 void init()
           
protected abstract  void parseParameters(javax.servlet.http.HttpServletRequest request)
          This method will be called automatically by the ImageServlet.
protected abstract  void renderJpegImage(javax.servlet.ServletOutputStream out, java.lang.Object imgObj)
          Render a JPEG version of the image into the output stream.
protected abstract  void renderPngImage(javax.servlet.ServletOutputStream out, java.lang.Object imgObj)
          Render a PNG version of the image into the output stream.
 
Methods inherited from class org.hyperic.hq.ui.servlet.ParameterizedServlet
invalidParamErr, invalidParamErr, invalidParamWarn, invalidParamWarn, invalidParamWarn, invalidParamWarn, invalidParamWarn, parseBooleanParameter, parseDoubleParameter, parseIntParameter, parseLongParameter, parseRequiredBooleanParameter, parseRequiredDoubleParameter, parseRequiredIntParameter, parseRequiredLongParameter, parseRequiredStringParameter, parseRequiredStringParameter, parseStringParameter, parseStringParameter, requiredParamErr
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMAGE_FORMAT_PARAM

public static final java.lang.String IMAGE_FORMAT_PARAM
Request parameter for image format.

See Also:
Constant Field Values

IMAGE_FORMAT_PNG

public static final java.lang.String IMAGE_FORMAT_PNG
Request parameter value representing a PNG image.

See Also:
Constant Field Values

IMAGE_FORMAT_JPEG

public static final java.lang.String IMAGE_FORMAT_JPEG
Request parameter value representing a JPEG image.

See Also:
Constant Field Values

IMAGE_WIDTH_PARAM

public static final java.lang.String IMAGE_WIDTH_PARAM
Request parameter for image width.

See Also:
Constant Field Values

IMAGE_WIDTH_DEFAULT

public static final int IMAGE_WIDTH_DEFAULT
Default image width.

See Also:
Constant Field Values

IMAGE_HEIGHT_PARAM

public static final java.lang.String IMAGE_HEIGHT_PARAM
Request parameter for image height.

See Also:
Constant Field Values

IMAGE_HEIGHT_DEFAULT

public static final int IMAGE_HEIGHT_DEFAULT
Default image height.

See Also:
Constant Field Values
Constructor Detail

ImageServlet

public ImageServlet()
Method Detail

init

public void init()
Overrides:
init in class javax.servlet.GenericServlet

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException
Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException

createImage

protected abstract java.lang.Object createImage(javax.servlet.http.HttpServletRequest request)
                                         throws javax.servlet.ServletException
Create the image being rendered.

Parameters:
request - the servlet request
Throws:
javax.servlet.ServletException

renderPngImage

protected abstract void renderPngImage(javax.servlet.ServletOutputStream out,
                                       java.lang.Object imgObj)
                                throws java.io.IOException
Render a PNG version of the image into the output stream.

Parameters:
out - the output stream
Throws:
java.io.IOException

renderJpegImage

protected abstract void renderJpegImage(javax.servlet.ServletOutputStream out,
                                        java.lang.Object imgObj)
                                 throws java.io.IOException
Render a JPEG version of the image into the output stream.

Parameters:
out - the output stream
Throws:
java.io.IOException

parseParameters

protected abstract void parseParameters(javax.servlet.http.HttpServletRequest request)
This method will be called automatically by the ImageServlet. It should handle the parsing and error-checking of any specific parameters for the chart being rendered.

Parameters:
request - the HTTP request object

getImageHeight

protected int getImageHeight(javax.servlet.http.HttpServletRequest request)
Return the image height.

Parameters:
request - TODO
Returns:
the height of the image
See Also:
{@link IMAGE_HEIGHT_DEFAULT}

getImageWidth

protected int getImageWidth(javax.servlet.http.HttpServletRequest request)
Return the image width.

Parameters:
request - TODO
Returns:
the width of the image
See Also:
{@link IMAGE_WIDTH_DEFAULT}

getDefaultImageFormat

protected java.lang.String getDefaultImageFormat()
Return the default imageFormat.


getDefaultImageWidth

protected int getDefaultImageWidth()
Return the default imageWidth.


getDefaultImageHeight

protected int getDefaultImageHeight()
Return the default imageHeight.


Hyperic HQ Plugin API v. 4.4.0.2

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.