Hi Ishara,

IMHO this is a valid requirement. But as Vidura mentioned ATM we don;t
support dynamic binding from MSF4J.
So we need to implement this from MSF4J level. Then we can provide the
ability to add/remove interceptors at the runtime.

@Azeez, Kishanthan WDYT?

Thanks
Thusitha


On Mon, Jun 5, 2017 at 4:39 AM, Ishara Cooray <[email protected]> wrote:

> + architecture
>
> I
> f you are asking about the dynamic interceptors similar to the dynamic
> binding of filters in JAX-RS spec [1],  MSF4J currently do not support
> dynamic binding of interceptors.
>
>
> [1] https://access.redhat.com/documentation/en-us/red_hat_jb
> oss_fuse/6.3/html/apache_cxf_development_guide/jaxrs20filte
> rs#JAXRS20Filters-DynamicBinding
>
> Yes,
>
> We need a way to bind Interceptors which are coming from a configuration.
> But that also has to be per service , not the global.
>
> Because
> For instance, We have the publisher REST API implemented as a micro
> service.
> We need to secure this service using interceptors. Further, we are
> planning to have one interceptor per authentication type(BasicAuth, OAuth2,
> etc.).
>
> Now, if someone need to add a custom authenticator, it should be possible
> to write a custom authentication interceptor and plug it into the
> Microservice.
>
> Can this be supported?
>
> Thanks & Regards,
> Ishara Cooray
> Senior Software Engineer
> Mobile : +9477 262 9512 <+94%2077%20262%209512>
> WSO2, Inc. | http://wso2.com/
> Lean . Enterprise . Middleware
>
> On Thu, Jun 1, 2017 at 2:25 PM, Vidura Nanayakkara <[email protected]>
> wrote:
>
>> Hi Ishara,
>>
>> So, can we have the support to be able to plug custom interceptors for
>>> microservices?
>>
>>
>> ​
>> I
>> f you are asking about the dynamic interceptors similar to the dynamic
>> binding of filters in JAX-RS spec [1],  MSF4J currently do not support
>> dynamic binding of interceptors.
>>
>>
>> [1] https://access.redhat.com/documentation/en-us/red_hat_jb
>> oss_fuse/6.3/html/apache_cxf_development_guide/jaxrs20filte
>> rs#JAXRS20Filters-DynamicBinding
>>
>> Best Regards,
>> Vidura Nanayakkara
>>
>> On Thu, Jun 1, 2017 at 1:19 PM, Ishara Cooray <[email protected]> wrote:
>>
>>> Thanks for the clarification Vidura.
>>>
>>> So, can we have the support to be able to plug custom interceptors for
>>> microservices?
>>>
>>>
>>> Thanks & Regards,
>>> Ishara Cooray
>>> Senior Software Engineer
>>> Mobile : +9477 262 9512 <+94%2077%20262%209512>
>>> WSO2, Inc. | http://wso2.com/
>>> Lean . Enterprise . Middleware
>>>
>>> On Thu, Jun 1, 2017 at 1:02 PM, Vidura Nanayakkara <[email protected]>
>>> wrote:
>>>
>>>> Hi Ishara,
>>>>
>>>> On Thu, Jun 1, 2017 at 12:29 PM, Ishara Cooray <[email protected]>
>>>> wrote:
>>>>
>>>>> According to the new Interceptor support in msf4j-2.3.0-m2
>>>>>
>>>>> AFAIU,
>>>>> We can bind interceptors for a given microservice as below.
>>>>>
>>>>> InterceptorService is the micro service that is going to be intercepted 
>>>>> by RequestInterceptors and Responseinterceptors annotated by
>>>>>
>>>>> @RequestInterceptor and @ResponseInterceptor
>>>>>
>>>>> @Component(
>>>>>>         name = "InterceptorService",
>>>>>>         service = Microservice.class,
>>>>>>         immediate = true
>>>>>> )@Path("/interceptor-service")public class InterceptorService implements 
>>>>>> Microservice {
>>>>>>
>>>>>>
>>>>>>     private static final Logger log = 
>>>>>> LoggerFactory.getLogger(InterceptorService.class);
>>>>>>
>>>>>>
>>>>>>     /**     * Method for getting the micro-service name.     *     * 
>>>>>> @return name of the micro-service.     */
>>>>>>     @GET
>>>>>>     @Path("/service-name")
>>>>>>     @RequestInterceptor(
>>>>>> ​​
>>>>>> HTTPRequestLogger.class)
>>>>>>     @ResponseInterceptor(HTTPResponseLogger.class)
>>>>>>     public String getServiceName() {
>>>>>>         log.info("HTTP Method Execution - getServiceName()");
>>>>>>         return "WSO2 Service";
>>>>>>     }
>>>>>> }
>>>>>>
>>>>>> 1. Can we use @RequestInterceptor and @ResponseInterceptor
>>>>> annotations to the class level so that it will apply for every resource
>>>>> invocation?
>>>>>
>>>>
>>>> ​Yes, you can use @RequestInterceptor and @ResponseInterceptor to the
>>>> class level so that it will apply to every resource invocation in the
>>>> service.
>>>>
>>>> Example:
>>>>
>>>> @Path("/stockquote")
>>>>
>>>> @RequestInterceptor(
>>>> ​
>>>> HTTPRequestLogger.class)
>>>>
>>>> @ResponseInterceptor({HTTPResponseLogger.class, 
>>>> LogTextResponseInterceptor.class})
>>>>
>>>> public class StockQuoteService {
>>>> // Your resource methods here
>>>> }
>>>>
>>>> Furthermore, if you want to apply the interceptors to all the services in 
>>>> a micro-service in OSGi mode please refer [1] and for non-OSGi mode please 
>>>> refer [2] and [3].
>>>>
>>>>
>>>>> 2. Can we plug a custom request/response interceptors?
>>>>>
>>>>>  Can it be supported something similar to below.
>>>>>  We have a class called ABCRequestInterceptor which implements 
>>>>> RequestInterceptor
>>>>> and there can be classes that extends
>>>>>  ABCRequestInterceptor
>>>>>
>>>>> But , we bind the interceptor as
>>>>>
>>>>>  @RequestInterceptor(ABCRequestInterceptor.class)
>>>>>
>>>>> Will this bind extended Interceptors too to the InterceptorService?
>>>>>
>>>>
>>>> ​In this case the ABCRequestInterceptor will be the interceptor which
>>>> gets executed. Please note that the other interceptors which is extended
>>>> from this class do not get executed​ (The class you mention in the
>>>> annotation is taken exactly as it is)
>>>>
>>>>
>>>>>
>>>>> Thanks & Regards,
>>>>> Ishara Cooray
>>>>> Senior Software Engineer
>>>>> Mobile : +9477 262 9512 <+94%2077%20262%209512>
>>>>> WSO2, Inc. | http://wso2.com/
>>>>> Lean . Enterprise . Middleware
>>>>>
>>>>
>>>>
>>>> ​[1] https://github.com/wso2/msf4j/blob/release-2.3.0-m1/samples/
>>>> interceptor/osgi-interceptor-service/README.md​
>>>> [2] https://github.com/wso2/msf4j/tree/release-2.3.0-m1/samp
>>>> les/interceptor/fatjar-interceptor-service
>>>> [3] https://github.com/wso2/msf4j/blob/release-2.3.0-m1/samp
>>>> les/interceptor/fatjar-interceptor-service/src/main/java/org
>>>> /wso2/msf4j/samples/fatjarinterceptorservice/Application.java
>>>>
>>>> Best Regards,
>>>> Vidura Nanayakkara
>>>>
>>>> --
>>>> Best Regards,
>>>>
>>>> *Vidura Nanayakkara*
>>>> Software Engineer
>>>>
>>>> Email : [email protected]
>>>> Mobile : +94 (0) 717 919277 <+94%2071%20791%209277>
>>>> Web : http://wso2.com
>>>> Blog : https://medium.com/@viduran
>>>> LinkedIn : https://lk.linkedin.com/in/vidura-nanayakkara
>>>>
>>>
>>>
>>
>>
>> --
>> Best Regards,
>>
>> *Vidura Nanayakkara*
>> Software Engineer
>>
>> Email : [email protected]
>> Mobile : +94 (0) 717 919277 <+94%2071%20791%209277>
>> Web : http://wso2.com
>> Blog : https://medium.com/@viduran
>> LinkedIn : https://lk.linkedin.com/in/vidura-nanayakkara
>>
>
>


-- 
Thusitha Dayaratne
WSO2 Inc. - lean . enterprise . middleware |  wso2.com

Mobile  +94712756809
Blog      alokayasoya.blogspot.com
About    http://about.me/thusithathilina
<http://wso2.com/signature>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to