01: package org.vraptor.interceptor;
02:
03: import org.vraptor.Interceptor;
04: import org.vraptor.LogicException;
05: import org.vraptor.LogicFlow;
06: import org.vraptor.introspector.Introspector;
07: import org.vraptor.reflection.GettingException;
08: import org.vraptor.reflection.MethodInvocationException;
09: import org.vraptor.view.ViewException;
10:
11: /**
12: * Outjects.
13: *
14: * @author Guilherme Silveira
15: */
16: public class OutjectionInterceptor implements Interceptor {
17:
18: private final Introspector introspector;
19:
20: public OutjectionInterceptor(Introspector introspector) {
21: this .introspector = introspector;
22: }
23:
24: public void intercept(LogicFlow flow) throws LogicException,
25: ViewException {
26:
27: Object component = flow.getLogicRequest().getLogicDefinition()
28: .getComponent();
29:
30: try {
31: introspector.outject(flow.getLogicRequest(), component,
32: flow.getLogicRequest().getLogicDefinition()
33: .getComponentType());
34: } catch (GettingException e) {
35: throw new LogicException(e.getMessage(), e);
36: } catch (MethodInvocationException e) {
37: throw new LogicException(e);
38: }
39:
40: flow.execute();
41:
42: }
43:
44: }
|