How to edit a Velosimacro without restarting the speed?

My speed macros are cached, and I don't want them to be ... not at development time, at least.

I set the following properties in my properties file ...

velocimacro.library.autoreload=true file.resource.loader.cache=false velocity.engine.resource.manager.cache.enabled=false 

... but that didn't seem to do the trick

Using speed properties, how to configure speed for non-macro caching?

(I use speed 1.6.4)

EDIT:

I do not think the line ...

 velocity.engine.resource.manager.cache.enabled=false 

... related to speed

+6
java velocity
source share
5 answers

I had the same problem with NVelocity (C # speed port). Delving into their totals, I found that reloading macros in the global namespace is controlled by the following property.

 properties.SetProperty(RuntimeConstants.VM_PERM_ALLOW_INLINE_REPLACE_GLOBAL, true); 

I have not tested this with speed, but looking at their documentation , the property exists and seems to do exactly what you need.

+8
source share

It sounds like you can't do what you want. The only way I could get the macro definitions for the reboot is to put them in my own library file and set the velocityimacro.library.autoreload = true value.

From http://velocity.apache.org/engine/devel/developer-guide.html

velocityimacro.library = VM_global_library.vm

A multi-valued key. Will take CSV for value. The name of the Velocimacro library file that will be loaded when the Velocity speed engine starts. These Velocimacros are available for all templates. It is assumed that the file belongs to the root of the file loader resource path.


speedimacro.library.autoreload = false

Controls the loading of the Velocimacro library. When set to true, the Velocimacro source library for the called Velocimacro will be checked for changes and reloaded if necessary. This allows you to modify and test Velocimacro libraries without having to restart the application or servlet container, just like regular templates. This mode only works when caching is disabled in resource loaders (for example, file.resource.loader.cache = false). This feature is for development, not production.

+2
source share

I'm not sure if this is possible if the macros are not in the speed library and only in any template file.

However, in this case, if you just want to simplify the development, you can simply rename the macro (by searching / replacing all and just adding a number to the end or something else). Then you can immediately see the change. You just need to remember to rename it back to what it should have when done!

+1
source share

You may need to install

 file.resource.loader.modificationCheckInterval 

This tells the speed how often to check if the file has been modified. I can’t say from the documents what default is, but we have 2 in our dev env. Perhaps this default value for this support is a large number or less than 0, which is essentially off, that is, it will never check for changes in your macro file.

0
source share

You can use the #define directive instead of #macro. These links are subject to change. With it, you can also name the VTL code block and name it how many times you need it. Define the macro arguments as variables in the same context and use them inside the named block as if it were a macro. Both can solve common situations; but they are not equivalent. https://velocity.apache.org/engine/1.7/user-guide.html#define

0
source share

All Articles