1 23 24 28 29 34 35 package com.sun.enterprise.management.support; 36 37 import java.lang.reflect.Proxy ; 38 import java.lang.reflect.Method ; 39 import java.lang.reflect.InvocationHandler ; 40 41 import com.sun.appserv.management.util.misc.ClassUtil; 42 43 45 public final class DelegateInvocationHandler implements InvocationHandler 46 { 47 private final Delegate mDelegate; 48 49 private 50 DelegateInvocationHandler( final Delegate delegate ) 51 { 52 mDelegate = delegate; 53 } 54 55 static public Object 56 newProxyInstance( 57 Delegate delegate, 58 Class interfaceClass ) 59 { 60 final DelegateInvocationHandler handler = 61 new DelegateInvocationHandler( delegate ); 62 63 final ClassLoader classLoader = interfaceClass.getClassLoader(); 64 65 final Class [] interfaces = new Class [] { interfaceClass }; 66 final Object proxy = Proxy.newProxyInstance( classLoader, 67 interfaces, handler); 68 69 return( proxy ); 70 } 71 72 75 public Object 76 invoke( 77 Object proxy, 78 Method method, 79 Object [] args 80 ) 81 throws java.lang.Throwable 82 { 83 final Class [] sig = method.getParameterTypes(); 84 85 return( mDelegate.invoke( method.getName(), args, ClassUtil.classnamesFromSignature( sig ) ) ); 86 } 87 88 } 89 90 91 92 93 94 95 96 97 98 99 100 | Popular Tags |