/*
 * The contents of this file are subject to the JOnAS Public License Version 
 * 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License on the JOnAS web site.
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.
 * See the License for the specific terms governing rights and limitations under 
 * the License.
 *
 * The Original Code is JOnAS application server code released July 1999.
 *
 * The Initial Developer of the Original Code is Bull S.A.
 * The Original Code and portions created by Bull S.A. are
 *    Copyright (C) 1999 Bull S.A. All Rights Reserved.
 *
 * Contributor(s): ______________________________________.
 *
 * --------------------------------------------------------------------------
 * $Id: PropagationContext.java,v 1.1 2000/11/15 15:54:06 jonas Exp $
 * --------------------------------------------------------------------------
 */


package org.objectweb.jonas_tm;

import java.io.Serializable;
import javax.transaction.xa.Xid;

/**
 * The propagation context is the context that should be propagated
 * between programs. The structure is defined in OTS specs. We use
 * here a simplified structure because we do not have nested transactions.
 */
public class PropagationContext implements org.omg.CosTransactions.PropagationContext {

    /**
     * @serial
     */
    private long timeout;
    /**
     * @serial
     */
    private Coordinator coordinator;
    /**
     * @serial
     */
    private Xid otid;
    
    
    
///////  TGU
    
    private Exception userException;
    
    public void setUserException(Exception e) {
    	userException = e;
    }
    public Exception getUserException() {
    	return userException;
    }
    
/////// fin TGU

    public PropagationContext(long timeout, Coordinator coord, Xid xid) {
	this.timeout = timeout;
	this.coordinator = coord;
	this.otid = xid;
    }

    /**
     * Get the timeout associated with the transaction
     */
    public long getTimeout() {
	return this.timeout;
    }

    /**
     * Get the coordinator associated with the transaction
     */
    public Coordinator getCoordinator() {
	return this.coordinator;
    }

    /**
     * Set the coordinator associated with the transaction
     */
    public void setCoordinator(Coordinator coord) {
	this.coordinator = coord;
    }

    /**
     * Get the Terminator associated with the transaction
     */
    public Terminator getTerminator() {
	return (Terminator) this.coordinator;
    }

    /**
     * Get the control associated with the transaction
     */
    public Control getControl() {
	return (Control) this.coordinator;
    }

    /**
     * Get the Xid associated with the transaction
     */
    public Xid getXid() {
	return (Xid) this.otid;
    }

}
