Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,128 | Comments: 45,550

filter by tags archive

Binsor 2.0

time to read 4 min | 671 words

All credit should go to Craig Neuwirt, for some amazing feats of syntax. He has managed to extend Binsor to include practically all of Windsor's configuration schema. This is important because previously we had to resort to either manual / ugly stuff or go back to XML (see: manual & ugly).

This is important because some of the more interesting things that you can do with Windsor are done using the facilities, and Craig has made sure that Binsor will support the main ones in a natural manner, including out of the box support for the standard configuration model.

Let us start by using the standard configuration model for a moment, the Active Record Integration Facility is expecting to be configured from XML, but we can configure it like this:

facility arintegration, ActiveRecordFacility:
		@isWeb = true, isDebug = true
		assemblies = [ Assembly.Load("My.Assembly") ]
		config(keyvalues, item: add):
			show_sql = true
			command_timeout = 5000
connection.isolation = 'ReadCommitted' cache.use_query_cache = false dialect = 'NHibernate.Dialect.MsSql2005Dialect' connection.provider = 'NHibernate.Connection.DriverConnectionProvider' connection.driver_class = 'NHibernate.Driver.SqlClientDriver' connection.connection_string_name = 'MyDatabase' end end

To compare, here is the equivalent  XML configuration.

<facility id="arintegration" 
	type="Castle.Facilities.ActiveRecordIntegration.ActiveRecordFacility, Castle.Facilities.ActiveRecordIntegration" 
	<add key="hibernate.cache.use_query_cache" value="true" />
	<add key="hibernate.connection.isolation" value="ReadCommitted" />
	<add key="hibernate.show_sql" value="false" />
	<add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2005Dialect" />
	<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
	<add key="hibernate.connection.connection_string_name" value="MyDatabase" />
	<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />

We don't have any significant reduction in the number of lines. This is mostly because we need to specify a lot of items for the facility to work, but we do have significant reduction in the noise that we have to deal with.

But, frankly, this isn't the best sample, let us take a look at the shortcuts that Binsor now provides, shall we?

Event Wiring

XML configuration:

      type="Castle.Facilities.EventWiring.Tests.Model.SimpleListener, Castle.Facilities.EventWiring.Tests" />

      type="Castle.Facilities.EventWiring.Tests.Model.SimplePublisher, Castle.Facilities.EventWiring.Tests" >
      	<subscriber id="SimpleListener" event="Event" handler="OnPublish"/>

And the Binsor configuration to match it:

component simple_listener, SimpleListener

component simple_publisher, SimplePublisher:
	wireEvent Publish:
		to @simple_listener.OnPublish

Now that is far clearer, isn't it?

Factory Support

XML configuration:

<component id="mycompfactory" 
      type="Company.Components.MyCompFactory, Company.Components"/>

<component id="mycomp" 
	type="Company.Components.MyComp, Company.Components"
	factoryCreate="Create" />

Binsor configuration:

component mycompfactory, MyCompFactory

component mycomp, MyComp:
	createUsing @mycompfactory.Create

Other new features:

  • Integrating Castle Resources, so now we can use Binsor over several files, which can be located anywhere, including assembly resources, for instance.
  • Easy support for startable and life styles.
  • Extension points for future needs.


Gian Maria

Ok, it is clear that you hate XML :D. I must admit that bindsor is really interesting, but I like the XML syntax too. It would be interesting making a pool to understand how many people feels confortable with XML and how many feels the need for a different syntax to handle configurations.


Have you ever considered extracting Binsor from Rhino Commons to separate project?

Binsor adds great value to the Windsor container and having it as a separate project might make it easier for people to use, also a rhino commons or a separate binsor release that was built against castle RC3 would be great. It's not bad but it's a little work to get rhino commons to compile against latest caste and nhibernate release.

Paul Cowan

I really like the look of binsor and have hated the bloated config files we have been producing in our apps for some time.

Is there a good binsor tutorial anywhere?



Ayende Rahien


Yes, I'll probably do that

Ayende Rahien



Paul Cowan

Now one thing I would like to throw in the mix is............

One thing I like about the xml approach in conjunction nant is being able to pass in properties like the connection string from the command line and then use xmlpoke to set them dependant on the environment.

Now how would we do that with the binsor approach..............

Arne Claassen

I have to admit that I must have been working with XML for too long, because I look at both versions and can grok the XML quicker and feel more confident that I wouldn't make syntax errors in writing it.

I won't argue about XML is verbosity, not being a language, etc. But for defining hierarchical configuration data, I have no problem reading it. And I don't have to learn a new syntax for every configuration I need to undertake.

I agree that once XML gets used to define logical things like if/else, etc. it's no longer config and XML is the wrong approach. But for most things that I need to configure, I'd rather them all be XML, because it reduces the learning curve and I can parse/generate/author it with one set of tools.

Mind you, I'm not promoting configuration over convention, but just saying if there is configuration to be done, I like the XML syntax.

Ayende Rahien

What I think that people are missing is that those are just the icing on the cake.

The main advantages are that you get rid of repeated stuff. This just mean that you can get read of even more stuff

Tom Opgenorth

Hmmm, I guess I should go get Binsor 2.0 and update my quick intro to Binsor on my website.


i have to second binsor being it's own project...

my environment is pretty open to open source(we're using nhibernate, windsor and nlog in our project)..... but introducing the terms "binsor" AND "rhino commons" just to get slimmer config files is a difficult argument to make.

Paul Cowan

I guess what I want to know is, can I use binsor to load all my services <component id='blah' type=''...

And still keep the xml for my facilities?

Is this possible.

Ayende Rahien


Yes, you can.

After you init the container,

BooReader.Read(container, "boo file")

David Gardiner

I've tried to document the necessary steps to compiling the code to get this to run.


Comment preview

Comments have been closed on this topic.


  1. The worker pattern - 2 days from now

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    26 May 2016 - The client side
  2. RavenDB 3.5 whirl wind tour (14):
    25 May 2016 - Got anything to declare, ya smuggler?
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats