See Also

IObjectFactory Members  | Spring.Objects.Factory Namespace

Requirements

Namespace: Spring.Objects.Factory

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

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

Language

Visual Basic

C#

Show All

See Also Requirements Languages Spring.Core Send comments on this topic.

IObjectFactory Interface

Spring.Objects.Factory Namespace : IObjectFactory Interface

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

For a list of all members of this type, see IObjectFactory members.

Syntax

[Visual Basic]
<DefaultMemberAttribute("Item")> Public Interface IObjectFactory
[C#]
[DefaultMemberAttribute("Item")] public interface IObjectFactory

Remarks

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

This si 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 Objects 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 IListableObjectFactory, all of the methods in this interface will also check parent factories if this is an 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 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

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

See Also

IObjectFactory Members  | Spring.Objects.Factory Namespace

 

 


© 2004-2006 Spring.NET Authors. All Rights Reserved.