Spring.Core
IObjectFactory Interface
Members  See Also  Send comments on this topic.
Spring.Objects.Factory Namespace : IObjectFactory Interface


The root interface for accessing a Spring.NET IoC container.

Syntax

Visual Basic (Declaration)  
<DefaultMemberAttribute("Item")>
Public Interface IObjectFactory 
Visual Basic (Usage) Copy Code
Dim instance As IObjectFactory
C#  
[DefaultMemberAttribute("Item")]
public interface IObjectFactory 

Remarks

This is the basic client view of a Spring.NET IoC container; further interfaces such as Spring.Objects.Factory.IListableObjectFactory and Spring.Objects.Factory.Config.IConfigurableObjectFactory are available for specific purposes such as enumeration and configuration.

This is the root interface to be implemented by objects that can hold a number of object definitions, each uniquely identified by a String name. An independent instance of any of these objects can be obtained (the Prototype design pattern), or a single shared instance can be obtained (a superior alternative to the Singleton design pattern, in which the instance is a singleton in the scope of the factory). Which type of instance will be returned depends on the object factory configuration - the API is the same. The Singleton approach is more useful and hence more common in practice.

The point of this approach is that the IObjectFactory is a central registry of application components, and centralizes the configuring of application components (no more do individual objects need to read properties files, for example). See chapters 4 and 11 of "Expert One-on-One J2EE Design and Development" for a discussion of the benefits of this approach.

Normally an IObjectFactory will load object definitions stored in a configuration source (such as an XML document), and use the Spring.Objects Namespace namespace to configure the objects. However, an implementation could simply return .NET objects it creates as necessary directly in .NET code. There are no constraints on how the definitions could be stored: LDAP, RDBMS, XML, properties file etc. Implementations are encouraged to support references amongst objects, to either Singletons or Prototypes.

In contrast to the methods in Spring.Objects.Factory.IListableObjectFactory, all of the methods in this interface will also check parent factories if this is an Spring.Objects.Factory.IHierarchicalObjectFactory. If an object is not found in this factory instance, the immediate parent is asked. Objects in this factory instance are supposed to override objects of the same name in any parent factory.

Object factories are supposed to support the standard object lifecycle interfaces as far as possible. The maximum set of initialization methods and their standard order is:

On shutdown of an object factory, the following lifecycle methods apply:

Requirements

Namespace: Spring.Objects.Factory

Platforms:Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family, Windows 7

Assembly: Spring.Core (in Spring.Core.dll)

See Also

© 2011 All Rights Reserved.