コード例 #1
0
    public void invoke(MethodInvocation invocation) throws Throwable {
      next.invoke(invocation);
      if (invocation.found() || invocation.getParameterTypes().length != 1) {
        return;
      }

      if (!invocation.isIsOrGet()) {
        return;
      }

      MethodInvocation getterInvocation =
          new MethodInvocation(
              invocation.getName(),
              invocation.getReturnType(),
              invocation.getGenericReturnType(),
              EMPTY_CLASS_ARRAY,
              invocation.getDelegate(),
              EMPTY);
      next.invoke(getterInvocation);
      if (getterInvocation.found() && getterInvocation.getResult() != null) {
        invocation.setResult(getterInvocation.getResult());
      } else {
        invocation.setResult(invocation.getParameters()[0]);
      }
    }
コード例 #2
0
    public void invoke(MethodInvocation invocation) throws Throwable {
      if (current.get() != null) {
        // Already invoking a method on the mix-in
        return;
      }

      if (instance == null) {
        instance = DirectInstantiator.INSTANCE.newInstance(mixInClass, proxy);
      }
      MethodInvocation beanInvocation =
          new MethodInvocation(
              invocation.getName(),
              invocation.getReturnType(),
              invocation.getGenericReturnType(),
              invocation.getParameterTypes(),
              instance,
              invocation.getParameters());
      current.set(beanInvocation);
      try {
        next.invoke(beanInvocation);
      } finally {
        current.set(null);
      }
      if (beanInvocation.found()) {
        invocation.setResult(beanInvocation.getResult());
      }
    }
コード例 #3
0
    public void invoke(MethodInvocation invocation) throws Throwable {
      Method targetMethod = locateMethod(invocation);
      if (targetMethod == null) {
        return;
      }

      Object returnValue;
      try {
        returnValue = targetMethod.invoke(invocation.getDelegate(), invocation.getParameters());
      } catch (InvocationTargetException e) {
        throw e.getCause();
      }

      invocation.setResult(returnValue);
    }