Return-Path: X-Original-To: apmail-stratos-dev-archive@minotaur.apache.org Delivered-To: apmail-stratos-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4A1491185D for ; Fri, 22 Aug 2014 22:22:06 +0000 (UTC) Received: (qmail 45166 invoked by uid 500); 22 Aug 2014 22:22:06 -0000 Delivered-To: apmail-stratos-dev-archive@stratos.apache.org Received: (qmail 45118 invoked by uid 500); 22 Aug 2014 22:22:06 -0000 Mailing-List: contact dev-help@stratos.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stratos.apache.org Delivered-To: mailing list dev@stratos.apache.org Received: (qmail 45103 invoked by uid 99); 22 Aug 2014 22:22:06 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Aug 2014 22:22:06 +0000 Received: from localhost (HELO mail-vc0-f169.google.com) (127.0.0.1) (smtp-auth username imesh, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 Aug 2014 22:22:05 +0000 Received: by mail-vc0-f169.google.com with SMTP id le20so13264551vcb.0 for ; Fri, 22 Aug 2014 15:22:04 -0700 (PDT) X-Received: by 10.220.251.200 with SMTP id mt8mr5733378vcb.24.1408746124949; Fri, 22 Aug 2014 15:22:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.156.164 with HTTP; Fri, 22 Aug 2014 15:21:43 -0700 (PDT) In-Reply-To: References: From: Imesh Gunaratne Date: Fri, 22 Aug 2014 18:21:43 -0400 Message-ID: Subject: Re: Subscription Intercepting Filters To: dev Content-Type: multipart/alternative; boundary=089e0122f0985b3f9c05013f443f --089e0122f0985b3f9c05013f443f Content-Type: text/plain; charset=UTF-8 +1 On Fri, Aug 22, 2014 at 2:02 AM, Nirmal Fernando wrote: > Hi Akila, > > You would need to implement the interface and add the fully qualified > class name of it, to the META-INF/services folder in a file named " > org.apache.stratos.manager.subscription.filter.SubscriptionFilter" (I am > planning to use the Java ServiceLoader - > http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html) > > > On Fri, Aug 22, 2014 at 10:38 AM, Akila Ravihansa Perera < > ravihansa@wso2.com> wrote: > >> Hi Nirmal, >> >> This is a very useful feature to have. >> >> Can you please give some implementation details about how we can hook a >> custom filter processor to the filter chain? >> >> Thanks. >> On 21 Aug 2014 09:28, "Nirmal Fernando" wrote: >> >>> Hi All, >>> >>> Currently, there's no clean way to intercept a subscription request and >>> do some pre-processing. As of now, we do some pre-processing of a >>> subscription request in order to identify the need of a load balancer and >>> act accordingly. I currently have another use-case to intercept a >>> subscription request and act upon a parameter. >>> >>> Hence, to make the code clean over there, I propose we introduce a >>> Subscription Filter chain where you could intercept a subscription request >>> and do some pre-processing before creating the actual subscription. >>> >>> Following is the interface design, I've come up with. >>> >>> /** >>> >>> * Intercepts the flow of Cartridge Subscription. >>> >>> * Implementations of this class would get executed before making the >>> real subscription. >>> >>> */ >>> >>> public interface SubscriptionFilter { >>> >>> >>> /** >>> >>> * Do some pre-processing on a subscription request. >>> >>> * @param cartridgeInfo {@link CartridgeInfo} >>> >>> * @param subscriptionData {@link SubscriptionData} >>> >>> * @return {@link Properties}, if there are any. >>> >>> * @throws ADCException on a failure while processing. >>> >>> */ >>> >>> public Properties execute(CartridgeInfo cartridgeInfo, SubscriptionData >>> subscriptionData) throws ADCException ; >>> >>> } >>> >>> Let me know your thoughts. >>> >>> -- >>> Best Regards, >>> Nirmal >>> >>> Nirmal Fernando. >>> PPMC Member & Committer of Apache Stratos, >>> Senior Software Engineer, WSO2 Inc. >>> >>> Blog: http://nirmalfdo.blogspot.com/ >>> >> > > > -- > Best Regards, > Nirmal > > Nirmal Fernando. > PPMC Member & Committer of Apache Stratos, > Senior Software Engineer, WSO2 Inc. > > Blog: http://nirmalfdo.blogspot.com/ > -- Imesh Gunaratne Technical Lead, WSO2 Committer & PMC Member, Apache Stratos --089e0122f0985b3f9c05013f443f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
+1


On Fri, Aug 22, 2014 at 2:02 AM, Nirmal Fernando <nirmal0= 70125@gmail.com> wrote:
Hi Akila,

You would need to implement the interface and add the fully qualified cla= ss name of it, to the META-INF/services folder in a file named "org.apache.stratos.manager.subs= cription.filter.Su= bscriptionFilter" (I am planning to use the Java ServiceLoader -=C2=A0= http://docs.oracle.com/javase/6/docs/api/ja= va/util/ServiceLoader.html)

On Fri, Aug 22, 2014 at 10:38 AM, Akila Ra= vihansa Perera <ravihansa@wso2.com> wrote:

Hi Nirmal,

This is a very useful feature to have.

Can you please give some implementation details about how we= can hook a custom filter processor to the filter chain?

Thanks.

On 21 Aug 2014 09:28, "Nirmal Fernando"= ; <nirmal070= 125@gmail.com> wrote:
Hi All,

Currently, there's no clean= way to intercept a subscription request and do some pre-processing. As of = now, we do some pre-processing of a subscription request in order to identi= fy the need of a load balancer and act accordingly. I currently have anothe= r use-case to intercept a subscription request and act upon a parameter.

Hence, to make the code clean over there, I propose we = introduce a Subscription Filter chain where you could intercept a subscript= ion request and do some pre-processing before creating the actual subscript= ion.=C2=A0

Following is the interface design, I've come up wit= h.

/**

=C2=A0* Intercepts the flow of Cartridge Subscription.

=C2=A0* Implementations of this class would get executed before making= the real subscription.

=C2=A0*/

public in= terface SubscriptionFilter {

<= br>

=C2=A0 =C2=A0 =C2=A0 =C2=A0/**

* Do some pre-processing on a subscription request.

= * @param cartridgeInfo {@link CartridgeInfo= }=C2=A0

* @param<= span style=3D"color:rgb(79,118,203)"> subscriptionData {@link Subscr= iptionData}

* @return {@link= Properties}, if there are any.

* @throws ADCException on a failure while processing.=

*/

public Properties execute(CartridgeInfo = cartridgeInfo, SubscriptionData subscriptionData) throws ADCException ;

}

<= br>
Let me know your thoughts.

--
Best Regards,
Nirmal

Nirmal Fernando.
PPMC Member &a= mp; Committer of Apache Stratos,
Senior Software Engineer, WSO2 Inc.




--
=
Best Regards,
Nirmal

Nirmal Fernando.
PPMC Me= mber & Committer of Apache Stratos,
Senior Software Engineer, WSO2 I= nc.




-= -
Imesh Gunaratne

Technical Lead, W= SO2
Committer & PMC Member, Apache Stratos
--089e0122f0985b3f9c05013f443f--