IC5Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Topic
  • 3 replies
  • Latest Post - ‏2012-12-13T19:17:55Z by SystemAdmin
SystemAdmin
SystemAdmin
126 Posts

Pinned topic Applying a Servlet Filter to SCA JSON/RPC generated servlets

‏2012-12-11T05:24:51Z |
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
  • SystemAdmin
    SystemAdmin
    126 Posts

    Re: Applying a Servlet Filter to SCA JSON/RPC generated servlets

    ‏2012-12-11T16:27:15Z  
    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:
    
    \temp\scacache\dynamicEars\MyServiceComposite\SCAHttpBindSERV__myRoot_MyService.war
    


    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
  • SystemAdmin
    SystemAdmin
    126 Posts

    Re: Applying a Servlet Filter to SCA JSON/RPC generated servlets

    ‏2012-12-11T19:51:39Z  
    For clarity sake, I can see this happening at startup:

    <pre class="jive-pre"> [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]. </pre>

    The related artifact is generated in the following location:
    <pre class="jive-pre"> \temp\scacache\dynamicEars\MyServiceComposite\SCAHttpBindSERV__myRoot_MyService.war </pre>

    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
    Hi John.

    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"
  • SystemAdmin
    SystemAdmin
    126 Posts

    Re: Applying a Servlet Filter to SCA JSON/RPC generated servlets

    ‏2012-12-13T19:17:55Z  
    Hi John.

    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"
    The difficulty with this approach (it seems) is that every component which performs logging would need to be wired up with this loggin service. This would include a lot of work within our blueprints as our entire business layer is implemented as osgi bundles.

    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?