Package com.google.protobuf

Examples of com.google.protobuf.ExtensionRegistry


   * Returns a registry of protocol buffer extensions of all the currently
   * registered key versions.
   */
  public ExtensionRegistry getProtoExtensions() {
    synchronized (keyVersions) {
      ExtensionRegistry registry = cachedProtoExtensions;
      if (registry == null) {
        registry = ExtensionRegistry.newInstance();
        for (RegisteredKeyVersion rkv : getRegisteredKeyVersions()) {
          try {
            rkv.registerProtoExtensions(registry);
          } catch (ReflectiveOperationException ex) {
            // Might get this if the proto is broken. Just print trace and
            // continue.
            // TODO(darylseah): Perhaps log this?
            ex.printStackTrace();
          }
        }
        registry = registry.getUnmodifiable();
        cachedProtoExtensions = registry;
      }
      return registry;
    }
  }
View Full Code Here


      throws UnregisteredKeyVersionException, InvalidKeyDataException {
   
    // NOTE: lower-level exceptions take precedence by design
   
    KeyVersionRegistry registry = context.getKeyVersionRegistry();
    ExtensionRegistry protoRegistry = registry.getProtoExtensions();

    // Retain the core
    if (!data.hasCore()) {
      // Core field is required
      throw new InvalidKeyDataException(
View Full Code Here

    // Dump its proto data bytes
    ByteString bytes = toSave.buildData().build().toByteString();
   
    // Create a proto extension registry and register AES extension
    // (this will normally be done by KeyVersionRegistry)
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    AesKeyVersionProto.registerAllExtensions(registry);
   
    // Read the proto
    AESKeyVersion loaded = new AESKeyVersion.Builder()
        .withData(KeyVersionData.parseFrom(bytes, registry), registry).build();
View Full Code Here

    File[] candidates = isFormerMoreReadable(tempFileA, tempFileB) ?
        new File[] { keyFile, tempFileA, tempFileB } :
        new File[] { keyFile, tempFileB, tempFileA };
   
    // Attempt to read each file and return the first successfully parsed Key
    ExtensionRegistry registry =
        context.getKeyVersionRegistry().getProtoExtensions();
    StoreIOException ioException = null;
    for (File file : candidates) {
      try {
        if (file != null) {
View Full Code Here

    // Dump its proto data bytes
    ByteString bytes = toSave.buildData().build().toByteString();
   
    // Create a proto extension registry and register HMAC extension
    // (this will normally be done by KeyVersionRegistry)
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    HmacKeyVersionProto.registerAllExtensions(registry);
   
    // Read the proto
    HMACKeyVersion loaded = new HMACKeyVersion.Builder()
        .withData(KeyVersionData.parseFrom(bytes, registry), registry).build();
View Full Code Here

    assertEquals(KeyVersionProto.Type.TEST, rkv.getType());
    assertEquals(MockKeyVersionProto.class, rkv.getProtoClass());
    assertEquals(MockKeyVersion.class.hashCode(), rkv.hashCode());
   
    // Make sure protobuf extensions get registered
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    rkv.registerProtoExtensions(registry);
    FieldDescriptor fd;
    fd = MockKeyVersionProto.MockKeyVersionCore.extension.getDescriptor();
    assertEquals(fd, registry.findExtensionByName(fd.getFullName()).descriptor);
    fd = MockKeyVersionProto.MockKeyVersionData.extension.getDescriptor();
    assertEquals(fd, registry.findExtensionByName(fd.getFullName()).descriptor);
  }
View Full Code Here

        return session;
    }

    private static ProtobufMessages.KnowledgeSession loadAndParseSession(MarshallerReaderContext context) throws IOException,
                                                                                                         ClassNotFoundException {
        ExtensionRegistry registry = PersisterHelper.buildRegistry( context, processMarshaller );

        ProtobufMessages.Header _header = PersisterHelper.readFromStreamWithHeaderPreloaded( context, registry );

        return ProtobufMessages.KnowledgeSession.parseFrom( _header.getPayload(), registry );
    }
View Full Code Here

            }
        }
    }
   
    public static ExtensionRegistry buildRegistry(MarshallerReaderContext context, ProcessMarshaller processMarshaller ) {
        ExtensionRegistry registry = ExtensionRegistry.newInstance();
        if( processMarshaller != null ) {
            context.parameterObject = registry;
            processMarshaller.init( context );
        }
        return registry;
View Full Code Here

        initialFactHandle.setEntryPoint( session.getEntryPoints().get( EntryPoint.DEFAULT.getEntryPointId() ) );
        return session;
    }

    private static ProtobufMessages.KnowledgeSession loadAndParseSession(MarshallerReaderContext context) throws IOException, ClassNotFoundException {
        ExtensionRegistry registry = PersisterHelper.buildRegistry( context, processMarshaller );

        ProtobufMessages.Header _header = PersisterHelper.readFromStreamWithHeader( context, registry );
       
        return ProtobufMessages.KnowledgeSession.parseFrom( _header.getPayload(), registry );
    }
View Full Code Here

            }
        }
    }
   
    public static ExtensionRegistry buildRegistry(MarshallerReaderContext context, ProcessMarshaller processMarshaller ) {
        ExtensionRegistry registry = ExtensionRegistry.newInstance();
        if( processMarshaller != null ) {
            context.parameterObject = registry;
            processMarshaller.init( context );
        }
        return registry;
View Full Code Here

TOP

Related Classes of com.google.protobuf.ExtensionRegistry

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.