Package org.infinispan.protostream
Class FileDescriptorSource
java.lang.Object
org.infinispan.protostream.FileDescriptorSource
Aggregator for source proto files to be passed to
SerializationContext.registerProtoFiles(FileDescriptorSource).
The files are guaranteed to be processed in the order they were added (for better predictability or error reporting).- Since:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA callback interface that receives status notifications during the processing of files defined by aFileDescriptorSource. -
Field Summary
FieldsModifier and TypeFieldDescriptionThe unparsed files.Optional progress callback. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddProtoFile(File protoFile) addProtoFile(String name, File protoFile) Add a proto file, given a name and the file contents as aFile.addProtoFile(String name, InputStream fileContents) Add a proto file, given a name and the file contents as anInputStream.addProtoFile(String name, Reader fileContents) Add a proto file, given a name and the file contents as aReader.addProtoFile(String name, String fileContents) Add a proto file, given a name and the file contents as aString.addProtoFiles(ClassLoader userClassLoader, String... classpathResources) Add proto files from class path.addProtoFiles(String... classpathResources) Add proto files from class path.static FileDescriptorSourcefromResources(ClassLoader userClassLoader, String... classPathResources) static FileDescriptorSourcefromResources(String... classPathResources) static FileDescriptorSourcefromString(String name, String fileContents) Deprecated.This method was added for internal use and is deprecated since 4.3.4 to be removed in 5.getFiles()static StringgetResourceAsString(Class<?> c, String resourcePath) Deprecated.This method is strictly for internal use and has been deprecated in 4.3.4 to prevent use from external projects as it is subject for removal in 5.withProgressCallback(FileDescriptorSource.ProgressCallback progressCallback) Set the ProgressCallback.
-
Field Details
-
files
The unparsed files. Using a LinkedHashMap to ensure parsing happens in the order specified by the user so the eventual errors will appear in a predictable order. -
progressCallback
Optional progress callback. If non-null it will be invoked based on the status of each parsed file.
-
-
Constructor Details
-
FileDescriptorSource
public FileDescriptorSource()
-
-
Method Details
-
withProgressCallback
public FileDescriptorSource withProgressCallback(FileDescriptorSource.ProgressCallback progressCallback) Set the ProgressCallback. Anullcallback indicates that errors are to be reported immediately and the parsing operation should be aborted on first error.- Parameters:
progressCallback- the callback, can benull- Returns:
- this object, for easy method chaining
-
addProtoFiles
Add proto files from class path. The resource names are expected to be absolute.- Throws:
IOException
-
addProtoFiles
public FileDescriptorSource addProtoFiles(ClassLoader userClassLoader, String... classpathResources) throws IOException Add proto files from class path. The resource names are expected to be absolute.- Throws:
IOException
-
addProtoFile
Add a proto file, given a name and the file contents as aString. -
addProtoFile
Add a proto file, given a name and the file contents as anInputStream.- Throws:
IOException
-
addProtoFile
Add a proto file, given a name and the file contents as aReader.- Throws:
IOException
-
addProtoFile
Add a proto file, given a name and the file contents as aFile.- Throws:
IOException
-
addProtoFile
- Throws:
IOException
-
fromResources
public static FileDescriptorSource fromResources(ClassLoader userClassLoader, String... classPathResources) throws IOException - Throws:
IOException
-
fromResources
- Throws:
IOException
-
fromString
-
getFileDescriptors
Deprecated.This method was added for internal use and is deprecated since 4.3.4 to be removed in 5. Replaced bygetFiles() -
getFiles
-
getProgressCallback
-
getResourceAsString
@Deprecated public static String getResourceAsString(Class<?> c, String resourcePath) throws UncheckedIOException Deprecated.This method is strictly for internal use and has been deprecated in 4.3.4 to prevent use from external projects as it is subject for removal in 5.- Throws:
UncheckedIOException- if the resource is not found or an I/O error occurs
-