/*
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 1999 Bull S.A.
 * Contact: jonas-team@objectweb.org
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

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. 
 * In case of RMI and JEREMIE, We use a simplified structure because 
 * we do not have nested transactions.
 * @author Philippe Durieux
 */
public class TransactionContextRMI implements TransactionContext {

    /**
     * @serial
     */
    private int timeout;

    /**
     * @serial
     */
    private Coordinator coordinator;

    /**
     * @serial
     */
    private Xid xid;

    /**
     * Build a new TransactionContext (from JTA layer)
     */
    public TransactionContextRMI(int t, Coordinator c, Xid x) {
	timeout = t;
	coordinator = c;
	xid = x;
    }

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

    /**
     * Get the coordinator associated with the transaction
     */
    public Coordinator getCoordinator() {
	return 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) coordinator;
    }

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

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

}
