Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-267

Create a DataSourceResourceLoader that can be wired to the datasource with IoC

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.5
    • 1.5
    • Engine
    • None
    • Operating System: other
      Platform: Other
    • 28611

    Description

      I'd like to create a ResourceLoader similar to DataSourceResourceLoader, except that I'd like to set
      the DataSource via IoC (in Spring). The main reason for this is so my database-loading of templates
      does not depend on a JNDI connection.

      The main problem is how to manage a ResourceLoader with Spring and then set it declaratively on its
      VelocityEngine - rather than via properties.

      <suggested patch from Will Glass-Husain>
      Does this mean that you'd need to pass in an instance of a resource manager
      (initialized with the datasource) to VelocityEngine, rather than just set
      the class name as a property? (MR - Yes)

      As I understand the source code, this doesn't seem possible. But I think a
      patch wouldn't be difficult. (a change to
      RuntimeInstance.initializeResourceManager) to look for an instance of the
      class as well as the class name. Something similar to
      LogManager.createLogSystem which accepts as a property the class name of a
      class that implements LogSystem, or an instance of the class itself.
      </suggested patch>

      Attachments

        1. ASF.LICENSE.NOT.GRANTED--resourceinstance.zip
          0.7 kB
          Will Glass-Husain
        2. ASF.LICENSE.NOT.GRANTED--resource_ioc.patch
          14 kB
          Will Glass-Husain
        3. ASF.LICENSE.NOT.GRANTED--DatabaseResourceLoader.java
          9 kB
          Matt Raible

        Activity

          People

            Unassigned Unassigned
            matt@raibledesigns.com Matt Raible
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: