![JAR search and dependency download from the Maven repository](/logo.png)
org.ibatis.cglib.MethodInvoker Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbatis Show documentation
Show all versions of jbatis Show documentation
The jBATIS persistence framework will help you to significantly reduce the amount of Java code that you normally need to access a relational database. iBATIS simply maps JavaBeans to SQL statements using a very simple XML descriptor.
The newest version!
package org.ibatis.cglib;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import com.ibatis.common.logging.ILog;
import com.ibatis.common.logging.ILogFactory;
public class MethodInvoker extends Invoker {
private static final ILog log = ILogFactory.getLog(Invoker.class);
private Method method;
private FastMethod fastMethod;
boolean beSetter;
public MethodInvoker(String name, Method method, boolean beSetter) {
super(name);
this.method = method;
this.beSetter = beSetter;
fixAccess(method);
}
@SuppressWarnings("deprecation")
public Object invoke(Object target, Object... args) throws IllegalAccessException, InvocationTargetException {
if (fastMethod == null) {
synchronized (this) {
try {
fastMethod = FastMethod.create(method);
} catch (Throwable e) {
log.warn("Failed to create fast method for " + method + ", " + e);
System.err.println("Failed to create fast method for " + method + ", " + e);
}
if (fastMethod == null) {
fastMethod = new FastMethod(method);
}
}
}
try {
return fastMethod.invoke(target, args);
} catch (IllegalArgumentException e) {
// ## ignore the primitive null value
if (args != null && args.length == 1 && args[0] == null) {
return null;
}
throw e;
}
}
public Method getMethod() {
return method;
}
public String getAccessName() {
return method.getName() + "()";
}
public AccessibleObject getAccessibleObject() {
return method;
}
@Override
public Class> getType() {
if (beSetter) {
return method.getParameterTypes()[0];
}
return method.getReturnType();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy