|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object freemarker.template.TemplateEventAdapter
public class TemplateEventAdapter
Adapter class for firing events that could happen at Template
runtime.
Different listeners can be registered for different events that can occur.
So far only one listener class is defined: TemplateExceptionEvent
.
Usage example:
// Configure Log4j ... // Set up the template Template template = new Template(filename); // Set up the model TemplateModelRoot modelRoot = (...) // Set up the listener TemplateEventAdapter adapter = new TemplateEventAdapter(); adapter.addTemplateExceptionListener( new Log4jExceptionListener() ); // Add more listeners as required adapter.addTemplateExceptionListener( ... ); // Call the template template.process( modelRoot, writer, adapter );
SimpleEventAdapter
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface freemarker.template.TemplateRuntimeHandler |
---|
TemplateRuntimeHandler.Severity |
Field Summary | |
---|---|
static TemplateRuntimeHandler |
DefaultEventAdapter
The default TemplateRuntimeHandler instance when no other one is specified. |
protected ListenerAdapter<TemplateExceptionEvent,TemplateExceptionListener> |
exceptionThrownAdapter
A ListenerAdapter for exceptionThrown events. |
static TemplateRuntimeHandler |
NullEventAdapter
The trivial TemplateRuntimeHandler instance where no events are fired. |
protected GenericEventMulticaster<TemplateExceptionListener> |
templateExceptionListeners
The multicaster that notifies all event listeners when an exception occurs. |
Constructor Summary | |
---|---|
TemplateEventAdapter()
Creates new TemplateEventAdapter. |
Method Summary | |
---|---|
void |
addTemplateExceptionListener(TemplateExceptionListener el)
Adds a listener for TemplateExceptionEvent events. |
void |
fireExceptionThrown(java.lang.Object source,
java.lang.Exception exception,
java.io.Writer output,
java.lang.String sourceName,
TemplateRuntimeHandler.Severity severity)
Fires a TemplateExceptionEvent to all the current listeners. |
TemplateExceptionListener[] |
getTemplateExceptionListeners()
Retrieves all the current TemplateExceptionListener s that
are listening for events. |
void |
removeTemplateExceptionListener(TemplateExceptionListener el)
Removes the specified listener. |
java.lang.String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final TemplateRuntimeHandler DefaultEventAdapter
TemplateRuntimeHandler
instance when no other one is specified.
public static final TemplateRuntimeHandler NullEventAdapter
TemplateRuntimeHandler
instance where no events are fired.
protected GenericEventMulticaster<TemplateExceptionListener> templateExceptionListeners
protected ListenerAdapter<TemplateExceptionEvent,TemplateExceptionListener> exceptionThrownAdapter
Constructor Detail |
---|
public TemplateEventAdapter()
Method Detail |
---|
public void fireExceptionThrown(java.lang.Object source, java.lang.Exception exception, java.io.Writer output, java.lang.String sourceName, TemplateRuntimeHandler.Severity severity)
TemplateExceptionEvent
to all the current listeners.
fireExceptionThrown
in interface TemplateRuntimeHandler
source
- the source object of the eventexception
- the exception that caused the event to be firedoutput
- the current Template output streamsourceName
- the name of the source class and method that fired
the eventseverity
- the severity of the exceptionpublic void addTemplateExceptionListener(TemplateExceptionListener el)
TemplateExceptionEvent
events.
el
- the event listener to be addedpublic void removeTemplateExceptionListener(TemplateExceptionListener el)
el
- the event listener to be removedpublic TemplateExceptionListener[] getTemplateExceptionListeners()
TemplateExceptionListener
s that
are listening for events.
TemplateExceptionListener
spublic java.lang.String toString()
toString
in class java.lang.Object
String
representation of the object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |