+ 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_ jboss_fuse/6.3/html/apache_cxf_development_guide/ jaxrs20filters#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 WSO2, Inc. | http://wso2.com/ Lean . Enterprise . Middleware On Thu, Jun 1, 2017 at 2:25 PM, Vidura Nanayakkara <vidu...@wso2.com> 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_ > jboss_fuse/6.3/html/apache_cxf_development_guide/ > jaxrs20filters#JAXRS20Filters-DynamicBinding > > Best Regards, > Vidura Nanayakkara > > On Thu, Jun 1, 2017 at 1:19 PM, Ishara Cooray <isha...@wso2.com> 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 <vidu...@wso2.com> >> wrote: >> >>> Hi Ishara, >>> >>> On Thu, Jun 1, 2017 at 12:29 PM, Ishara Cooray <isha...@wso2.com> 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 : vidu...@wso2.com >>> 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 : vidu...@wso2.com > 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 >
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev