Package hudson.model

Class Actionable

All Implemented Interfaces:
ModelObject, SearchableModelObject, SearchItem, ModelObjectWithContextMenu
Direct Known Subclasses:
AbstractItem, Cloud, Computer, Label, Queue.Item, Run

@ExportedBean public abstract class Actionable extends AbstractModelObject implements ModelObjectWithContextMenu
ModelObject that can have additional Actions.
Author:
Kohsuke Kawaguchi
  • Constructor Details

    • Actionable

      public Actionable()
  • Method Details

    • getActions

      @Deprecated @NonNull public List<Action> getActions()
      Deprecated.
      Normally outside code should not call this method any more. Use getAllActions(), or addAction(hudson.model.Action), or replaceAction(hudson.model.Action). May still be called for compatibility reasons from subclasses predating TransientActionFactory.
      Gets actions contributed to this object.

      A new Action can be added by addAction(hudson.model.Action).

      If you are reading the list, rather than modifying it, use getAllActions() instead. This method by default returns only persistent actions (though some subclasses override it to return an extended unmodifiable list).

      Returns:
      a possibly empty list
    • getAllActions

      @Exported(name="actions") @NonNull public final List<? extends Action> getAllActions()
      Gets all actions, transient or persistent. getActions() is supplemented with anything contributed by TransientActionFactory.
      Returns:
      an unmodifiable, possible empty list
      Since:
      1.548
    • getActions

      @NonNull public <T extends Action> List<T> getActions(Class<T> type)
      Gets all actions of a specified type that contributed to this object.
      Parameters:
      type - The type of action to return.
      Returns:
      an unmodifiable, possible empty list
      See Also:
    • addAction

      public void addAction(@NonNull Action a)
      Adds a new action. Note: calls to getAllActions() that happen before calls to this method may not see the update. Note: this method will always modify the actions
    • replaceAction

      public void replaceAction(@NonNull Action a)
      Add an action, replacing any existing actions of the (exact) same class. Note: calls to getAllActions() that happen before calls to this method may not see the update. Note: this method does not affect transient actions contributed by a TransientActionFactory. Note: this method cannot provide concurrency control due to the backing storage being a CopyOnWriteArrayList so concurrent calls to any of the mutation methods may produce surprising results though technically consistent from the concurrency contract of CopyOnWriteArrayList (we would need some form of transactions or a different backing type).

      See also addOrReplaceAction(Action) if you want to know whether the backing actions was modified, for example in cases where the caller would need to persist the Actionable in order to persist the change and there is a desire to elide unnecessary persistence of unmodified objects.

      Parameters:
      a - an action to add/replace
      Since:
      1.548
    • addOrReplaceAction

      public boolean addOrReplaceAction(@NonNull Action a)
      Add an action, replacing any existing actions of the (exact) same class. Note: calls to getAllActions() that happen before calls to this method may not see the update. Note: this method does not affect transient actions contributed by a TransientActionFactory Note: this method cannot provide concurrency control due to the backing storage being a CopyOnWriteArrayList so concurrent calls to any of the mutation methods may produce surprising results though technically consistent from the concurrency contract of CopyOnWriteArrayList (we would need some form of transactions or a different backing type).
      Parameters:
      a - an action to add/replace
      Returns:
      true if this actions changed as a result of the call
      Since:
      2.29
    • removeAction

      public boolean removeAction(@Nullable Action a)
      Remove an action. Note: calls to getAllActions() that happen before calls to this method may not see the update. Note: this method does not affect transient actions contributed by a TransientActionFactory Note: this method cannot provide concurrency control due to the backing storage being a CopyOnWriteArrayList so concurrent calls to any of the mutation methods may produce surprising results though technically consistent from the concurrency contract of CopyOnWriteArrayList (we would need some form of transactions or a different backing type).
      Parameters:
      a - an action to remove (if null then this will be a no-op)
      Returns:
      true if this actions changed as a result of the call
      Since:
      2.29
    • removeActions

      public boolean removeActions(@NonNull Class<? extends Action> clazz)
      Removes any actions of the specified type. Note: calls to getAllActions() that happen before calls to this method may not see the update. Note: this method does not affect transient actions contributed by a TransientActionFactory Note: this method cannot provide concurrency control due to the backing storage being a CopyOnWriteArrayList so concurrent calls to any of the mutation methods may produce surprising results though technically consistent from the concurrency contract of CopyOnWriteArrayList (we would need some form of transactions or a different backing type).
      Parameters:
      clazz - the type of actions to remove
      Returns:
      true if this actions changed as a result of the call
      Since:
      2.29
    • replaceActions

      public boolean replaceActions(@NonNull Class<? extends Action> clazz, @NonNull Action a)
      Replaces any actions of the specified type by the supplied action. Note: calls to getAllActions() that happen before calls to this method may not see the update. Note: this method does not affect transient actions contributed by a TransientActionFactory Note: this method cannot provide concurrency control due to the backing storage being a CopyOnWriteArrayList so concurrent calls to any of the mutation methods may produce surprising results though technically consistent from the concurrency contract of CopyOnWriteArrayList (we would need some form of transactions or a different backing type).
      Parameters:
      clazz - the type of actions to replace (note that the action you are replacing this with need not extend this class)
      a - the action to replace with
      Returns:
      true if this actions changed as a result of the call
      Since:
      2.29
    • getAction

      @Deprecated public Action getAction(int index)
      Deprecated.
      No clear purpose, since subclasses may have overridden getActions(), and does not consider TransientActionFactory.
    • getAction

      public <T extends Action> T getAction(Class<T> type)
      Gets the action (first instance to be found) of a specified type that contributed to this build.
      Returns:
      The action or null if no such actions exist.
      See Also:
    • getDynamic

      public Object getDynamic(String token, org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp)
      Since:
      2.475
    • getDynamic

      @Deprecated public Object getDynamic(String token, org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
    • doContextMenu

      public ModelObjectWithContextMenu.ContextMenu doContextMenu(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) throws Exception
      Description copied from interface: ModelObjectWithContextMenu
      Generates the context menu. The typical implementation is return new ContextMenu().from(this,request,response);, which implements the default behaviour. See ModelObjectWithContextMenu.ContextMenu.from(ModelObjectWithContextMenu, StaplerRequest2, StaplerResponse2) for more details of what it does. This should suit most implementations.
      Specified by:
      doContextMenu in interface ModelObjectWithContextMenu
      Throws:
      Exception
      Since:
      2.475
    • doContextMenu

      @Deprecated @StaplerNotDispatchable public ModelObjectWithContextMenu.ContextMenu doContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws Exception
      Specified by:
      doContextMenu in interface ModelObjectWithContextMenu
      Throws:
      Exception