|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.webmacro.WM
This class implements the WebMacro Manager interface. You can instantiate this yourself if you want to use WebMacro in standalone mode, rather than subclassing from org.webmacro.servlet.WMServlet. This is actually the same class used by the servlet framework to manage access to the broker there, so you really don't lose much of anything by choosing to go standalone by using this object. All you have to do is come up with your own context objects.
Field Summary |
Fields inherited from interface org.webmacro.WebMacro |
BUILD_DATE, VERSION |
Constructor Summary | |
WM()
Constructs a WM which gets its properties (optionally) from the file WebMacro.properties, as found on the class path. |
|
WM(Broker broker)
Constructs a WM from an arbitrary Broker. |
|
WM(javax.servlet.Servlet s)
Constructs a WM is tied to a Servlet broker. |
|
WM(java.lang.String config)
Constructs a WM which gets its properties from the file specified, which must exist on the class path or be an absolute path. |
Method Summary | |
void |
destroy()
Call this method when you are finished with WebMacro. |
protected void |
finalize()
You should never call this method, on any object. |
Broker |
getBroker()
This object is used to access components that have been plugged into WebMacro; it is shared between all instances of this class and its subclasses. |
java.lang.String |
getConfig(java.lang.String key)
Retrieve configuration information from the "config" provider. |
Context |
getContext()
Instantiate a new context from a pool. |
FastWriter |
getFastWriter(java.io.OutputStream out,
java.lang.String enctype)
Retrieve a FastWriter from WebMacro's internal pool of FastWriters. |
Log |
getLog(java.lang.String type)
Get a log using the type as the description |
Log |
getLog(java.lang.String type,
java.lang.String description)
Get a log to write information to. |
Template |
getTemplate(java.lang.String key)
Retrieve a template from the "template" provider. |
java.lang.String |
getURL(java.lang.String url)
Retrieve a URL from the "url" provider. |
WebContext |
getWebContext(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp)
Instantiate a new webcontext from a pool. |
boolean |
isDestroyed()
This message returns false until you destroy() this object, subsequently it returns true. |
static void |
main(java.lang.String[] args)
Print the version, and quit |
java.lang.String |
toString()
|
void |
writeTemplate(java.lang.String templateName,
java.io.OutputStream out,
Context context)
Convenience method for writing a template to an OutputStream. |
void |
writeTemplate(java.lang.String templateName,
java.io.OutputStream out,
java.lang.String encoding,
Context context)
Convienence method for writing a template to an OutputStream. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public WM() throws InitException
public WM(java.lang.String config) throws InitException
public WM(javax.servlet.Servlet s) throws InitException
public WM(Broker broker) throws InitException
Method Detail |
public final void destroy()
After a call to destroy() attempts to use this object may yield unpredicatble results.
destroy
in interface WebMacro
public java.lang.String toString()
public final boolean isDestroyed()
isDestroyed
in interface WebMacro
protected void finalize() throws java.lang.Throwable
java.lang.Throwable
public final Broker getBroker()
getBroker
in interface WebMacro
public final FastWriter getFastWriter(java.io.OutputStream out, java.lang.String enctype) throws java.io.UnsupportedEncodingException
getFastWriter
in interface WebMacro
out
- The output stream the FastWriter should write to. Typically
this will be your ServletOutputStream. It can be null if
only want the fast writer to buffer the output.enctype
- the Encoding type to use
java.io.UnsupportedEncodingException
- if the encoding type
specified is not supported by your JVM.public final Context getContext()
getContext
in interface WebMacro
public final WebContext getWebContext(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
getWebContext
in interface WebMacro
public final Template getTemplate(java.lang.String key) throws ResourceException
getTemplate
in interface WebMacro
NotFoundException
- if the template could not be found
ResourceException
- if the template could not be loadedpublic final java.lang.String getURL(java.lang.String url) throws ResourceException
getURL
in interface WebMacro
NotFoundException
- if the template could not be found
ResourceException
- if the template could not be loadedpublic final java.lang.String getConfig(java.lang.String key) throws NotFoundException
getConfig
in interface WebMacro
NotFoundException
- could not locate requested informationpublic final Log getLog(java.lang.String type, java.lang.String description)
getLog
in interface WebMacro
public final Log getLog(java.lang.String type)
getLog
in interface WebMacro
public final void writeTemplate(java.lang.String templateName, java.io.OutputStream out, Context context) throws java.io.IOException, ResourceException, PropertyException
This method uses the default TemplateOutputEncoding
specified in
WebMacro.defaults or your custom WebMacro.properties.
writeTemplate
in interface WebMacro
templateName
- name of Template to write. Must be accessible
via TemplatePathout
- where the output of the template should gocontext
- The Context (can be a WebContext too) used
during the template evaluation phase
java.io.IOException
- if the template cannot be written to the
specified output stream
ResourceException
- if the template name specified cannot be found
PropertyException
- if a fatal error occured during the Template
evaluation phasepublic final void writeTemplate(java.lang.String templateName, java.io.OutputStream out, java.lang.String encoding, Context context) throws java.io.IOException, ResourceException, PropertyException
writeTemplate
in interface WebMacro
templateName
- name of Template to write. Must be accessible
via TemplatePathout
- where the output of the template should goencoding
- character encoding to use when writing the template
if the encoding is null
, the default
TemplateOutputEncoding
is usedcontext
- The Context (can be a WebContext too) used
during the template evaluation phase
java.io.IOException
- if the template cannot be written to the
specified output stream
ResourceException
- if the template name specified cannot be found
PropertyException
- if a fatal error occured during the Template
evaluation phasepublic static void main(java.lang.String[] args)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |