Question

I am using Spring. I have an several endpoints in my application. Basically, each endpoint return a different object. The application consists in several layers. It is important to us , no matter where an error occurs , to propagate the errors to the caller of the endpoints. Our approach It is to throw an exception where the error happens , and it should be caught up in the endpoint , and the endpoint should change the status codes of the response according to the information in the exception. We catch up the exception, because we don't want to throw soap faults to the caller

we have come to a point in the architecture, we don't want the endpoint to manage the exception. We think t should be done in some kind of interceptor or by AOP. The important It is that at that "outer exception handling component" I could get the exception fully and its attribute and based on that , no matter , what endpoint was called, get the return type object of the endpoint and return it by filling some appropriate fields based on the exception, possibly by some java reflection

My first approach was to use a SOAP interceptor, but I think it is limited according to what I need. I am doing research on AOP , any ideas?

Was it helpful?

Solution

In my opinion this is a perfect scenario for AOP. But where is the problem ? :) You can create an Aspect of type @Around on your service methods (not end point) and then call joinPoint.proceed() inside a try catch block. Catch the exception and return what you want :P By using AOP API you can check what should be the return type, the arguments .. basically everything you need :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top