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
Afficher le fichier Open project: spring-projects/spring-net Class Usage Examples

Private Properties

Свойство Type Description
CreateCaseInsensitiveDictionary IDictionary
CreateCaseSensitiveDictionary IDictionary
EnsureEventHandlersRegistered void
GetObjectScope ObjectScope
IsWebScopedSingleton bool
OnEndRequest void
OnEndSession void
WebObjectFactory System

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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

Méthode 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 méthode

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.
Résultat void

ConfigureObject() protected méthode

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. ///
Résultat object

CreateAndCacheScopedSingletonInstance() protected méthode

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
Résultat object

CreateAndCacheSingletonInstance() protected méthode

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. ///
Résultat object

CreateObjectDictionary() protected méthode

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

CreateRootObjectDefinition() protected méthode

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

GetScopedSingleton() protected méthode

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
Résultat object

GetSingleton() public méthode

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.
Résultat object

RegisterDisposableObjectIfNecessary() protected méthode

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
Résultat void

RemoveEagerlyCachedSingleton() protected méthode

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.
Résultat void

WebObjectFactory() public méthode

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.
Résultat System

WebObjectFactory() public méthode

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. ///
Résultat System