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 M2

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 July 11, 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
I. Core Technologies
4. Objects, Object Factories, and Application Contexts
4.1. Introduction
4.2. Introduction to the IObjectFactory, IApplicationContext, and IObjectDefinition
4.2.1. The IObjectFactory and IApplicationContext
4.2.2. The IObjectDefinition
4.2.3. Object Creation
4.2.3.1. Object creation via constructor invocation
4.2.3.2. Object creation via a static factory method
4.2.3.3. Object creation via an instance factory method
4.2.4. Object creation of generic types
4.2.4.1. Object creation of generic types via constructor invocation
4.2.4.2. Object creation of generic types via static factory method
4.2.4.3. Object creation of generic types via instance factory method
4.2.5. The object identifiers (id and name)
4.2.6. Singleton & Prototype Scope
4.3. Properties, collaborators, autowiring and dependency checking
4.3.1. Setting object properties and collaborators
4.3.2. Constructor Argument Resolution
4.3.2.1. Constructor Argument Type Matching
4.3.2.2. Constructor Argument Index
4.3.2.3. Constructor Arguments by Name
4.3.3. Object properties and constructor arguments in detail
4.3.3.1. Setting null values
4.3.3.2. Setting collection values
4.3.3.3. Setting generic collection values
4.3.3.4. Setting indexer properties
4.3.3.5. Inline objects
4.3.3.6. The idref element
4.3.3.7. Referring to collaborating objects
4.3.3.8. Value and ref shortcut forms
4.3.3.9. Compound property names
4.3.4. Method Injection
4.3.4.1. Lookup Method Injection
4.3.4.2. Arbitrary method replacement
4.3.5. Setting a reference using the members of other objects and classes.
4.3.5.1. Setting a reference to the value of property.
4.3.5.2. Setting a reference to the value of field.
4.3.5.3. Setting a property or constructor argument to the return value of a method invocation.
4.3.6. Additional IFactoryObject implementations
4.3.6.1. Log4Net
4.3.7. Using depends-on
4.3.8. Autowiring collaborators
4.3.9. Checking for dependencies
4.4. Type conversion
4.4.1. Type Conversion for Enumerations
4.4.2. Built-in TypeConverters
4.4.3. Custom Type Conversion
4.4.3.1. Using CustomConverterConfigurer
4.5. Customizing the nature of an object
4.5.1. Lifecycle interfaces
4.5.1.1. IInitializingObject / init-method
4.5.1.2. IDisposable / destroy-method
4.5.2. Knowing who you are
4.5.2.1. IObjectFactoryAware
4.5.2.2. IObjectNameAware
4.5.3. IFactoryObject
4.5.4. IConfigurableFactoryObject
4.6. Abstract and Child object definitions
4.7. Interacting with the IObjectFactory
4.7.1. Obtaining an IFactoryObject, not its product
4.8. Customizing objects with IObjectPostProcessors
4.9. Customizing object factories with ObjectFactoryPostProcessors
4.9.1. The PropertyPlaceholderConfigurer
4.9.1.1. Replacement with Environment Variables
4.9.2. The PropertyOverrideConfigurer
4.9.3. IVariableSource
4.10. Using the alias element to add aliases for existing objects
4.11. Introduction to the IApplicationContext
4.12. Configuration of IApplicationContext
4.12.1. Registering custom parsers
4.12.2. Registering custom resource handlers
4.12.3. Registering Type Aliases
4.12.4. Registering Type Converters
4.13. Added functionality of the IApplicationContext
4.13.1. Context Hierarchies
4.13.2. Using the IMessageSource
4.13.3. Using resources within Spring.NET
4.13.4. Loosely coupled events
4.13.5. Event notification from IApplicationContext
4.14. Customized behavior in the ApplicationContext
4.14.1. The IApplicationContextAware marker interface
4.14.2. The IObjectPostProcessor
4.14.3. The IObjectFactoryPostProcessor
4.14.4. The PropertyPlaceholderConfigurer
4.15. Importing Object Definitions from One File Into Another
4.16. Configuration of ApplicationContext without using XML
4.17. Service Locator access
5. The IObjectWrapper and Type conversion
5.1. Introduction
5.2. Manipulating objects using the IObjectWrapper
5.2.1. Setting and getting basic and nested properties
5.2.2. Other features worth mentioning
5.3. Type conversion
5.3.1. Type Conversion for Enumerations
5.4. Built-in TypeConverters
6. The IResource abstraction
6.1. Introduction
6.2. The IResource interface
6.3. Built-in IResource implementations
6.3.1. Registering custom IResource implementations
6.4. The IResourceLoader
6.5. The IResourceLoaderAware interface
6.6. Application contexts and IResource paths
7. Threading and Concurrency Support
7.1. Introduction
7.2. Thread Local Storage
7.3. Synchronization Primitives
7.3.1. ISync
7.3.2. SyncHolder
7.3.3. Latch
7.3.4. Semaphore
8. Object Pooling
8.1. Introduction
8.2. Interfaces and Implementations
9. Spring.NET miscellanea
9.1. Introduction
9.2. PathMatcher
9.2.1. General rules
9.2.2. Matching filenames
9.2.3. Matching subdirectories
9.2.4. Case does matter, slashes don't
10. Expression Evaluation
10.1. Introduction
10.2. Evaluating Expressions
10.3. Language Reference
10.3.1. Literal expressions
10.3.2. Properties, Arrays, Lists, Dictionaries, Indexers
10.3.2.1. Defining Arrays, Lists and Dictionaries Inline
10.3.3. Methods
10.3.4. Operators
10.3.4.1. Relational operators
10.3.4.2. Logical operators
10.3.4.3. Mathmatical operators
10.3.5. Assignment
10.3.6. Expression lists
10.3.7. Types
10.3.8. Type Registration
10.3.9. Constructors
10.3.10. Variables
10.3.10.1. The '#this' and '#root' variables
10.3.11. Ternary Operator (If-Then-Else)
10.3.12. List Projection and Selection
10.3.13. Collection Processors and Aggregators
10.3.13.1. Count Aggregator
10.3.13.2. Sum Aggregator
10.3.13.3. Average Aggregator
10.3.13.4. Minimum Aggregator
10.3.13.5. Maximum Aggregator
10.3.13.6. Non-null Processor
10.3.13.7. Distinct Processor
10.3.13.8. Sort Processor
10.3.14. Spring Object References
10.3.15. Lambda Expressions
10.3.16. Null Context
10.4. Classes used in the examples
11. Validation Framework
11.1. Introduction
11.2. Example Usage
11.3. Validator Groups
11.4. Validators
11.4.1. Condition Validator
11.4.2. Required Validator
11.4.3. Regular Expression Validator
11.4.4. Generic Validator
11.4.5. Conditional Validator Execution
11.5. Validator Actions
11.5.1. Error Message Action
11.5.2. Generic Actions
11.6. Validator References
11.7. Usage tips within ASP.NET
11.7.1. Rendering Validation Errors
11.7.1.1. Configuring which Error Renderer to use.
12. Aspect Oriented Programming with Spring.NET
12.1. Introduction
12.1.1. AOP concepts
12.1.2. Spring.NET AOP capabilities
12.1.3. AOP Proxies in Spring.NET
12.2. Pointcut API in Spring.NET
12.2.1. Concepts
12.2.2. Operations on pointcuts
12.2.3. Convenience pointcut implementations
12.2.3.1. Static pointcuts
12.2.3.2. Dynamic Pointcuts
12.2.4. Custom pointcuts
12.3. Advice API in Spring.NET
12.3.1. Advice Lifecycle
12.3.2. Advice types
12.3.2.1. Interception Around Advice
12.3.2.2. Before advice
12.3.2.3. Throws advice
12.3.2.4. After Returning advice
12.3.2.5. Advice Ordering
12.3.2.6. Introduction advice
12.4. Advisor API in Spring.NET
12.5. Using the ProxyFactoryObject to create AOP proxies
12.5.1. Basics
12.5.2. ProxyFactoryObject Properties
12.5.3. Proxying Interfaces
12.5.4. Proxying Classes
12.6. Proxying mechanisms
12.7. Creating AOP Proxies Programmatically with the ProxyFactory
12.8. Manipulating Advised Objects
12.9. Using the "autoproxy" facility
12.9.1. Autoproxy object definitions
12.9.1.1. ObjectNameAutoProxyCreator
12.9.1.2. DefaultAdvisorAutoProxyCreator
12.9.1.3. AbstractAutoProxyCreator
12.9.2. Using attribute-driven auto-proxying
12.10. Using AOP Namespace
12.11. Using TargetSources
12.11.1. Hot swappable target sources
12.11.2. Pooling target sources
12.11.3. Prototype target sources
12.12. Defining new Advice types
12.13. Further reading and resources
13. Common Logging
13.1. Introduction
13.2. Using Common.Logging API
13.3. Configuring Logging
13.3.1. Declarative Configuration
13.3.2. Configuring Logging in your code
13.4. Logging Adapters
13.4.1. NoOpLoggerFactoryAdapter
13.4.2. ConsoleOutLoggerFactoryAdapter
13.4.3. TraceLoggerFactoryAdapter
13.4.4. Log4NetLoggerFactoryAdapter
13.5. Advanced Logging Tasks
13.5.1. Implementing a custom FactoryAdapter
14. Testing
14.1. Introduction
14.2. Unit testing
14.3. Integration testing
14.3.1. Context management and caching
14.3.2. Dependency Injection of test fixtures
14.3.2.1. Field level injection
14.3.3. Transaction management
14.3.4. Convenience variables
14.3.5.
14.4. Further Resources
II. Middle Tier Data Access
15. Transaction management
15.1. Introduction
15.2. Motivations
15.3. Key Abstractions
15.4. Resource synchronization with transactions
15.4.1. High-level approach
15.4.2. Low-level approach
15.5. Declarative transaction management
15.5.1. Understanding Spring's declarative transaction implementation
15.5.2. A First Example
15.5.3. Declarative transactions using the transaction namespace
15.5.4. Transaction attribute settings
15.5.5. Declarative Transactions using AutoProxy
15.5.5.1. Creating transactional proxies with ObjectNameAutoProxyCreator
15.5.5.2. Creating transactional proxies with DefaultAdvisorAutoProxyCreator
15.5.6. Declarative Transactions using TransactionProxyFactoryObject
15.5.7. Concise proxy definitions
15.5.8. Declarative Transactions using ProxyFactoryObject
15.6. Programmatic transaction management
15.6.1. Using the TransactionTemplate
15.6.2. Using the PlatformTransactionManager
15.7. Choosing between programmatic and declarative transaction management
16. DAO support
16.1. Introduction
16.2. Consistent exception hierarchy
16.3. Consistent abstract classes for DAO support
17. DbProvider
17.1. Introduction
17.2. IDbProvider and DbProviderFactory
17.3. XML based configuration
17.4. Connection String management
18. Data access using ADO.NET
18.1. Introduction
18.2. Motivations
18.3. Provider Abstraction
18.3.1. Creating an instance of IDbProvider
18.4. Namespaces
18.5. Approaches to Data Access
18.6. Introduction to AdoTemplate
18.6.1. Execute Callback
18.6.2. Execute Callback .NET 2.0
18.6.3. .NET 1.1
18.6.4. Quick Guide to AdoTemplate Methods
18.7. Exception Translation
18.8. Parameter Management
18.8.1. IDbParametersBuilder
18.8.2. IDbParameters
18.9. Mapping DBNull values
18.10. Basic data access operations
18.10.1. ExecuteNonQuery
18.10.2. ExecuteScalar
18.11. Queries and Lightweight Object Mapping
18.11.1. ResultSetExtractor
18.11.2. RowCallback
18.11.3. RowMapper
18.11.4. Query for a single object
18.11.5. Query using a CommandCreator
18.12. DataTable and DataSet
18.12.1. DataTables
18.12.2. DataSets
18.13. Deriving Stored Procedure Parameters
18.14. Database operations as Objects
18.14.1. AdoNonQuery
18.14.2. AdoQuery
18.14.3. MappingAdoQuery
18.14.4. Stored Procedure
18.14.5. DataSetOperation
19. Object Relational Mapping (ORM) data access
19.1. Introduction
19.2. NHibernate
19.2.1. Resource management
19.2.2. SessionFactory setup in a Spring container
19.2.3. The HibernateTemplate
19.2.4. Implementing Spring-based DAOs without callbacks
19.2.5. Implementing DAOs based on plain Hibernate 1.2 API
19.2.6. Programmatic transaction demarcation
19.2.7. Declarative transaction demarcation
19.2.8. Transaction management strategies
19.2.9. Web Session Management
III. The Web
20. Spring.NET Web Framework
20.1. Introduction
20.2. Automatic context loading and hierarchical contexts
20.2.1. Configuration
20.2.2. Context Hierarchy
20.3. Dependency Injection for ASP.NET Pages
20.3.1. Injecting Dependencies into Controls
20.4. Object Scope
20.5. Master Pages in ASP.NET 1.1
20.5.1. Linking child pages to their master
20.6. Bidirectional Data Binding and Model Management
20.6.1. Data Binding Under the Hood
20.6.1.1. Binding Direction
20.6.1.2. Formatters
20.6.1.3. Type Conversion
20.6.1.4. Data Binding Events
20.7. Localization
20.7.1. Automatic Localization Using Localizers ("Push" Localization)
20.7.2. Working with Localizers
20.7.3. Applying Resources Manually ("Pull" Localization)
20.7.4. Localizing Images within a Web Application
20.7.5. Global Resources
20.7.6. User Culture Management
20.7.6.1. DefaultWebCultureResolver
20.7.6.2. RequestCultureResolver
20.7.6.3. SessionCultureResolver
20.7.6.4. CookieCultureResolver
20.7.7. Changing Cultures
20.8. Result Mapping
20.9. Client-Side Scripting
20.9.1. Registering Scripts within the head HTML section
20.9.2. Adding CSS Definitions to the head Section
20.9.3. Well-Known Directories
21. ASP.NET AJAX
21.1. Introduction
21.2. Web Services
21.2.1. Exposing Web Services
21.2.2. Calling Web Services by using JavaScript
IV. Services
22. .NET Remoting
22.1. Introduction
22.2. Publishing SAOs on the Server
22.2.1. SAO Singleton
22.2.2. SAO SingleCall
22.2.3. IIS Application Configuration
22.3. Accessing a SAO on the Client
22.4. CAO best practices
22.5. Registering a CAO object on the Server
22.5.1. Applying AOP advice to exported CAO objects
22.6. Accessing a CAO on the Client
22.6.1. Applying AOP advice to client side CAO objects.
22.7. XML Schema for configuration
22.8. Additional Resources
23. .NET Enterprise Services
23.1. Introduction
23.2. Serviced Components
23.3. Server Side
23.4. Client Side
24. Web Services
24.1. Server-side
24.1.1. Removing the need for .asmx files
24.1.2. Injecting dependencies into web services
24.1.3. Exposing PONOs as Web Services
24.1.4. Exporting an AOP Proxy as a Web Service
24.1.5. Client-side issues
24.2. Client-side
24.2.1. Using VS.NET generated proxy
24.2.2. Generating proxy dynamically
25. Windows Services
25.1. Remarks
25.2. Introduction
25.3. The Spring.Services.WindowsService.Process.exe application
25.3.1. Installing
25.3.2. Configuration
25.4. Running an application context as a windows service
25.4.1. service.config
25.4.1.1. Let the application know where it is
25.4.2. watcher.xml - optional
25.4.3. bin directory - optional
25.5. Customizing or extending
25.5.1. The .config file
V. VS.NET Integration
26. Visual Studio.NET Integration
26.1. XML Editing and Validation
26.2. Versions of XML Schema
26.3. Integrated API help
VI. Quickstart applications
27. IoC Quickstarts
27.1. Introduction
27.2. Movie Finder
27.2.1. Getting Started - Movie Finder
27.2.2. First Object Definition
27.2.3. Setter Injection
27.2.4. Constructor Injection
27.2.5. Summary
27.2.6. Logging
27.3. ApplicationContext and IMessageSource
27.3.1. Introduction
27.4. ApplicationContext and IEventRegistry
27.4.1. Introduction
27.5. Pooling example
27.5.1. Implementing Spring.Pool.IPoolableObjectFactory
27.5.2. Being smart using pooled objects
27.5.3. Using the executor to do a parallel grep
27.6. AOP
28. AOP Guide
28.1. Introduction
28.2. The basics
28.2.1. Applying advice
28.2.2. Using Pointcuts - the basics
28.3. Going deeper
28.3.1. Other types of Advice
28.3.1.1. Before advice
28.3.1.2. After advice
28.3.1.3. Throws advice
28.3.1.4. Introductions (mixins)
28.3.1.5. Layering advice
28.3.1.6. Configuring advice
28.3.2. Using Attributes to define Pointcuts
28.4. The Spring.NET AOP Cookbook
28.4.1. Caching
28.4.2. Performance Monitoring
28.4.3. Retry Rules
28.5. Spring.NET AOP Best Practices
29. .NET Remoting Quick start
29.1. Introduction
29.2. The Remoting Sample Project
29.3. Implementation
29.4. Running the application
29.5. Remoting Schema
29.6. Additional Resources
30. Web Quickstarts
30.1. Introduction
31. SpringAir - Reference Application
31.1. Introduction
31.2. Getting Started
31.3. The Architecture
31.4. The Implementation
31.4.1. The Domain Layer
31.4.2. The Service Layer
31.4.3. The Web Layer
31.5. Summary
32. Data Access QuickStart
32.1. Introduction
33. Transactions QuickStart
33.1. Introduction
33.2. Application Overview
33.2.1. Interfaces
VII. Spring.NET for Java developers
34. Spring.NET for Java Developers
34.1. Introduction
34.2. Beans to Objects
34.3. PropertyEditors to TypeConverters
34.4. ResourceBundle-ResourceManager
34.5. Exceptions
34.6. Application Configuration
34.7. AOP Framework
34.7.1. Cannot specify target name at the end of interceptorNames for ProxyFactoryObject
A. Spring.NET's spring-objects.xsd