001/*
002 * Copyright (c) 2006-2011 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the Eclipse Public License v1.0
006 * which accompanies this distribution, and is available at
007 * http://www.eclipse.org/legal/epl-v10.html
008 *
009 * Contributors:
010 *     bstefanescu
011 */
012package org.nuxeo.ecm.automation;
013
014/**
015 * Throw it from an operation to interrupt a chain execution. The chain terminates silently (without throwing an
016 * exception) and the <code>output</code> object is returned as the chain output.
017 * <p>
018 * Also, you can set the <code>rollback</code> argument to true to rollback the current transaction.
019 *
020 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
021 */
022@SuppressWarnings("serial")
023public class ExitException extends OperationException {
024
025    protected Object output;
026
027    public ExitException() {
028        this(null, false);
029    }
030
031    public ExitException(Object output) {
032        this(output, false);
033    }
034
035    public ExitException(Object output, boolean rollback) {
036        super("Chain Interrupted");
037        this.output = output;
038        this.rollback = rollback;
039    }
040
041    public ExitException setOutput(Object output) {
042        this.output = output;
043        return this;
044    }
045
046    public Object getOutput() {
047        return output;
048    }
049
050}