I do have something more specific in mind, however:
Each web service method needs to be wrapped with some boiler place code (cross cutting concern, yes, spring AOP would work great here but it either doesn’t work or unapproved by gov’t architecture group). A simple service call is as follows:
@WebMethod...
public Foo performFoo(...) {
Object result = null;
Object something = blah;
try {
soil(something);
result = handlePerformFoo(...);
} catch(Exception e) {
throw translateException(e);
} finally {
wash(something);
}
return result;
}
protected abstract Foo handlePerformFoo(...);
(I hope that’s enough context). Basically, I would like a hook (that was in the same thread – like a method invocation interceptor) that could have a before() and after() that could could soil(something) and wash(something) around the method call for every freaking WebMethod.
Can’t use Spring AOP because my web services are not Spring managed beans 🙁
HELP!!!!! Give advice! Please don’t let me copy-paste that boiler plate 1 billion times (as I’ve been instructed to do).
Regards,
LES
I ended up using the JAX-WS Commons Spring Extention and made my web service impl a spring managed bean and used around advice to handle all that boiler plate in one place.
If I wanted to maintain the original constraint of no AOP, I suppose I could have created an interface and a helper method as follows:
Finally, the business methods would be coded as follows:
Basically, each business method would use the doOperation helper method in it’s body and an anonymous class containing the code that needs to execute within the context created by the doOperation method. I’m sure there’s a name for this pattern (reminds me of the Loan Pattern).