当前位置: 首页>>代码示例>>Java>>正文


Java ExtensionRegistry.newInstance方法代码示例

本文整理汇总了Java中com.google.protobuf.ExtensionRegistry.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ExtensionRegistry.newInstance方法的具体用法?Java ExtensionRegistry.newInstance怎么用?Java ExtensionRegistry.newInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.protobuf.ExtensionRegistry的用法示例。


在下文中一共展示了ExtensionRegistry.newInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getExtensionRegistry

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
/**
 * Returns the {@link ExtensionRegistry} listing all known Protocol Buffers extension messages
 * to {@code T} registered with this {@link ProtoCoder}.
 */
public ExtensionRegistry getExtensionRegistry() {
  if (memoizedExtensionRegistry == null) {
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    for (Class<?> extensionHost : extensionHostClasses) {
      try {
        extensionHost
            .getDeclaredMethod("registerAllExtensions", ExtensionRegistry.class)
            .invoke(null, registry);
      } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        throw new IllegalStateException(e);
      }
    }
    memoizedExtensionRegistry = registry.getUnmodifiable();
  }
  return memoizedExtensionRegistry;
}
 
开发者ID:apache,项目名称:beam,代码行数:21,代码来源:ProtoCoder.java

示例2: main

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
	ExtensionRegistry registry = ExtensionRegistry.newInstance();
	Options.registerAllExtensions(registry);
	PluginProtos.CodeGeneratorRequest request = PluginProtos.CodeGeneratorRequest.
			parseFrom(System.in, registry);
	PluginProtos.CodeGeneratorResponse response;
	try {
		Scope<Object> root = buildScopeTree(request);
		PluginProtos.CodeGeneratorResponse.Builder responseBuilder =
				PluginProtos.CodeGeneratorResponse.newBuilder();
		writeFiles(root, responseBuilder);
		response = responseBuilder.build();
	} catch (Exception e) {
		// 出错,报告给 protoc ,然后退出
		StringWriter sw = new StringWriter();
		PrintWriter pw = new PrintWriter(sw);
		e.printStackTrace(pw);
		pw.flush();
		PluginProtos.CodeGeneratorResponse.newBuilder().setError(sw.toString()).
				build().writeTo(System.out);
		System.out.flush();
		return;
	}
	response.writeTo(System.out);
	System.out.flush();
}
 
开发者ID:funkypandagame,项目名称:protoc-gen-as3,代码行数:27,代码来源:Main.java

示例3: Xbuf

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
/**
 * A full constructor that allow to define every service (to injection).
 * @param assetManager the AssetManager used to load assets (texture, sound,...)
 * @param registry the protobuf registry for extensions
 * @param loader4Materials the xbuf way to load materials (null == use default implementation)
 * @param loader4Relations the xbuf way to load relations (null == use default implementation)
 */
public Xbuf(AssetManager assetManager, ExtensionRegistry registry, MaterialsMerger loader4Materials, RelationsMerger loader4Relations){
	loader4Materials = (loader4Materials != null) ?loader4Materials : new MaterialsMerger(assetManager);
	loader4Relations = (loader4Relations != null) ?loader4Relations : new RelationsMerger(loader4Materials);
	mergers=new LinkedList<Merger>();
	mergers.add(new NodesMerger());
	mergers.add(new MeshesMerger(loader4Materials));
	mergers.add(loader4Materials);
	mergers.add(new LightsMerger());
	mergers.add(new SkeletonsMerger());
	mergers.add(new AnimationsMerger());
	mergers.add(new CustomParamsMerger());
	mergers.add(new PhysicsMerger());

	// relations should be the last because it reuse data provide by other (put in components)
	mergers.add(loader4Relations);

	this.registry=registry!=null?registry:ExtensionRegistry.newInstance();
	setupExtensionRegistry(this.registry);
}
 
开发者ID:xbuf,项目名称:jme3_xbuf,代码行数:27,代码来源:Xbuf.java

示例4: parseFrom

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
public static ValuePartition parseFrom(final byte[] bytes) throws DeserializationException {
  ValuePartitionProtos.ValuePartition valuePartition = null;
  try {
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    registry
        .add(org.apache.hadoop.hbase.index.protobuf.generated.ValuePartitionProtos.SpatialPartition.offset);
    registry
        .add(org.apache.hadoop.hbase.index.protobuf.generated.ValuePartitionProtos.SpatialPartition.length);
    valuePartition =
        ValuePartitionProtos.ValuePartition.newBuilder().mergeFrom(bytes, registry).build();
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  return new SpatialPartition(
      valuePartition
          .getExtension(org.apache.hadoop.hbase.index.protobuf.generated.ValuePartitionProtos.SpatialPartition.offset),
      valuePartition
          .getExtension(org.apache.hadoop.hbase.index.protobuf.generated.ValuePartitionProtos.SpatialPartition.length));
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:20,代码来源:SpatialPartition.java

示例5: parseFrom

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
public static ValuePartition parseFrom(final byte[] bytes) throws DeserializationException {
  ValuePartitionProtos.ValuePartition valuePartition;
  try {
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    registry
        .add(org.apache.hadoop.hbase.index.protobuf.generated.ValuePartitionProtos.SeparatorPartition.separator);
    registry
        .add(org.apache.hadoop.hbase.index.protobuf.generated.ValuePartitionProtos.SeparatorPartition.position);
    valuePartition = ValuePartitionProtos.ValuePartition.parseFrom(bytes, registry);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  return new SeparatorPartition(
      valuePartition
          .getExtension(
            org.apache.hadoop.hbase.index.protobuf.generated.ValuePartitionProtos.SeparatorPartition.separator)
          .toByteArray(),
      valuePartition
          .getExtension(org.apache.hadoop.hbase.index.protobuf.generated.ValuePartitionProtos.SeparatorPartition.position));
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:21,代码来源:SeparatorPartition.java

示例6: ProtobufDataParserFactory

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
public ProtobufDataParserFactory(Settings settings) throws StageException {
  super(settings);
  this.protoDescriptorFile = settings.getConfig(ProtobufConstants.PROTO_DESCRIPTOR_FILE_KEY);
  this.messageType = settings.getConfig(ProtobufConstants.MESSAGE_TYPE_KEY);
  this.isDelimited = settings.getConfig(ProtobufConstants.DELIMITED_KEY);
  messageTypeToExtensionMap = new HashMap<>();
  defaultValueMap = new HashMap<>();
  // Get the descriptor for the expected message type
  descriptor = ProtobufTypeUtil.getDescriptor(
    settings.getContext(),
    protoDescriptorFile,
    messageType,
    messageTypeToExtensionMap,
    defaultValueMap
  );

  // Build the extension registry based on the cached extension map
  extensionRegistry = ExtensionRegistry.newInstance();
  for(Map.Entry<String, Set<Descriptors.FieldDescriptor>> e : messageTypeToExtensionMap.entrySet()) {
    Set<Descriptors.FieldDescriptor> value = e.getValue();
    for (Descriptors.FieldDescriptor f : value) {
      extensionRegistry.add(f);
    }
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:26,代码来源:ProtobufDataParserFactory.java

示例7: setUp

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
@Before public void setUp() {
  Retrofit retrofit = new Retrofit.Builder()
      .baseUrl(server.url("/"))
      .addConverterFactory(ProtoConverterFactory.create())
      .build();
  service = retrofit.create(Service.class);

  ExtensionRegistry registry = ExtensionRegistry.newInstance();
  PhoneProtos.registerAllExtensions(registry);
  Retrofit retrofitWithRegistry = new Retrofit.Builder()
      .baseUrl(server.url("/"))
      .addConverterFactory(ProtoConverterFactory.createWithRegistry(registry))
      .build();
  serviceWithRegistry = retrofitWithRegistry.create(ServiceWithRegistry.class);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:ProtoConverterFactoryTest.java

示例8: getExtraActionInfo

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
public static ExtraActionInfo getExtraActionInfo(String extraActionFile) {
  ExtensionRegistry registry = ExtensionRegistry.newInstance();
  ExtraActionsBase.registerAllExtensions(registry);

  try (InputStream stream = Files.newInputStream(Paths.get(extraActionFile))) {
    CodedInputStream coded = CodedInputStream.newInstance(stream);
    return ExtraActionInfo.parseFrom(coded, registry);
  } catch (IOException e) {
    throw new RuntimeException("ERROR: failed to deserialize extra action file "
      + extraActionFile + ": " + e.getMessage(), e);
  }
}
 
开发者ID:DSC-SPIDAL,项目名称:twister2,代码行数:13,代码来源:ExtraActionUtils.java

示例9: getStandardPlatformExtensions

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
/**
 * Get the standard extension registry to use for processing service config. By default,
 * registers extensions from {@code google/api/annotations.proto} (and related proto files).
 */
public static ExtensionRegistry getStandardPlatformExtensions() {
  ExtensionRegistry registry = ExtensionRegistry.newInstance();
  AnnotationsProto.registerAllExtensions(registry);

  return registry;
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:11,代码来源:ToolProtoUtil.java

示例10: testRecursiveDescriptorsMessageCWithExtensions

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
@Test
public void testRecursiveDescriptorsMessageCWithExtensions() {
  // With extensions, Message C has a reference to Message A and Message B.
  ExtensionRegistry registry = ExtensionRegistry.newInstance();
  Proto2CoderTestMessages.registerAllExtensions(registry);
  assertThat(getRecursiveDescriptorFullNames(MessageC.class, registry), equalTo(MESSAGE_C_EXT));
}
 
开发者ID:apache,项目名称:beam,代码行数:8,代码来源:ProtobufUtilTest.java

示例11: getPipeline

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
/**
 * 
 */
public ChannelPipeline getPipeline() throws Exception
{
    log.debug("getPipeline");
    ChannelPipeline p = Channels.pipeline();
    p.addLast("frameDecoder", new ProtobufVarint64FrameDecoder());
    p.addLast("frameEncoder", new ProtobufVarint64LengthFieldPrepender());
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    InfoProtocol.registerAllExtensions(registry);
    p.addLast("protobufDecoder",
            new ProtobufDecoder(InfoProtocol.InfoReqPack.getDefaultInstance(), registry));
    p.addLast("protobufEncoder", new ProtobufEncoder());
    p.addLast("handler", new InfoChannelHandler());
    return p;
}
 
开发者ID:mornsun,项目名称:infoserver,代码行数:18,代码来源:InfoChannelPipelineFactory.java

示例12: createExtensionRegistry

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
public static ExtensionRegistry createExtensionRegistry(Map<String, Set<Descriptors.FieldDescriptor>> extensionMap) {
  ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance();
  for(Map.Entry<String, Set<Descriptors.FieldDescriptor>> e : extensionMap.entrySet()) {
    Set<Descriptors.FieldDescriptor> value = e.getValue();
    for (Descriptors.FieldDescriptor f : value) {
      extensionRegistry.add(f);
    }
  }
  return extensionRegistry;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:11,代码来源:ProtobufTestUtil.java

示例13: checkProtobufDataUnknownFields

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
public static void checkProtobufDataUnknownFields(byte[] bytes) throws IOException {

    ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance();
    ExtensionsProto.registerAllExtensions(extensionRegistry);

    ByteArrayInputStream bIn = new ByteArrayInputStream(bytes);
    EmployeeProto.Employee.Builder builder = EmployeeProto.Employee.newBuilder();
    EmployeeProto.Employee employee;
    for(int i = 0; i < 10; i++) {
      builder.mergeDelimitedFrom(bIn, extensionRegistry);
      employee = builder.build();
      PersonProto.Person person;

      UnknownFieldsUtil.checkEmployeeUnknownFields(employee.getUnknownFields());

      if( i % 2 == 0) {
        EngineerProto.Engineer engineer = employee.getEngineer();
        Assert.assertNotNull(engineer);
        person = engineer.getPerson();
      } else {
        ExecutiveProto.Executive exec = employee.getExec();
        Assert.assertNotNull(exec);
        person = exec.getPerson();
      }

      Assert.assertNotNull(person);
      UnknownFieldsUtil.checkPersonUnknownFields(person.getUnknownFields());

      builder.clear();
    }
  }
 
开发者ID:streamsets,项目名称:datacollector,代码行数:32,代码来源:ProtobufTestUtil.java

示例14: readStudy

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
private Pair<BaseStudy, List<Attachment>> readStudy(InputStream inputStream) throws IOException {
  Mica.StudyDto.Builder builder = Mica.StudyDto.newBuilder();
  Readable input = new InputStreamReader(inputStream, Charsets.UTF_8);
  ExtensionRegistry extensionRegistry = ExtensionRegistry.newInstance();
  extensionRegistry .add(Mica.CollectionStudyDto.type);
  extensionRegistry .add(Mica.HarmonizationStudyDto.type);
  JsonFormat.merge(input, extensionRegistry, builder);
  List<Attachment> atts = extractAttachments(builder);
  BaseStudy study = dtos.fromDto( builder);
  return Pair.create(study, atts);
}
 
开发者ID:obiba,项目名称:mica2,代码行数:12,代码来源:StudyPackageImportServiceImpl.java

示例15: buildExtensionRegistry

import com.google.protobuf.ExtensionRegistry; //导入方法依赖的package包/类
private ExtensionRegistry buildExtensionRegistry(){
    ExtensionRegistry er = ExtensionRegistry.newInstance();
    er.add(OlapMessage.Submit.command);
    er.add(OlapMessage.Status.command);
    er.add(OlapMessage.Cancel.command);
    return er;
}
 
开发者ID:splicemachine,项目名称:spliceengine,代码行数:8,代码来源:OlapPipelineFactory.java


注:本文中的com.google.protobuf.ExtensionRegistry.newInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。