AbstractActionInterceptor.java
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 org.codehaus.griffon.runtime.core.controller;
17 
18 import griffon.core.artifact.GriffonController;
19 import griffon.core.controller.AbortActionExecution;
20 import griffon.core.controller.ActionExecutionStatus;
21 import griffon.core.controller.ActionInterceptor;
22 
23 import javax.annotation.Nonnull;
24 import java.lang.reflect.Method;
25 
26 import static griffon.util.GriffonNameUtils.requireNonBlank;
27 import static java.util.Objects.requireNonNull;
28 
29 /**
30  @author Andres Almiray
31  @since 2.0.0
32  @deprecated use {@code ActionHandler} instead.
33  */
34 @Deprecated
35 public class AbstractActionInterceptor implements ActionInterceptor {
36     private static final String ERROR_CONTROLLER_NULL = "Argument 'controller' must not be null";
37     private static final String ERROR_ACTION_NAME_BLANK = "Argument 'actionName' must not be blank";
38 
39     @Override
40     public void configure(@Nonnull GriffonController controller, @Nonnull String actionName, @Nonnull Method method) {
41     }
42 
43     @Nonnull
44     @Override
45     public Object[] before(@Nonnull GriffonController controller, @Nonnull String actionName, @Nonnull Object[] args) {
46         return new Object[0];
47     }
48 
49     @Override
50     public void after(@Nonnull ActionExecutionStatus status, @Nonnull GriffonController controller, @Nonnull String actionName, @Nonnull Object[] args) {
51     }
52 
53     @Override
54     public boolean exception(@Nonnull Exception exception, @Nonnull GriffonController controller, @Nonnull String actionName, @Nonnull Object[] args) {
55         return false;
56     }
57 
58     @Nonnull
59     protected AbortActionExecution abortActionExecution() throws AbortActionExecution {
60         throw new AbortActionExecution();
61     }
62 
63     @Nonnull
64     protected String qualifyActionName(@Nonnull GriffonController controller, @Nonnull String actionName) {
65         requireNonNull(controller, ERROR_CONTROLLER_NULL);
66         requireNonBlank(actionName, ERROR_ACTION_NAME_BLANK);
67         return controller.getClass().getName() "." + actionName;
68     }
69 }