Package org.infinispan.protostream.descriptors

Examples of org.infinispan.protostream.descriptors.FileDescriptor$Builder


   public Map<String, FileDescriptor> parse(FileDescriptorSource fileDescriptorSource) throws IOException, DescriptorParserException {
      Map<String, ProtoFile> fileMap = parseInternal(fileDescriptorSource.getFileDescriptors());
      Map<String, FileDescriptor> fileDescriptorMap = new HashMap<>(fileMap.size());
      for (String fileName : fileMap.keySet()) {
         if (!fileDescriptorMap.containsKey(fileName)) {
            FileDescriptor mapped = new ProtofileMapper(fileMap).map(fileMap.get(fileName));
            fileDescriptorMap.put(fileName, mapped);
         }
      }
      return fileDescriptorMap;
   }
View Full Code Here


      List<ExtendDeclaration> extendDeclarations = protoFile.getExtendDeclarations();
      List<String> dependencies = protoFile.getDependencies();
      List<FileDescriptor> protoFiles = new ArrayList<>(dependencies.size());

      for (String dependency : dependencies) {
         FileDescriptor fd = mapInternal(protoFile.getFileName(), dependency, processedFile);
         protoFiles.add(fd);
      }

      return new FileDescriptor.Builder()
              .withName(protoFile.getFileName())
View Full Code Here

      Map<String, FileDescriptor> fileDescriptors = ctx.getFileDescriptors();

      assertEquals(3, fileDescriptors.size());

      FileDescriptor fd1 = fileDescriptors.get("file1.proto");
      assertNotNull(fd1);
      assertEquals(1, fd1.getTypes().size());
      assertTrue(fd1.getTypes().containsKey("p.A"));

      FileDescriptor fd2 = fileDescriptors.get("file2.proto");
      assertNotNull(fd2);
      assertTrue(fd2.getTypes().isEmpty());
   }
View Full Code Here

              "org/infinispan/protostream/lib/base.proto",
              "org/infinispan/protostream/lib/base2.proto");

      Map<String, FileDescriptor> files = parseAndResolve(fileDescriptorSource);

      FileDescriptor descriptor = files.get("org/infinispan/protostream/test/message.proto");

      assertThat(descriptor.getMessageTypes()).hasSize(3);
      assertThat(descriptor.getEnumTypes()).hasSize(1);
      assertThat(descriptor.getOptions()).hasSize(2);

      assertSearchRequest(descriptor.getMessageTypes().get(0));
      assertTopLevelEnum(descriptor.getEnumTypes().iterator().next());
      assertSearchResponse(descriptor.getMessageTypes().get(1));
      assertResult(descriptor.getMessageTypes().get(2));
      assertExtensions(descriptor.getExtensionsTypes());
   }
View Full Code Here

      fileDescriptorSource.addProtoFile("file1.proto", file1);

      Map<String, FileDescriptor> descriptors = parseAndResolve(fileDescriptorSource);
      assertEquals(1, descriptors.size());
      assertTrue(descriptors.containsKey("file1.proto"));
      FileDescriptor fd = descriptors.get("file1.proto");
      assertEquals(1, fd.getMessageTypes().size());
   }
View Full Code Here

              "org/infinispan/protostream/lib/base.proto",
              "org/infinispan/protostream/lib/base2.proto");

      Map<String, FileDescriptor> files = new SquareProtoParser().parse(fileDescriptorSource);

      FileDescriptor descriptor = files.get("org/infinispan/protostream/test/message.proto");

      assertThat(descriptor.getMessageTypes()).hasSize(3);
      assertThat(descriptor.getEnumTypes()).hasSize(1);
      assertThat(descriptor.getOptions()).hasSize(2);

      assertSearchRequest(descriptor.getMessageTypes().get(0));
      assertTopLevelEnum(descriptor.getEnumTypes().iterator().next());
      assertSearchResponse(descriptor.getMessageTypes().get(1));
      assertResult(descriptor.getMessageTypes().get(2));
      assertExtensions(descriptor.getExtensionsTypes());

   }
View Full Code Here

      Map<String, char[]> input = fileDescriptorSource.getFileDescriptors();
      Map<String, FileDescriptor> fileDescriptorMap = new LinkedHashMap<>(input.size());
      for (Map.Entry<String, char[]> entry : input.entrySet()) {
         try {
            ProtoFile protoFile = ProtoSchemaParser.parse(entry.getKey(), new CharArrayReader(entry.getValue()));
            FileDescriptor fileDescriptor = PROTOFILE_MAPPER.map(protoFile);
            fileDescriptorMap.put(entry.getKey(), fileDescriptor);
         } catch (IOException e) {
            throw new DescriptorParserException("Internal parsing error : " + e.getMessage());
         } catch (DescriptorParserException e) {
            throw e;
View Full Code Here

      Map<String, FileDescriptor> fileDescriptorMap = parser.parse(source);
      writeLock.lock();
      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);
View Full Code Here

   @Override
   public void unregisterProtoFile(String fileName) {
      log.debugf("Unregistering proto file : %s", fileName);
      writeLock.lock();
      try {
         FileDescriptor fileDescriptor = fileDescriptors.get(fileName);
         if (fileDescriptor != null) {
            fileDescriptors.remove(fileDescriptor.getName());
            unregisterFileDescriptorTypes(fileDescriptor);
         }
      } finally {
         writeLock.unlock();
      }
View Full Code Here

   public Map<String, FileDescriptor> parse(FileDescriptorSource fileDescriptorSource) throws IOException, DescriptorParserException {
      Map<String, ProtoFile> fileMap = parseInternal(fileDescriptorSource.getFileDescriptors());
      Map<String, FileDescriptor> fileDescriptorMap = new HashMap<>(fileMap.size());
      for (String fileName : fileMap.keySet()) {
         if (!fileDescriptorMap.containsKey(fileName)) {
            FileDescriptor mapped = new ProtofileMapper(fileMap).map(fileMap.get(fileName));
            fileDescriptorMap.put(fileName, mapped);
         }
      }
      return fileDescriptorMap;
   }
View Full Code Here

TOP

Related Classes of org.infinispan.protostream.descriptors.FileDescriptor$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.