コード例 #1
0
  /** @Around("localEjbCommandExecution") */
  public Object commandExecution(final JoinPoint jp) throws Throwable {
    final MethodRtti rtti = (MethodRtti) jp.getRtti();

    Method m = (Method) threadLocal.get();
    if (m != null && m.equals(rtti.getMethod())) {
      Object value = jp.proceed();
      threadLocal.set(null);
      return value;
    }

    final CommandResolver obj = (CommandResolver) jp.getTarget();
    final Class[] classes = rtti.getParameterTypes();
    final String[] classNames = new String[classes.length];
    final String methodName = rtti.getMethod().getName();
    final Object[] parameterValues = rtti.getParameterValues();

    for (int i = 0; i < classes.length; i++) {
      classNames[i] = classes[i].getName();
    }

    CommandExecutorLocal commandExecutorLocal = null;

    try {
      commandExecutorLocal = getCommandExecutor();

      threadLocal.set(rtti.getMethod());

      if (obj.isTransactional(rtti.getMethod())) {
        return commandExecutorLocal.executeTransaction(
            obj, methodName, classNames, parameterValues);
      } else if (obj.isRemotable(rtti.getMethod())) {
        return commandExecutorLocal.executeQuery(obj, methodName, classNames, parameterValues);
      } else {
        return jp.proceed();
      }
    } catch (final InvocationTargetException ite) {
      throw ite.getTargetException();
    } finally {
      threadLocal.set(null);
    }
  }
コード例 #2
0
 /**
  * FIXME: this expression leads to match all at cflow early filtering.
  *
  * <p>X@Around execution(* test.CFlowTest.step2_C()) AND !cflow(call(* test.CFlowTest.step1_C())
  * AND within(test.CFlowTest))
  */
 public Object executeC(final JoinPoint joinPoint) throws Throwable {
   ((Loggable) joinPoint.getTarget()).log("advice-beforeC ");
   final Object result = joinPoint.proceed();
   ((Loggable) joinPoint.getTarget()).log("advice-afterC ");
   return result;
 }