You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Yes, that could be done with the help of an interceptor.

+ Method One +

public class MyInterceptor implements Interceptor {
  ...
	public String intercept(ActionInvocation invocation) throws Exception {
		Map<String, ResultConfig> resultsMap = invocation.getProxy().getConfig().getResults();

                // do something with ResultConfig in map

		return invocation.invoke();
	}
  ...
}

+ Method Two +

public class MyInterceptor implements Interceptor {
  ...
        public String intercept(ActionInvocation invocation) throws Exception {
             invocation.addPreResultListener(new PreResultListener() {
			public void beforeResult(ActionInvocation invocation, String resultCode) {
				Map<String, ResultConfig> resultsMap = invocation.getProxy().getConfig().getResults();
                                ResultConfig finalResultConfig = resultsMap.get(resultCode);
                                
                                // do something interesting with the 'to-be' executed result
			}
	     });

             return invocation.invoke();
        }

  ...
}

The difference between Method One and Two is that method two gives one, the final result to be executed.

  • No labels