C# Class Spring.Objects.Factory.Support.WebObjectFactory

Concrete implementation of Spring.Objects.Factory.IListableObjectFactory that knows how to handle IWebObjectDefinitions.

This class should only be used within the context of an ASP.NET web application.

Inheritance: Spring.Objects.Factory.Support.DefaultListableObjectFactory
Datei anzeigen Open project: spring-projects/spring-net Class Usage Examples

Private Properties

Property Type Description
CreateCaseInsensitiveDictionary IDictionary
CreateCaseSensitiveDictionary IDictionary
EnsureEventHandlersRegistered void
GetObjectScope ObjectScope
IsWebScopedSingleton bool
OnEndRequest void
OnEndSession void
WebObjectFactory System

Public Methods

Method Description
GetSingleton ( string objectName ) : object

Tries to find cached object for the specified name.

This implementation tries to find object first in the Request scope, then in the Session scope and finally in the Application scope.

WebObjectFactory ( string contextPath, bool caseSensitive ) : System

Creates a new instance of the Spring.Objects.Factory.Support.WebObjectFactory class.

WebObjectFactory ( string contextPath, bool caseSensitive, IObjectFactory parentFactory ) : System

Creates a new instance of the Spring.Objects.Factory.Support.WebObjectFactory class.

Protected Methods

Method Description
AddEagerlyCachedSingleton ( string objectName, IObjectDefinition objectDefinition, object rawSingletonInstance ) : void

Add the created, but yet unpopulated singleton to the singleton cache to be able to resolve circular references

Derived classes may override this method to select the right cache based on the object definition.

ConfigureObject ( string name, Spring.Objects.Factory.Support.RootObjectDefinition definition, IObjectWrapper wrapper ) : object

Configures object instance by injecting dependencies, satisfying Spring lifecycle interfaces and applying object post-processors.

CreateAndCacheScopedSingletonInstance ( string objectName, Spring.Objects.Factory.Support.RootObjectDefinition objectDefinition, object arguments, IDictionary scopedSingletonCache ) : object

Creates a singleton instance for the specified object name and definition and caches the instance in the specified dictionary

If the object is successfully created, scopedSingletonCache contains the cached instance with the key objectName.

CreateAndCacheSingletonInstance ( string objectName, Spring.Objects.Factory.Support.RootObjectDefinition objectDefinition, object arguments ) : object

Creates a singleton instance for the specified object name and definition.

CreateObjectDictionary ( ) : IDictionary

Creates a dictionary matching this factory's case sensitivity behaviour.

CreateRootObjectDefinition ( IObjectDefinition templateDefinition ) : Spring.Objects.Factory.Support.RootObjectDefinition

Creates the root object definition.

GetScopedSingleton ( string objectName, IDictionary scopedSingletonCache ) : object

Looks up an objectName in the specified cache dictionary.

RegisterDisposableObjectIfNecessary ( string name, object instance, Spring.Objects.Factory.Support.RootObjectDefinition objectDefinition ) : void

We need this override so that Web Scoped Singletons are not registered in general DisposalObjectRegister

RemoveEagerlyCachedSingleton ( string objectName, IObjectDefinition objectDefinition ) : void

Remove the specified singleton from the singleton cache that has been added before by a call to AddEagerlyCachedSingleton

Derived classes may override this method to select the right cache based on the object definition.

Private Methods

Method Description
CreateCaseInsensitiveDictionary ( ) : IDictionary

Creates a case insensitive hashtable instance

CreateCaseSensitiveDictionary ( ) : IDictionary

Creates a case sensitive hashtable instance

EnsureEventHandlersRegistered ( ) : void

Registers events handlers with WebSupportModule to ensure proper disposal of 'request'- and 'session'-scoped objects

GetObjectScope ( IObjectDefinition objectDefinition ) : ObjectScope
IsWebScopedSingleton ( IObjectDefinition objectDefinition ) : bool
OnEndRequest ( HttpContext context ) : void

Disposes all 'request'-scoped objects at the end of each Request

OnEndSession ( System.Web.SessionState.HttpSessionState session, CacheItemRemovedReason reason ) : void

Disposes all 'session'-scoped objects at the end of a session

WebObjectFactory ( ) : System

Method Details

AddEagerlyCachedSingleton() protected method

Add the created, but yet unpopulated singleton to the singleton cache to be able to resolve circular references
Derived classes may override this method to select the right cache based on the object definition.
protected AddEagerlyCachedSingleton ( string objectName, IObjectDefinition objectDefinition, object rawSingletonInstance ) : void
objectName string the name of the object to add to the cache.
objectDefinition IObjectDefinition the definition used to create and populated the object.
rawSingletonInstance object the raw object instance.
return void

ConfigureObject() protected method

Configures object instance by injecting dependencies, satisfying Spring lifecycle interfaces and applying object post-processors.
protected ConfigureObject ( string name, Spring.Objects.Factory.Support.RootObjectDefinition definition, IObjectWrapper wrapper ) : object
name string /// The name of the object definition expressing the dependencies that are to /// be injected into the supplied instance. ///
definition Spring.Objects.Factory.Support.RootObjectDefinition /// An object definition that should be used to configure object. ///
wrapper IObjectWrapper /// A wrapped object instance that is to be so configured. ///
return object

CreateAndCacheScopedSingletonInstance() protected method

Creates a singleton instance for the specified object name and definition and caches the instance in the specified dictionary
If the object is successfully created, scopedSingletonCache contains the cached instance with the key objectName.
protected CreateAndCacheScopedSingletonInstance ( string objectName, Spring.Objects.Factory.Support.RootObjectDefinition objectDefinition, object arguments, IDictionary scopedSingletonCache ) : object
objectName string /// The object name (will be used as the key in the singleton cache key). ///
objectDefinition Spring.Objects.Factory.Support.RootObjectDefinition The object definition.
arguments object /// The arguments to use if creating a prototype using explicit arguments to /// a static factory method. It is invalid to use a non-null arguments value /// in any other case. ///
scopedSingletonCache IDictionary the dictionary to be used for caching singleton instances
return object

CreateAndCacheSingletonInstance() protected method

Creates a singleton instance for the specified object name and definition.
protected CreateAndCacheSingletonInstance ( string objectName, Spring.Objects.Factory.Support.RootObjectDefinition objectDefinition, object arguments ) : object
objectName string /// The object name (will be used as the key in the singleton cache key). ///
objectDefinition Spring.Objects.Factory.Support.RootObjectDefinition The object definition.
arguments object /// The arguments to use if creating a prototype using explicit arguments to /// a static factory method. It is invalid to use a non-null arguments value /// in any other case. ///
return object

CreateObjectDictionary() protected method

Creates a dictionary matching this factory's case sensitivity behaviour.
protected CreateObjectDictionary ( ) : IDictionary
return IDictionary

CreateRootObjectDefinition() protected method

Creates the root object definition.
protected CreateRootObjectDefinition ( IObjectDefinition templateDefinition ) : Spring.Objects.Factory.Support.RootObjectDefinition
templateDefinition IObjectDefinition The template definition.
return Spring.Objects.Factory.Support.RootObjectDefinition

GetScopedSingleton() protected method

Looks up an objectName in the specified cache dictionary.
protected GetScopedSingleton ( string objectName, IDictionary scopedSingletonCache ) : object
objectName string the name to lookup.
scopedSingletonCache IDictionary the cache dictionary to search
return object

GetSingleton() public method

Tries to find cached object for the specified name.
This implementation tries to find object first in the Request scope, then in the Session scope and finally in the Application scope.
public GetSingleton ( string objectName ) : object
objectName string Object name to look for.
return object

RegisterDisposableObjectIfNecessary() protected method

We need this override so that Web Scoped Singletons are not registered in general DisposalObjectRegister
protected RegisterDisposableObjectIfNecessary ( string name, object instance, Spring.Objects.Factory.Support.RootObjectDefinition objectDefinition ) : void
name string
instance object
objectDefinition Spring.Objects.Factory.Support.RootObjectDefinition
return void

RemoveEagerlyCachedSingleton() protected method

Remove the specified singleton from the singleton cache that has been added before by a call to AddEagerlyCachedSingleton
Derived classes may override this method to select the right cache based on the object definition.
protected RemoveEagerlyCachedSingleton ( string objectName, IObjectDefinition objectDefinition ) : void
objectName string the name of the object to remove from the cache.
objectDefinition IObjectDefinition the definition used to create and populated the object.
return void

WebObjectFactory() public method

Creates a new instance of the Spring.Objects.Factory.Support.WebObjectFactory class.
public WebObjectFactory ( string contextPath, bool caseSensitive ) : System
contextPath string The virtual path resources will be relative resolved to.
caseSensitive bool Flag specifying whether to make this object factory case sensitive or not.
return System

WebObjectFactory() public method

Creates a new instance of the Spring.Objects.Factory.Support.WebObjectFactory class.
public WebObjectFactory ( string contextPath, bool caseSensitive, IObjectFactory parentFactory ) : System
contextPath string The virtual path resources will be relative resolved to.
caseSensitive bool Flag specifying whether to make this object factory case sensitive or not.
parentFactory IObjectFactory /// The parent object factory. ///
return System