The Spring.NET Framework

Reference Documentation

Authors

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

Version 1.1 RC1

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 August 10, 2007


1. Preface
2. Introduction
2.1. Overview
2.2. Background
2.3. Modules
2.4. License Information
2.5. Support
3. Background information
3.1. Inversion of Control
4. Moving from M2 to RC1
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. Objects, Object Factories, and Application Contexts
5.1. Introduction
5.2. Introduction to the IObjectFactory, IApplicationContext, and IObjectDefinition
5.2.1. The IObjectFactory and IApplicationContext
5.2.2. The IObjectDefinition
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.2.5. The object identifiers (id and name)
5.2.6. Singleton & Prototype Scope
5.3. Properties, collaborators, autowiring and dependency checking
5.3.1. Setting object properties and collaborators
5.3.2. Constructor Argument Resolution
5.3.2.1. Constructor Argument Type Matching
5.3.2.2. Constructor Argument Index
5.3.2.3. Constructor Arguments by Name
5.3.3. Object properties and constructor arguments in detail
5.3.3.1. Setting null values
5.3.3.2. Setting collection values
5.3.3.3. Setting generic collection values
5.3.3.4. Setting indexer properties
5.3.3.5. Inline objects
5.3.3.6. The idref element
5.3.3.7. Referring to collaborating objects
5.3.3.8. Value and ref shortcut forms
5.3.3.9. Compound property names
5.3.4. Method Injection
5.3.4.1. Lookup Method Injection
5.3.4.2. Arbitrary method replacement
5.3.5. Setting a reference using the members of other objects and classes.
5.3.5.1. Setting a reference to the value of property.
5.3.5.2. Setting a reference to the value of field.
5.3.5.3. Setting a property or constructor argument to the return value of a method invocation.
5.3.6. Additional IFactoryObject implementations
5.3.6.1. Log4Net
5.3.7. Using depends-on
5.3.8. Autowiring collaborators
5.3.9. Checking for dependencies
5.4. Type conversion
5.4.1. Type Conversion for Enumerations
5.4.2. Built-in TypeConverters
5.4.3. Custom Type Conversion
5.4.3.1. Using CustomConverterConfigurer
5.5. Customizing the nature of an object
5.5.1. Lifecycle interfaces
5.5.1.1. IInitializingObject / init-method
5.5.1.2. IDisposable / destroy-method
5.5.2. Knowing who you are
5.5.2.1. IObjectFactoryAware
5.5.2.2. IObjectNameAware
5.5.3. IFactoryObject
5.5.4. IConfigurableFactoryObject
5.6. Abstract and Child object definitions
5.7. Interacting with the IObjectFactory
5.7.1. Obtaining an IFactoryObject, not its product
5.8. Customizing objects with IObjectPostProcessors
5.9. Customizing object factories with ObjectFactoryPostProcessors
5.9.1. The PropertyPlaceholderConfigurer
5.9.1.1. Replacement with Environment Variables
5.9.2. The PropertyOverrideConfigurer
5.9.3. IVariableSource
5.10. Using the alias element to add aliases for existing objects
5.11. Introduction to the IApplicationContext
5.12. Configuration of IApplicationContext
5.12.1. Registering custom parsers
5.12.2. Registering custom resource handlers
5.12.3. Registering Type Aliases
5.12.4. Registering Type Converters
5.13. Added functionality of the IApplicationContext
5.13.1. Context Hierarchies
5.13.2. Using the IMessageSource
5.13.3. Using resources within Spring.NET
5.13.4. Loosely coupled events
5.13.5. Event notification from IApplicationContext
5.14. Customized behavior in the ApplicationContext
5.14.1. The IApplicationContextAware marker interface
5.14.2. The IObjectPostProcessor
5.14.3. The IObjectFactoryPostProcessor
5.14.4. The PropertyPlaceholderConfigurer
5.15. Importing Object Definitions from One File Into Another
5.16. Configuration of ApplicationContext without using XML
5.17. 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
7. The IResource abstraction
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. Mathmatical 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. Usage tips within ASP.NET
12.7.1. Rendering Validation Errors
12.7.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.6. Proxying mechanisms
13.7. Creating AOP Proxies Programmatically 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.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. Reference
14.4. Transactions
15. Common Logging
15.1. Introduction
15.2. Using Common.Logging API
15.3. Configuring Logging
15.3.1. Declarative Configuration
15.3.2. Configuring Logging in your code
15.4. Logging Adapters
15.4.1. NoOpLoggerFactoryAdapter
15.4.2. ConsoleOutLoggerFactoryAdapter
15.4.3. TraceLoggerFactoryAdapter
15.4.4. Log4NetLoggerFactoryAdapter
15.5. Advanced Logging Tasks
15.5.1. Implementing a custom FactoryAdapter
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
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
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.7. Exception Translation
20.8. Parameter Management
20.8.1. IDbParametersBuilder
20.8.2. IDbParameters
20.9. Mapping DBNull values
20.10. Basic data access operations
20.10.1. ExecuteNonQuery
20.10.2. ExecuteScalar
20.11. Queries and Lightweight Object Mapping
20.11.1. ResultSetExtractor
20.11.2. RowCallback
20.11.3. RowMapper
20.11.4. Query for a single object
20.11.5. Query using a CommandCreator
20.12. DataTable and DataSet
20.12.1. DataTables
20.12.2. DataSets
20.13. TableAdapters and participation in transactional context
20.14. Deriving Stored Procedure Parameters
20.15. Database operations as Objects
20.15.1. AdoNonQuery
20.15.2. AdoQuery
20.15.3. MappingAdoQuery
20.15.4. Stored Procedure
20.15.5. DataSetOperation
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 setup 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.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.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.7. Localization
22.7.1. Automatic Localization Using Localizers ("Push" Localization)
22.7.2. Working with Localizers
22.7.3. Applying Resources Manually ("Pull" Localization)
22.7.4. Localizing Images within a Web Application
22.7.5. Global Resources
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
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. .NET Remoting
24.1. Introduction
24.2. Publishing SAOs on the Server
24.2.1. SAO Singleton
24.2.2. SAO SingleCall
24.2.3. IIS Application Configuration
24.3. Accessing a SAO on the Client
24.4. CAO best practices
24.5. Registering a CAO object on the Server
24.5.1. Applying AOP advice to exported CAO objects
24.6. Accessing a CAO on the Client
24.6.1. Applying AOP advice to client side CAO objects.
24.7. XML Schema for configuration
24.8. Additional Resources
25. .NET Enterprise Services
25.1. Introduction
25.2. Serviced Components
25.3. Server Side
25.4. Client Side
26. Web Services
26.1. Server-side
26.1.1. Removing the need for .asmx files
26.1.2. Injecting dependencies into web services
26.1.3. Exposing PONOs as Web Services
26.1.4. Exporting an AOP Proxy as a Web Service
26.1.5. Client-side issues
26.2. Client-side
26.2.1. Using VS.NET generated proxy
26.2.2. Generating proxy dynamically
27. Windows Services
27.1. Remarks
27.2. Introduction
27.3. The Spring.Services.WindowsService.Process.exe application
27.3.1. Installing
27.3.2. Configuration
27.4. Running an application context as a windows service
27.4.1. service.config
27.4.1.1. Let the application know where it is
27.4.2. watcher.xml - optional
27.4.3. bin directory - optional
27.5. Customizing or extending
27.5.1. The .config file
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. .NET Remoting Quick start
31.1. Introduction
31.2. The Remoting Sample Project
31.3. Implementation
31.4. Running the application
31.5. Remoting Schema
31.6. Additional Resources
32. Web Quickstarts
32.1. Introduction
33. SpringAir - Reference Application
33.1. Introduction
33.2. Getting Started
33.3. The Architecture
33.4. The Implementation
33.4.1. The Domain Layer
33.4.2. The Service Layer
33.4.3. The Web Layer
33.5. Summary
34. Data Access QuickStart
34.1. Introduction
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