Hello,

I'm using Camel 2.23.1 to create camel based application.

I use velocity component of camel.

My requirement is to somehow override template reading logic, so I can 
inject a template from DB if it's defined and if not - use a file, the 
usual way.
Also, the camel velocity cache should be used to speed things up, so the 
injection should be pretty high in the call tree.

I've decided to try to use the functionality of overriding 
VelocityEngine as described here:

https://github.com/apache/camel/blob/master/components/camel-velocity/src/main/docs/velocity-component.adoc

So I've added this into the properties file:

camel:
   component:
     velocity:
       velocity-engine: 
pl.altkom.software.dpc.camelrider.cc.module.dpc.dpcapi.route.VelocityEngineTest

And I've created this VelocityEngine implementation:

=============================================

package pl.altkom.software.dpc.camelrider.cc.module.dpc.dpcapi.route;

import org.apache.velocity.Template;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class VelocityEngineTest extends VelocityEngine {

     @Override
     public Template getTemplate(String name) throws 
ResourceNotFoundException, ParseErrorException {
         log.error("TEST");
         return super.getTemplate(name);
     }

     @Override
     public Template getTemplate(String name, String encoding) throws 
ResourceNotFoundException, ParseErrorException {
         log.error("TEST");
         return super.getTemplate(name, encoding);
     }

}
=========================================================

Unfortunately, the test message isn't shown. I've done some more tests, 
and the class is not used by camel.

I tried to search the source code of camel to find this property and 
figure out how to properly use it.

It seems as it's not used by camel to initialize the velocity engine:( 
Am I wrong? Is it a bug or I just can't properly use it?

Can you guys help me use it properly? Or maybe can you guide me on how 
to do the thing I want to do some other way?

I'll be very grateful.

Piotr Kaczmarski




Reply via email to