Need to dynamicaly get all parameters in a method call.
While I am inside a method, I need a way to dynamically get the parameters for the method call that I am in. I need to put these in an array, map, or something that can be generically added to a custom exception.
If anyone can let me know how to do this it would be greatly appreciated.
For more info keep reading:
Short Scenario:
We have a SOA project. In our remote service layer all method calls contain a try catch block that catches any checked exception that we have already caught and logged and any Hibernate exception (is a standard method framework we use for all methods on this layer). However, if we get an error that we did not expect, we are going to create a separate dump file and log the name of the dump file.
In the dump file we would like to include information about the parameters for the service. I have an exception object that can take a generic object, collection, or map.
What I need to do:
I would like a way to dynamically get the parameters for the method and put them in my exception object so that I can just include the same code in my exception clause instead of having to include each parameter by name in the exception.
I have not been able to find a way to do this inside the method call.
Sample Code Snippet:
public PagingContext findAreacode(AreacodeTO areacodeTOcriteria, PagingContext pageContext) throws AjentException {
...
try {
... do method stuff ...
} catch (HibernateException e) {
... handle hibernate exception
} catch (AjentException ae) {
// All of our errors should extend AjentException
... Hanlde ajent exception
} catch (Throwable e) {
/* This is the code I want to replace with a dynamic method that will allow me to
* determine what the parameters are to this call (findAreaCode(p1, p2).
*/
Map paramatersMap = new HashMap();
paramatersMap.put("areacodeTOcriteria", areacodeTOcriteria);
paramatersMap.put("pageContext", pageContext);
// End Parameter Entry Section.
// Create exception & call logger
AjilityServerDumpException asde = new AjilityServerDumpException(e, context, ctx, null, null, paramatersMap );
ServerLogger.logErrorDump(asde, context, ctx, this.getClass(), ServerLogger.ADMIN_LOGGER, ServerLogger.ERROR);
throw asde;
} finally {
... do finally stuff
}
return pageContext;
}
David Johns