velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Travis P <>
Subject Configuring my Velocity Tool: where are the properties to be found?
Date Thu, 18 Mar 2010 17:56:09 GMT
I'm using VelocityTool 2.0-beta4 with Velocity 1.6.3 under Tomcat 6.0.24.

I'm trying to figure out how I can pass some configuration info into my
velocity tool.

I expected the data to be passed to the configure routine, but I don't see
it in the property map that is passed, or any other map that I could find to
look at.

Below is simple tools.xml and that pretty much show what I've
tried.   I do get output showing that MyTool's constructor and configure()
method are called.  I just get null from all property lookups.  I also see
Velocity printing this in the log output:
 Data 'GENERIC_TOOLS_AVAILABLE' -boolean-> true
 Data 'TOOLS_VERSION' -number-> 2.0
 Data 'VIEW_TOOLS_AVAILABLE' -boolean-> true
 Data 'my_data' -auto-> data 1

That looks promising.  But where can I query the value of "my_data"?


I've got a configuration like this:
<?xml version="1.0" encoding="ISO-8859-1"?>

 <toolbox scope="application">
   <tool key="my" class="MyTool" />
   <data key="my_data" value="data 2" />

 <data key="my_data" value="data 1" />

public class MyTool
  public MyTool()
    System.err.println("MyTool init");

  public void configure(Map props)
    System.err.println("[my-conf] configure");
    for (Object meo : props.entrySet()) {
      Map.Entry me = (Map.Entry)meo;
      System.err.println("[my-conf] "+me.getKey()+" : " + me.getValue());

    VelocityEngine ve = (VelocityEngine)props.get("velocityEngine");

    System.err.println("[my-conf] PG my_data=>'"+

    System.err.println("[my-conf] RS my_data=>'"+


    System.err.println("[my-conf] SY my_data=>'"+


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message