commonlib/src/main/java/com/streamsets/pipeline/lib/util/ProtobufTypeUtil.java
public static Descriptors.Descriptor getDescriptor(
      ProtoConfigurableEntity.Context context,
      String protoDescriptorFile,
      String messageType,
      Map<String, Set<Descriptors.FieldDescriptor>> messageTypeToExtensionMap,
      Map<String, Object> defaultValueMap
  ) throws StageException {
    File descriptorFileHandle = new File(context.getResourcesDirectory(), protoDescriptorFile);
    try(
      FileInputStream fin = new FileInputStream(descriptorFileHandle);
      ) {
      DescriptorProtos.FileDescriptorSet set = DescriptorProtos.FileDescriptorSet.parseFrom(fin);

      // Iterate over all the file descriptor set computed above and cache dependencies and all encountered
      // file descriptors

      // this map holds all the dependencies that a given file descriptor has.
      // This cached map will be looked up while building FileDescriptor instances
      Map<String, Set<Descriptors.FileDescriptor>> fileDescriptorDependentsMap = new HashMap<>();
      // All encountered FileDescriptor instances cached based on their name.
      Map<String, Descriptors.FileDescriptor> fileDescriptorMap = new HashMap<>();
      ProtobufTypeUtil.getAllFileDescriptors(set, fileDescriptorDependentsMap, fileDescriptorMap);

      // Get the descriptor for the expected message type
      Descriptors.Descriptor descriptor = ProtobufTypeUtil.getDescriptor(set, fileDescriptorMap, protoDescriptorFile, messageType);

      // Compute and cache all extensions defined for each message type
      ProtobufTypeUtil.populateDefaultsAndExtensions(fileDescriptorMap, messageTypeToExtensionMap, defaultValueMap);
      return descriptor;
    } catch (FileNotFoundException e) {
      throw new StageException(Errors.PROTOBUF_06, descriptorFileHandle.getAbsolutePath(), e);
    } catch (IOException e) {
      throw new StageException(Errors.PROTOBUF_08, e.toString(), e);
    }
  }
public static Descriptors.Descriptor getDescriptor(
      ProtoConfigurableEntity.Context context,
      String protoDescriptorFile,
      String messageType,
      Map<String, Set<Descriptors.FieldDescriptor>> messageTypeToExtensionMap,
      Map<String, Object> defaultValueMap
  ) throws StageException {
    File descriptorFileHandle = new File(context.getResourcesDirectory(), protoDescriptorFile);
    try(
      FileInputStream fin = new FileInputStream(descriptorFileHandle);
      ) {
      DescriptorProtos.FileDescriptorSet set = DescriptorProtos.FileDescriptorSet.parseFrom(fin);

      // Iterate over all the file descriptor set computed above and cache dependencies and all encountered
      // file descriptors

      // this map holds all the dependencies that a given file descriptor has.
      // This cached map will be looked up while building FileDescriptor instances
      Map<String, Set<Descriptors.FileDescriptor>> fileDescriptorDependentsMap = new HashMap<>();
      // All encountered FileDescriptor instances cached based on their name.
      Map<String, Descriptors.FileDescriptor> fileDescriptorMap = new HashMap<>();
      ProtobufTypeUtil.getAllFileDescriptors(set, fileDescriptorDependentsMap, fileDescriptorMap);

      // Get the descriptor for the expected message type
      Descriptors.Descriptor descriptor = ProtobufTypeUtil.getDescriptor(set, fileDescriptorMap, protoDescriptorFile, messageType);

      // Compute and cache all extensions defined for each message type
      ProtobufTypeUtil.populateDefaultsAndExtensions(fileDescriptorMap, messageTypeToExtensionMap, defaultValueMap);
      return descriptor;
    } catch (FileNotFoundException e) {
      throw new StageException(Errors.PROTOBUF_06, descriptorFileHandle.getAbsolutePath(), e);
    } catch (IOException e) {
      throw new StageException(Errors.PROTOBUF_08, e.toString(), e);
    }
  }
public static Descriptors . Descriptor getDescriptor ( ProtoConfigurableEntity . Context context , String protoDescriptorFile , String messageType , Map < String , Set < Descriptors . FieldDescriptor > > messageTypeToExtensionMap , Map < String , Object > defaultValueMap ) throws StageException { File descriptorFileHandle = new File ( context . getResourcesDirectory ( ) , protoDescriptorFile ) ; try ( FileInputStream fin = new FileInputStream ( descriptorFileHandle ) ; ) { DescriptorProtos . FileDescriptorSet set = DescriptorProtos . FileDescriptorSet . parseFrom ( fin ) ; // Iterate over all the file descriptor set computed above and cache dependencies and all encountered // file descriptors // this map holds all the dependencies that a given file descriptor has. // This cached map will be looked up while building FileDescriptor instances Map < String , Set < Descriptors . FileDescriptor > > fileDescriptorDependentsMap = new HashMap <> ( ) ; // All encountered FileDescriptor instances cached based on their name. Map < String , Descriptors . FileDescriptor > fileDescriptorMap = new HashMap <> ( ) ; ProtobufTypeUtil . getAllFileDescriptors ( set , fileDescriptorDependentsMap , fileDescriptorMap ) ; // Get the descriptor for the expected message type Descriptors . Descriptor descriptor = ProtobufTypeUtil . getDescriptor ( set , fileDescriptorMap , protoDescriptorFile , messageType ) ; // Compute and cache all extensions defined for each message type ProtobufTypeUtil . populateDefaultsAndExtensions ( fileDescriptorMap , messageTypeToExtensionMap , defaultValueMap ) ; return descriptor ; } catch ( FileNotFoundException e ) { throw new StageException ( Errors . PROTOBUF_06 , descriptorFileHandle . getAbsolutePath ( ) , e ) ; } catch ( IOException e ) { throw new StageException ( Errors . PROTOBUF_08 , e . toString ( ) , e ) ; } }
Returns a protobuf descriptor instance from the provided descriptor file.

@param context                   Stage context used for finding the SDC resources directory
@param protoDescriptorFile       Path to descriptor file relative to SDC_RESOURCES
@param messageType               The name of the message to decode
@param messageTypeToExtensionMap Map of protobuf extensions required for decoding
@param defaultValueMap           Map of default values to use for the message
@return protobuf descriptor instance
@throws StageException
Returns a protobuf descriptor instance from the provided descriptor file .