Sunday, February 27, 2011

Spring.Net Overview

Table of Contents

1. Introduction
2. References
3. Modules
4. Spring.Net Framework Advantages
5. Why spring.Net?


1. Introduction
 Spring.NET provides comprehensive infrastructural support for developing enterprise .NET applications. It allows you to remove incidental complexity when using the base class libraries makes best practices, such as test-driven development, easy practices.
 Spring.NET is created, supported and sustained by Spring Source. The design of Spring.NET is based on the Java version of the Spring Framework, which has shown real-world benefits and is used in thousands of enterprise applications worldwide.
 Spring .NET is not a quick port from the Java version, but rather a 'spiritual port' based on following proven architectural and design patterns in that are not tied to a particular platform. The breath of functionality in spring .NET spans application tiers, which allows you to treat it as a ‘one stop shop’ but that is not required.
 Spring .NET is not an all-or-nothing solution. You can use the functionality in its modules independently.

2. References
http://www.springframework.net

3. Modules
The Spring Framework contains a lot of features, which are well-organized into modules shown in the diagram below. The diagram below shows the various core modules of Spring.NET.



Spring.Core is the most fundamental part of the framework allowing you to configure your application using Dependency Injection. Other supporting functionality, listed below, is located in Spring.Core

Spring.Aop - Use this module to perform Aspect-Oriented Programming (AOP). AOP centralizes common functionality that can then be declaratively applied across your application in a targeted manner. Spring's aspect library provides predefined easy to use aspects for transactions, logging, performance monitoring, caching, method retry, and exception handling.

Spring.Data - Use this module to achieve greater efficiency and consistency in writing data access functionality in ADO.NET and to perform declarative transaction management. Introduction Spring Framework (Version 1.2.0) 4

Spring.Data.NHibernate - Use this module to integrate NHibernate with spring’s declarative transaction management functionality allowing easy mixing of ADO.NET and NHibernate operations within the same transaction. NHibernate 1.0 users will benefit from ease of use APIs to perform data access operations.

Spring.Web - Use this module to raise the level of abstraction when writing ASP.NET web applications allowing you to effectively address common pain-points in ASP.NET such as data binding, validation, and ASP.NET page/control/module/provider configuration.

Spring.Web.Extensions - Use this module to raise the level of abstraction when writing ASP.NET web applications allowing you to effectively address common pain-points in ASP.NET such as data binding, validation, and ASP.NET page/control/module/provider configuration.

Spring.Services - Use this module to adapt plain .NET objects so they can be used with a specific distributed communication technology, such as .NET Remoting, Enterprise Services, and ASMX Web Services. These services can be configured via dependency injection and ‘decorated’ by applying AOP.

Spring.Testing.NUnit - Use this module to perform integration testing with NUnit.

The Spring.Core module also includes the following additional features

• Expression Language - provides efficient querying and manipulation of an object graphs at runtime.

• Validation Framework - a robust UI agnostic framework for creating complex validation rules for business objects either programmatically or declaratively.

• Data binding Framework - a UI agnostic framework for performing data binding.
• Dynamic Reflection - provides a high performance reflection API

• Threading - provides additional concurrency abstractions such as Latch, Semaphore and Thread Local Storage.

• Resource abstraction - provides a common interface to treat the Input Stream from a file and from a URL in a polymorphic and protocol-independent manner.

Notice:

-You can use spring in all sorts of scenarios, from simple stand-alone console applications to fully-fledged enterprise applications using spring’s transaction management functionality and web framework integration.

-It is important to note that the Spring Framework does not force you to use everything within it; it is not an allor-nothing solution. Existing front-ends built using standard ASP.NET can be integrated perfectly well with a Spring-based middle-tier, allowing you to use the transaction and/or data access features that spring offers. The only things you need to do is wire up your business logic using Spring's IoC container and integrate it into your web layer using WebApplicationContext to locate middle tier services and/or configure your standard ASP.NET pages with dependency injection. While the spring framework does not force any particular application architecture, it encourages the use of a well layered application architecture with distinct tiers for the presentation, service, data access, and database.



4. Spring.Net Framework Advantages
1.Spring.Net enables Dependency Injection for your web pages and controls, which mean that you can inject services into pages, configure controls, and all other good stuff that DI buys you.

2. Spring.Net gives you bidirectional data binding with automatic type conversion, which means that you can avoid a lot of ugly code in your code-behind classes that is normally used to move data from the controls to the model and vice versa. This also means that your event handlers/controller methods do not depend on the input controls, but only on the data model, which allows them to be moved into a separate class if so desired (makes their unit testing much simpler).

3. Spring.Net provides a superior data validation framework that allows you to use same validator definitions in multiple places (web pages and service layer, for example), because it is not tied to the UI in any way. It also makes it very easy to compose validation rules, so you will very rarely have to write your own custom validator, and even when you do, it is a much simpler task than with standard ASP.NET validation framework. Not to mention, you can easily change how validation errors are displayed by plugging in appropriate rendering strategy using standard Spring DI.

4. Spring.Net has arguably better localization support, with well defined fallback rules. For example, you don't really need to do anything in your page in order to apply certain resources automatically. All you need to do is follow the simple resource naming convention. Also, unlike in ASP.NET 2.0, where you need to specify whether you want to access global or local resources, with Spring.NET simple GetMessage call will look for resource in the local resource file and then automatically fall back to global resources. Not to menion that if you don't feel like storing resources in the .NET resource files you can easily implement new message source that will access resources from plain text files, XML files, database, content management system, etc. Finally, image localization is supported as well, in a very simple but effective way.

5. Spring.Net also gives you completely configurable strategies for user's culture management. Out of the box you can choose the one that reads culture information from HTTP request, the one that manages it in a session, or the one that stores it in a cookie. You can also easily write your own culture resolver that stores user's culture information in a database, if that's what you need.

6. You can configure master pages using Dependency Injection, which is arguably a better way to do it than by either specifying it within each page or by configuring it globally in web.config. With Spring, you can choose the granularity that best suits your needs and configure it globally, per context, or on a page by page basis.

7. Spring.Net have library for tackling common jobs like transaction management, logging, caching and exception handling. AOP has been described as a method that allows programmers to modularize the way they deal with components that cut across system elements.

5. Why spring.Net?
Because spring.net take all features of .net framework plus all of this points:
 Open source framework
 Spring provide Patterns of Enterprise Application Architecture by Martin Fowler
And many others.
 Most ideas and architectural concepts in Spring are not platform specific
 Framework to manage object dependencies throughout its lifecycle
 Powerful expression language for manipulating an object at runtime
 Spring provide a validation framework Leverage expression support for validating objects based on expressions
 Spring provide new feature in .net technologies Dependency Injection
– Object not responsible for looking up resources or dependencies.
– Container pushes resources/dependencies into object by reflection-based calls to constructor and/or properties.
– Promotes a design that is easy to unit test
– Promotes coding to interfaces(Strategy Pattern)
– Enables Dependency Injection for Web Services, Remote Objects and Serviced Components
– Enables Dependency Injection for ASP.NET web pages and controls
 Wide range of data access strategies and associated technologies to choose from(Not just ADO.NET),you can use nhibernate O/R …
 Transaction Management Abstraction
 Established persistence patterns at the API level
 Adds Master Pages support to ASP.NET 1.1
 Enables bi-directional data binding
 Isolates you from the changes in the technology
 Another way to think about program structure(AOP)
– Apply common behavior across OO hierarchies “Cross Cutting Concerns”
– Minimize code duplication
– Complementary to good OOP design
– Solves problems that are difficult to solve with OOP
– Leads to cleaner, better modularized code that is easier to maintain and extend.
Examples
– Logging entry/exit/exception to methods
– Performance Metrics
– Observer design pattern
– Caching Method return values
– Security Checks
– Monitoring
– Transaction Management
 Object obtained from a Spring IoC container can be transparently advised based on configuration
– XML, Attributes.
– Can also use programmatic API.


No comments:

Post a Comment