KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ibatis > sqlmap > engine > binding > MapperProxy


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