You are welcome.

Werner

Sébastien PERES-LABOURDETTE - Public wrote:
> I had a look too.
> 
> I wrote a "quick and dirty" workaround that creates a second instance of
> the (potential) dataSoure by calling
> 
>             jdoConf = (JdoConf) Unmarshaller.unmarshal(JdoConf.class,
> new InputSource(this.getClass().getResourceAsStream(jdoConfResource)));
>             _dsMap = new HashMap<String, DataSource>();
>             for (String dbName : datasourcesToLoad) {
>                 JDOManager jdoManager = JDOManager.createInstance(dbName);
>                 jdoManager.setDatabasePooling(true);
>                 _jdoMap.put(dbName, jdoManager);
> 
>                 for (org.castor.jdo.conf.Database dbConf :
> jdoConf.getDatabase()) {
>                     if (dbConf.getName().equalsIgnoreCase(dbName))
>                         _dsMap.put(dbName,
> DataSourceConnectionFactory.loadDataSource(dbConf,
> this.getClass().getClassLoader()));
>                 }
>             }
> 
> 
> Where datasourcesToLoad is the List of database names (matching 
> <database name="asap_odp">) implementing a datasource
> 
> Thanks for helping !!
> 
> 
> Werner Guttmann a écrit :
>> Actually, let me check whether a getdataSource() method could be added
>> to JDOManager *easily*.
>>  
>> Werner
>>
>>     ------------------------------------------------------------------------
>>     *From:* Werner Guttmann [mailto:[EMAIL PROTECTED]
>>     *Sent:* Montag, 26. Februar 2007 13:18
>>     *To:* [email protected]
>>     *Subject:* RE: [castor-user] CastorTransactionManager
>>
>>     Just had a look at the code on the weekend, and I am afraid
>>     there´s no such functionality available to obtain an instance of
>>     the (potentially) DataSource used within Castor to obtain JDBC
>>     connections. That's in core Castor JDO, to be precise.
>>      
>>     Werner
>>
>>         
>> ------------------------------------------------------------------------
>>         *From:* Sébastien PERES-LABOURDETTE - Public
>>         [mailto:[EMAIL PROTECTED]
>>         *Sent:* Freitag, 23. Februar 2007 15:54
>>         *To:* [email protected]
>>         *Subject:* Re: [castor-user] CastorTransactionManager
>>
>>         :) copy that
>>
>>         My class hierarchy currently relies on Castor JDOManagers (10
>>         instances, more to come).
>>         I just need to mix Spring JdbcTemplate queries with OQLQueries
>>         where my object model fails on performance.
>>         If there is a standard way to get the DataSource Instance (or
>>         null if there isn't) from a JDOManager instance, that would be
>>         nice.
>>
>>         Thanks for reading.
>>
>>
>>
>>         Werner Guttmann a écrit :
>>>         I am not going as far as saying that you should not try to do
>>>         this, but please be aware that the bean factories as provided
>>>         by Spring and Castor itself work togetehr to e.g. guarantee
>>>         that transaction enlistement works as specified, etc.
>>>          
>>>         Can you briefly describe what you are trying to achieve.
>>>          
>>>         Werner
>>>
>>>             
>>> ------------------------------------------------------------------------
>>>             *From:* Sébastien PERES-LABOURDETTE - Public
>>>             [mailto:[EMAIL PROTECTED]
>>>             *Sent:* Freitag, 23. Februar 2007 14:54
>>>             *To:* [email protected]
>>>             *Subject:* Re: [castor-user] CastorTransactionManager
>>>
>>>             Indeed.
>>>
>>>             (I won't pretend to be  a "core J2EE Patterns" architect
>>>             best friend but considering my current needs and duties ,
>>>             it would be useful.)
>>>
>>>
>>>             Werner Guttmann a écrit :
>>>>             Are you trying to say that you are not using Spring and
>>>>             its configuration files to define Spring beans for a
>>>>             Castor JDO manager, a JDBC DataSource, a JDBCTemplate,
>>>>             etc ?
>>>>              
>>>>             Werner
>>>>
>>>>                 
>>>> ------------------------------------------------------------------------
>>>>                 *From:* Sébastien PERES-LABOURDETTE - Public
>>>>                 [mailto:[EMAIL PROTECTED]
>>>>                 *Sent:* Freitag, 23. Februar 2007 14:34
>>>>                 *To:* [email protected]
>>>>                 *Subject:* Re: [castor-user] CastorTransactionManager
>>>>
>>>>                 I don't have any of such beans, i just have a heavy
>>>>                 jdo-conf xml file .....
>>>>
>>>>                 How can i get some ?
>>>>
>>>>
>>>>                 Werner Guttmann a écrit :
>>>>>                 Oh, by simply wiring the same spring bean
>>>>>                 definition for the jdbc datasource to both the jdbc
>>>>>                 template and Castor.
>>>>>                  
>>>>>                 Werner
>>>>>
>>>>>                     
>>>>> ------------------------------------------------------------------------
>>>>>                     *From:* Sébastien PERES-LABOURDETTE - Public
>>>>>                     [mailto:[EMAIL PROTECTED]
>>>>>                     *Sent:* Freitag, 23. Februar 2007 14:15
>>>>>                     *To:* [email protected]
>>>>>                     *Subject:* Re: [castor-user]
>>>>>                     CastorTransactionManager
>>>>>
>>>>>                     This is it :
>>>>>                     What is the standard way to use (or re-use) my 
>>>>>                     jdo Database Datasource to instantiate a
>>>>>                     JdbcTemplate the standard way :
>>>>>
>>>>>                     new |*JdbcTemplate
>>>>>                     
>>>>> <http://www.springframework.org/docs/api/org/springframework/jdbc/core/JdbcTemplate.html#JdbcTemplate%28javax.sql.DataSource%29>*(DataSource
>>>>>                     
>>>>> <http://java.sun.com/j2se/1.5.0/docs/api/javax/sql/DataSource.html> 
>>>>> dataSource)|
>>>>>
>>>>>                     ?
>>>>>
>>>>>                     Werner Guttmann a écrit :
>>>>>>                     Hi,
>>>>>>                      
>>>>>>                     there's no rule that manadates that a JDBC
>>>>>>                     template has to use a JDBC connection that has
>>>>>>                     been instantiated from within Castor. Just
>>>>>>                     instantiate a jdbcTemplate using the standard
>>>>>>                     way, and Spring (together with Castor's help
>>>>>>                     and vice versa) will be able to figure that
>>>>>>                     there's already an active transaction
>>>>>>                     associated with a given JDBC connection (and
>>>>>>                     thus re-use it).
>>>>>>                      
>>>>>>                     Werner
>>>>>>
>>>>>>                         
>>>>>> ------------------------------------------------------------------------
>>>>>>                         *From:* Sébastien PERES-LABOURDETTE
>>>>>>                         [mailto:[EMAIL PROTECTED]
>>>>>>
>>>>>>                         *Sent:* Freitag, 23. Februar 2007 12:40
>>>>>>                         *To:* [email protected]
>>>>>>                         *Subject:* Re: [castor-user]
>>>>>>                         CastorTransactionManager
>>>>>>
>>>>>>                         You are right, this is just what i wish to
>>>>>>                         do, but how do you get a JDBCTemplate
>>>>>>                         working with a JDOManager (or a Database)
>>>>>>                         since it expects a DataSource ?
>>>>>>
>>>>>>                         For native JDBC code (out of spring) this
>>>>>>                         is easy with Database.getJDBCConnection()
>>>>>>
>>>>>>
>>>>>>
>>>>>>                         Werner Guttmann a écrit :
>>>>>>>                         Yes, that is true. But the limitation is
>>>>>>>                         that this still needs to run within the
>>>>>>>                         context of a Spring platform tx manager,
>>>>>>>                         as all the code written is
>>>>>>>                         Spring-specific. In other words, I do not
>>>>>>>                         think that it is possible to use things
>>>>>>>                         your way.
>>>>>>>                          
>>>>>>>                         If you want to use Castor JDO and plain
>>>>>>>                         JDBC from 'within' Spring, please
>>>>>>>                         consider using the JDBCTemplate classes,
>>>>>>>                         as this is designed for exectly this
>>>>>>>                         need, i.e. to span transactions across
>>>>>>>                         multiple datasources.
>>>>>>>                          
>>>>>>>                         Regards
>>>>>>>                         Werner
>>>>>>>
>>>>>>>                             
>>>>>>> ------------------------------------------------------------------------
>>>>>>>                             *From:* Sébastien PERES-LABOURDETTE -
>>>>>>>                             Public
>>>>>>>                             [mailto:[EMAIL PROTECTED]
>>>>>>>
>>>>>>>                             *Sent:* Freitag, 23. Februar 2007 11:48
>>>>>>>                             *To:* Castor User
>>>>>>>                             *Subject:* [castor-user]
>>>>>>>                             CastorTransactionManager
>>>>>>>
>>>>>>>                             Hi.
>>>>>>>
>>>>>>>                             Performance issues leads me to mix
>>>>>>>                             jdo with some plain jdbc code.
>>>>>>>                             For that reason, i wish to use the
>>>>>>>                             spring orm implementation for castor.
>>>>>>>
>>>>>>>                             I wrote a method  :
>>>>>>>
>>>>>>>                                 public DataSource getDbDs(String
>>>>>>>                             dbId) {
>>>>>>>                                     CastorTransactionManager ctm
>>>>>>>                             = new
>>>>>>>                             CastorTransactionManager(_jdoMap.get(dbId));
>>>>>>>                                     return ctm.getDataSource();
>>>>>>>                                 }
>>>>>>>
>>>>>>>                             _jdoMap being a map of JDOManagers
>>>>>>>                             successfully initialized.
>>>>>>>
>>>>>>>                             Each JDOManager points to a database
>>>>>>>                             conf that maps a data-source such :
>>>>>>>
>>>>>>>                                     <data-source
>>>>>>>                             
>>>>>>> class-name="org.apache.commons.dbcp.BasicDataSource">
>>>>>>>                                         <param
>>>>>>>                             name="driver-class-name"
>>>>>>>                             value="com.informix.jdbc.IfxDriver" />
>>>>>>>                                         <param name="username"
>>>>>>>                             value="informix" />
>>>>>>>                                         <param name="password"
>>>>>>>                             value="informix" />
>>>>>>>                                         <param name="url"
>>>>>>>                             value="jdbc:informix-sqli://url" />
>>>>>>>                                         <param name="maxActive"
>>>>>>>                             value="10" />
>>>>>>>                                         <param name="initialSize"
>>>>>>>                             value="3" />
>>>>>>>                                         <param
>>>>>>>                             name="removeAbandoned" value="true" />
>>>>>>>                                     </data-source>       
>>>>>>>
>>>>>>>                             But the "getDbDs" method returns null
>>>>>>>                             anyway.
>>>>>>>
>>>>>>>                             Any issue ?
>>>>>>>
>>>>>>>
>>>>>>>                             NB :
>>>>>>>                             The javadoc for
>>>>>>>                             "CastorTransactionManager" specifies
>>>>>>>                             this :
>>>>>>>
>>>>>>>                             "With a CastorDialect specified, this
>>>>>>>                             implementation also supports direct
>>>>>>>                             DataSource access within a
>>>>>>>                             transaction (i.e. plain JDBC code
>>>>>>>                             working with the same DataSource).
>>>>>>>                             This allows for mixing services that
>>>>>>>                             access Castor JDO (including
>>>>>>>                             transactional caching) and services
>>>>>>>                             that use plain JDBC (without being
>>>>>>>                             aware of Castor JDO)! Application
>>>>>>>                             code needs to stick to the same
>>>>>>>                             simple Connection lookup pattern as
>>>>>>>                             with DataSourceTransactionManager
>>>>>>>                             (i.e. |DataSourceUtils.getConnection|)."
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>                             -- 
>>>>>>>                             Sébastien PERES-LABOURDETTE
>>>>>>>
>>>>>>
>>>>>>                         -- 
>>>>>>                         Cordialement,
>>>>>>                         *Sébastien PERES-LABOURDETTE
>>>>>>                         <mailto:[EMAIL PROTECTED]>*
>>>>>>                         Responsable applications portail.
>>>>>>                         Service Informatique
>>>>>>                         Plus de 500 fiches techniques disponibles
>>>>>>                         sur notre site Web
>>>>>>                         <http://www.omerin.com>  *Tél :
>>>>>>                         (+33)4-73-82-57-65*
>>>>>>                         Fax : (+33)4-73-82-50-10
>>>>>>
>>>>>
>>>>>                     -- 
>>>>>                     Sébastien PERES-LABOURDETTE
>>>>>
>>>>
>>>>                 -- 
>>>>                 Sébastien PERES-LABOURDETTE
>>>>
>>>
>>>             -- 
>>>             Sébastien PERES-LABOURDETTE
>>>
>>
>>         -- 
>>         Sébastien PERES-LABOURDETTE
>>
> 
> -- 
> Sébastien PERES-LABOURDETTE


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to