You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stratos.apache.org by Nirmal Fernando <ni...@gmail.com> on 2014/08/21 05:58:27 UTC
Subscription Intercepting Filters
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/
Re: Subscription Intercepting Filters
Posted by Imesh Gunaratne <im...@apache.org>.
+1
On Fri, Aug 22, 2014 at 2:02 AM, Nirmal Fernando <ni...@gmail.com>
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" <ni...@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 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
Re: Subscription Intercepting Filters
Posted by Nirmal Fernando <ni...@gmail.com>.
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" <ni...@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 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/
Re: Subscription Intercepting Filters
Posted by Akila Ravihansa Perera <ra...@wso2.com>.
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" <ni...@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 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/
>
Re: Subscription Intercepting Filters
Posted by Nirmal Fernando <ni...@gmail.com>.
Hi Pradeep,
Filters could leverage these key-value pairs to pass properties into the
main subscription.
One existing use-case is passing LB subscription related properties to the
main subscription.
On Fri, Aug 22, 2014 at 6:21 AM, Pradeep Fernando <pr...@gmail.com>
wrote:
> Hi,
>
> +1.
> Can you please give me a usage for returned 'properties' in the
> interface/implementation ?
>
> thanks.
>
>
> On Thu, Aug 21, 2014 at 6:09 AM, Isuru Haththotuwa <is...@apache.org>
> wrote:
>
>> +1 for this change. This will enable us to cater to such customizations
>> in future as well, without using long and ugly if-else statements.
>>
>>
>> On Thu, Aug 21, 2014 at 9:28 AM, Nirmal Fernando <ni...@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 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/
>>>
>>> --
>>> <http://nirmalfdo.blogspot.com/>
>>> Thanks and Regards,
>>>
>>> Isuru H.
>>> <http://nirmalfdo.blogspot.com/>
>>> +94 716 358 048 <http://nirmalfdo.blogspot.com/>* <http://wso2.com/>*
>>>
>>>
>>> * <http://wso2.com/>*
>>>
>>>
>>>
>
>
> --
> Pradeep Fernando.
> http://pradeepfernando.blogspot.com/
>
--
Best Regards,
Nirmal
Nirmal Fernando.
PPMC Member & Committer of Apache Stratos,
Senior Software Engineer, WSO2 Inc.
Blog: http://nirmalfdo.blogspot.com/
Re: Subscription Intercepting Filters
Posted by Pradeep Fernando <pr...@gmail.com>.
Hi,
+1.
Can you please give me a usage for returned 'properties' in the
interface/implementation ?
thanks.
On Thu, Aug 21, 2014 at 6:09 AM, Isuru Haththotuwa <is...@apache.org>
wrote:
> +1 for this change. This will enable us to cater to such customizations in
> future as well, without using long and ugly if-else statements.
>
>
> On Thu, Aug 21, 2014 at 9:28 AM, Nirmal Fernando <ni...@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 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/
>>
>> --
>> <http://nirmalfdo.blogspot.com/>
>> Thanks and Regards,
>>
>> Isuru H.
>> <http://nirmalfdo.blogspot.com/>
>> +94 716 358 048 <http://nirmalfdo.blogspot.com/>* <http://wso2.com/>*
>>
>>
>> * <http://wso2.com/>*
>>
>>
>>
--
Pradeep Fernando.
http://pradeepfernando.blogspot.com/
Re: Subscription Intercepting Filters
Posted by Isuru Haththotuwa <is...@apache.org>.
+1 for this change. This will enable us to cater to such customizations in
future as well, without using long and ugly if-else statements.
On Thu, Aug 21, 2014 at 9:28 AM, Nirmal Fernando <ni...@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 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/
>
> --
> Thanks and Regards,
>
> Isuru H.
> +94 716 358 048* <http://wso2.com/>*
>
>
> * <http://wso2.com/>*
>
>
>