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