Package hudson.model
Class Actionable
java.lang.Object
hudson.model.AbstractModelObject
hudson.model.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 Action
s.- Author:
- Kohsuke Kawaguchi
-
Nested Class Summary
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new action.boolean
Add an action, replacing any existing actions of the (exact) same class.doContextMenu
(org.kohsuke.stapler.StaplerRequest2 request, org.kohsuke.stapler.StaplerResponse2 response) Generates the context menu.doContextMenu
(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) Deprecated.getAction
(int index) Deprecated.No clear purpose, since subclasses may have overriddengetActions()
, and does not considerTransientActionFactory
.<T extends Action>
TGets the action (first instance to be found) of a specified type that contributed to this build.Deprecated.Normally outside code should not call this method any more.getActions
(Class<T> type) Gets all actions of a specified type that contributed to this object.Gets all actions, transient or persistent.getDynamic
(String token, org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) getDynamic
(String token, org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp) Deprecated.boolean
Remove an action.boolean
removeActions
(Class<? extends Action> clazz) Removes any actions of the specified type.void
Add an action, replacing any existing actions of the (exact) same class.boolean
replaceActions
(Class<? extends Action> clazz, Action a) Replaces any actions of the specified type by the supplied action.Methods inherited from class hudson.model.AbstractModelObject
getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError, sendError, sendError, sendError
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface hudson.model.ModelObject
getDisplayName
Methods inherited from interface hudson.search.SearchItem
getSearchUrl
-
Constructor Details
-
Actionable
public Actionable()
-
-
Method Details
-
getActions
Deprecated.Normally outside code should not call this method any more. UsegetAllActions()
, oraddAction(hudson.model.Action)
, orreplaceAction(hudson.model.Action)
. May still be called for compatibility reasons from subclasses predatingTransientActionFactory
.Gets actions contributed to this object.A new
Action
can be added byaddAction(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
Gets all actions, transient or persistent.getActions()
is supplemented with anything contributed byTransientActionFactory
.- Returns:
- an unmodifiable, possible empty list
- Since:
- 1.548
-
getActions
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
Adds a new action. Note: calls togetAllActions()
that happen before calls to this method may not see the update. Note: this method will always modify the actions -
replaceAction
Add an action, replacing any existing actions of the (exact) same class. Note: calls togetAllActions()
that happen before calls to this method may not see the update. Note: this method does not affect transient actions contributed by aTransientActionFactory
. Note: this method cannot provide concurrency control due to the backing storage being aCopyOnWriteArrayList
so concurrent calls to any of the mutation methods may produce surprising results though technically consistent from the concurrency contract ofCopyOnWriteArrayList
(we would need some form of transactions or a different backing type).See also
addOrReplaceAction(Action)
if you want to know whether the backingactions
was modified, for example in cases where the caller would need to persist theActionable
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
Add an action, replacing any existing actions of the (exact) same class. Note: calls togetAllActions()
that happen before calls to this method may not see the update. Note: this method does not affect transient actions contributed by aTransientActionFactory
Note: this method cannot provide concurrency control due to the backing storage being aCopyOnWriteArrayList
so concurrent calls to any of the mutation methods may produce surprising results though technically consistent from the concurrency contract ofCopyOnWriteArrayList
(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
Remove an action. Note: calls togetAllActions()
that happen before calls to this method may not see the update. Note: this method does not affect transient actions contributed by aTransientActionFactory
Note: this method cannot provide concurrency control due to the backing storage being aCopyOnWriteArrayList
so concurrent calls to any of the mutation methods may produce surprising results though technically consistent from the concurrency contract ofCopyOnWriteArrayList
(we would need some form of transactions or a different backing type).- Parameters:
a
- an action to remove (ifnull
then this will be a no-op)- Returns:
true
if this actions changed as a result of the call- Since:
- 2.29
-
removeActions
Removes any actions of the specified type. Note: calls togetAllActions()
that happen before calls to this method may not see the update. Note: this method does not affect transient actions contributed by aTransientActionFactory
Note: this method cannot provide concurrency control due to the backing storage being aCopyOnWriteArrayList
so concurrent calls to any of the mutation methods may produce surprising results though technically consistent from the concurrency contract ofCopyOnWriteArrayList
(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
Replaces any actions of the specified type by the supplied action. Note: calls togetAllActions()
that happen before calls to this method may not see the update. Note: this method does not affect transient actions contributed by aTransientActionFactory
Note: this method cannot provide concurrency control due to the backing storage being aCopyOnWriteArrayList
so concurrent calls to any of the mutation methods may produce surprising results though technically consistent from the concurrency contract ofCopyOnWriteArrayList
(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.No clear purpose, since subclasses may have overriddengetActions()
, and does not considerTransientActionFactory
. -
getAction
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) Deprecated. -
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 isreturn new ContextMenu().from(this,request,response);
, which implements the default behaviour. SeeModelObjectWithContextMenu.ContextMenu.from(ModelObjectWithContextMenu, StaplerRequest2, StaplerResponse2)
for more details of what it does. This should suit most implementations.- Specified by:
doContextMenu
in interfaceModelObjectWithContextMenu
- Throws:
Exception
- Since:
- 2.475
-
doContextMenu
@Deprecated @StaplerNotDispatchable public ModelObjectWithContextMenu.ContextMenu doContextMenu(org.kohsuke.stapler.StaplerRequest request, org.kohsuke.stapler.StaplerResponse response) throws Exception Deprecated.- Specified by:
doContextMenu
in interfaceModelObjectWithContextMenu
- Throws:
Exception
-
doContextMenu(StaplerRequest2, StaplerResponse2)