1 package com.ibatis.sqlmap.engine.binding; 2 3 import com.ibatis.sqlmap.client.SqlMapClient; 4 5 import java.lang.reflect.InvocationHandler ; 6 import java.lang.reflect.Method ; 7 import java.lang.reflect.Proxy ; 8 9 public class MapperProxy implements InvocationHandler { 10 11 private SqlMapClient client; 12 13 private MapperProxy(SqlMapClient client) { 14 this.client = client; 15 } 16 17 public Object invoke(Object proxy, Method method, Object [] args) throws Throwable { 18 return new MapperCommand(method, client).execute(args); 19 } 20 21 public static Object newMapperProxy (SqlMapClient client, Class iface) { 22 ClassLoader classLoader = iface.getClassLoader(); 23 Class [] interfaces = new Class []{iface}; 24 MapperProxy handler = new MapperProxy(client); 25 return Proxy.newProxyInstance(classLoader, interfaces, handler); 26 } 27 28 } 29 | Popular Tags |