Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Pinned topic Applying a Servlet Filter to SCA JSON/RPC generated servlets
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
We have a number of services exposed as JSON-RPC endpoints where I'd like to apply a servlet filter (with the intent of leveraging MDC for logging traceability purposes). I'm struggling to find documentation related to this need; can someone advise or point me in the right direction?
Updated on 2012-12-13T19:17:55Z at 2012-12-13T19:17:55Z by SystemAdmin
Re: Applying a Servlet Filter to SCA JSON/RPC generated servlets2012-12-11T16:27:15ZThis is the accepted answer. This is the accepted answer.For clarity sake, I can see this happening at startup:
[12/11/12 9:56:23:554 CST] 0000000f WASSessionCor I SessionContextRegistry getSessionContext SESN0176I: Will create a new session context for application key default_host/myRoot/MyService [12/11/12 9:56:23:569 CST] 0000000f webcontainer I com.ibm.ws.wswebcontainer.VirtualHost addWebApplication SRVE0250I: Web Module SCA-generated Dynamic WAR from BLA Name_CompositeName:MyServiceComposite, WAR NameSCAHttpBindSERV__myRoot_MyService.war has been bound to default_host[*:9080,*:80,*:9443,*:5060,*:5061,*:443].
The related artifact is generated in the following location:
If one wanted to filter this service, they would hypothetically need a way to influence the creation of this war's web.xml.
If this is not an appropriate path, is there some other supported mechanizm which would allow us to filter/intercept requests to these services?
*-Names have been changed for illustration purposes
Re: Applying a Servlet Filter to SCA JSON/RPC generated servlets2012-12-11T19:51:39ZThis is the accepted answer. This is the accepted answer.
- SystemAdmin 110000D4XK
My understanding is that you cannot modify the creation of the WAR. Sorry I can't point you to the right path, but can come with an idea.
You can create a component which has a Java implementation and offer a service that will do the actual logging job.
Now, you can use that service as a reference in your business component and call the logger from within the implementation.
This is not a really a perfect solution because you need to mix your business logic with the tracing logic :(.
I understand that's exactly what you are trying to avoid by using a ServletFilter.
Hope someone in the forum can help a lot more than my disappointing comment.
"If you prefer to speak in Spanish, please contact me directly"
Re: Applying a Servlet Filter to SCA JSON/RPC generated servlets2012-12-13T19:17:55ZThis is the accepted answer. This is the accepted answer.
- SystemAdmin 110000D4XK
Compared to our current implementation which simply requires a bundle dependency on slf4j-api and we're talking about a lot of overhead.
I understand the limitation on the filter approach and I'm wondering if there's a more "SCA way" of intercepting these requests?