Enhydra 3.1.1b1 API

org.enhydra.xml.xmlc.servlet
Class XMLCContext

java.lang.Object
  |
  +--org.enhydra.xml.xmlc.servlet.XMLCContext

public class XMLCContext
extends java.lang.Object

Class to facility the use of XMLC in a HTTP servlet. This object contains a XMLC factory to create instances of XMLC document classes and methods to output documents.

An instance of this object is associated with the ServletContext object for an application (one per WebApp). The object is created on first use by ({@see #getContext getContext}. It provides a factory for creating XMLC document class with optional automatic reloading of out of date classes or recompilation and reloading of classes out-of-date relative to a source file. Also provided are methods to output a XMLC document as a HTTP response, with automatic setting of response content type.

Instance of this class are configured using the following Servlet context-wide init parameters:

See Also:
ServletContext

Inner Class Summary
static class XMLCContext.SessionURLEncodingMode
          Enumerated constant indicating how URL session encoding is to be handled.
 
Field Summary
static java.lang.String CONTEXT_ATTRIBUTE
          Name of ServletContext attribute that contains the instance of this class for a WebApp.
static XMLCContext.SessionURLEncodingMode URL_ENCODING_ALWAYS
          Value indicating that URL session encoding should always be used.
static XMLCContext.SessionURLEncodingMode URL_ENCODING_AUTO
          Value indicating that URL session encoding should be detected automatically based on if it was used for the current requested.
static XMLCContext.SessionURLEncodingMode URL_ENCODING_NEVER
          Value indicating that URL session encoding should never be used.
 
Method Summary
 OutputOptions createOutputOptions(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, XMLObject document)
          Create an OutputOptions object for a document.
static XMLCContext getContext(javax.servlet.http.HttpServlet servlet)
          Obtain the XMLCContext for the current application, creating it if it doesn't exist.
 XMLCContext.SessionURLEncodingMode getSessionURLEncoding()
           
 XMLCFactory getXMLCFactory()
          Get the XMLC factory object associated with the context.
 void setSessionURLEncoding(XMLCContext.SessionURLEncodingMode mode)
          Set the session URL encoding mode.
 void setXMLCFactory(XMLCFactory factory)
          Explictly set XMLC factory.
 void writeDOM(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, OutputOptions outputOptions, XMLObject document)
          Output an an XMLC document object (DOM).
 void writeDOM(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, XMLObject document)
          Output an an XMLC document object (DOM).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL_ENCODING_AUTO

public static final XMLCContext.SessionURLEncodingMode URL_ENCODING_AUTO
Value indicating that URL session encoding should be detected automatically based on if it was used for the current requested.

URL_ENCODING_ALWAYS

public static final XMLCContext.SessionURLEncodingMode URL_ENCODING_ALWAYS
Value indicating that URL session encoding should always be used.

URL_ENCODING_NEVER

public static final XMLCContext.SessionURLEncodingMode URL_ENCODING_NEVER
Value indicating that URL session encoding should never be used.

CONTEXT_ATTRIBUTE

public static final java.lang.String CONTEXT_ATTRIBUTE
Name of ServletContext attribute that contains the instance of this class for a WebApp.
Method Detail

getXMLCFactory

public XMLCFactory getXMLCFactory()
Get the XMLC factory object associated with the context.

setXMLCFactory

public void setXMLCFactory(XMLCFactory factory)
Explictly set XMLC factory. The XMLC factory is normally defined base on the servlet configuration parameters. This allows the user to overide the standard factories.

setSessionURLEncoding

public void setSessionURLEncoding(XMLCContext.SessionURLEncodingMode mode)
Set the session URL encoding mode. This option is normally set from the servlet configuration parameters. This allows the explicit setting of this option.
Parameters:
mode - Constant indicating what mode to use
See Also:
XMLCContext.SessionURLEncodingMode

getSessionURLEncoding

public XMLCContext.SessionURLEncodingMode getSessionURLEncoding()

createOutputOptions

public OutputOptions createOutputOptions(javax.servlet.http.HttpServletRequest request,
                                         javax.servlet.http.HttpServletResponse response,
                                         XMLObject document)
Create an OutputOptions object for a document. Options are defaulted for the specified document. The object maybe then modified as needed to override the default values.

The following attributes are set in the object:

Parameters:
request - The servlet request object. The request is required to determine if URL encoding should be done on the document.
response - The servlet response object. The response is required to set up the URL encoder.
document - The DOM object to be returned as response.

writeDOM

public void writeDOM(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     OutputOptions outputOptions,
                     XMLObject document)
              throws java.io.IOException
Output an an XMLC document object (DOM). The document is formatted according to it's type. The MIME type of the response is automatically set.
Parameters:
request - The servlet request object. The request is required to determine if URL encoding should be done on the document.
response - The servlet response object. The Content-Type and Content-Length will be set from the document..
outputFormat - Object use to specify options controlling the formatting of the document.
document - The DOM object to be returned as response.

writeDOM

public void writeDOM(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response,
                     XMLObject document)
              throws java.io.IOException
Output an an XMLC document object (DOM). The document is formatted according to it's type. The MIME type of the response is automatically set.
Parameters:
request - The servlet request object. The request is required to determine if URL encoding should be done on the document.
response - The servlet response object. The Content-Type and Content-Length will be set from the document..
document - The DOM object to be returned as response.

getContext

public static XMLCContext getContext(javax.servlet.http.HttpServlet servlet)
Obtain the XMLCContext for the current application, creating it if it doesn't exist.
Parameters:
servlet - A servlet in the application. The class loader that loaded this servlet will be used to load XMLC document classes.
Returns:
The XMLC context object for the application.

Enhydra 3.1.1b1 API