Welcome Guest, you are in: Login

Castle Project

RSS RSS

Navigation (Windsor)






Search the wiki
»

PoweredBy

This documentation is a work in progress.

Let us know if some information is not clear, inaccurate or missing. Also feel free to update the wiki yourself.

How components are created

RSS
Modified on 2011/02/20 15:45 by Jon Marozick Categorized as Uncategorized
Component creation flow

Component creation flow

Introduction

When a component is requested from Windsor container, the container goes through several steps in order to provide the instance. The image on the right depicts the more important aspects of these steps. We'll discuss them here in more detail.

Locating handler

First step performed by the container when a component is requested is to check whether the requested component was registered with the container. The container asks its naming subsystem for the component, and if the component could not be found, the container will try to register it lazily, and if that does not succeed, a ComponentNotFoundException will be thrown.

Assuming the correct component can be found, the container will poll its handler and ask it to resolve the component instance.

What handler does

Handler does few things:


  • When no in-line arguments were provided, it checks whether the component and all its mandatory dependencies can be resolved. If not, a HandlerException is thrown.


What lifestyle manager does

Lifestyle manager has relatively simple role. If it has an instance it can reuse it gets it and returns immediately back to the handler. If not, it asks its component activator to create one for it.

What component activator does

Image
Component activators

Component activator is responsible for creating the instance of the component. Various activators have various ways of achieving that. When you create your component via UsingFactoryMethod the delegate you provided will be invoked to create the instance. Factory Support Facility or Remoting Facility have their own set of activators that perform custom initialization of the components.

Most of the time you will be using DefaultComponentActivator which does the following:

  • Instantiates the component by invoking its constructor.
    Image
    How constructor is selected

    To learn how default component activator selects constructor to use see here.

  • When the instance is created, it then resolves component's property dependencies.
  • When the component is fully created it invokes all commission concerns of the component.
  • Triggers ComponentCreated event on the kernel.
  • Returns the instance back to lifestyle manager.

What handler does 2

Lifestyle manager may save the instance to some contextual cache if needed, so that it can be later reused, and passes it down to the handler. Handler asks release policy to track the component, and then passes it down to the container, which returns it to the user.

See also

How dependencies are resolved

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