class ContextsMediaTypeAspect {

    @Before("execution(public * ContextsJaxrsService.*(..))")
    public void checkMediaType(JoinPoint joinPoint) {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String mediaType = request.getHeader(CONTENT_TYPE);
        String accept = request.getHeader(ACCEPT);

        failIfHeaderEndsWithXml(mediaType, Response.Status.UNSUPPORTED_MEDIA_TYPE);
        failIfHeaderEndsWithXml(accept, Response.Status.NOT_ACCEPTABLE);
    }

}