提交 4ca37cfd 编写于 作者: K kohsuke

FoldableAction isn't used by any plugin yet, so changing the signature and moving it to a new home.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@22992 71c3de6d-444a-0410-be80-ed276b4c234a
上级 542ab897
......@@ -24,13 +24,13 @@
package hudson.model;
import hudson.model.Queue.Task;
import hudson.model.queue.FoldableAction;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
import java.util.ArrayList;
import java.util.List;
import org.kohsuke.stapler.export.Exported;
import org.kohsuke.stapler.export.ExportedBean;
@ExportedBean
public class CauseAction implements FoldableAction {
/**
......@@ -77,15 +77,14 @@ public class CauseAction implements FoldableAction {
return causes.get(0).getShortDescription();
}
public void foldIntoExisting(Task t, List<Action> actions) {
for(Action action : actions) {
if(action instanceof CauseAction) {
this.causes.addAll(((CauseAction)action).causes);
return;
}
public void foldIntoExisting(hudson.model.Queue.Item item, Task owner, List<Action> otherActions) {
CauseAction existing = item.getAction(CauseAction.class);
if (existing!=null) {
existing.causes.addAll(this.causes);
return;
}
// no CauseAction found, so add a copy of this one
actions.add(new CauseAction(this));
item.getActions().add(new CauseAction(this));
}
private Object readResolve() {
......
......@@ -380,7 +380,7 @@ public class Queue extends ResourceController implements Saveable {
return scheduleInternal(p, quietPeriod, actions);
}
/**
* Schedules an execution of a task.
*
......@@ -426,7 +426,7 @@ public class Queue extends ResourceController implements Saveable {
// but let the actions affect the existing stuff.
for(Item item : duplicatesInQueue) {
for(FoldableAction a : Util.filter(actions,FoldableAction.class)) {
a.foldIntoExisting(item.task, item.getActions());
a.foldIntoExisting(item, p, actions);
}
}
......@@ -1207,6 +1207,8 @@ public class Queue extends ResourceController implements Saveable {
/**
* An optional interface for actions on Queue.Item.
* Lets the action cooperate in queue management.
*
* @since 1.300-ish.
*/
public interface QueueAction extends Action {
/**
......
......@@ -21,18 +21,39 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package hudson.model;
package hudson.model.queue;
import hudson.model.Queue.Task;
import hudson.model.Action;
import hudson.model.Queue;
import java.util.List;
/**
* @author mdonohue
* An action interface that allows action data to be folded together.
* This is useful for combining any distinct values from a build determined to
* be a duplicate of a build already in the build queue.
*
* <p>
* {@link Action} can implement this optional marker interface to be notified when
* the {@link Task} that it's added to the queue with is determined to be "already in the queue".
*
* <p>
* This is useful for passing on parameters to the task that's already in the queue.
*
* @author mdonohue
* @since 1.300-ish.
*/
public interface FoldableAction extends Action {
public void foldIntoExisting(Task t, List<Action> actions);
/**
* Notifies that the {@link Task} that "owns" this action (that is, the task for which this action is submitted)
* is considered as a duplicate.
*
* @param item
* The existing {@link Queue.Item} in the queue against which we are judged as a duplicate. Never null.
* @param owner
* The {@link Task} with which this action was submitted to the queue. Never null.
* @param otherActions
* Other {@link Action}s that are submitted with the task. (One of them is this {@link FoldableAction}.)
* Never null.
*/
void foldIntoExisting(Queue.Item item, Task owner, List<Action> otherActions);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册