Cuyahoga logo

Castle vs Spring.NET

Modified: 2008/07/10 08:55 by zeuslin - Categorized as: Development
Edit

Introduction

Both frameworks provide IoC and AOP capabilities, a Web Application Framework and further complementary capabilities.

Spring makes heavy use of XML configuration files, whereas Castle also provides an API allowing to programmatically configure the Container.

Edit

Inversion of Control Container

Edit

Spring.NET

The Spring.Core library provides Dependency Injection functionality. Most of the libraries in the Spring.NET distribution depend upon and extend the functionality provided by this core library. The basic concept here is provided by the IObjectFactory interface that provides a factory pattern removing the need for programmatic singletons and numerous service locator stubs, allowing you to decouple the configuration and specification of dependencies from your actual program logic. An extension to the IObjectFactory, the IApplicationContext is also located here and adds more enterprise-centric features such as text localization using resource files, event-propagation, and resource-loading.

Edit

Castle

The WindsorContainer aggregates the MicroKernel providing a simpler interface and a set of important features that relies on MicroKernel extension points. The MicroKernel concern is to offer an extensible inversion of control container core. The Windsor concern is to offer a facade to the kernel and deal with external configuration, proxies and automatic component/facilities install. These are not MicroKernel's concern, and we want to keep both code bases as small and simple as possible.

Edit

Aspect Oriented Programming

Edit

Spring.NET

The Spring.Aop library provides Aspect Oriented Programming (AOP) support to your business objects. The Spring.Aop library complements the IoC container in the Spring.Core library to provide a foundation for building enterprise applications and applying services to business objects declaratively.

Edit

Castle

Aspect# is an AOP (Aspect Oriented Programming) framework for the CLI (.Net and Mono). It relies on DynamicProxy and offers a built-in language to declare and configure aspects, and is compliant with AopAlliance.

Edit

Web Framework

This is probably a feature where the frameworks differ most.

Edit

MonoRail

MonoRail (MR) uses the Front Controller pattern to serve web requests. A HttpHandler maps requests with a special extension (default: .rails) to controllers which in turn render the contents using a predefined view template.

Actually MR doesn't even rely on ASP.NET as view engine but integrates NVelocity as view engine. Although MR offers lots of features for Web Applications, due to its completely different approach regarding Cuyahoga, it will not be discussed further.

More detailed information can be here http://www.castleproject.org/index.php/MonoRail MonoRail at Castle

Edit

Spring Web Framework

The Spring Web Framework (SW), relies on ASP.NET's Page Controller implementation to serve requests.

Here too, a HttpHandler is used to handle calls to *.aspx requests. The page is being "preprocessed" so the IoC Container can inject dependencies to the pages or even controls.

To be able to make use of further features, aspx pages or controls have to inherit from Springs extended base classes.

Edit

Master Pages

Very similar approach as ASP.NET 2.0 Master Pages. Since Cuyahog already offers this feature (in an even more dynamic way), this is probably not much of interest.

Edit

Bidirectional Data binding

Automatic mapping from the model to the controls and vice versa. At the time of this writing, the mapping is being defined using attributes but will soon change to use methods for allowing more flexibility.

Edit

Automatic Localization

Push and Pull Localization. Whereas "Push" is probably more interesting, allowing to automatically fill predefined controls (e.g. Label) with localized strings.

Edit

Result Mapping

Page flow can be externalized using configuration files. When using Server.Transfer (internally) arbitrary objects can be transferred between pages using HttpContext.

Edit

Web Services Support

Spring allows to expose plain C# classes as webservices and brings full support for IoC with Web Services

More information can be found here http://www.springframework.net/doc/reference/html/web.html Web Framework Reference

Edit

NHibernate Integration

Edit

Spring.NET

Spring.Net provides support to NHibernate. In addition, it provides HibernateTemplates and other classes to simplify the use of NHibernate. Transaction Management is able to manage ADO.NET and NHibernate data access objects under one single local transaction or global transaction if you wish.

Edit

Castle: NHibernate facility

Castle offers NHibernate integration, providing session and transaction management for NHibernate.

Edit

Additional Components/Services

Edit

Spring.NET





Edit

Castle

Facilities:

Automatic Transaction Management, Perform automatic transaction management for your classes through interception Batch Registration, Registers components based on configuration instructions Cache, Allows cache for your components

EnterpriseLibrary, Provides integration with MS' Enterprise Library Configuration package

EventWiring, Allow subscribers to connect to events exposed by publishers

FactorySupport, Allow your application to use external factories

Logging, Provides logging abilities for your components

RemotingFacility, Configures and provide access to remote components in a transparent fashion.

Startable, Implements the startable semantic for components

TypedFactory, Given a factory interface, automatic implement it delegating creation to the container

Services:

Transaction,Logging

ScrewTurn Wiki version 2.0.31. Some of the icons created by FamFamFam.