/*
 * 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.rmi.Remote;
import java.rmi.RemoteException;

/**
 * This interface must be implemented by objects that will be
 * registered to the JTM Coordinator. They may be remote.
 * @author Philippe Durieux
 */
public interface Resource extends Remote {

    /** 
     * phase 1 of the 2PC.
     *
     * @return int vote commit, rollback, or readonly.
     */
    public int prepare() throws RemoteException;
    public final static int VOTE_COMMIT = 0;
    public final static int VOTE_ROLLBACK = 1;
    public final static int VOTE_READONLY = 2;

    /** 
     * rollback transaction
     */
    public void rollback() throws RemoteException;

    /** 
     * phase 2 of the 2PC.
     */
    public void commit() throws RemoteException;

    /** 
     * commit 1 phase.
     */
    public void commit_one_phase() throws RemoteException;

    /** 
     * forget heuristics about this transaction.
     */
    public void forget() throws RemoteException;
}
