avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Albert Kwong <mandr...@yahoo.com>
Subject Proposal: container supported interceptable service
Date Fri, 16 Apr 2004 03:39:42 GMT
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


Mime
View raw message