Class GoogleDescriptorLoader
java.lang.Object
ai.pipestream.common.util.descriptor.GoogleDescriptorLoader
- All Implemented Interfaces:
DescriptorLoader
Loads Protocol Buffer descriptors from Google descriptor set files (.dsc).
These files are typically generated by protoc with --descriptor_set_out flag
and packaged in JAR files under META-INF/grpc/.
Example usage:
GoogleDescriptorLoader loader = new GoogleDescriptorLoader("META-INF/grpc/services.dsc");
List<FileDescriptor> descriptors = loader.loadDescriptors();
-
Nested Class Summary
Nested classes/interfaces inherited from interface ai.pipestream.common.util.descriptor.DescriptorLoader
DescriptorLoader.DescriptorLoadException -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault descriptor path used by grpc-google-descriptor module. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a loader with the default descriptor path.GoogleDescriptorLoader(String descriptorPath) Creates a loader with a custom descriptor path.GoogleDescriptorLoader(String descriptorPath, ClassLoader classLoader) Creates a loader with a custom descriptor path and class loader. -
Method Summary
Modifier and TypeMethodDescriptionGets the descriptor path being used.Gets a human-readable name for this loader type.booleanChecks if this loader is available and can load descriptors.com.google.protobuf.Descriptors.FileDescriptorloadDescriptor(String fileName) Loads a specific file descriptor by name.List<com.google.protobuf.Descriptors.FileDescriptor> Loads all available file descriptors from this loader's source.static GoogleDescriptorLoadersearchPaths(String... paths) Creates a loader that searches for descriptor files in multiple locations.
-
Field Details
-
DEFAULT_DESCRIPTOR_PATH
Default descriptor path used by grpc-google-descriptor module.- See Also:
-
-
Constructor Details
-
GoogleDescriptorLoader
public GoogleDescriptorLoader()Creates a loader with the default descriptor path. -
GoogleDescriptorLoader
Creates a loader with a custom descriptor path.- Parameters:
descriptorPath- The classpath resource path to the .dsc file
-
GoogleDescriptorLoader
Creates a loader with a custom descriptor path and class loader.- Parameters:
descriptorPath- The classpath resource path to the .dsc fileclassLoader- The class loader to use for loading resources
-
-
Method Details
-
loadDescriptors
public List<com.google.protobuf.Descriptors.FileDescriptor> loadDescriptors() throws DescriptorLoader.DescriptorLoadExceptionDescription copied from interface:DescriptorLoaderLoads all available file descriptors from this loader's source.- Specified by:
loadDescriptorsin interfaceDescriptorLoader- Returns:
- A list of FileDescriptors
- Throws:
DescriptorLoader.DescriptorLoadException- if loading fails
-
loadDescriptor
public com.google.protobuf.Descriptors.FileDescriptor loadDescriptor(String fileName) throws DescriptorLoader.DescriptorLoadException Description copied from interface:DescriptorLoaderLoads a specific file descriptor by name.- Specified by:
loadDescriptorin interfaceDescriptorLoader- Parameters:
fileName- The proto file name (e.g., "my_types.proto")- Returns:
- The FileDescriptor, or null if not found
- Throws:
DescriptorLoader.DescriptorLoadException- if loading fails
-
isAvailable
public boolean isAvailable()Description copied from interface:DescriptorLoaderChecks if this loader is available and can load descriptors. For example, a GoogleDescriptorLoader would return false if the .dsc file is not on classpath.- Specified by:
isAvailablein interfaceDescriptorLoader- Returns:
- true if the loader can load descriptors
-
getLoaderType
Description copied from interface:DescriptorLoaderGets a human-readable name for this loader type.- Specified by:
getLoaderTypein interfaceDescriptorLoader- Returns:
- The loader type name
-
getDescriptorPath
Gets the descriptor path being used.- Returns:
- The descriptor path
-
searchPaths
Creates a loader that searches for descriptor files in multiple locations.- Parameters:
paths- The paths to search- Returns:
- A loader that tries each path until one succeeds
-