
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
The newest version!
/*
* Copyright 2019 IBM 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.List;
import java.util.logging.Logger;
import org.hyperledger.fabric.contract.Context;
import org.hyperledger.fabric.contract.ContractInterface;
import org.hyperledger.fabric.contract.ContractRuntimeException;
import org.hyperledger.fabric.contract.annotation.Serializer;
import org.hyperledger.fabric.contract.execution.ExecutionService;
import org.hyperledger.fabric.contract.execution.InvocationRequest;
import org.hyperledger.fabric.contract.execution.SerializerInterface;
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.impl.SerializerRegistryImpl;
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 final Logger LOGGER = Logger.getLogger(ContractExecutionService.class.getName());
private final SerializerRegistryImpl serializers;
/** @param serializers */
public ContractExecutionService(final SerializerRegistryImpl serializers) {
this.serializers = serializers;
}
/** */
@Override
public Chaincode.Response executeRequest(
final TxFunction txFn, final InvocationRequest req, final ChaincodeStub stub) {
LOGGER.fine(() -> "Routing Request" + txFn);
final TxFunction.Routing rd = txFn.getRouting();
Chaincode.Response response;
try {
final ContractInterface contractObject = rd.getContractInstance();
final Context context = contractObject.createContext(stub);
final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy