Reputation: 139
I am using CXF/Karaf, and I have many different RESTful resources within multiple packages/classes.
Question: Is there a way to avoid having to write annotations above every resource, such as @CrossOriginResourceSharing
?
I would like to be able to put this in one place. Below is an example of how this is currently being used:
@CrossOriginResourceSharing(
allowOrigins = {"http://<ip>:<port>"}
)
@GET
@Path("/rest")
@Produces(MediaType.APPLICATION_JSON)
public String rest();
Upvotes: 1
Views: 726
Reputation: 756
You can add this to the class instead of on each resource in the class (and I haven't tested this but you could possible create a super class with this annotation and extend it but I'm not sure if CXF will honour it):
@CrossOriginResourceSharing(
allowOrigins = {"http://<ip>:<port>"}
)
public class resourceGroup {
@GET
@Path("/rest")
@Produces(MediaType.APPLICATION_JSON)
public String rest();
}
Upvotes: 1