Uploaded image for project: 'ServiceMix 4'
  1. ServiceMix 4
  2. SMX4-851

Velocity bundle - Add dynamic imports so the #parse macro can load the resource

    Details

    • Type: Task
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.4.0
    • Component/s: Bundles
    • Labels:
      None

      Description

      Velocity templates can contain a macro which includes another template. And that template is loaded from the classpath.

      However with OSGi its not so easy to have this working as its VelocityEngine that loads that resource. And its classloader do not have imports to any end users packages where his/hers .vm template files reside.

      So if possible maybe the SMX bundle of Velocity can have a dynamic import. So we have a chance of loading those template files using #macro

      For example you may have a .vm file in org/apache/camel/itest/osgi/velocity/example.vm which includes another .vm file from the classpath.

      #parse("org/apache/camel/itest/osgi/velocity/header.vm")
      <hello>${headers.cheese}</hello>
      

      When #parse is executed its VelocityEngine that takes over and load that resource. And this its a different classloader tree we end up taking.

        Activity

        Hide
        ffang Freeman Fang added a comment -

        Using DynamicImport-Package is one solution to load external resources, Alternatively we can create fragment bundle with contain resources and attachment it to the velocity bundle, so that all resource from fragment bundle is available to the host bundle.

        Anyway, I'm going to add DynamicImport-Package to the velocity bundle to make life easier.

        Freeman

        Show
        ffang Freeman Fang added a comment - Using DynamicImport-Package is one solution to load external resources, Alternatively we can create fragment bundle with contain resources and attachment it to the velocity bundle, so that all resource from fragment bundle is available to the host bundle. Anyway, I'm going to add DynamicImport-Package to the velocity bundle to make life easier. Freeman
        Show
        ffang Freeman Fang added a comment - commit fix http://svn.apache.org/viewvc?rev=1129449&view=rev

          People

          • Assignee:
            ffang Freeman Fang
            Reporter:
            davsclaus Claus Ibsen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development