use of org.infinispan.protostream.descriptors.ResolutionContext in project protostream by infinispan.
the class SerializationContextImpl method registerProtoFiles.
@Override
public void registerProtoFiles(FileDescriptorSource source) throws DescriptorParserException {
if (log.isDebugEnabled()) {
log.debugf("Registering proto files : %s", source.getFiles().keySet());
}
Map<String, FileDescriptor> fileDescriptorMap = parser.parse(source);
long stamp = descriptorLock.writeLock();
try {
// unregister all types from the files that are being overwritten
for (String fileName : fileDescriptorMap.keySet()) {
FileDescriptor oldFileDescriptor = fileDescriptors.get(fileName);
if (oldFileDescriptor != null) {
unregisterFileDescriptorTypes(oldFileDescriptor);
}
}
fileDescriptors.putAll(fileDescriptorMap);
// resolve imports and types for all files
ResolutionContext resolutionContext = new ResolutionContext(source.getProgressCallback(), fileDescriptors, genericDescriptors, typeIds, enumValueDescriptors);
resolutionContext.resolve();
} finally {
descriptorLock.unlockWrite(stamp);
}
}
use of org.infinispan.protostream.descriptors.ResolutionContext in project protostream by infinispan.
the class DescriptorsTest method parseAndResolve.
private Map<String, FileDescriptor> parseAndResolve(FileDescriptorSource fileDescriptorSource, Configuration config) {
// parse the input
SquareProtoParser protoParser = new SquareProtoParser(config);
Map<String, FileDescriptor> fileDescriptorMap = protoParser.parse(fileDescriptorSource);
// resolve imports and types
ResolutionContext resolutionContext = new ResolutionContext(null, fileDescriptorMap, new HashMap<>(), new HashMap<>(), new HashMap<>());
resolutionContext.resolve();
return fileDescriptorMap;
}
Aggregations