try {
runmethod1 = this.getClass().getMethod("run", signature1);
runmethod2 = null;
}
catch(SecurityException e) {
throw new APIViolationException("Security exception finding an appropriate 'run' method.", e);
}
catch(NoSuchMethodException e) {
runmethod1 = null;
// Try without "database" parameter.
try {
runmethod2 = this.getClass().getMethod("run", signature2);
}
catch(NoSuchMethodException e2) {
runmethod2 = null;
}
catch(SecurityException e2) {
throw new APIViolationException("Security exception finding an appropriate 'run' method.", e2);
}
}
if(runmethod1 != null) {
try {
StringBuffer buf = new StringBuffer();
for(Class<?> cls : signature1) {
buf.append(cls.toString()).append(",");
}
return (R) runmethod1.invoke(this, relations1);
}
catch(IllegalArgumentException e) {
throw new APIViolationException("Invoking the real 'run' method failed.", e);
}
catch(IllegalAccessException e) {
throw new APIViolationException("Invoking the real 'run' method failed.", e);
}
catch(InvocationTargetException e) {
if(e.getTargetException() instanceof RuntimeException) {
throw (RuntimeException) e.getTargetException();
}
if(e.getTargetException() instanceof AssertionError) {
throw (AssertionError) e.getTargetException();
}
throw new APIViolationException("Invoking the real 'run' method failed: " + e.getTargetException().toString(), e.getTargetException());
}
}
else if(runmethod2 != null) {
try {
StringBuffer buf = new StringBuffer();
for(Class<?> cls : signature1) {
buf.append(cls.toString()).append(",");
}
return (R) runmethod2.invoke(this, relations2);
}
catch(IllegalArgumentException e) {
throw new APIViolationException("Invoking the real 'run' method failed.", e);
}
catch(IllegalAccessException e) {
throw new APIViolationException("Invoking the real 'run' method failed.", e);
}
catch(InvocationTargetException e) {
if(e.getTargetException() instanceof RuntimeException) {
throw (RuntimeException) e.getTargetException();
}
if(e.getTargetException() instanceof AssertionError) {
throw (AssertionError) e.getTargetException();
}
throw new APIViolationException("Invoking the real 'run' method failed: " + e.getTargetException().toString(), e.getTargetException());
}
}
else {
throw new APIViolationException("No appropriate 'run' method found.");
}
}