On Feb 13, 2010, at 6:29 PM, Sergiu Dumitriu wrote:

> On 02/13/2010 04:40 PM, vmassol (SVN) wrote:
>> Author: vmassol
>> Date: 2010-02-13 16:40:57 +0100 (Sat, 13 Feb 2010)
>> New Revision: 27004
>> 
>> Modified:
>>    
>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/hibernate/DefaultHibernateSessionFactory.java
>> Log:
>> XWIKI-4893: Make XWiki support recovering from a connection problem with the 
>> database
>> 
>> Modified: 
>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/hibernate/DefaultHibernateSessionFactory.java
>> ===================================================================
>> --- 
>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/hibernate/DefaultHibernateSessionFactory.java
>>    2010-02-13 12:09:34 UTC (rev 27003)
>> +++ 
>> platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/store/hibernate/DefaultHibernateSessionFactory.java
>>    2010-02-13 15:40:57 UTC (rev 27004)
>> @@ -19,7 +19,9 @@
>>   */
>>  package com.xpn.xwiki.store.hibernate;
>> 
>> +import java.io.File;
>>  import java.io.InputStream;
>> +import java.net.URL;
>> 
>>  import org.hibernate.HibernateException;
>>  import org.hibernate.SessionFactory;
>> @@ -33,8 +35,8 @@
>>   *
>>   * @version $Id$
>>   * @since 2.0M1
>> - * @todo this was coded by Artem. Find out why we need this as a component.
>>   */
>> +// TODO: This was coded by Artem. Find out why we need this as a component.
>>  @Component
>>  public class DefaultHibernateSessionFactory implements 
>> HibernateSessionFactory
>>  {
>> @@ -45,6 +47,78 @@
>>      {
>>          private static final long serialVersionUID = 1L;
>> 
>> +        /**
>> +         * Whether the Hibernate Configuration has alreayd been initialized 
>> or not. We do this so that the
>> +         * Hibernate {...@link org.hibernate.cfg.Configuration#configure()} 
>> methods can be called several times in a
>> +         * row without causing some Duplicate Mapping errors, see our 
>> overridden
>> +         * {...@link #getConfigurationInputStream(String)} below.
>> +         */
>> +        private boolean isConfigurationInitialized;
>> +
>> +        /**
>> +         * {...@inheritdoc}
>> +         * @see org.hibernate.cfg.Configuration#configure()
>> +         */
> 
> Are you sure there's no need for synchronized? Same for all the others.

Actually I think the synchronized should be added to the initHibernate() 
method. But maybe to both. Synchronized should hurt anyway so yes probably best 
to add them everywhere.

-Vincent

> 
>> +        @Override public Configuration configure() throws HibernateException
>> +        {
>> +            Configuration configuration;
>> +            if (this.isConfigurationInitialized) {
>> +                configuration = this;
>> +            } else {
>> +                configuration = super.configure();
>> +                this.isConfigurationInitialized = true;
>> +            }
>> +            return configuration;
>> +        }
>> +
>> +        /**
>> +         * {...@inheritdoc}
>> +         * @see org.hibernate.cfg.Configuration#configure(String)
>> +         */
>> +        @Override public Configuration configure(String resource) throws 
>> HibernateException
>> +        {
>> +            Configuration configuration;
>> +            if (this.isConfigurationInitialized) {
>> +                configuration = this;
>> +            } else {
>> +                configuration = super.configure(resource);
>> +                this.isConfigurationInitialized = true;
>> +            }
>> +            return configuration;
>> +        }
>> +
>> +        /**
>> +         * {...@inheritdoc}
>> +         * @see org.hibernate.cfg.Configuration#configure(java.net.URL)
>> +         */
>> +        @Override public Configuration configure(URL url) throws 
>> HibernateException
>> +        {
>> +            Configuration configuration;
>> +            if (this.isConfigurationInitialized) {
>> +                configuration = this;
>> +            } else {
>> +                configuration = super.configure(url);
>> +                this.isConfigurationInitialized = true;
>> +            }
>> +            return configuration;
>> +        }
>> +
>> +        /**
>> +         * {...@inheritdoc}
>> +         * @see org.hibernate.cfg.Configuration#configure(java.io.File)
>> +         */
>> +        @Override public Configuration configure(File configFile) throws 
>> HibernateException
>> +        {
>> +            Configuration configuration;
>> +            if (this.isConfigurationInitialized) {
>> +                configuration = this;
>> +            } else {
>> +                configuration = super.configure(configFile);
>> +                this.isConfigurationInitialized = true;
>> +            }
>> +            return configuration;
>> +        }
>> +
>>          // there is no #configure(InputStream) so we use #configure(String) 
>> and override #getConfigurationInputStream
>>          @Override
>>          protected InputStream getConfigurationInputStream(String resource) 
>> throws HibernateException

_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to