01 /*
02 * Copyright 2008-2016 the original author or authors.
03 *
04 * Licensed under the Apache License, Version 2.0 (the "License");
05 * you may not use this file except in compliance with the License.
06 * You may obtain a copy of the License at
07 *
08 * http://www.apache.org/licenses/LICENSE-2.0
09 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package griffon.core.controller;
17
18 import griffon.core.artifact.GriffonController;
19
20 import javax.annotation.Nonnull;
21 import java.lang.reflect.Method;
22
23 /**
24 * @author Andres Almiray
25 * @since 2.0.0
26 * @deprecated use {@code ActionHandler} instead.
27 */
28 @Deprecated
29 public interface ActionInterceptor {
30 String SUFFIX = "ActionInterceptor";
31
32 /**
33 * Inspect the action during the configuration phase.
34 * <p/>
35 * This is the perfect time to search for annotations or any other information
36 * required by the action. Interceptors have the option to cache such inspections
37 * and recall them during {@code before()}, {@code after()} and {@code exception()}.
38 *
39 * @param controller the controller that owns the action
40 * @param actionName the action's name
41 * @param method the method that represents the action itself
42 */
43 void configure(@Nonnull GriffonController controller, @Nonnull String actionName, @Nonnull Method method);
44
45 /**
46 * Called before an action is executed.
47 * <p/>
48 * Implementors have the choice of throwing an {@code AbortActionExecution} in
49 * order to signal that the action should not be invoked. In any case this method
50 * returns the arguments to be sent to the action, thus allowing the interceptor
51 * to modify the arguments as it deem necessary. Failure to return an appropriate
52 * value will most likely cause an error during the action's execution.
53 *
54 * @param controller the controller that owns the action
55 * @param actionName the action's name
56 * @param args the action's arguments
57 * @return arguments to be sent to the action
58 * @throws AbortActionExecution if action execution should be aborted.
59 */
60 @Nonnull
61 Object[] before(@Nonnull GriffonController controller, @Nonnull String actionName, @Nonnull Object[] args);
62
63 /**
64 * Called after the action has been aborted or executed, even if an exception
65 * occurred during execution.
66 * <p/>
67 *
68 * @param status a flag that indicates the execution status of the action
69 * @param controller the controller that owns the action
70 * @param actionName the action's name
71 * @param args the arguments sent to the action
72 */
73 void after(@Nonnull ActionExecutionStatus status, @Nonnull GriffonController controller, @Nonnull String actionName, @Nonnull Object[] args);
74
75 /**
76 * Called after the action has been executed when an exception occurred
77 * during execution.
78 * <p/>
79 * The exception will be rethrown by the ActionManager if is not handled by
80 * any interceptor.
81 *
82 * @param exception the exception thrown during the action's execution
83 * @param controller the controller that owns the action
84 * @param actionName the action's name
85 * @param args the arguments sent to the action during execution
86 * @return <code>true</code> if the exception was handled successfully,
87 * <code>false</code> otherwise.
88 */
89 boolean exception(@Nonnull Exception exception, @Nonnull GriffonController controller, @Nonnull String actionName, @Nonnull Object[] args);
90 }
|