|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.xml.xmlc.servlet.XMLCContext
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
getContext
. It provides a factory for creating XMLC
document classes. Also provided are methods to output a XMLC document as an
HTTP response, with automatic setting of response content type.
Note: that XMLCContextInit
supports a context-param named
xmlcContextImpl, which allows for custom XMLCContext implementations
to be defined. The value must be a FQCN of the custom XMLCContext, which must
extend XMLCContext and define a constructor with the same signature as XMLCContext,
e.g.,...
public MyCustomXMLCContext(ServletContext servletContext, XMLCFactory factory, SessionURLEncodingMode sessionURLEncodingMode, boolean logStats, int compressionType)
Instances of this class are configured using the following Servlet context-wide init parameters:
XMLCLogger
and
define a constructor with a signature of MyXMLCLogger(
ServletContext servletContext, boolean enableInfoLogging, boolean
enableDebugLogging)
, same as ServletXMLCLogger.ServletXMLCLogger(ServletContext, boolean, boolean)
.
xmlcDefaultFallbackLocale
as below, set directly using
XMLCDeferredParsingFactory.setDefaultFallbackLocale(Locale), or
using XMLCCreateOptions.setFallbackLocale(Locale)
passed to the
create(XMLCCreateOptions) method, which takes precedence. If no template is
found for the user-defined or fallback locale, the ultimate fallback is the
base template; foo.html. The
user-defined
and/or
fallback
Locale objects are
provided to the deferred parsing factory
create(XMLCCreateOptions)
method. The markup file base name/path is either
given directly
or taken from the 'XMLC_SOURCE_FILE' constant in an XMLC-compiled class.
- xmlcDefaultFallbackLocale - The default fallback Locale, used
in the case where I18n is enabled and no locale-named template is found to
match the user-defined locale and no non-null fallbackLocale is provided to
XMLCCreateOptions passed to the create(XMLCCreateOptions) method, e.g., en_US.
If no fallback is specified here or on the create(XMLCCreateOptions) method,
then the final fallback is the base template.
ServletContext
Inner Class Summary | |
static class |
XMLCContext.SessionURLEncodingMode
Enumerated constant indicating how URL session encoding is to be handled. |
Field Summary | |
static 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. |
(package private) static int |
XMLC_COMPRESS_GZIP
|
(package private) static int |
XMLC_COMPRESS_NONE
Definition of xmlcCompression parameter values as a bit set. |
Constructor Summary | |
XMLCContext(javax.servlet.ServletContext servletContext,
XMLCFactory factory,
XMLCContext.SessionURLEncodingMode sessionURLEncodingMode,
boolean logStats,
int compressionType)
Constructor. |
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. |
static XMLCContext |
getContext(javax.servlet.ServletContext servletContext)
Obtain the XMLCContext for the current application, creating it if it doesn't exist. |
protected javax.servlet.ServletContext |
getServletContext()
Get the associated servlet context |
XMLCContext.SessionURLEncodingMode |
getSessionURLEncoding()
|
XMLCDeferredParsingFactory |
getXMLCDeferredParsingFactory()
Get the XMLC factory object associated with the context. |
XMLCFactory |
getXMLCFactory()
Deprecated. |
void |
setSessionURLEncoding(XMLCContext.SessionURLEncodingMode mode)
Set the session URL encoding mode. |
protected URLRewriter |
setupURLRewriter(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Setup the session URL encoder as required by configuration and request. |
void |
setXMLCDeferredParsingFactory(XMLCDeferredParsingFactory factory)
Explicitly set XMLC factory. |
void |
setXMLCFactory(XMLCFactory factory)
Deprecated. |
protected boolean |
shouldEncodeSessionId(javax.servlet.http.HttpServletRequest request)
Determine if a session id should be encoded URLs. |
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 |
|
Field Detail |
public static final XMLCContext.SessionURLEncodingMode URL_ENCODING_AUTO
public static final XMLCContext.SessionURLEncodingMode URL_ENCODING_ALWAYS
public static final XMLCContext.SessionURLEncodingMode URL_ENCODING_NEVER
public static final String CONTEXT_ATTRIBUTE
static final int XMLC_COMPRESS_NONE
static final int XMLC_COMPRESS_GZIP
Constructor Detail |
public XMLCContext(javax.servlet.ServletContext servletContext, XMLCFactory factory, XMLCContext.SessionURLEncodingMode sessionURLEncodingMode, boolean logStats, int compressionType)
getContext
.Method Detail |
public XMLCFactory getXMLCFactory()
getXMLCDeferredParsingFactory()
public void setXMLCFactory(XMLCFactory factory)
ClassCastException
- if the factory is not an instance of XMLCDeferredParsingFactorysetXMLCDeferredParsingFactory(org.enhydra.xml.xmlc.deferredparsing.XMLCDeferredParsingFactory)
public XMLCDeferredParsingFactory getXMLCDeferredParsingFactory()
public void setXMLCDeferredParsingFactory(XMLCDeferredParsingFactory factory)
public void setSessionURLEncoding(XMLCContext.SessionURLEncodingMode mode)
mode
- Constant indicating what mode to useXMLCContext.SessionURLEncodingMode
public XMLCContext.SessionURLEncodingMode getSessionURLEncoding()
protected boolean shouldEncodeSessionId(javax.servlet.http.HttpServletRequest request)
protected URLRewriter setupURLRewriter(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
public OutputOptions createOutputOptions(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, XMLObject document)
The following attributes are set in the object:
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.public void writeDOM(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, OutputOptions outputOptions, XMLObject document) throws IOException
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.public void writeDOM(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, XMLObject document) throws IOException
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.public static XMLCContext getContext(javax.servlet.http.HttpServlet servlet)
servlet
- A servlet in the application. Used to obtain the servlet context.getContext(ServletContext)
public static XMLCContext getContext(javax.servlet.ServletContext servletContext)
servletContext
- The servlet context of this application.protected javax.servlet.ServletContext getServletContext()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |