org.hyperledger.fabric.contract.execution.impl.ContractExecutionService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fabric-chaincode-shim Show documentation
Show all versions of fabric-chaincode-shim Show documentation
Hyperledger Fabric Java Chaincode Shim
/*
Copyright IBM Corp., DTCC All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.fabric.contract.execution.impl;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hyperledger.fabric.Logger;
import org.hyperledger.fabric.contract.Context;
import org.hyperledger.fabric.contract.ContractInterface;
import org.hyperledger.fabric.contract.ContractRuntimeException;
import org.hyperledger.fabric.contract.execution.ExecutionService;
import org.hyperledger.fabric.contract.execution.InvocationRequest;
import org.hyperledger.fabric.contract.execution.JSONTransactionSerializer;
import org.hyperledger.fabric.contract.metadata.TypeSchema;
import org.hyperledger.fabric.contract.routing.ParameterDefinition;
import org.hyperledger.fabric.contract.routing.TxFunction;
import org.hyperledger.fabric.contract.routing.TypeRegistry;
import org.hyperledger.fabric.shim.Chaincode;
import org.hyperledger.fabric.shim.ChaincodeException;
import org.hyperledger.fabric.shim.ChaincodeStub;
import org.hyperledger.fabric.shim.ResponseUtils;
public class ContractExecutionService implements ExecutionService {
private static Logger logger = Logger.getLogger(ContractExecutionService.class.getName());
private JSONTransactionSerializer serializer;
Map proxies = new HashMap<>();
public ContractExecutionService(TypeRegistry typeRegistry) {
// FUTURE: Permit this to swapped out as per node.js
this.serializer = new JSONTransactionSerializer(typeRegistry);
}
@Override
public Chaincode.Response executeRequest(TxFunction txFn, InvocationRequest req, ChaincodeStub stub) {
logger.debug(() -> "Routing Request" + txFn);
TxFunction.Routing rd = txFn.getRouting();
Chaincode.Response response;
try {
ContractInterface contractObject = rd.getContractInstance();
Context context = contractObject.createContext(stub);
final List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy