public class EventCartridge extends Object
Stores the event handlers. Event handlers can be assigned on a per VelocityEngine instance basis by specifying the class names in the velocity.properties file. Event handlers may also be assigned on a per-page basis by creating a new instance of EventCartridge, adding the event handlers, and then calling attachToContext. For clarity, it's recommended that one approach or the other be followed, as the second method is primarily presented for backwards compatibility.
Note that Event Handlers follow a filter pattern, with multiple event handlers allowed for each event. When the appropriate event occurs, all the appropriate event handlers are called in the sequence they were added to the Event Cartridge. See the javadocs of the specific event handler interfaces for more details.
Modifier and Type | Field and Description |
---|---|
protected RuntimeServices |
rsvc |
Constructor and Description |
---|
EventCartridge() |
Modifier and Type | Method and Description |
---|---|
boolean |
addEventHandler(EventHandler ev)
Adds an event handler(s) to the Cartridge.
|
void |
addIncludeEventHandler(IncludeEventHandler ev)
Add an include event handler to the Cartridge.
|
void |
addInvalidReferenceEventHandler(InvalidReferenceEventHandler ev)
Add an invalid reference event handler to the Cartridge.
|
void |
addMethodExceptionHandler(MethodExceptionEventHandler ev)
Add a method exception event handler to the Cartridge.
|
void |
addReferenceInsertionEventHandler(ReferenceInsertionEventHandler ev)
Add a reference insertion event handler to the Cartridge.
|
boolean |
attachToContext(Context context)
Attached the EventCartridge to the context
Final because not something one should mess with lightly :)
|
protected org.slf4j.Logger |
getLog() |
String |
includeEvent(Context context,
String includeResourcePath,
String currentResourcePath,
String directiveName)
Call include event handlers
|
Object |
invalidGetMethod(Context context,
String reference,
Object object,
String property,
Info info)
Call invalid reference handlers for an invalid getter
|
Object |
invalidMethod(Context context,
String reference,
Object object,
String method,
Info info)
Call invalid reference handlers for an invalid method call
|
boolean |
invalidSetMethod(Context context,
String leftreference,
String rightreference,
Info info)
Call invalid reference handlers for an invalid setter
|
Object |
methodException(Context context,
Class claz,
String method,
Exception e,
Info info)
Call method exception event handler
|
Object |
referenceInsert(InternalContextAdapter context,
String reference,
Object value)
Call reference insertion handlers
|
boolean |
removeEventHandler(EventHandler ev)
Removes an event handler(s) from the Cartridge.
|
void |
setRuntimeServices(RuntimeServices rs)
runtime services setter, called during initialization
|
protected RuntimeServices rsvc
protected org.slf4j.Logger getLog()
public void setRuntimeServices(RuntimeServices rs)
rs
- runtime servicespublic boolean addEventHandler(EventHandler ev)
ev
- object implementing a valid EventHandler-derived interfacepublic void addReferenceInsertionEventHandler(ReferenceInsertionEventHandler ev)
ev
- ReferenceInsertionEventHandlerpublic void addMethodExceptionHandler(MethodExceptionEventHandler ev)
ev
- MethodExceptionEventHandlerpublic void addIncludeEventHandler(IncludeEventHandler ev)
ev
- IncludeEventHandlerpublic void addInvalidReferenceEventHandler(InvalidReferenceEventHandler ev)
ev
- InvalidReferenceEventHandlerpublic boolean removeEventHandler(EventHandler ev)
ev
- object impementing a valid EventHandler-derived interfacepublic Object referenceInsert(InternalContextAdapter context, String reference, Object value)
context
- reference
- value
- public Object methodException(Context context, Class claz, String method, Exception e, Info info)
context
- claz
- method
- e
- exceptioninfo
- template name, line and column infospublic String includeEvent(Context context, String includeResourcePath, String currentResourcePath, String directiveName)
context
- includeResourcePath
- currentResourcePath
- directiveName
- public Object invalidGetMethod(Context context, String reference, Object object, String property, Info info)
context
- reference
- object
- property
- info
- public boolean invalidSetMethod(Context context, String leftreference, String rightreference, Info info)
context
- leftreference
- rightreference
- info
- public Object invalidMethod(Context context, String reference, Object object, String method, Info info)
context
- reference
- object
- method
- info
- public final boolean attachToContext(Context context)
context
- context to attach toCopyright © 2000–2020 The Apache Software Foundation. All rights reserved.