
Originally Posted by
lnader
Here's my enviroment in more detail. I have business services that being used by local classes running inside the same JVM AND by remote consumers. I need to include a version number (as an argument) in the remote API call (which is not needed for local calls). On the remote calls the method signature is obviously not checked until runtime. I was hoping to wrap these calls with an @Before advice that will do the version checking and fail/forward accordingly.
I am already aware of the following options but don't like them (maintenance nightmare):
1. Overload each method to add an additional argument.
2. Add an optional argument to all methods
3. Create a second set of interfaces and services that pretty much mirror the existing services. In other words wrapper classes.
So I was looking for other alternatives in particular a runtime solution hence looking at AOP.
Why don't you use varargs in your methods like:
Code:
public Object serviceMethod(Object param1, Object param2, Object... optionalArguments)
You won't have maintenance nightmare and you can pass in any number of optional parameters (if more are needed later)...