Class ChildObserver<I extends TopLevelItem>
- java.lang.Object
-
- com.cloudbees.hudson.plugins.folder.computed.ChildObserver<I>
-
- All Implemented Interfaces:
AutoCloseable
public abstract class ChildObserver<I extends TopLevelItem> extends Object implements AutoCloseable
Callback forComputedFolder
. Methods may be called only inside the scope ofComputedFolder.computeChildren(com.cloudbees.hudson.plugins.folder.computed.ChildObserver<I>, hudson.model.TaskListener)
or an out-of-band event handler.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract void
close()
Closes theChildObserver
completing any observations that were notcompleted(String)
.abstract void
completed(String name)
Notify the observer that you have completed with the named child and other threads are now permitted to proceed with observations of theItem.getName()
.abstract void
created(I child)
Notify the observer that you did create a new child.abstract boolean
mayCreate(String name)
Checks whether we may create a new child of the given name.abstract Set<String>
observed()
Returns a copy of the item names that have been observed.abstract Map<String,I>
orphaned()
Returns a copy of the map of orphaned items keyed by name.abstract I
shouldUpdate(String name)
Checks whether there is an existing child which should be updated.
-
-
-
Method Detail
-
shouldUpdate
@CheckForNull public abstract I shouldUpdate(String name) throws InterruptedException
Checks whether there is an existing child which should be updated. It is strongly recommended to callcompleted(String)
after completion of processing the proposedItem.getName()
as otherwise no otherChildObserver
will be able to proceed with thisItem.getName()
.- Parameters:
name
- a proposedItem.getName()
- Returns:
- the existing child to update, if there is one (in which case go ahead and update it as needed); else
null
, in which case continue by checkingmayCreate(java.lang.String)
- Throws:
InterruptedException
- if interrupted.
-
mayCreate
public abstract boolean mayCreate(String name)
Checks whether we may create a new child of the given name.- Parameters:
name
- a proposedItem.getName()
- Returns:
- true if you may go ahead and call
created(I)
(though you are not obliged to do so);false
if you may not
-
created
public abstract void created(I child)
Notify the observer that you did create a new child.- Parameters:
child
- a newly constructed child item; do not callItem.onCreatedFromScratch()
and try to avoid calls toItem.save()
-
completed
public abstract void completed(String name)
Notify the observer that you have completed with the named child and other threads are now permitted to proceed with observations of theItem.getName()
.- Parameters:
name
- theItem.getName()
.- Since:
- 6.0.0
-
observed
public abstract Set<String> observed()
Returns a copy of the item names that have been observed.- Returns:
- a copy of the item names that have been observed.
- Since:
- 5.14
-
orphaned
public abstract Map<String,I> orphaned()
Returns a copy of the map of orphaned items keyed by name.- Returns:
- a copy of the map of orphaned items keyed by name.
- Since:
- 5.14
-
close
public abstract void close()
Closes theChildObserver
completing any observations that were notcompleted(String)
. This method is idempotent.- Specified by:
close
in interfaceAutoCloseable
-
-