All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jd.blockchain.transaction.ContractInvocationStub Maven / Gradle / Ivy

There is a newer version: 1.6.5.RELEASE
Show newest version
package com.jd.blockchain.transaction;

/**
 * 用于在上下文中传递合约调用返回值的工具类;
 * 
 * @author huanghaiquan
 *
 */
class ContractInvocationStub {

	private static ThreadLocal stub = new ThreadLocal();

	private ContractInvocationStub() {
	}

	public static void set(ContractInvocation invocation) {
		if (invocation == null) {
			throw new IllegalArgumentException("Null stub value!");
		}
		stub.set(invocation);
	}

	public static ContractInvocation take() {
		ContractInvocation subValue = stub.get();
		if (subValue == null) {
//			throw new IllegalStateException(
//					"The latest invocation of contract has not been stubbed! It may be caused by the wrong call sequence from the upper layer!");
			return null;
		}
		stub.remove();
		return subValue;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy