<commit_before>#region License

/*
 * Copyright  2002-2005 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#endregion

#region Imports

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;

using Common.Logging;
using NHibernate;
using NHibernate.Bytecode;
using NHibernate.Cfg;
using NHibernate.Connection;
using NHibernate.Dialect;
using NHibernate.Engine;
using NHibernate.Event;
using NHibernate.Tool.hbm2ddl;
using Spring.Context;
using Spring.Core.IO;
using Spring.Dao;
using Spring.Dao.Attributes;
using Spring.Dao.Support;
using Spring.Data.Common;
using Spring.Data.Support;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Config;
using Spring.Util;

using Environment = NHibernate.Cfg.Environment;
using Configuration = NHibernate.Cfg.Configuration;

#endregion

namespace Spring.Data.NHibernate
{
	/// <summary>
	///  An IFactoryObject that creates a local Hibernate SessionFactory instance.
    /// Behaves like a SessionFactory instance when used as bean reference,
    /// e.g. for HibernateTemplate's "SessionFactory" property.
	/// </summary>
	/// <remarks>
	/// The typical usage will be to register this as singleton factory
	/// in an application context and give objects references to application services
	/// that need it.
	/// <para>
	/// Hibernate configuration settings can be set using the IDictionary property 'HibernateProperties'.
	/// </para>
	/// <para>
	/// This class implements the <see cref="IPersistenceExceptionTranslator"/> interface,
    /// as autodetected by Spring's <see cref="PersistenceExceptionTranslationPostProcessor"/>
    /// for AOP-based translation of PersistenceExceptionTranslationPostProcessor.
    /// Hence, the presence of e.g. LocalSessionFactoryBean automatically enables
    /// a PersistenceExceptionTranslationPostProcessor to translate Hibernate exceptions. 
	/// </para>
	/// </remarks>
	/// <author><NAME> (.NET)</author>
    public class LocalSessionFactoryObject : IFactoryObject, IInitializingObject, IPersistenceExceptionTranslator, IDisposable
        , IApplicationContextAware
	{
		#region Fields

        private Configuration configuration;

	    private ISessionFactory sessionFactory;

        private string[] mappingAssemblies;

        private string[] mappingResources;

	    private string[] configFilenames;

        private IDictionary hibernateProperties;

        private IDbProvider dbProvider;

	    private bool exposeTransactionAwareSessionFactory = false;

        private IInterceptor entityInterceptor;

        private INamingStrategy namingStrategy;

        private IObjectDefinition[] typeDefinitions;

        private FilterDefinition[] filterDefinitions;

        private Properties entityCacheStrategies;

        private Properties collectionCacheStrategies;

        private IDictionary eventListeners;

        private bool schemaUpdate = false;

        private IAdoExceptionTranslator adoExceptionTranslator;

	    private IResourceLoader resourceLoader;

        private IApplicationContext applicationContext;

        // Configuration time DB provider. 
        // This will not be available after configuration has been done.
        private static IDbProvider configTimeDbProvider;

#if NH_2_1
        private IBytecodeProvider bytecodeProvider;
#endif
		#endregion

		#region Constants

		/// <summary>
		/// The shared <see cref="ILog"/> instance for this class (and derived classes).
		/// </summary>
		protected static readonly ILog log =
			LogManager.GetLogger(typeof (LocalSessionFactoryObject));

	    #endregion

		#region Constructor (s)
		/// <summary>
		/// Initializes a new instance of the <see cref="LocalSessionFactoryObject"/> class.
        /// </summary>
		public LocalSessionFactoryObject()
		{

		}

		#endregion

		#region Properties

        /// <summary>
        /// Setting the Application Context determines were resources are loaded from
        /// </summary>
	    public IApplicationContext ApplicationContext
	    {
	        set { this.applicationContext = value; }
	    }

        /// <summary>
        /// Gets or sets the <see cref="IResourceLoader"/> to use for loading mapping assemblies etc.
        /// </summary>
	    public IResourceLoader ResourceLoader
	    {
	        get
	        {
                if (resourceLoader == null)
                {
                    resourceLoader = new ConfigurableResourceLoader();
                }
	            return resourceLoader;<commit_msg>Make LocalSessionFactoryObject's ApplicationContext getter protected to allow easier BytecodeProvider integration with inheritance<commit_after>#region License

/*
 * Copyright  2002-2005 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#endregion

#region Imports

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;

using Common.Logging;
using NHibernate;
using NHibernate.Bytecode;
using NHibernate.Cfg;
using NHibernate.Connection;
using NHibernate.Dialect;
using NHibernate.Engine;
using NHibernate.Event;
using NHibernate.Tool.hbm2ddl;
using Spring.Context;
using Spring.Core.IO;
using Spring.Dao;
using Spring.Dao.Attributes;
using Spring.Dao.Support;
using Spring.Data.Common;
using Spring.Data.Support;
using Spring.Objects.Factory;
using Spring.Objects.Factory.Config;
using Spring.Util;

using Environment = NHibernate.Cfg.Environment;
using Configuration = NHibernate.Cfg.Configuration;

#endregion

namespace Spring.Data.NHibernate
{
	/// <summary>
	///  An IFactoryObject that creates a local Hibernate SessionFactory instance.
    /// Behaves like a SessionFactory instance when used as bean reference,
    /// e.g. for HibernateTemplate's "SessionFactory" property.
	/// </summary>
	/// <remarks>
	/// The typical usage will be to register this as singleton factory
	/// in an application context and give objects references to application services
	/// that need it.
	/// <para>
	/// Hibernate configuration settings can be set using the IDictionary property 'HibernateProperties'.
	/// </para>
	/// <para>
	/// This class implements the <see cref="IPersistenceExceptionTranslator"/> interface,
    /// as autodetected by Spring's <see cref="PersistenceExceptionTranslationPostProcessor"/>
    /// for AOP-based translation of PersistenceExceptionTranslationPostProcessor.
    /// Hence, the presence of e.g. LocalSessionFactoryBean automatically enables
    /// a PersistenceExceptionTranslationPostProcessor to translate Hibernate exceptions. 
	/// </para>
	/// </remarks>
	/// <author><NAME> (.NET)</author>
    public class LocalSessionFactoryObject : IFactoryObject, IInitializingObject, IPersistenceExceptionTranslator, IDisposable
        , IApplicationContextAware
	{
		#region Fields

        private Configuration configuration;

	    private ISessionFactory sessionFactory;

        private string[] mappingAssemblies;

        private string[] mappingResources;

	    private string[] configFilenames;

        private IDictionary hibernateProperties;

        private IDbProvider dbProvider;

	    private bool exposeTransactionAwareSessionFactory = false;

        private IInterceptor entityInterceptor;

        private INamingStrategy namingStrategy;

        private IObjectDefinition[] typeDefinitions;

        private FilterDefinition[] filterDefinitions;

        private Properties entityCacheStrategies;

        private Properties collectionCacheStrategies;

        private IDictionary eventListeners;

        private bool schemaUpdate = false;

        private IAdoExceptionTranslator adoExceptionTranslator;

	    private IResourceLoader resourceLoader;

        private IApplicationContext applicationContext;

        // Configuration time DB provider. 
        // This will not be available after configuration has been done.
        private static IDbProvider configTimeDbProvider;

#if NH_2_1
        private IBytecodeProvider bytecodeProvider;
#endif
		#endregion

		#region Constants

		/// <summary>
		/// The shared <see cref="ILog"/> instance for this class (and derived classes).
		/// </summary>
		protected static readonly ILog log =
			LogManager.GetLogger(typeof (LocalSessionFactoryObject));

	    #endregion

		#region Constructor (s)
		/// <summary>
		/// Initializes a new instance of the <see cref="LocalSessionFactoryObject"/> class.
        /// </summary>
		public LocalSessionFactoryObject()
		{

		}

		#endregion

		#region Properties

        /// <summary>
        /// Setting the Application Context determines were resources are loaded from
        /// </summary>
	    public IApplicationContext ApplicationContext
	    {
	        set { this.applicationContext = value; }
            protected get { return this.applicationContext; }
	    }

        /// <summary>
        /// Gets or sets the <see cref="IResourceLoader"/> to use for loading mapping assemblies etc.
        /// </summary>
	    public IResourceLoader ResourceLoader
	    {
	        get
	        {
                if (resourceLoader == null)
                {
                    resourceLoader = new ConfigurableResourceLoader();
                }
	            return resourceLoader;
{'fraction_non_alphanumeric': 0.0799261920947849, 'fraction_numerical': 0.002913469942701758, 'mean_word_length': 3.2222222222222223, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3144031', 'n_tokens_mistral': 2678, 'n_tokens_neox': 2464, 'n_words': 874}