0

I have a JAX-RS based (RESTEasy) REST server that uses Java annotations to label resource methods with URLs, etc. For example, a methods can have the annotations

@javax.ws.rs.GET
@javax.ws.rs.Path("/users/{user_id}")
public Response getUser(...)

and will be called automatically when a client calls the GET /users/1234 HTTP/1.1 URL.

I am finding that my resource methods have more and more "common" logic that must be executed with every method: logging, security checks, query parameter validation, etc. I believe that this calls for Aspect-Orient-Programming (AOP), but I have not used this technology before. If I use one of the AOP frameworks, will my annotation "labeling" be preserved so that the JAX-RS driver can find my resource methods? Which AOP frameworks will work with my requirements?

1 Answer 1

1

AspectJ fulfills your requirements: AspectJ can intercept calls or executions of annotated methods without changing or removing the annotations.

For instance, we used AspectJ on JPA entities and these classes were still visible by Hibernate.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.