You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by raghuku <ra...@yahoo.com> on 2017/02/13 06:40:09 UTC

@PreMatching doesn't seem to work - apache-tomee-7.0.2-plus

I want to create and assign a unique request id for every REST request. In
order to accomplish this, I have implemented ContainerRequestFilter, and
annotated it as @PreMatching - please see below:

-----------------------------------
package com.test.filter;

import java.io.IOException;

import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.PreMatching;
import javax.ws.rs.ext.Provider;

@Provider
@PreMatching
public class MyRequestFilter implements ContainerRequestFilter {
	@Override
	public void filter(ContainerRequestContext context) throws IOException {
		System.out.println("TestRequestFilter.filter");
		String requestId = Utils.requestId();	// generate unique id for this
request...
		context.getHeaders().add("test-requestid",requestId);
	}
}

--------------------------------------------------------------------

However, the container/ JAX-RS framework doesn't seem to be invoking the
filter at all. I put system out in the filter function as shown, and don't
see that happens. Any thoughts what could be causing this? Is there anything
else that I need to do for ContainerRequestFilter and PreMatching to work? I
am using apache-tomee-7.0.2-plus.

Appreciate any lead in resolving the issue...



--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/PreMatching-doesn-t-seem-to-work-apache-tomee-7-0-2-plus-tp4681059.html
Sent from the TomEE Users mailing list archive at Nabble.com.