On Wed, Mar 1, 2017 at 9:19 AM, Thusitha Thilina Dayaratne <
[email protected]> wrote:

> Hi Malintha,
>
> ATM if you try to access the request payload at the interceptor level, you
> won't be able to access that again in the service level and it will cause
> the particular thread to get wait.
> Shall we have a quick discussion on that today? That will help to come up
> with a solution for this.
>
Sure Thusitha. Let's have a discussion today. That would be great.

Thanks!
Malintha

>
> Thanks
> Thusitha
>
> On Tue, Feb 28, 2017 at 10:29 PM, Malintha Amarasinghe <[email protected]
> > wrote:
>
>> + NuwanD, Sanjeewa
>>
>> On Tue, Feb 28, 2017 at 10:28 PM, Malintha Amarasinghe <
>> [email protected]> wrote:
>>
>>> Hi Vidura,
>>>
>>> I went through the links and the approaches you suggested and I have a
>>> couple of questions. I have also tried is to build the Request inside the
>>> Interceptor and get the Java method and the args from the Request (which
>>> was suggested during the offline discussion). For that, I tried to get this
>>> block of code [1] (which builds the request) inside the Interceptor. And
>>> that was successful, but I needed access to some of the internal objects in
>>> MSF4J request path. Ex: HttpResourceModel object [2]. They are not
>>> currently available in Interceptor level, so I had to modify ms4fj-core bit
>>> locally (just to check) to get them inside the Interceptor.
>>>
>>> Let's say we are following the approach 1.
>>>
>>>    - *Write a custom context provider of your own which will describe
>>>    how the injected value is generated by implementing a certain interface.*
>>>
>>> In the custom context provider, will we have access to the internal
>>> objects like [1] so that we can use them to generate the custom context
>>> object?
>>>
>>>    - *Register the custom context provider to the MSF4J*
>>>    - *Inject the value using @Context annotation (Ex:- @Context(String
>>>    key) Object[] arguments)*
>>>
>>> Will it be possible to access the injected values within Interceptors?
>>> Since one of our requirement is to come up with an Interceptor to validate
>>> ETags in a central place, we need to access them within the Interceptor.
>>>
>>> [1] https://github.com/wso2/msf4j/blob/v2.1.1/core/src/main/
>>> java/org/wso2/msf4j/internal/MSF4JMessageProcessor.java#L137-L144
>>> [2] https://github.com/wso2/msf4j/blob/v2.1.1/core/src/main/java
>>> /org/wso2/msf4j/internal/MSF4JMessageProcessor.java#L129
>>>
>>> Thanks!
>>> Malintha
>>>
>>> On Mon, Feb 27, 2017 at 3:08 PM, Malintha Amarasinghe <
>>> [email protected]> wrote:
>>>
>>>> Hi Thusitha and all,
>>>>
>>>> Thank you very much for considering this.
>>>>
>>>> @Vidura, Thanks a lot for the detailed response. I will go through it
>>>> and get back to you.
>>>>
>>>> Thanks!
>>>> Malintha
>>>>
>>>>
>>>> On Mon, Feb 27, 2017 at 2:54 PM, Vidura Nanayakkara <[email protected]>
>>>> wrote:
>>>>
>>>>> [Adding Azeez]
>>>>>
>>>>> Hi,
>>>>>
>>>>> In relation to the offline discussion we had, it was clear that the
>>>>> above functionality is not sufficient for your requirement. As per the
>>>>> offline discussion, the suggested approach was to use custom contexts.
>>>>> [1] <http:///>, [2]
>>>>> <https://www.blackpepper.co.uk/blog/custom-context-providers-for-cxf-with-the-context-annotation>
>>>>>  describes
>>>>> an Apache CXF example of using custom contexts.
>>>>>
>>>>> Currently in MSF4J using @Context annotation we can inject the
>>>>> Request, Response, HttpStreamer, FormParamIterator and MultivaluedMap
>>>>> instances. However, these are not accessible via interceptors as per the
>>>>> current implementation. The approach we were using to inject values is by
>>>>> using the approach I have explained in the previous email.
>>>>>
>>>>> Therefore to solve the above problem, there are 2 solutions we can
>>>>> introduce to MSF4J.
>>>>>
>>>>>    1. *Introduce custom injection and lifecycle management [1]
>>>>>    <https://jersey.java.net/documentation/latest/ioc.html>, [2]
>>>>>    
>>>>> <https://www.blackpepper.co.uk/blog/custom-context-providers-for-cxf-with-the-context-annotation>
>>>>>    to MSF4J.*
>>>>>
>>>>> Using this approach what you should basically do is:
>>>>>
>>>>>
>>>>>    - Write a custom context provider of your own which will describe
>>>>>       how the injected value is generated by implementing a certain 
>>>>> interface.
>>>>>       - Register the custom context provider to the MSF4J
>>>>>       - Inject the value using @Context annotation (Ex:-
>>>>>       @Context(String key) Object[] arguments)
>>>>>
>>>>>
>>>>>    1. *Have a Map<String, Object> map that could be injected using
>>>>>    @Context annotation*
>>>>>
>>>>> Using this approach what you basically do is:
>>>>>
>>>>>
>>>>>    - Add the arguments you need to inject using the @Context
>>>>>       annotation using @SetContext(String key, Object value). This can be 
>>>>> done
>>>>>       inside interceptors or HTTP methods
>>>>>       - Inject the value to using @Context(String key)
>>>>>
>>>>> WDYT?
>>>>>
>>>>> [1] Custom Injection and Lifecycle Management
>>>>> <https://jersey.java.net/documentation/latest/ioc.html>
>>>>> [2] Custom Context Providers for CXF with the Context Annotation
>>>>> <https://www.blackpepper.co.uk/blog/custom-context-providers-for-cxf-with-the-context-annotation>
>>>>>
>>>>> On Mon, Feb 27, 2017 at 9:59 AM, Vidura Nanayakkara <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Hi Malintha,
>>>>>>
>>>>>> You can access the `Request` instance from the interceptors. You also
>>>>>> can access the same Request instance from the HTTP resource by injecting
>>>>>> the request to the HTTP method (`@Context Request request`). You also can
>>>>>> set any argument in the request using `request.setProperty(String key,
>>>>>> Object value)` method and retrieve the value using
>>>>>> `request.getProperty(String key)` method. Will this be sufficient for 
>>>>>> your
>>>>>> requirement?
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Mon, Feb 27, 2017 at 5:55 AM, Thusitha Thilina Dayaratne <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Hi Malintha,
>>>>>>>
>>>>>>> Thank you very much for the PR. We did some restructuring for the
>>>>>>> interceptors to cater product requirementsts[1]. Therefore we won't be 
>>>>>>> able
>>>>>>> to directly merge this. But surely we will check what we can do with 
>>>>>>> this.
>>>>>>>
>>>>>>> [1] - https://github.com/wso2/msf4j/pull/338
>>>>>>>
>>>>>>> Thanks
>>>>>>> Thusitha
>>>>>>>
>>>>>>> On Sun, Feb 26, 2017 at 4:04 PM, Malintha Amarasinghe <
>>>>>>> [email protected]> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> Currently in MSF4J Interceptor level, we can get the HTTP handler
>>>>>>>> method which would be invoked by calling  serviceMethodInfo.get
>>>>>>>> Method().
>>>>>>>>
>>>>>>>> Additionally, It will be useful to have request parameters as well
>>>>>>>> in order to perform various types of request validations in Interceptor
>>>>>>>> level such as Bean validation and ETag validation.
>>>>>>>>
>>>>>>>> Tried to do a fix which adds a new field to ServiceMethodInfo class
>>>>>>>> as args[] [1]. But this required some API changes.
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>>
>>>>>>>> [1] https://github.com/wso2/msf4j/pull/356
>>>>>>>>
>>>>>>>> --
>>>>>>>> Malintha Amarasinghe
>>>>>>>> Software Engineer
>>>>>>>> *WSO2, Inc. - lean | enterprise | middleware*
>>>>>>>> http://wso2.com/
>>>>>>>>
>>>>>>>> Mobile : +94 712383306P
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Thusitha Dayaratne
>>>>>>> Software Engineer
>>>>>>> WSO2 Inc. - lean . enterprise . middleware |  wso2.com
>>>>>>>
>>>>>>> Mobile  +94712756809 <+94%2071%20275%206809>
>>>>>>> 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
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> 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 <http://wso2.com/>
>>>>>> Twitter : http://twitter.com/viduranana
>>>>>> LinkedIn : https://lk.linkedin.com/in/vidura-nanayakkara
>>>>>> <http://wso2.com/>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 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 <http://wso2.com/>
>>>>> Twitter : http://twitter.com/viduranana
>>>>> LinkedIn : https://lk.linkedin.com/in/vidura-nanayakkara
>>>>> <http://wso2.com/>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Malintha Amarasinghe
>>>> Software Engineer
>>>> *WSO2, Inc. - lean | enterprise | middleware*
>>>> http://wso2.com/
>>>>
>>>> Mobile : +94 712383306 <+94%2071%20238%203306>
>>>>
>>>
>>>
>>>
>>> --
>>> Malintha Amarasinghe
>>> Software Engineer
>>> *WSO2, Inc. - lean | enterprise | middleware*
>>> http://wso2.com/
>>>
>>> Mobile : +94 712383306 <+94%2071%20238%203306>
>>>
>>
>>
>>
>> --
>> Malintha Amarasinghe
>> Software Engineer
>> *WSO2, Inc. - lean | enterprise | middleware*
>> http://wso2.com/
>>
>> Mobile : +94 712383306 <+94%2071%20238%203306>
>>
>
>
>
> --
> Thusitha Dayaratne
> Software Engineer
> WSO2 Inc. - lean . enterprise . middleware |  wso2.com
>
> Mobile  +94712756809 <+94%2071%20275%206809>
> Blog      alokayasoya.blogspot.com
> About    http://about.me/thusithathilina
> <http://wso2.com/signature>
>
>


-- 
Malintha Amarasinghe
Software Engineer
*WSO2, Inc. - lean | enterprise | middleware*
http://wso2.com/

Mobile : +94 712383306
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to