You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Albert Kwong <ma...@yahoo.com> on 2004/04/16 05:39:42 UTC

Proposal: container supported interceptable service

I have used the chain of responsibility design pattern
for some of my components, which makes the design
quite clean.  The following proposal generalizes the
pattern and suggests a way to support it through the
container.  What do you think?  Is there anything
similar in avalon that already exists?

Thanks.

Albert Kwong

Proposal: Container Supported Interceptable Service
===================================================

Objective
=========
Allow components (interceptors) to intercept the
operations of another component in a Chain of
Responsibility pattern.  Better support for SOC.


Component
=========

/** @avalon.interceptor type='AbcServiceInterceptor'
*/
public interface AbcService
{
    String doAbc (String param) throws Exception;
}

/**
 * Automatically generated from AbcService meta tags.
 */
public interface AbcServiceInterceptor
{
    String doAbc (String param, Iterator chain) throws
Exception;
}

/**
 * To be deployed as abcService.
 */
public class AbcServiceImpl implements AbcService
{
    String doAbc (String param) throws Exception {};
}

/**
 * to be deployed as abcInterceptor
 */
public class AbcServiceInterceptorImpl implements
AbcServiceInterceptor
{
    String doAbc (String param, Iterator chain) throws
Exception
    {
        /* pre processing interception */
        ((AbcServiceInterceptor) chain.next()).doAbc
(param, chain);
        /* post processing interception */
    }
}


Deployment
==========

<targets>
    <target name='abcInterceptor'>
        <intercept
order='1000'><source>abcService</source></intercept>
    </target>
</targets>


Proxy processing
================
1. Application calls abcService.doAbc (param)
2. Proxy creates the Iterator chain [abcInterceptor,
Proxy(abcService)]     (note: Proxy(abcService)
implements AbcServiceInterceptor)
3. Container calls abcInterceptor.doAbc (param, chain)
4. abcInterceptor pre processing
5. abcInterceptor calls Proxy(abcService).doAbc
(param, chain)
5. Proxy(abcService) calls abcService.doAbc(param)
6. abcService returns
7. Proxy(abcService) returns
8. abcInterceptor post processing
9. abcInterceptor returns
10. ...


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: Proposal: container supported interceptable service

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Friday 16 April 2004 11:39, Albert Kwong wrote:
> What do you think?  

I think you have thrown in some fresh thinking into the pot :o)

However, maybe I am a bit tired, or maybe not smart enough, but I have a bit 
of problems to realize all the details.

Could you elaborate with a larger example;

MyClientImpl  -->  InterceptorOne --> InterceptorTwo  -->  MyServiceImpl



The following things is a bit unclear;

1. How does InceptorOne and InterceptorTwo, respectively, declare that they 
should be 'injected' where they are?

2. You mentioned that the Proxy for AbcServiceImpl is implementing 
AbcInterceptor (just like InterceptorOne and InterceptorTwo above, I guess). 
What if the two interceptors above are removed from the chain?

3. Is there something in the name between AbcService and AbcInceptor?

Sorry, it is a bit blur...

Cheers
Niclas

+---------//-------------------+
|   http://www.bali.ac         |
|  http://niclas.hedhman.org   |
+------//----------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: Proposal: container supported interceptable service

Posted by hammett <ha...@uol.com.br>.
Oh, take a look at that too:

http://jroller.com/comments/hammett?anchor=castle_microkernel

I used aspects to provide interceptors capabilities. However this works for
all components, not for some in particular. What you are proposing can be
(or should be) possible using simple extensions.

Cheers,
hammett


----- Original Message ----- 
From: "hammett" <ha...@uol.com.br>
To: "Avalon Developers List" <de...@avalon.apache.org>
Sent: Friday, April 16, 2004 9:19 AM
Subject: Re: Proposal: container supported interceptable service


> Hi Albert.
>
>
> Take a look at this:
>
> http://marc.theaimsgroup.com/?l=avalon-dev&m=107696768708344&w=2
>
> http://marc.theaimsgroup.com/?t=107678024500003&r=1&w=2
>
> Tell us what you think.
>
>
> Regards,
> hammett
>
>
> ----- Original Message ----- 
> From: "Albert Kwong" <ma...@yahoo.com>
> To: <de...@avalon.apache.org>
> Sent: Friday, April 16, 2004 12:39 AM
> Subject: Proposal: container supported interceptable service
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
> For additional commands, e-mail: dev-help@avalon.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: Proposal: container supported interceptable service

Posted by hammett <ha...@uol.com.br>.
Hi Albert.


Take a look at this:

http://marc.theaimsgroup.com/?l=avalon-dev&m=107696768708344&w=2

http://marc.theaimsgroup.com/?t=107678024500003&r=1&w=2

Tell us what you think.


Regards,
hammett


----- Original Message ----- 
From: "Albert Kwong" <ma...@yahoo.com>
To: <de...@avalon.apache.org>
Sent: Friday, April 16, 2004 12:39 AM
Subject: Proposal: container supported interceptable service




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org