InvocationHandlerFactory.java 851 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package cn.nosum.support.proxy;
  2. import java.lang.reflect.InvocationHandler;
  3. /**
  4. * InvocationHandlerFactory.
  5. *
  6. * @author Young
  7. */
  8. public interface InvocationHandlerFactory {
  9. /**
  10. * create InvocationHandler。
  11. *
  12. * @param target Target Object Information
  13. * @return InvocationHandler
  14. */
  15. InvocationHandler create(Target target);
  16. /**
  17. * Like {@link InvocationHandler#invoke(Object, java.lang.reflect.Method, Object[])}, except for a
  18. * single method.
  19. */
  20. interface MethodHandler {
  21. Object invoke(Object[] argv) throws Throwable;
  22. }
  23. final class Default implements InvocationHandlerFactory {
  24. @Override
  25. public InvocationHandler create(Target target) {
  26. return new ReflectiveDynamicClientCreator.DynamicMethodsInvocationHandler(target);
  27. }
  28. }
  29. }