The Spring.NET Framework

Reference Documentation

Authors

Mark Pollack, Rick Evans, Aleksandar Seovic, Bruno Baia, Federico Spinazzi, Rob Harrop, Griffin Caprio, Ruben Bartelink, Choy Rim, The Spring Java Team

Version 1.1.1

Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.

Last Updated April 7, 2008


1. Preface
2. Introduction
2.1. Overview
2.2. Background
2.3. Modules
2.4. Quickstart applications
2.5. License Information
2.6. Support
3. Background information
3.1. Inversion of Control
4. Migrating from 1.1 M2
4.1. Introduction
4.2. Important Changes
4.2.1. Namespaces
4.2.2. Core
4.2.3. Web
4.2.4. Data
I. Core Technologies
5. The IoC container
5.1. Introduction
5.2. Basics - containers and objects
5.2.1. The container
5.2.1.1. Configuration metadata
5.2.1.2. Instantiating a container
5.2.1.3. Composing XML-based configuration metadata
5.2.2. The Objects
5.2.2.1. Naming objects
5.2.3. Object creation
5.2.3.1. Object creation via constructor invocation
5.2.3.2. Object creation via a static factory method
5.2.3.3. Object creation via an instance factory method
5.2.4. Object creation of generic types
5.2.4.1. Object creation of generic types via constructor invocation
5.2.4.2. Object creation of generic types via static factory method
5.2.4.3. Object creation of generic types via instance factory method
5.3. Dependencies
5.3.1. Injecting dependencies
5.3.1.1. Constructor Injection
5.3.1.2. Setter Injection
5.3.1.3. Some examples
5.3.2. Dependencies and configuration in detail
5.3.2.1. Straight values (primitives, strings, etc.)
5.3.2.2. Referring to collaborating objects
5.3.2.3. Inline objects
5.3.2.4. Setting collection values
5.3.2.5. Setting generic collection values
5.3.2.6. Setting null values
5.3.2.7. Setting indexer properties
5.3.2.8. Value and ref shortcut forms
5.3.2.9. Compound property names and Spring expression references
5.3.3. Using depends-on
5.3.4. Lazily-instantiated objects
5.3.5. Autowiring collaborators
5.3.6. Checking for dependencies
5.3.7. Method Injection
5.3.7.1. Lookup Method Injection
5.3.7.2. Arbitrary method replacement
5.3.8. Setting a reference using the members of other objects and classes.
5.3.8.1. Setting a reference to the value of property.
5.3.8.2. Setting a reference to the value of field.
5.3.8.3. Setting a property or constructor argument to the return value of a method invocation.
5.3.9. Provided IFactoryObject implementations
5.3.9.1. Common logging
5.4. Object Scopes
5.4.1. The singleton scope
5.4.2. The prototype scope
5.4.3. Singleton objecgts with prototype-object dependencies
5.4.4. The other scopes
5.5. Type conversion
5.5.1. Type Conversion for Enumerations
5.5.2. Built-in TypeConverters
5.5.3. Custom Type Conversion
5.5.3.1. Using CustomConverterConfigurer
5.6. Customizing the nature of an object
5.6.1. Lifecycle interfaces
5.6.1.1. IInitializingObject / init-method
5.6.1.2. IDisposable / destroy-method
5.6.2. Knowing who you are
5.6.2.1. IObjectFactoryAware
5.6.2.2. IObjectNameAware
5.7. Object definition inheritance
5.8. Interacting with the container
5.8.1. Obtaining an IFactoryObject, not its product
5.9. Container extension points
5.9.1. Customizing objects with IObjectPostProcessors
5.9.1.1. Example: Hello World, IObjectPostProcessor-style
5.9.1.2. Example: the RequiredAttributeObjectPostProcessor
5.9.2. Customizing configuration metadata with ObjectFactoryPostProcessors
5.9.2.1. Example: The PropertyPlaceholderConfigurer
5.9.2.2. Example: The PropertyOverrideConfigurer
5.9.2.3. IVariableSource
5.9.3. Customizing instantiation logic using IFactoryObjects
5.9.3.1. IConfigurableFactoryObject
5.10. The IApplicationContext
5.10.1. IObjectFactory or IApplicationContext?
5.11. Configuration of IApplicationContext
5.11.1. Registering custom parsers
5.11.2. Registering custom resource handlers
5.11.3. Registering Type Aliases
5.11.4. Registering Type Converters
5.12. Added functionality of the IApplicationContext
5.12.1. Context Hierarchies
5.12.2. Using IMessageSource
5.12.3. Using resources within Spring.NET
5.12.4. Loosely coupled events
5.12.5. Event notification from IApplicationContext
5.13. Customized behavior in the ApplicationContext
5.13.1. The IApplicationContextAware marker interface
5.13.2. The IObjectPostProcessor
5.13.3. The IObjectFactoryPostProcessor
5.13.4. The PropertyPlaceholderConfigurer
5.14. Configuration of ApplicationContext without using XML
5.15. Service Locator access
6. The IObjectWrapper and Type conversion
6.1. Introduction
6.2. Manipulating objects using the IObjectWrapper
6.2.1. Setting and getting basic and nested properties
6.2.2. Other features worth mentioning
6.3. Type conversion
6.3.1. Type Conversion for Enumerations
6.4. Built-in TypeConverters
6.4.1. Custom type converters
7. Resources
7.1. Introduction
7.2. The IResource interface
7.3. Built-in IResource implementations
7.3.1. Registering custom IResource implementations
7.4. The IResourceLoader
7.5. The IResourceLoaderAware interface
7.6. Application contexts and IResource paths
8. Threading and Concurrency Support
8.1. Introduction
8.2. Thread Local Storage
8.3. Synchronization Primitives
8.3.1. ISync
8.3.2. SyncHolder
8.3.3. Latch
8.3.4. Semaphore
9. Object Pooling
9.1. Introduction
9.2. Interfaces and Implementations
10. Spring.NET miscellanea
10.1. Introduction
10.2. PathMatcher
10.2.1. General rules
10.2.2. Matching filenames
10.2.3. Matching subdirectories
10.2.4. Case does matter, slashes don't
11. Expression Evaluation
11.1. Introduction
11.2. Evaluating Expressions
11.3. Language Reference
11.3.1. Literal expressions
11.3.2. Properties, Arrays, Lists, Dictionaries, Indexers
11.3.2.1. Defining Arrays, Lists and Dictionaries Inline
11.3.3. Methods
11.3.4. Operators
11.3.4.1. Relational operators
11.3.4.2. Logical operators
11.3.4.3. Mathematical operators
11.3.5. Assignment
11.3.6. Expression lists
11.3.7. Types
11.3.8. Type Registration
11.3.9. Constructors
11.3.10. Variables
11.3.10.1. The '#this' and '#root' variables
11.3.11. Ternary Operator (If-Then-Else)
11.3.12. List Projection and Selection
11.3.13. Collection Processors and Aggregators
11.3.13.1. Count Aggregator
11.3.13.2. Sum Aggregator
11.3.13.3. Average Aggregator
11.3.13.4. Minimum Aggregator
11.3.13.5. Maximum Aggregator
11.3.13.6. Non-null Processor
11.3.13.7. Distinct Processor
11.3.13.8. Sort Processor
11.3.14. Spring Object References
11.3.15. Lambda Expressions
11.3.16. Null Context
11.4. Classes used in the examples
12. Validation Framework
12.1. Introduction
12.2. Example Usage
12.3. Validator Groups
12.4. Validators
12.4.1. Condition Validator
12.4.2. Required Validator
12.4.3. Regular Expression Validator
12.4.4. Generic Validator
12.4.5. Conditional Validator Execution
12.5. Validator Actions
12.5.1. Error Message Action
12.5.2. Generic Actions
12.6. Validator References
12.7. Progammatic usage
12.8. Usage tips within ASP.NET
12.8.1. Rendering Validation Errors
12.8.1.1. Configuring which Error Renderer to use.
13. Aspect Oriented Programming with Spring.NET
13.1. Introduction
13.1.1. AOP concepts
13.1.2. Spring.NET AOP capabilities
13.1.3. AOP Proxies in Spring.NET
13.2. Pointcut API in Spring.NET
13.2.1. Concepts
13.2.2. Operations on pointcuts
13.2.3. Convenience pointcut implementations
13.2.3.1. Static pointcuts
13.2.3.2. Dynamic Pointcuts
13.2.4. Custom pointcuts
13.3. Advice API in Spring.NET
13.3.1. Advice Lifecycle
13.3.2. Advice types
13.3.2.1. Interception Around Advice
13.3.2.2. Before advice
13.3.2.3. Throws advice
13.3.2.4. After Returning advice
13.3.2.5. Advice Ordering
13.3.2.6. Introduction advice
13.4. Advisor API in Spring.NET
13.5. Using the ProxyFactoryObject to create AOP proxies
13.5.1. Basics
13.5.2. ProxyFactoryObject Properties
13.5.3. Proxying Interfaces
13.5.4. Proxying Classes
13.5.5. Concise proxy definitions
13.6. Proxying mechanisms
13.7. Creating AOP Proxies Programatically with the ProxyFactory
13.8. Manipulating Advised Objects
13.9. Using the "autoproxy" facility
13.9.1. Autoproxy object definitions
13.9.1.1. ObjectNameAutoProxyCreator
13.9.1.2. DefaultAdvisorAutoProxyCreator
13.9.1.3. AbstractAutoProxyCreator
13.9.2. Using attribute-driven auto-proxying
13.10. Using AOP Namespace
13.11. Using TargetSources
13.11.1. Hot swappable target sources
13.11.2. Pooling target sources
13.11.3. Prototype target sources
13.11.4. ThreadLocal target sources
13.12. Defining new Advice types
13.13. Further reading and resources
14. Aspect Library
14.1. Introduction
14.2. Caching
14.3. Exception Handling
14.3.1. Language Reference
14.4. Logging
14.5. Retry
14.5.1. Language Reference
14.6. Transactions
14.7. Parameter Validation
15. Common Logging
15.1. Introduction
16. Testing
16.1. Introduction
16.2. Unit testing
16.3. Integration testing
16.3.1. Context management and caching
16.3.2. Dependency Injection of test fixtures
16.3.2.1. Field level injection
16.3.3. Transaction management
16.3.4. Convenience variables
16.3.5.
16.4. Further Resources
II. Middle Tier Data Access
17. Transaction management
17.1. Introduction
17.2. Motivations
17.3. Key Abstractions
17.4. Resource synchronization with transactions
17.4.1. High-level approach
17.4.2. Low-level approach
17.5. Declarative transaction management
17.5.1. Understanding Spring's declarative transaction implementation
17.5.2. A First Example
17.5.3. Declarative transactions using the transaction namespace
17.5.4. Transaction attribute settings
17.5.5. Declarative Transactions using AutoProxy
17.5.5.1. Creating transactional proxies with ObjectNameAutoProxyCreator
17.5.5.2. Creating transactional proxies with DefaultAdvisorAutoProxyCreator
17.5.6. Declarative Transactions using TransactionProxyFactoryObject
17.5.7. Concise proxy definitions
17.5.8. Declarative Transactions using ProxyFactoryObject
17.6. Programmatic transaction management
17.6.1. Using the TransactionTemplate
17.6.2. Using the PlatformTransactionManager
17.7. Choosing between programmatic and declarative transaction management
17.8. Transaction lifecycle and status information
18. DAO support
18.1. Introduction
18.2. Consistent exception hierarchy
18.3. Consistent abstract classes for DAO support
19. DbProvider
19.1. Introduction
19.2. IDbProvider and DbProviderFactory
19.3. XML based configuration
19.4. Connection String management
19.5. Additional IDbProvider implementations
19.5.1. UserCredentialsDbProvider
19.5.2. MultiDelegatingDbProvider
20. Data access using ADO.NET
20.1. Introduction
20.2. Motivations
20.3. Provider Abstraction
20.3.1. Creating an instance of IDbProvider
20.4. Namespaces
20.5. Approaches to Data Access
20.6. Introduction to AdoTemplate
20.6.1. Execute Callback
20.6.2. Execute Callback in .NET 2.0
20.6.3. Execute Callback in .NET 1.1
20.6.4. Quick Guide to AdoTemplate Methods
20.6.5. Quick Guide to AdoTemplate Properties
20.7. Transaction Management
20.8. Exception Translation
20.9. Parameter Management
20.9.1. IDbParametersBuilder
20.9.2. IDbParameters
20.10. Custom IDataReader implementations
20.11. Basic data access operations
20.11.1. ExecuteNonQuery
20.11.2. ExecuteScalar
20.12. Queries and Lightweight Object Mapping
20.12.1. ResultSetExtractor
20.12.2. RowCallback
20.12.3. RowMapper
20.12.4. Query for a single object
20.12.5. Query using a CommandCreator
20.13. DataTable and DataSet
20.13.1. DataTables
20.13.2. DataSets
20.14. TableAdapters and participation in transactional context
20.15. Database operations as Objects
20.15.1. AdoQuery
20.15.2. MappingAdoQuery
20.15.3. AdoNonQuery
20.15.4. Stored Procedure
21. Object Relational Mapping (ORM) data access
21.1. Introduction
21.2. NHibernate
21.2.1. Resource management
21.2.2. Transaction Management
21.2.3. SessionFactory set up in a Spring container
21.2.4. The HibernateTemplate
21.2.5. Implementing Spring-based DAOs without callbacks
21.2.6. Implementing DAOs based on plain Hibernate 1.2 API
21.2.7. Programmatic transaction demarcation
21.2.8. Declarative transaction demarcation
21.2.9. Transaction management strategies
21.2.10. Web Session Management
21.2.11. Session Scope
III. The Web
22. Spring.NET Web Framework
22.1. Introduction
22.2. Automatic context loading and hierarchical contexts
22.2.1. Configuration
22.2.1.1. Configuration for IIS7
22.2.2. Context Hierarchy
22.3. Dependency Injection for ASP.NET Pages
22.3.1. Injecting Dependencies into Controls
22.3.2. Injecting dependencies into custom HTTP modules
22.3.3. Injecting dependencies into custom providers
22.3.4. Customizing control dependency injection
22.4. Object Scope
22.5. Master Pages in ASP.NET 1.1
22.5.1. Linking child pages to their master
22.6. Bidirectional Data Binding and Model Management
22.6.1. Data Binding Under the Hood
22.6.1.1. Binding Direction
22.6.1.2. Formatters
22.6.1.3. Type Conversion
22.6.1.4. Data Binding Events
22.6.1.5. Rendering Binding Errors
22.6.1.6. HttpRequestListBindingContainer
22.6.2. Using DataBindingPanel
22.7. Localization and Message Sources
22.7.1. Automatic Localization Using Localizers ("Push" Localization)
22.7.2. Global Message Sources
22.7.3. Working with Localizers
22.7.4. Applying Resources Manually ("Pull" Localization)
22.7.5. Localizing Images within a Web Application
22.7.6. User Culture Management
22.7.6.1. DefaultWebCultureResolver
22.7.6.2. RequestCultureResolver
22.7.6.3. SessionCultureResolver
22.7.6.4. CookieCultureResolver
22.7.7. Changing Cultures
22.8. Result Mapping
22.9. Client-Side Scripting
22.9.1. Registering Scripts within the head HTML section
22.9.2. Adding CSS Definitions to the head Section
22.9.3. Well-Known Directories
22.10. Spring User Controls
22.10.1. Validation Controls
22.10.2. Databinding Controls
22.10.3. Calendar Control
22.10.4. Panel Control
23. ASP.NET AJAX
23.1. Introduction
23.2. Web Services
23.2.1. Exposing Web Services
23.2.2. Calling Web Services by using JavaScript
IV. Services
24. Introduction to Spring Services
24.1. Introduction
25. .NET Remoting
25.1. Introduction
25.2. Publishing SAOs on the Server
25.2.1. SAO Singleton
25.2.2. SAO SingleCall
25.2.3. IIS Application Configuration
25.3. Accessing a SAO on the Client
25.4. CAO best practices
25.5. Registering a CAO object on the Server
25.5.1. Applying AOP advice to exported CAO objects
25.6. Accessing a CAO on the Client
25.6.1. Applying AOP advice to client side CAO objects.
25.7. XML Schema for configuration
25.8. Additional Resources
26. .NET Enterprise Services
26.1. Introduction
26.2. Serviced Components
26.3. Server Side
26.4. Client Side
27. Web Services
27.1. Introduction
27.2. Server-side
27.2.1. Removing the need for .asmx files
27.2.2. Injecting dependencies into web services
27.2.3. Exposing PONOs as Web Services
27.2.4. Exporting an AOP Proxy as a Web Service
27.3. Client-side
27.3.1. Using VS.NET generated proxy
27.3.2. Generating proxies dynamically
27.3.3. Configuring the proxy instance
V. VS.NET Integration
28. Visual Studio.NET Integration
28.1. XML Editing and Validation
28.2. Versions of XML Schema
28.3. Integrated API help
VI. Quickstart applications
29. IoC Quickstarts
29.1. Introduction
29.2. Movie Finder
29.2.1. Getting Started - Movie Finder
29.2.2. First Object Definition
29.2.3. Setter Injection
29.2.4. Constructor Injection
29.2.5. Summary
29.2.6. Logging
29.3. ApplicationContext and IMessageSource
29.3.1. Introduction
29.4. ApplicationContext and IEventRegistry
29.4.1. Introduction
29.5. Pooling example
29.5.1. Implementing Spring.Pool.IPoolableObjectFactory
29.5.2. Being smart using pooled objects
29.5.3. Using the executor to do a parallel grep
29.6. AOP
30. AOP Guide
30.1. Introduction
30.2. The basics
30.2.1. Applying advice
30.2.2. Using Pointcuts - the basics
30.3. Going deeper
30.3.1. Other types of Advice
30.3.1.1. Before advice
30.3.1.2. After advice
30.3.1.3. Throws advice
30.3.1.4. Introductions (mixins)
30.3.1.5. Layering advice
30.3.1.6. Configuring advice
30.3.2. Using Attributes to define Pointcuts
30.4. The Spring.NET AOP Cookbook
30.4.1. Caching
30.4.2. Performance Monitoring
30.4.3. Retry Rules
30.5. Spring.NET AOP Best Practices
31. Portable Service Abstraction Quick Start
31.1. Introduction
31.2. .NET Remoting Example
31.3. Implementation
31.4. Running the application
31.5. Remoting Schema
31.6. .NET Enterprise Services Example
31.7. Web Services Example
31.8. Additional Resources
32. Web Quickstarts
32.1. Introduction
33. SpringAir - Reference Application
33.1. Introduction
33.2. Getting Started
33.3. Container configuration
33.4. Bi-directional data binding
33.5. Declarative Validation
33.6. Internationalization
33.7. Web Services
34. Data Access QuickStart
34.1. Introduction
34.1.1. Database configuration
34.1.1.1. AdoTemplate Configuration
34.1.2. CommandCallback
35. Transactions QuickStart
35.1. Introduction
35.2. Application Overview
35.2.1. Interfaces
35.3. Implementation
35.4. Configuration
35.4.1. Rollback Rules
35.5. Adding additional Aspects
VII. Spring.NET for Java developers
36. Spring.NET for Java Developers
36.1. Introduction
36.2. Beans to Objects
36.3. PropertyEditors to TypeConverters
36.4. ResourceBundle-ResourceManager
36.5. Exceptions
36.6. Application Configuration
36.7. AOP Framework
36.7.1. Cannot specify target name at the end of interceptorNames for ProxyFactoryObject
A. Spring.NET's spring-objects.xsd