Difference between IWindsorInstaller and AbstractFacility in Castle
Asked Answered
V

1

10

I've always been using facilities to register my components but noticed the IWindsorInstaller.

It both look similar to me and I would like to know what the difference is between both and which one should be used where.

Vaticination answered 4/3, 2011 at 21:1 Comment(0)
T
19

Dan,

the difference is the following:

  • installers are meant to encapsulate discrete units of registration. In other words you use installers to register application components in the container. There are helpers for that like Configuration class, or FromAssembly class that you can use to either use configuration file, or to autodiscover your installers and run them all in one go because in most apps you will have several of them.
  • facilities are meant to augment the out of the box capabilities of the container. So you have (using standard facilities as examples) things like TypedFactoryFacility which adds ability to auto create factories to transparently pull components from the container. You have StartableFacility which allows components to be started/stopped without you having to explicitly worry about it. You also have integration facilities for things like NHibernate, or WCF, or Monorail, or ASP.NET MVC that make Windsor aware of certain aspects of other frameworks it works with so that your work is easier. In terms of capabilities facilities can have their own configuration. There also is no helpers to batch add facilities as in most apps you'll only need a few.

Both of them can register stuff, but the main difference is - installers register whatever your application needs (including adding facilities). Facilities on the other hand register what they need in order to do their job.

That usually means that facilities register extensions to the container like custom resolvers, ComponentModel construction contributors or interceptors - things which by definition are aware of the container.

Installers register application level components which best have no knowledge of the container at all.

Hope that makes the distinction clearer.

Tertia answered 5/3, 2011 at 2:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.