Search in sources :

Example 1 with TemplateEvent

use of org.xwiki.template.event.TemplateEvent in project xwiki-platform by xwiki.

the class DefaultVelocityManager method initialize.

@Override
public void initialize() throws InitializationException {
    this.observation.addListener(new EventListener() {

        @Override
        public void onEvent(Event event, Object source, Object data) {
            if (event instanceof TemplateEvent) {
                TemplateEvent templateEvent = (TemplateEvent) event;
                DefaultVelocityManager.this.velocityFactory.removeVelocityEngine(templateEvent.getId());
            }
        }

        @Override
        public String getName() {
            return DefaultVelocityManager.class.getName();
        }

        @Override
        public List<Event> getEvents() {
            return EVENTS;
        }
    });
    // Set reserved bindings
    // "context" is a reserved binding in JSR223 world
    this.reservedBindings.add("context");
    // Macros directive
    this.reservedBindings.add("macro");
    // Foreach directive
    this.reservedBindings.add("foreach");
    this.reservedBindings.add(this.velocityConfiguration.getProperties().getProperty(RuntimeConstants.COUNTER_NAME, RuntimeSingleton.getString(RuntimeConstants.COUNTER_NAME)));
    this.reservedBindings.add(this.velocityConfiguration.getProperties().getProperty(RuntimeConstants.HAS_NEXT_NAME, RuntimeSingleton.getString(RuntimeConstants.HAS_NEXT_NAME)));
    // Evaluate directive
    this.reservedBindings.add("evaluate");
    // TryCatch directive
    this.reservedBindings.add("exception");
    this.reservedBindings.add("try");
    // Default directive
    this.reservedBindings.add("define");
    // The name of the context variable used for the template-level scope
    this.reservedBindings.add("template");
}
Also used : TemplateEvent(org.xwiki.template.event.TemplateEvent) TemplateDeletedEvent(org.xwiki.template.event.TemplateDeletedEvent) TemplateUpdatedEvent(org.xwiki.template.event.TemplateUpdatedEvent) TemplateEvent(org.xwiki.template.event.TemplateEvent) Event(org.xwiki.observation.event.Event) List(java.util.List) EventListener(org.xwiki.observation.EventListener)

Aggregations

List (java.util.List)1 EventListener (org.xwiki.observation.EventListener)1 Event (org.xwiki.observation.event.Event)1 TemplateDeletedEvent (org.xwiki.template.event.TemplateDeletedEvent)1 TemplateEvent (org.xwiki.template.event.TemplateEvent)1 TemplateUpdatedEvent (org.xwiki.template.event.TemplateUpdatedEvent)1