ActionManager.java
001 /*
002  * SPDX-License-Identifier: Apache-2.0
003  *
004  * Copyright 2008-2017 the original author or authors.
005  *
006  * Licensed under the Apache License, Version 2.0 (the "License");
007  * you may not use this file except in compliance with the License.
008  * You may obtain a copy of the License at
009  *
010  *     http://www.apache.org/licenses/LICENSE-2.0
011  *
012  * Unless required by applicable law or agreed to in writing, software
013  * distributed under the License is distributed on an "AS IS" BASIS,
014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015  * See the License for the specific language governing permissions and
016  * limitations under the License.
017  */
018 package griffon.core.controller;
019 
020 import griffon.core.artifact.GriffonController;
021 
022 import javax.annotation.Nonnull;
023 import javax.annotation.Nullable;
024 import java.util.Map;
025 
026 /**
027  @author Andres Almiray
028  @since 2.0.0
029  */
030 public interface ActionManager {
031     String ACTION = "Action";
032 
033     @Nonnull
034     Map<String, Action> actionsFor(@Nonnull GriffonController controller);
035 
036     @Nullable
037     Action actionFor(@Nonnull GriffonController controller, @Nonnull String actionName);
038 
039     void createActions(@Nonnull GriffonController controller);
040 
041     @Nonnull
042     String normalizeName(@Nonnull String actionName);
043 
044     /**
045      * Updates all actions currently configured.
046      *
047      @since 2.1.0
048      */
049     void updateActions();
050 
051     /**
052      * Updates all actions belonging to the supplied controller.
053      *
054      @param controller the controller that owns the actions to be updated.
055      *
056      @since 2.1.0
057      */
058     void updateActions(@Nonnull GriffonController controller);
059 
060     /**
061      * Update the action's properties using registered {@code ActionHandler}s.
062      *
063      @param action the action to be updated
064      *
065      @since 2.1.0
066      */
067     void updateAction(@Nonnull Action action);
068 
069     /**
070      * Update the action's properties using registered {@code ActionHandler}s.
071      *
072      @param controller the controller that owns the action
073      @param actionName the action's name
074      *
075      @since 2.1.0
076      */
077     void updateAction(@Nonnull GriffonController controller, @Nonnull String actionName);
078 
079     /**
080      * Execute the action using registered {@code ActionHandler}s.
081      *
082      @param controller the controller that owns the action
083      @param actionName the action's name
084      @param args       additional arguments to be sent to the action
085      */
086     void invokeAction(@Nonnull GriffonController controller, @Nonnull String actionName, Object... args);
087 
088     /**
089      * Execute the action using registered {@code ActionHandler}s.
090      *
091      @param action the action to be invoked
092      @param args   additional arguments to be sent to the action
093      *
094      @since 2.1.0
095      */
096     void invokeAction(@Nonnull Action action, @Nonnull Object... args);
097 
098     /**
099      * Register an {@code ActionHandler} with this instance.
100      *
101      @param actionHandler the handler to be added to this ActionManager
102      *
103      @since 2.1.0
104      */
105     void addActionHandler(@Nonnull ActionHandler actionHandler);
106 
107     /**
108      * Register an {@code ActionInterceptor} with this instance.
109      *
110      @param actionInterceptor the interceptor to be added to this ActionManager
111      *
112      @deprecated use {@code addActionHandler} instead.
113      */
114     @Deprecated
115     void addActionInterceptor(@Nonnull ActionInterceptor actionInterceptor);
116 }