C# Class Castle.Facilities.NHibernateIntegration.NHibernateFacility

Provides a basic level of integration with the NHibernate project
This facility allows components to gain access to the NHibernate's objects: NHibernate.Cfg.Configuration NHibernate.ISessionFactory

It also allow you to obtain the ISession instance through the component ISessionManager, which is transaction aware and save you the burden of sharing session or using a singleton.

Inheritance: Castle.MicroKernel.Facilities.AbstractFacility
Show file Open project: nats/castle-1.0.3-mono

Protected Methods

Method Description
ApplyConfigurationSettings ( NHibernate.Cfg.Configuration cfg, IConfiguration facilityConfig ) : void
ConfigureFacility ( ) : void
GenerateMappingFromAttributesIfNeeded ( NHibernate.Cfg.Configuration cfg, String targetAssembly ) : void

If targetAssembly has a reference on NHibernate.Mapping.Attributes : use the NHibernate mapping attributes contained in that assembly to update NHibernate configuration (cfg). Else do nothing

To avoid an unnecessary dependency on the library NHibernate.Mapping.Attributes.dll when using this facility without NHibernate mapping attributes, all calls to that library are made using reflexion.

Init ( ) : void
RegisterAssemblies ( NHibernate.Cfg.Configuration cfg, IConfiguration facilityConfig ) : void
RegisterComponents ( ) : void
RegisterResources ( NHibernate.Cfg.Configuration cfg, IConfiguration facilityConfig ) : void
RegisterSessionFactoryResolver ( ) : void
RegisterSessionManager ( ) : void
RegisterSessionStore ( ) : void
RegisterTransactionManager ( ) : void

Private Methods

Method Description
AssertHasAtLeastOneFactoryConfigured ( ) : void
AssertHasConfig ( ) : void
ConfigureFactories ( IConfiguration config, ISessionFactoryResolver sessionFactoryResolver, bool firstFactory ) : void
ConfigureReflectionOptimizer ( IConfiguration config ) : void

Reads the attribute useReflectionOptimizer and configure the reflection optimizer accordingly.

As reported on Jira (FACILITIES-39) the reflection optimizer slow things down. So by default it will be disabled. You can use the attribute useReflectionOptimizer to turn it on.

ObtainAssembly ( String assembly ) : Assembly

Method Details

ApplyConfigurationSettings() protected method

protected ApplyConfigurationSettings ( NHibernate.Cfg.Configuration cfg, IConfiguration facilityConfig ) : void
cfg NHibernate.Cfg.Configuration
facilityConfig IConfiguration
return void

ConfigureFacility() protected method

protected ConfigureFacility ( ) : void
return void

GenerateMappingFromAttributesIfNeeded() protected method

If targetAssembly has a reference on NHibernate.Mapping.Attributes : use the NHibernate mapping attributes contained in that assembly to update NHibernate configuration (cfg). Else do nothing
To avoid an unnecessary dependency on the library NHibernate.Mapping.Attributes.dll when using this facility without NHibernate mapping attributes, all calls to that library are made using reflexion.
protected GenerateMappingFromAttributesIfNeeded ( NHibernate.Cfg.Configuration cfg, String targetAssembly ) : void
cfg NHibernate.Cfg.Configuration NHibernate configuration
targetAssembly String Target assembly name
return void

Init() protected method

protected Init ( ) : void
return void

RegisterAssemblies() protected method

protected RegisterAssemblies ( NHibernate.Cfg.Configuration cfg, IConfiguration facilityConfig ) : void
cfg NHibernate.Cfg.Configuration
facilityConfig IConfiguration
return void

RegisterComponents() protected method

protected RegisterComponents ( ) : void
return void

RegisterResources() protected method

protected RegisterResources ( NHibernate.Cfg.Configuration cfg, IConfiguration facilityConfig ) : void
cfg NHibernate.Cfg.Configuration
facilityConfig IConfiguration
return void

RegisterSessionFactoryResolver() protected method

protected RegisterSessionFactoryResolver ( ) : void
return void

RegisterSessionManager() protected method

protected RegisterSessionManager ( ) : void
return void

RegisterSessionStore() protected method

protected RegisterSessionStore ( ) : void
return void

RegisterTransactionManager() protected method

protected RegisterTransactionManager ( ) : void
return void