excalibur-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hamilton Verissimo de Oliveira (Engenharia - SPO)" <hamilton.olive...@agenciaclick.com.br>
Subject [RT] Components and Handlers
Date Tue, 29 Jun 2004 14:17:06 GMT

Today, Fortress uses different handlers for different components lifestyles.
In Avalon Castle I thought about adopting this approach and the Merlin's
approach. In fact I ended up using both of them. 

- Component handlers, in Castle, ensure components dependencies can be
satisfied and keeps itself in a non-valid state until it finds the
dependencies. 

[
https://svn.apache.org/repos/asf/avalon/trunk/central/laboratory/avalon-net/
Castle/MicroKernel/Handler/ ]

- The component lifestyle is managed by the ILyfestyle's implementation. 

[
https://svn.apache.org/repos/asf/avalon/trunk/central/laboratory/avalon-net/
Castle/MicroKernel/Lifestyle/ ]

- The component construction is handled by IComponentFactory implementation.

[
https://svn.apache.org/repos/asf/avalon/trunk/central/laboratory/avalon-net/
Castle/MicroKernel/Factory/ ]

The kernel must have a valid IHandlerFactory implementation. This factory
can return different handlers implementation given the component being
registered. Today Castle has two factories that only returns one handler
implementation.

This work was based on Leo Sutic's effort in the Avalon's sandbox in the
constant struggle for the simplest container :-)

In the light of recent discussion about To proxy or not to proxy, to pool or
not to pool, I've imagined that you'd like to have different component
handler (or something like that) to customize components with proxy, aop,
interceptors. Ok, that's fair. Let's work towards it, shall we?

First, lets imagine a hypotechical component coded in three different ways:


/// POJO style
public class EMailSender
{
  // Dependency through constructor
  public EmailSender( Sender sender )
  {
  }
}

/// Avalon style
public class EmailSender implements Configurable
{
  public EmailSender()
  {
  }

  public void configure( Configuration config )
  { 
  }
}

/// Hybrid of Avalon and POJO style
public class EmailSender implements Configurable
{
  public EmailSender( Sender sender )
  {
  }

  public void configure( Configuration config )
  { 
  }
}


Having a separated handler for POJOs and other for Avalon would kill us if
the user'd like to code his components using both of them. Ok, so now we can
make the AvalonHandler extends PojoHandler. That's fine. Now we'd like to
write a InterceptorHandler that gives components interceptors/aop
capabilities. We should extend what?

Creating a chain of handler can solve this situation, or composing them. But
this can be a bit harsh to configure, don't you think? Speaking of thinking,
what do you guys think? ;-)


(Btw I'm not trying to push this model here, just asking for opinions.)

Cheers,
hammett


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org
Apache Excalibur Project -- URL: http://excalibur.apache.org/


Mime
View raw message