1. /*
  2. * @(#)DelegateInvocationHandlerImpl.java 1.8 04/07/27
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.spi.orbutil.proxy ;
  8. import java.io.Serializable ;
  9. import java.util.Map ;
  10. import java.util.LinkedHashMap ;
  11. import java.lang.reflect.Proxy ;
  12. import java.lang.reflect.Method ;
  13. import java.lang.reflect.InvocationHandler ;
  14. import java.lang.reflect.InvocationTargetException ;
  15. public abstract class DelegateInvocationHandlerImpl
  16. {
  17. private DelegateInvocationHandlerImpl() {}
  18. public static InvocationHandler create( final Object delegate )
  19. {
  20. return new InvocationHandler() {
  21. public Object invoke( Object proxy, Method method, Object[] args )
  22. throws Throwable
  23. {
  24. // This throws an IllegalArgument exception if the delegate
  25. // is not assignable from method.getDeclaring class.
  26. try {
  27. return method.invoke( delegate, args ) ;
  28. } catch (InvocationTargetException ite) {
  29. // Propagate the underlying exception as the
  30. // result of the invocation
  31. throw ite.getCause() ;
  32. }
  33. }
  34. } ;
  35. }
  36. }