package multithreaded;

import java.util.Map;

import com.atomikos.icatch.HeurCommitException;
import com.atomikos.icatch.HeurHazardException;
import com.atomikos.icatch.HeurMixedException;
import com.atomikos.icatch.HeurRollbackException;
import com.atomikos.icatch.Participant;
import com.atomikos.icatch.RollbackException;
import com.atomikos.icatch.SysException;

public class SubTransactionTerminationVerifier implements Participant {

	private static final long serialVersionUID = 1L;
	private boolean commitCalled;
	private boolean rollbackCalled;

	@Override
	public String getURI() {
		return null;
	}

	@Override
	public void setCascadeList(Map<String, Integer> allParticipants)
			throws SysException {
		

	}

	@Override
	public void setGlobalSiblingCount(int count) {

	}

	@Override
	public int prepare() throws RollbackException, HeurHazardException,
			HeurMixedException, SysException {
		return Participant.READ_ONLY + 1;
	}

	@Override
	public void commit(boolean onePhase) throws HeurRollbackException,
			HeurHazardException, HeurMixedException, RollbackException,
			SysException {
		commitCalled = true;

	}

	@Override
	public void rollback() throws HeurCommitException, HeurMixedException,
			HeurHazardException, SysException {
		rollbackCalled = true;
	}

	@Override
	public void forget() {
		
	}

	@Override
	public String getResourceName() {
		return null;
	}
	
	public boolean commitCalled() {
		return commitCalled;
	}
	
	public boolean rollbackCalled() {
		return rollbackCalled;
	}

}
