|
From: <aye...@us...> - 2008-10-09 23:48:33
|
Revision: 3824
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3824&view=rev
Author: ayenderahien
Date: 2008-10-09 23:48:30 +0000 (Thu, 09 Oct 2008)
Log Message:
-----------
fixed typo
Added Paths:
-----------
branches/static-proxies/
Removed Paths:
-------------
branches/static-proxis/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aye...@us...> - 2010-01-22 14:04:13
|
Revision: 4922
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4922&view=rev
Author: ayenderahien
Date: 2010-01-22 14:04:02 +0000 (Fri, 22 Jan 2010)
Log Message:
-----------
Creating branch for lazy prop
Modified Paths:
--------------
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmAny.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmArray.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmBag.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmComponent.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmDynamicComponent.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmIdbag.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmKeyManyToOne.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmKeyProperty.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmList.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmManyToOne.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmMap.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmNestedCompositeElement.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmOneToOne.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmPrimitiveArray.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmProperty.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/HbmSet.cs
branches/LazyProps/src/NHibernate/Cfg/MappingSchema/IEntityPropertyMapping.cs
branches/LazyProps/src/NHibernate/Cfg/XmlHbmBinding/PropertiesBinder.cs
branches/LazyProps/src/NHibernate/Engine/StatefulPersistenceContext.cs
branches/LazyProps/src/NHibernate/Intercept/FieldInterceptionHelper.cs
branches/LazyProps/src/NHibernate/Mapping/PersistentClass.cs
branches/LazyProps/src/NHibernate/NHibernate.csproj
branches/LazyProps/src/NHibernate/Proxy/AbstractProxyFactory.cs
branches/LazyProps/src/NHibernate/Proxy/IProxyFactory.cs
branches/LazyProps/src/NHibernate/Proxy/Map/MapProxyFactory.cs
branches/LazyProps/src/NHibernate/Tuple/Entity/AbstractEntityTuplizer.cs
branches/LazyProps/src/NHibernate/Tuple/Entity/PocoEntityTuplizer.cs
branches/LazyProps/src/NHibernate/Tuple/PocoInstantiator.cs
branches/LazyProps/src/NHibernate.ByteCode.Castle/NHibernate.ByteCode.Castle.csproj
branches/LazyProps/src/NHibernate.ByteCode.Castle/ProxyFactory.cs
branches/LazyProps/src/NHibernate.ByteCode.Castle/ProxyFactoryFactory.cs
branches/LazyProps/src/NHibernate.ByteCode.LinFu/NHibernate.ByteCode.LinFu.csproj
branches/LazyProps/src/NHibernate.ByteCode.LinFu/ProxyFactory.cs
branches/LazyProps/src/NHibernate.Test/App.config
branches/LazyProps/src/NHibernate.sln
Added Paths:
-----------
branches/LazyProps/
branches/LazyProps/src/NHibernate/Cfg/Configuration.cs
branches/LazyProps/src/NHibernate/Event/Default/OnLockVisitor.cs
branches/LazyProps/src/NHibernate/Intercept/IFieldInterceptorAccessor.cs
branches/LazyProps/src/NHibernate.ByteCode.Castle/LazyPropertyInterceptor.cs
branches/LazyProps/src/NHibernate.ByteCode.LinFu/FieldInterceptor.cs
branches/LazyProps/src/NHibernate.Test/FilterTest/ConfigFixture.cs
branches/LazyProps/src/NHibernate.Test/HQL/Ast/HqlFixture.cs
branches/LazyProps/src/NHibernate.Test/NHSpecificTest/LazyProperties/
branches/LazyProps/src/NHibernate.Test/NHSpecificTest/LazyProperties/Fixture.cs
branches/LazyProps/src/NHibernate.Test/NHSpecificTest/LazyProperties/Mappings.hbm.xml
branches/LazyProps/src/NHibernate.Test/NHSpecificTest/LazyProperties/Model.cs
branches/LazyProps/src/NHibernate.Test/NHSpecificTest/NH2065/
branches/LazyProps/src/NHibernate.Test/NHibernate.Test.csproj
Removed Paths:
-------------
branches/LazyProps/src/NHibernate/Cfg/Configuration.cs
branches/LazyProps/src/NHibernate/Event/Default/OnLockVisitor.cs
branches/LazyProps/src/NHibernate.Test/FilterTest/ConfigFixture.cs
branches/LazyProps/src/NHibernate.Test/HQL/Ast/HqlFixture.cs
branches/LazyProps/src/NHibernate.Test/NHibernate.Test.csproj
Property changes on: branches/LazyProps
___________________________________________________________________
Added: bugtraq:url
+ http://jira.nhibernate.org/browse/%BUGID%
Added: svn:ignore
+ build
Added: bugtraq:logregex
+ NH-\d+
Added: svn:mergeinfo
+ /branches/2.1.x/nhibernate:4690-4691,4696-4697,4711,4715-4716,4905-4908
Deleted: branches/LazyProps/src/NHibernate/Cfg/Configuration.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Cfg/Configuration.cs 2010-01-10 19:01:42 UTC (rev 4916)
+++ branches/LazyProps/src/NHibernate/Cfg/Configuration.cs 2010-01-22 14:04:02 UTC (rev 4922)
@@ -1,2292 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
-using System.Text;
-using System.Xml;
-using System.Xml.Schema;
-using Iesi.Collections;
-using Iesi.Collections.Generic;
-using log4net;
-using NHibernate.Bytecode;
-using NHibernate.Cfg.ConfigurationSchema;
-using NHibernate.Cfg.MappingSchema;
-using NHibernate.Cfg.XmlHbmBinding;
-using NHibernate.Dialect;
-using NHibernate.Dialect.Function;
-using NHibernate.Dialect.Schema;
-using NHibernate.Engine;
-using NHibernate.Event;
-using NHibernate.Id;
-using NHibernate.Impl;
-using NHibernate.Mapping;
-using NHibernate.Proxy;
-using NHibernate.Tool.hbm2ddl;
-using NHibernate.Type;
-using NHibernate.Util;
-using Array=System.Array;
-using System.Runtime.Serialization;
-
-namespace NHibernate.Cfg
-{
- /// <summary>
- /// Allows the application to specify properties and mapping documents to be used when creating
- /// a <see cref="ISessionFactory" />.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Usually an application will create a single <see cref="Configuration" />, build a single instance
- /// of <see cref="ISessionFactory" />, and then instantiate <see cref="ISession"/> objects in threads
- /// servicing client requests.
- /// </para>
- /// <para>
- /// The <see cref="Configuration" /> is meant only as an initialization-time object. <see cref="ISessionFactory" />
- /// is immutable and does not retain any association back to the <see cref="Configuration" />
- /// </para>
- /// </remarks>
- [Serializable]
- public class Configuration:ISerializable
- {
- /// <summary>Default name for hibernate configuration file.</summary>
- public const string DefaultHibernateCfgFileName = "hibernate.cfg.xml";
-
- private string currentDocumentName;
- private bool preMappingBuildProcessed;
-
- protected IDictionary<string, PersistentClass> classes; // entityName, PersistentClass
- protected IDictionary<string, NHibernate.Mapping.Collection> collections;
- protected IDictionary<string, Table> tables;
- protected IList<SecondPassCommand> secondPasses;
- protected Queue<FilterSecondPassArgs> filtersSecondPasses;
- protected IList<Mappings.PropertyReference> propertyReferences;
- private IInterceptor interceptor;
- private IDictionary<string, string> properties;
- protected IList<IAuxiliaryDatabaseObject> auxiliaryDatabaseObjects;
-
- private INamingStrategy namingStrategy = DefaultNamingStrategy.Instance;
- private MappingsQueue mappingsQueue;
-
- private EventListeners eventListeners;
- protected IDictionary<string, TypeDef> typeDefs;
- protected ISet<ExtendsQueueEntry> extendsQueue;
- protected IDictionary<string, Mappings.TableDescription> tableNameBinding;
- protected IDictionary<Table, Mappings.ColumnNames> columnNameBindingPerTable;
-
- private static readonly ILog log = LogManager.GetLogger(typeof (Configuration));
-
-
- protected internal SettingsFactory settingsFactory;
-
- #region ISerializable Members
- public Configuration(SerializationInfo info, StreamingContext context)
- {
- Reset();
-
- EntityNotFoundDelegate = GetSerialedObject<IEntityNotFoundDelegate>(info, "entityNotFoundDelegate");
-
- auxiliaryDatabaseObjects = GetSerialedObject<IList<IAuxiliaryDatabaseObject>>(info, "auxiliaryDatabaseObjects");
- classes = GetSerialedObject<IDictionary<string, PersistentClass>>(info, "classes");
- collections = GetSerialedObject<IDictionary<string, NHibernate.Mapping.Collection>>(info, "collections");
-
- columnNameBindingPerTable = GetSerialedObject<IDictionary<Table, Mappings.ColumnNames>>(info,
- "columnNameBindingPerTable");
- defaultAssembly = GetSerialedObject<string>(info, "defaultAssembly");
- defaultNamespace = GetSerialedObject<string>(info, "defaultNamespace");
- eventListeners = GetSerialedObject<EventListeners>(info, "eventListeners");
- //this.extendsQueue = GetSerialedObject<ISet<ExtendsQueueEntry>>(info, "extendsQueue");
- FilterDefinitions = GetSerialedObject<IDictionary<string, FilterDefinition>>(info, "filterDefinitions");
- Imports = GetSerialedObject<IDictionary<string, string>>(info, "imports");
- interceptor = GetSerialedObject<IInterceptor>(info, "interceptor");
- mapping = GetSerialedObject<IMapping>(info, "mapping");
- NamedQueries = GetSerialedObject<IDictionary<string, NamedQueryDefinition>>(info, "namedQueries");
- NamedSQLQueries = GetSerialedObject<IDictionary<string, NamedSQLQueryDefinition>>(info, "namedSqlQueries");
- namingStrategy = GetSerialedObject<INamingStrategy>(info, "namingStrategy");
- properties = GetSerialedObject<IDictionary<string, string>>(info, "properties");
- propertyReferences = GetSerialedObject<IList<Mappings.PropertyReference>>(info, "propertyReferences");
- settingsFactory = GetSerialedObject<SettingsFactory>(info, "settingsFactory");
- SqlFunctions = GetSerialedObject<IDictionary<string, ISQLFunction>>(info, "sqlFunctions");
- SqlResultSetMappings = GetSerialedObject<IDictionary<string, ResultSetMappingDefinition>>(info,
- "sqlResultSetMappings");
- tableNameBinding = GetSerialedObject<IDictionary<string, Mappings.TableDescription>>(info, "tableNameBinding");
- tables = GetSerialedObject<IDictionary<string, Table>>(info, "tables");
- typeDefs = GetSerialedObject<IDictionary<string, TypeDef>>(info, "typeDefs");
- filtersSecondPasses = GetSerialedObject<Queue<FilterSecondPassArgs>>(info, "filtersSecondPasses");
- }
-
- private T GetSerialedObject<T>(SerializationInfo info, string name)
- {
- return (T)info.GetValue(name, typeof(T));
- }
-
- public void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- ConfigureProxyFactoryFactory();
- SecondPassCompile();
- Validate();
-
- info.AddValue("entityNotFoundDelegate", EntityNotFoundDelegate);
-
- info.AddValue("auxiliaryDatabaseObjects", auxiliaryDatabaseObjects);
- info.AddValue("classes", classes);
- info.AddValue("collections", collections);
- info.AddValue("columnNameBindingPerTable", columnNameBindingPerTable);
- info.AddValue("defaultAssembly", defaultAssembly);
- info.AddValue("defaultNamespace", defaultNamespace);
- info.AddValue("eventListeners", eventListeners);
- //info.AddValue("extendsQueue", this.extendsQueue);
- info.AddValue("filterDefinitions", FilterDefinitions);
- info.AddValue("imports", Imports);
- info.AddValue("interceptor", interceptor);
- info.AddValue("mapping", mapping);
- info.AddValue("namedQueries", NamedQueries);
- info.AddValue("namedSqlQueries", NamedSQLQueries);
- info.AddValue("namingStrategy", namingStrategy);
- info.AddValue("properties", properties);
- info.AddValue("propertyReferences", propertyReferences);
- info.AddValue("settingsFactory", settingsFactory);
- info.AddValue("sqlFunctions", SqlFunctions);
- info.AddValue("sqlResultSetMappings", SqlResultSetMappings);
- info.AddValue("tableNameBinding", tableNameBinding);
- info.AddValue("tables", tables);
- info.AddValue("typeDefs", typeDefs);
- info.AddValue("filtersSecondPasses", filtersSecondPasses);
- }
- #endregion
-
- /// <summary>
- /// Clear the internal state of the <see cref="Configuration"/> object.
- /// </summary>
- protected void Reset()
- {
- classes = new Dictionary<string, PersistentClass>(); //new SequencedHashMap(); - to make NH-369 bug deterministic
- Imports = new Dictionary<string, string>();
- collections = new Dictionary<string, NHibernate.Mapping.Collection>();
- tables = new Dictionary<string, Table>();
- NamedQueries = new Dictionary<string, NamedQueryDefinition>();
- NamedSQLQueries = new Dictionary<string, NamedSQLQueryDefinition>();
- SqlResultSetMappings = new Dictionary<string, ResultSetMappingDefinition>();
- secondPasses = new List<SecondPassCommand>();
- propertyReferences = new List<Mappings.PropertyReference>();
- FilterDefinitions = new Dictionary<string, FilterDefinition>();
- interceptor = emptyInterceptor;
- properties = Environment.Properties;
- auxiliaryDatabaseObjects = new List<IAuxiliaryDatabaseObject>();
- SqlFunctions = new Dictionary<string, ISQLFunction>();
- mappingsQueue = new MappingsQueue();
- eventListeners = new EventListeners();
- typeDefs = new Dictionary<string, TypeDef>();
- extendsQueue = new HashedSet<ExtendsQueueEntry>();
- tableNameBinding = new Dictionary<string, Mappings.TableDescription>();
- columnNameBindingPerTable = new Dictionary<Table, Mappings.ColumnNames>();
- filtersSecondPasses = new Queue<FilterSecondPassArgs>();
- }
- [Serializable]
- private class Mapping : IMapping
- {
- private readonly Configuration configuration;
-
- public Mapping(Configuration configuration)
- {
- this.configuration = configuration;
- }
-
- private PersistentClass GetPersistentClass(string className)
- {
- PersistentClass pc = configuration.classes[className];
- if (pc == null)
- {
- throw new MappingException("persistent class not known: " + className);
- }
- return pc;
- }
-
- public IType GetIdentifierType(string className)
- {
- return GetPersistentClass(className).Identifier.Type;
- }
-
- public string GetIdentifierPropertyName(string className)
- {
- PersistentClass pc = GetPersistentClass(className);
- if (!pc.HasIdentifierProperty)
- {
- return null;
- }
- return pc.IdentifierProperty.Name;
- }
-
- public IType GetReferencedPropertyType(string className, string propertyName)
- {
- PersistentClass pc = GetPersistentClass(className);
- Property prop = pc.GetProperty(propertyName);
-
- if (prop == null)
- {
- throw new MappingException("property not known: " + pc.MappedClass.FullName + '.' + propertyName);
- }
- return prop.Type;
- }
-
- public bool HasNonIdentifierPropertyNamedId(string className)
- {
- return "id".Equals(GetIdentifierPropertyName(className));
- }
- }
-
- private IMapping mapping;
-
- protected Configuration(SettingsFactory settingsFactory)
- {
- InitBlock();
- this.settingsFactory = settingsFactory;
- Reset();
- }
-
- private void InitBlock()
- {
- mapping = BuildMapping();
- }
-
- public virtual IMapping BuildMapping()
- {
- return new Mapping(this);
- }
-
- /// <summary>
- /// Create a new Configuration object.
- /// </summary>
- public Configuration() : this(new SettingsFactory()) {}
-
- /// <summary>
- /// The class mappings
- /// </summary>
- public ICollection<PersistentClass> ClassMappings
- {
- get { return classes.Values; }
- }
-
- /// <summary>
- /// The collection mappings
- /// </summary>
- public ICollection<NHibernate.Mapping.Collection> CollectionMappings
- {
- get { return collections.Values; }
- }
-
- /// <summary>
- /// The table mappings
- /// </summary>
- private ICollection<Table> TableMappings
- {
- get { return tables.Values; }
- }
-
- /// <summary>
- /// Get the mapping for a particular class
- /// </summary>
- public PersistentClass GetClassMapping(System.Type persistentClass)
- {
- // TODO NH: Remove this method
- return GetClassMapping(persistentClass.FullName);
- }
-
- /// <summary> Get the mapping for a particular entity </summary>
- /// <param name="entityName">An entity name. </param>
- /// <returns> the entity mapping information </returns>
- public PersistentClass GetClassMapping(string entityName)
- {
- PersistentClass result;
- classes.TryGetValue(entityName, out result);
- return result;
- }
-
- /// <summary>
- /// Get the mapping for a particular collection role
- /// </summary>
- /// <param name="role">a collection role</param>
- /// <returns><see cref="NHibernate.Mapping.Collection" /></returns>
- public NHibernate.Mapping.Collection GetCollectionMapping(string role)
- {
- return collections.ContainsKey(role) ? collections[role] : null;
- }
-
- /// <summary>
- /// Read mappings from a particular XML file. This method is equivalent
- /// to <see cref="AddXmlFile(string)" />.
- /// </summary>
- /// <param name="xmlFile"></param>
- /// <returns></returns>
- public Configuration AddFile(string xmlFile)
- {
- return AddXmlFile(xmlFile);
- }
-
- public Configuration AddFile(FileInfo xmlFile)
- {
- return AddFile(xmlFile.FullName);
- }
-
- private static void LogAndThrow(Exception exception)
- {
- if (log.IsErrorEnabled)
- {
- log.Error(exception.Message, exception);
- }
-
- throw exception;
- }
-
- /// <summary>
- /// Read mappings from a particular XML file.
- /// </summary>
- /// <param name="xmlFile">a path to a file</param>
- /// <returns>This configuration object.</returns>
- public Configuration AddXmlFile(string xmlFile)
- {
- log.Info("Mapping file: " + xmlFile);
- XmlTextReader textReader = null;
- try
- {
- textReader = new XmlTextReader(xmlFile);
- AddXmlReader(textReader, xmlFile);
- }
- catch (MappingException)
- {
- throw;
- }
- catch (Exception e)
- {
- LogAndThrow(new MappingException("Could not configure datastore from file " + xmlFile, e));
- }
- finally
- {
- if (textReader != null)
- {
- textReader.Close();
- }
- }
- return this;
- }
-
- public Configuration AddXml(string xml)
- {
- return AddXml(xml, "(string)");
- }
-
- /// <summary>
- /// Read mappings from a <see cref="string" />. This method is equivalent to
- /// <see cref="AddXmlString(string)" />.
- /// </summary>
- /// <param name="xml">an XML string</param>
- /// <param name="name">The name to use in error reporting. May be <see langword="null" />.</param>
- /// <returns>This configuration object.</returns>
- public Configuration AddXml(string xml, string name)
- {
- if (log.IsDebugEnabled)
- {
- log.Debug("Mapping XML:\n" + xml);
- }
- XmlTextReader reader = null;
- try
- {
- reader = new XmlTextReader(xml, XmlNodeType.Document, null);
- // make a StringReader for the string passed in - the StringReader
- // inherits from TextReader. We can use the XmlTextReader.ctor that
- // takes the TextReader to build from a string...
- AddXmlReader(reader, name);
- }
- catch (MappingException)
- {
- throw;
- }
- catch (Exception e)
- {
- LogAndThrow(new MappingException("Could not configure datastore from XML string " + name, e));
- }
- finally
- {
- if (reader != null)
- {
- reader.Close();
- }
- }
- return this;
- }
-
- /// <summary>
- /// Read mappings from a <see cref="string" />.
- /// </summary>
- /// <param name="xml">an XML string</param>
- /// <returns>This configuration object.</returns>
- public Configuration AddXmlString(string xml)
- {
- return AddXml(xml);
- }
-
- /// <summary>
- /// Read mappings from a URL.
- /// </summary>
- /// <param name="url">a URL</param>
- /// <returns>This configuration object.</returns>
- public Configuration AddUrl(string url)
- {
- // AddFile works for URLs currently
- return AddFile(url);
- }
-
- /// <summary>
- /// Read mappings from a URL.
- /// </summary>
- /// <param name="url">a <see cref="Uri" /> to read the mappings from.</param>
- /// <returns>This configuration object.</returns>
- public Configuration AddUrl(Uri url)
- {
- return AddUrl(url.AbsolutePath);
- }
-
- public Configuration AddDocument(XmlDocument doc)
- {
- return AddDocument(doc, "(XmlDocument)");
- }
-
- /// <summary>
- /// Read mappings from an <see cref="XmlDocument" />.
- /// </summary>
- /// <param name="doc">A loaded <see cref="XmlDocument" /> that contains the mappings.</param>
- /// <param name="name">The name of the document, for error reporting purposes.</param>
- /// <returns>This configuration object.</returns>
- public Configuration AddDocument(XmlDocument doc, string name)
- {
- if (log.IsDebugEnabled)
- {
- log.Debug("Mapping XML:\n" + doc.OuterXml);
- }
-
- try
- {
- using (var ms = new MemoryStream())
- {
- doc.Save(ms);
- ms.Position = 0;
- AddInputStream(ms, name);
- }
- return this;
- }
- catch (MappingException)
- {
- throw;
- }
- catch (Exception e)
- {
- LogAndThrow(new MappingException("Could not configure datastore from XML document " + name, e));
- return this; // To please the compiler
- }
- }
-
- /// <summary>
- /// Takes the validated XmlDocument and has the Binder do its work of
- /// creating Mapping objects from the Mapping Xml.
- /// </summary>
- /// <param name="doc">The NamedXmlDocument that contains the <b>validated</b> mapping XML file.</param>
- private void AddValidatedDocument(NamedXmlDocument doc)
- {
- AddDeserializedMapping(doc.Document, doc.Name);
- }
-
- /// <summary>
- /// Add mapping data using deserialized class.
- /// </summary>
- /// <param name="mappingDocument">Mapping metadata.</param>
- /// <param name="documentFileName">XML file's name where available; otherwise null.</param>
- public void AddDeserializedMapping(HbmMapping mappingDocument, string documentFileName)
- {
- if (mappingDocument == null)
- {
- throw new ArgumentNullException("mappingDocument");
- }
- try
- {
- Dialect.Dialect dialect = Dialect.Dialect.GetDialect(properties);
- Mappings mappings = CreateMappings(dialect);
-
- new MappingRootBinder(mappings, dialect).Bind(mappingDocument);
- }
- catch (Exception e)
- {
- var message = documentFileName == null
- ? "Could not compile deserialized mapping document."
- : "Could not compile the mapping document: " + documentFileName;
- LogAndThrow(new MappingException(message, e));
- }
- }
-
- /// <summary>
- /// Create a new <see cref="Mappings" /> to add classes and collection
- /// mappings to.
- /// </summary>
- public Mappings CreateMappings(Dialect.Dialect dialect)
- {
- ProcessPreMappingBuildProperties();
- return new Mappings(classes, collections, tables, NamedQueries, NamedSQLQueries, SqlResultSetMappings, Imports,
- secondPasses, filtersSecondPasses, propertyReferences, namingStrategy, typeDefs, FilterDefinitions, extendsQueue,
- auxiliaryDatabaseObjects, tableNameBinding, columnNameBindingPerTable, defaultAssembly,
- defaultNamespace, dialect);
- }
-
- private void ProcessPreMappingBuildProperties()
- {
- if(preMappingBuildProcessed)
- {
- return;
- }
- ConfigureCollectionTypeFactory();
- preMappingBuildProcessed = true;
- }
-
- private void ConfigureCollectionTypeFactory()
- {
- var ctfc = GetProperty(Environment.CollectionTypeFactoryClass);
- if(string.IsNullOrEmpty(ctfc))
- {
- return;
- }
- var ictfc = Environment.BytecodeProvider as IInjectableCollectionTypeFactoryClass;
- if(ictfc == null)
- {
- return;
- }
- ictfc.SetCollectionTypeFactoryClass(ctfc);
- }
-
- /// <summary>
- /// Read mappings from a <see cref="Stream" />.
- /// </summary>
- /// <param name="xmlInputStream">The stream containing XML</param>
- /// <returns>This Configuration object.</returns>
- /// <remarks>
- /// The <see cref="Stream"/> passed in through the parameter <paramref name="xmlInputStream" />
- /// is not <em>guaranteed</em> to be cleaned up by this method. It is the caller's responsiblity to
- /// ensure that <paramref name="xmlInputStream" /> is properly handled when this method
- /// completes.
- /// </remarks>
- public Configuration AddInputStream(Stream xmlInputStream)
- {
- return AddInputStream(xmlInputStream, null);
- }
-
- /// <summary>
- /// Read mappings from a <see cref="Stream" />.
- /// </summary>
- /// <param name="xmlInputStream">The stream containing XML</param>
- /// <param name="name">The name of the stream to use in error reporting. May be <see langword="null" />.</param>
- /// <returns>This Configuration object.</returns>
- /// <remarks>
- /// The <see cref="Stream"/> passed in through the parameter <paramref name="xmlInputStream" />
- /// is not <em>guaranteed</em> to be cleaned up by this method. It is the caller's responsiblity to
- /// ensure that <paramref name="xmlInputStream" /> is properly handled when this method
- /// completes.
- /// </remarks>
- public Configuration AddInputStream(Stream xmlInputStream, string name)
- {
- XmlTextReader textReader = null;
- try
- {
- textReader = new XmlTextReader(xmlInputStream);
- AddXmlReader(textReader, name);
- return this;
- }
- catch (MappingException)
- {
- throw;
- }
- catch (Exception e)
- {
- LogAndThrow(new MappingException("Could not configure datastore from input stream " + name, e));
- return this; // To please the compiler
- }
- finally
- {
- if (textReader != null)
- {
- textReader.Close();
- }
- }
- }
-
- /// <summary>
- /// Adds the mappings in the resource of the assembly.
- /// </summary>
- /// <param name="path">The path to the resource file in the assembly.</param>
- /// <param name="assembly">The assembly that contains the resource file.</param>
- /// <returns>This configuration object.</returns>
- public Configuration AddResource(string path, Assembly assembly)
- {
- string debugName = path;
- log.Info("Mapping resource: " + debugName);
- Stream rsrc = assembly.GetManifestResourceStream(path);
- if (rsrc == null)
- {
- LogAndThrow(new MappingException("Resource not found: " + debugName));
- }
-
- try
- {
- return AddInputStream(rsrc, debugName);
- }
- catch (MappingException)
- {
- throw;
- }
- catch (Exception e)
- {
- LogAndThrow(new MappingException("Could not configure datastore from resource " + debugName, e));
- return this; // To please the compiler
- }
- finally
- {
- if (rsrc != null)
- {
- rsrc.Close();
- }
- }
- }
-
- /// <summary>
- /// Adds the mappings from ebedded resources of the assembly.
- /// </summary>
- /// <param name="paths">Paths to the resource files in the assembly.</param>
- /// <param name="assembly">The assembly that contains the resource files.</param>
- /// <returns>This configuration object.</returns>
- public Configuration AddResources(IEnumerable<string> paths, Assembly assembly)
- {
- if (paths == null)
- {
- throw new ArgumentNullException("paths");
- }
- foreach (var path in paths)
- {
- AddResource(path, assembly);
- }
- return this;
- }
-
- /// <summary>
- /// Read a mapping from an embedded resource, using a convention.
- /// </summary>
- /// <param name="persistentClass">The type to map.</param>
- /// <returns>This configuration object.</returns>
- /// <remarks>
- /// The convention is for class <c>Foo.Bar.Foo</c> to be mapped by
- /// the resource named <c>Foo.Bar.Foo.hbm.xml</c>, embedded in
- /// the class' assembly. If the mappings and classes are defined
- /// in different assemblies or don't follow the naming convention,
- /// this method cannot be used.
- /// </remarks>
- public Configuration AddClass(System.Type persistentClass)
- {
- return AddResource(persistentClass.FullName + ".hbm.xml", persistentClass.Assembly);
- }
-
- /// <summary>
- /// Adds all of the assembly's embedded resources whose names end with <c>.hbm.xml</c>.
- /// </summary>
- /// <param name="assemblyName">The name of the assembly to load.</param>
- /// <returns>This configuration object.</returns>
- /// <remarks>
- /// The assembly must be loadable using <see cref="Assembly.Load(string)" />. If this
- /// condition is not satisfied, load the assembly manually and call
- /// <see cref="AddAssembly(Assembly)"/> instead.
- /// </remarks>
- public Configuration AddAssembly(string assemblyName)
- {
- log.Info("Searching for mapped documents in assembly: " + assemblyName);
-
- Assembly assembly = null;
- try
- {
- assembly = Assembly.Load(assemblyName);
- }
- catch (Exception e)
- {
- LogAndThrow(new MappingException("Could not add assembly " + assemblyName, e));
- }
-
- return AddAssembly(assembly);
- }
-
- /// <summary>
- /// Adds all of the assembly's embedded resources whose names end with <c>.hbm.xml</c>.
- /// </summary>
- /// <param name="assembly">The assembly.</param>
- /// <returns>This configuration object.</returns>
- public Configuration AddAssembly(Assembly assembly)
- {
- IList<string> resourceNames = GetAllHbmXmlResourceNames(assembly);
- if (resourceNames.Count == 0)
- {
- log.Warn("No mapped documents found in assembly: " + assembly.FullName);
- }
- foreach (var name in resourceNames)
- {
- AddResource(name, assembly);
- }
- return this;
- }
-
- private static IList<string> GetAllHbmXmlResourceNames(Assembly assembly)
- {
- var result = new List<string>();
-
- foreach (var resource in assembly.GetManifestResourceNames())
- {
- if (resource.EndsWith(".hbm.xml"))
- {
- result.Add(resource);
- }
- }
-
- return result;
- }
-
- /// <summary>
- /// Read all mapping documents from a directory tree. Assume that any
- /// file named <c>*.hbm.xml</c> is a mapping document.
- /// </summary>
- /// <param name="dir">a directory</param>
- public Configuration AddDirectory(DirectoryInfo dir)
- {
- foreach (var subDirectory in dir.GetDirectories())
- {
- AddDirectory(subDirectory);
- }
-
- foreach (var hbmXml in dir...
[truncated message content] |
|
From: <jul...@us...> - 2011-02-10 14:29:45
|
Revision: 5377
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5377&view=rev
Author: julian-maughan
Date: 2011-02-10 14:29:39 +0000 (Thu, 10 Feb 2011)
Log Message:
-----------
Renamed feature branch to something more appropriate
Added Paths:
-----------
branches/ReadOnlyEntities/
Removed Paths:
-------------
branches/ReadOnlyCriteria/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|