You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Matt Raible <li...@raibledesigns.com> on 2004/04/27 00:35:24 UTC

DataSourceResourceLoader - modify to inject DataSource dependency

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.  This seems like it should be fairly straightforward, yet I can't 
figure it out.  

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

Any ideas?

Thanks,

Matt

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: DataSourceResourceLoader - modify to inject DataSource dependency

Posted by Will Glass-Husain <wg...@forio.com>.
Sounds like a good plan.  Maybe I'll even implement it.

WILL

----- Original Message ----- 
From: "Matt Raible" <li...@raibledesigns.com>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Monday, April 26, 2004 7:28 PM
Subject: Re: DataSourceResourceLoader - modify to inject DataSource
dependency


>
> On Apr 26, 2004, at 4:53 PM, Will Glass-Husain wrote:
>
> > Hi Matt,
> >
> > 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?
>
> Correct.
>
> >
> > 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.
>
> Should I create an enhancement request - and note your comment above as
> a possible howto?
>
> Thanks,
>
> Matt
>
> >
> > WILL
> >
> >
> > ----- Original Message -----
> > From: "Matt Raible" <li...@raibledesigns.com>
> > To: <ve...@jakarta.apache.org>
> > Sent: Monday, April 26, 2004 3:35 PM
> > Subject: DataSourceResourceLoader - modify to inject DataSource
> > dependency
> >
> >
> >> 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.  This seems like it should be
> >> fairly
> > straightforward, yet I can't
> >> figure it out.
> >>
> >> The main problem is how to manage a ResourceLoader with Spring and
> >> then
> > set it declaratively on its
> >> VelocityEngine - rather than via properties.
> >>
> >> Any ideas?
> >>
> >> Thanks,
> >>
> >> Matt
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: DataSourceResourceLoader - modify to inject DataSource dependency

Posted by Matt Raible <li...@raibledesigns.com>.
On Apr 26, 2004, at 4:53 PM, Will Glass-Husain wrote:

> Hi Matt,
>
> 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?

Correct.

>
> 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.

Should I create an enhancement request - and note your comment above as 
a possible howto?

Thanks,

Matt

>
> WILL
>
>
> ----- Original Message -----
> From: "Matt Raible" <li...@raibledesigns.com>
> To: <ve...@jakarta.apache.org>
> Sent: Monday, April 26, 2004 3:35 PM
> Subject: DataSourceResourceLoader - modify to inject DataSource 
> dependency
>
>
>> 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.  This seems like it should be 
>> fairly
> straightforward, yet I can't
>> figure it out.
>>
>> The main problem is how to manage a ResourceLoader with Spring and 
>> then
> set it declaratively on its
>> VelocityEngine - rather than via properties.
>>
>> Any ideas?
>>
>> Thanks,
>>
>> Matt
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: DataSourceResourceLoader - modify to inject DataSource dependency

Posted by Will Glass-Husain <wg...@forio.com>.
Hi Matt,

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?

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.

WILL


----- Original Message ----- 
From: "Matt Raible" <li...@raibledesigns.com>
To: <ve...@jakarta.apache.org>
Sent: Monday, April 26, 2004 3:35 PM
Subject: DataSourceResourceLoader - modify to inject DataSource dependency


> 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.  This seems like it should be fairly
straightforward, yet I can't
> figure it out.
>
> The main problem is how to manage a ResourceLoader with Spring and then
set it declaratively on its
> VelocityEngine - rather than via properties.
>
> Any ideas?
>
> Thanks,
>
> Matt
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org