erard22.ch - Erard 22 – Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

Example domain paragraphs

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

With RESTeasy it’s not that easy to log the response times of your resources in a generic way. The framework provides you several interceptors that you can use. And implementing two of them you can easily log your response times quite nice:

import javax.servlet.http.HttpServletRequest; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.ext.Provider; import org.jboss.resteasy.annotations.interception.ServerInterceptor; import org.jboss.resteasy.core.ResourceMethod; import org.jboss.resteasy.core.ServerResponse; import org.jboss.resteasy.spi.Failure; import org.jboss.resteasy.spi.HttpRequest; import org.jboss.resteasy.spi.interception.PostProcessInterceptor; import org.jboss.resteasy.spi.interception.