You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Stefano Bagnara <ap...@bago.org> on 2006/10/14 19:21:03 UTC

Torque as avalon service and use of the DataSourceSelector service

Hi all,

we integrated Torque in Apache James trunk for our IMAP storage needs.
James is currently Avalon based and works on Avalon.

I saw there is an Avalon component for James but I saw it does not 
depend on the DataSourceSelector component that we currently use to 
access the db.

I thought we could write our own torque avalon service depending on 
datasourceselector but I'm not sure we can do this.

I see Torque need a static configuration of the class used as the 
datasource factory while using DataSourceSelector the datasource is 
obtained via dependency injection or service lookup.

Maybe we should switch from Torque static usage to TorqueInstance?

Pardon my ignorance on Torque: Using TorqueInstance is it possible to 
override its getDataSource to ask the datasource to the DataSourceSelector?

I see that generated "om" contains static "Torque.method" calls: how do 
this integrate with the TorqueInstance usage/configuration?

Is this possible? Otherwise I think I have to use publish the datasource 
selector via JNDI and to use the JNDI factory or to put the 
datasourceselector in a static field and then access it via a custom 
factory but I don't like this solutions (static fields/singleton are bad 
in then avalon world) so I'm investigating other options first.

Thank you for any suggestion!
Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: Torque as avalon service and use of the DataSourceSelector service

Posted by Thomas Vandahl <tv...@apache.org>.
Stefano Bagnara wrote:
> Hi all,
> 
> we integrated Torque in Apache James trunk for our IMAP storage needs.
> James is currently Avalon based and works on Avalon.
> 
[...]
> I see Torque need a static configuration of the class used as the
> datasource factory while using DataSourceSelector the datasource is
> obtained via dependency injection or service lookup.
> 
> Maybe we should switch from Torque static usage to TorqueInstance?

This probably won't help. I changed the Torque static to use the real
TorqueInstance created during the container initialization.

I would suggest extending from the AbstractDataSourceFactory to use your
DataSourceSelector Service. You can configure the factory to use in the
Torque.properties file. This way nothing will have to be changed on the
"user"-side of Torque.

If you have any more questions,  I will be happy to assist.

Bye, Thomas.


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


RE: Torque as avalon service and use of the DataSourceSelector service

Posted by Thomas Fischer <fi...@seitenbau.net>.
Hi,

I have to admit that I have never used avalon nor do I know the reasoning
for separating the TorqueInstance class from the Torque class, so this may
be of limited or no value to you.

Internally, most (if not all)Torque classes use the Torque.java object to
access their configuration. The Torque object has a reference to a
TorqueInstance object which is _INTERNALLY_ used by the Torque.java object
to access the configuration.

So you cannot get around a static configuration of Torque in the current
version, as far as I can see. I do not see a way to use TorqueInstance
instead of the static Torque object. This has  its reason that Torque is
intended to be a standalone component, and the avalon part is just an
addon.

Of course you can provide your own implementation of TorqueInstance
instance by using the Torque.setTorqueInstance method, and thus override
the getDataSourceFactory() part.

I cannot see anything against using an own factory, but then I'm no avalon
user and do not see the evil in this :-)

Hope this helps. If I have been writing nonsense, perhaps Thomas V can
correct me, he is using avalon himself.

   Thomas F



Stefano Bagnara <ap...@bago.org> schrieb am 14.10.2006 19:21:03:

> Hi all,
>
> we integrated Torque in Apache James trunk for our IMAP storage needs.
> James is currently Avalon based and works on Avalon.
>
> I saw there is an Avalon component for James but I saw it does not
> depend on the DataSourceSelector component that we currently use to
> access the db.
>
> I thought we could write our own torque avalon service depending on
> datasourceselector but I'm not sure we can do this.
>
> I see Torque need a static configuration of the class used as the
> datasource factory while using DataSourceSelector the datasource is
> obtained via dependency injection or service lookup.
>
> Maybe we should switch from Torque static usage to TorqueInstance?
>
> Pardon my ignorance on Torque: Using TorqueInstance is it possible to
> override its getDataSource to ask the datasource to the
DataSourceSelector?
>
> I see that generated "om" contains static "Torque.method" calls: how do
> this integrate with the TorqueInstance usage/configuration?
>
> Is this possible? Otherwise I think I have to use publish the datasource
> selector via JNDI and to use the JNDI factory or to put the
> datasourceselector in a static field and then access it via a custom
> factory but I don't like this solutions (static fields/singleton are bad
> in then avalon world) so I'm investigating other options first.
>
> Thank you for any suggestion!
> Stefano
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


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


RE: Torque as avalon service and use of the DataSourceSelector service

Posted by Thomas Fischer <fi...@seitenbau.net>.
Hi,

I have to admit that I have never used avalon nor do I know the reasoning
for separating the TorqueInstance class from the Torque class, so this may
be of limited or no value to you.

Internally, most (if not all)Torque classes use the Torque.java object to
access their configuration. The Torque object has a reference to a
TorqueInstance object which is _INTERNALLY_ used by the Torque.java object
to access the configuration.

So you cannot get around a static configuration of Torque in the current
version, as far as I can see. I do not see a way to use TorqueInstance
instead of the static Torque object. This has  its reason that Torque is
intended to be a standalone component, and the avalon part is just an
addon.

Of course you can provide your own implementation of TorqueInstance
instance by using the Torque.setTorqueInstance method, and thus override
the getDataSourceFactory() part.

I cannot see anything against using an own factory, but then I'm no avalon
user and do not see the evil in this :-)

Hope this helps. If I have been writing nonsense, perhaps Thomas V can
correct me, he is using avalon himself.

   Thomas F



Stefano Bagnara <ap...@bago.org> schrieb am 14.10.2006 19:21:03:

> Hi all,
>
> we integrated Torque in Apache James trunk for our IMAP storage needs.
> James is currently Avalon based and works on Avalon.
>
> I saw there is an Avalon component for James but I saw it does not
> depend on the DataSourceSelector component that we currently use to
> access the db.
>
> I thought we could write our own torque avalon service depending on
> datasourceselector but I'm not sure we can do this.
>
> I see Torque need a static configuration of the class used as the
> datasource factory while using DataSourceSelector the datasource is
> obtained via dependency injection or service lookup.
>
> Maybe we should switch from Torque static usage to TorqueInstance?
>
> Pardon my ignorance on Torque: Using TorqueInstance is it possible to
> override its getDataSource to ask the datasource to the
DataSourceSelector?
>
> I see that generated "om" contains static "Torque.method" calls: how do
> this integrate with the TorqueInstance usage/configuration?
>
> Is this possible? Otherwise I think I have to use publish the datasource
> selector via JNDI and to use the JNDI factory or to put the
> datasourceselector in a static field and then access it via a custom
> factory but I don't like this solutions (static fields/singleton are bad
> in then avalon world) so I'm investigating other options first.
>
> Thank you for any suggestion!
> Stefano
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org