0

I have created a standard CDI (WELD) interceptor to log method calls:

@MyInterceptorBinding
@Interceptor
public class MyInterceptor implements Serializable {

    @AroundInvoke
    public Object interceptMethod(InvocationContext ctx) throws Exception {

        // Do some Logging Operations

        try {
            Object result = ctx.proceed();
            return result;
        } catch (Exception e) {
            throw e;
        }
    }
}

I would like to log also the session id from which the method is called (log also the request id would be great!).

Is there any way?

1 Answers1

0

Yes.

So you would need to create a @WebFilter installed in your app that stored the session id in a requestScoped bean. You could then inject said requestScoped bean into your interceptor and retrieve it.

Jonathan S. Fisher
  • 8,189
  • 6
  • 46
  • 84