You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@excalibur.apache.org by "Hamilton Verissimo de Oliveira (Engenharia - SPO)" <ha...@agenciaclick.com.br> on 2004/06/29 16:17:06 UTC

[RT] Components and Handlers

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/


Re: [RT] Components and Handlers

Posted by Leo Simons <ls...@jicarilla.org>.
Hamilton Verissimo de Oliveira (Engenharia - SPO) wrote:
> 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.

better use delegation.

> That's fine. Now we'd like to
> write a InterceptorHandler that gives components interceptors/aop
> capabilities. We should extend what?

what is interceptor capability? If you want to add interceptors you add 
interceptors.

> 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?

Not really. Can use a builder pattern for example.

handler = myHandlerBuilder
   .newHandler( MyBasicHandlerImplementation.class )
   .addInterceptor( MyAdvice.class )
   .enableConstructorDependencyInjection()
   .enableAvalon()
   .enableLifecycleExtension( MyLifecycleExtension.class )
   .create();

or whatever. Have all the composition is behind the scenes (which is 
also not /that/ difficult to implement well).

> Speaking of thinking,
> what do you guys think? ;-)

Me:
http://lsd.student.utwente.nl/jicarilla/IocContainerInternals
http://jicarilla.sourceforge.net/jicarilla-container-class-diagram.gif
http://cvs.sourceforge.net/viewcvs.py/*checkout*/jicarilla/jicarilla-sandbox/platform/container/api/src/java/org/jicarilla/container/Attic/package.html?content-type=text%2Fplain&rev=1.2

Berin:
http://cvs.sourceforge.net/viewcvs.py/d-haven/dojo/core-j15/src/java/org/d_haven/dojo/

Some others:
http://cvs.picocontainer.codehaus.org/java/picocontainer/src/java/org/picocontainer/?only_with_tag=MX_PROPOSAL

googling for '"Leo Simons" container' or something like that should pop 
up a whole lot of thoughts from a while back ;)

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

hehehe :D

You (and Leo Sutic :-D ) are not so far from what in my current thinking 
is the best architecture. Berin is a few steps ahead of me; Pico nor the 
current fortress are actually /that/ different when you get down to it.

In fact, I decided pico was "good enough" in terms of architecture and 
"a whole lot better" in terms of community and maturity so I rm -Rfed my 
own container experiments and joined Paul 'n Aslak 'n friends. /If/ a 
from-scratch-rewrite of fortress is a good idea (I'm not so sure that it 
is), I think it would be a good idea to start with pico and build on that.

- LSD

---------------------------------------------------------------------
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/