Search in sources :

Example 1 with ResolutionContext

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);
    }
}
Also used : ResolutionContext(org.infinispan.protostream.descriptors.ResolutionContext) FileDescriptor(org.infinispan.protostream.descriptors.FileDescriptor)

Example 2 with ResolutionContext

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;
}
Also used : ResolutionContext(org.infinispan.protostream.descriptors.ResolutionContext) FileDescriptor(org.infinispan.protostream.descriptors.FileDescriptor)

Aggregations

FileDescriptor (org.infinispan.protostream.descriptors.FileDescriptor)2 ResolutionContext (org.infinispan.protostream.descriptors.ResolutionContext)2