01 /*
02 * SPDX-License-Identifier: Apache-2.0
03 *
04 * Copyright 2008-2017 the original author or authors.
05 *
06 * Licensed under the Apache License, Version 2.0 (the "License");
07 * you may not use this file except in compliance with the License.
08 * You may obtain a copy of the License at
09 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package org.codehaus.griffon.runtime.core.controller;
19
20 import griffon.core.artifact.GriffonController;
21 import griffon.core.controller.AbortActionExecution;
22 import griffon.core.controller.ActionExecutionStatus;
23 import griffon.core.controller.ActionInterceptor;
24
25 import javax.annotation.Nonnull;
26 import java.lang.reflect.Method;
27
28 import static griffon.util.GriffonNameUtils.requireNonBlank;
29 import static java.util.Objects.requireNonNull;
30
31 /**
32 * @author Andres Almiray
33 * @since 2.0.0
34 * @deprecated use {@code ActionHandler} instead.
35 */
36 @Deprecated
37 public class AbstractActionInterceptor implements ActionInterceptor {
38 private static final String ERROR_CONTROLLER_NULL = "Argument 'controller' must not be null";
39 private static final String ERROR_ACTION_NAME_BLANK = "Argument 'actionName' must not be blank";
40
41 @Override
42 public void configure(@Nonnull GriffonController controller, @Nonnull String actionName, @Nonnull Method method) {
43 }
44
45 @Nonnull
46 @Override
47 public Object[] before(@Nonnull GriffonController controller, @Nonnull String actionName, @Nonnull Object[] args) {
48 return new Object[0];
49 }
50
51 @Override
52 public void after(@Nonnull ActionExecutionStatus status, @Nonnull GriffonController controller, @Nonnull String actionName, @Nonnull Object[] args) {
53 }
54
55 @Override
56 public boolean exception(@Nonnull Exception exception, @Nonnull GriffonController controller, @Nonnull String actionName, @Nonnull Object[] args) {
57 return false;
58 }
59
60 @Nonnull
61 protected AbortActionExecution abortActionExecution() throws AbortActionExecution {
62 throw new AbortActionExecution();
63 }
64
65 @Nonnull
66 protected String qualifyActionName(@Nonnull GriffonController controller, @Nonnull String actionName) {
67 requireNonNull(controller, ERROR_CONTROLLER_NULL);
68 requireNonBlank(actionName, ERROR_ACTION_NAME_BLANK);
69 return controller.getTypeClass().getName() + "." + actionName;
70 }
71 }
|