Package org.infinispan.protostream

Examples of org.infinispan.protostream.FileDescriptorSource


   public static final String QUERY_PROTO_RES = "/org/infinispan/query/remote/client/query.proto";
   public static final String MESSAGE_PROTO_RES = "/org/infinispan/protostream/message-wrapping.proto";

   public static void registerMarshallers(SerializationContext ctx) throws IOException, DescriptorParserException {
      FileDescriptorSource fileDescriptorSource = new FileDescriptorSource();
      fileDescriptorSource.addProtoFile("query.proto", MarshallerRegistration.class.getResourceAsStream(QUERY_PROTO_RES));
      fileDescriptorSource.addProtoFile("message-wrapping.proto", MarshallerRegistration.class.getResourceAsStream(MESSAGE_PROTO_RES));
      ctx.registerProtoFiles(fileDescriptorSource);
      ctx.registerMarshaller(new QueryRequestMarshaller());
      ctx.registerMarshaller(new QueryResponseMarshaller());
   }
View Full Code Here


      }

      final Object result = invokeNextInterceptor(ctx, command);

      if (command.isSuccessful()) {
         FileDescriptorSource source = new FileDescriptorSource()
               .addProtoFile((String) key, (String) value);

         ProgressCallback progressCallback = null;
         if (ctx.isOriginLocal() && !command.hasFlag(Flag.PUT_FOR_STATE_TRANSFER)) {
            progressCallback = new ProgressCallback(ctx);
            source.withProgressCallback(progressCallback);
         } else {
            source.withProgressCallback(EMPTY_CALLBACK);
         }

         try {
            serializationContext.registerProtoFiles(source);
         } catch (IOException e) {
View Full Code Here

   @Override
   public Object visitPutMapCommand(final InvocationContext ctx, PutMapCommand command) throws Throwable {
      final Map<Object, Object> map = command.getMap();

      FileDescriptorSource source = new FileDescriptorSource();
      for (Object key : map.keySet()) {
         final Object value = map.get(key);
         if (!(key instanceof String)) {
            throw new CacheException("The key must be a string");
         }
         if (!(value instanceof String)) {
            throw new CacheException("The value must be a string");
         }
         if (shouldIntercept(key)) {
            if (!((String) key).endsWith(PROTO_KEY_SUFFIX)) {
               throw new CacheException("The key must end with \".proto\" : " + key);
            }
            source.addProtoFile((String) key, (String) value);
         }
      }

      // lock .errors key
      VisitableCommand cmd = commandsFactory.buildLockControlCommand(ERRORS_KEY_SUFFIX, null, null);
      invoker.invoke(ctx, cmd);

      final Object result = invokeNextInterceptor(ctx, command);

      ProgressCallback progressCallback = null;
      if (ctx.isOriginLocal()) {
         progressCallback = new ProgressCallback(ctx);
         source.withProgressCallback(progressCallback);
      } else {
         source.withProgressCallback(EMPTY_CALLBACK);
      }

      try {
         serializationContext.registerProtoFiles(source);
      } catch (IOException e) {
View Full Code Here

         invoker.invoke(ctx, cmd);

         final Object result = invokeNextInterceptor(ctx, command);

         if (command.isSuccessful()) {
            FileDescriptorSource source = new FileDescriptorSource()
                  .addProtoFile((String) key, (String) value);

            ProgressCallback progressCallback = null;
            if (ctx.isOriginLocal()) {
               progressCallback = new ProgressCallback(ctx);
               source.withProgressCallback(progressCallback);
            } else {
               source.withProgressCallback(EMPTY_CALLBACK);
            }

            try {
               serializationContext.registerProtoFiles(source);
            } catch (IOException e) {
View Full Code Here

      protobufMetadataManager.getCache().putAll(files);
   }

   @Override
   public void registerProtoFiles(String... classpathResources) throws IOException, DescriptorParserException {
      FileDescriptorSource fileDescriptorSource = new FileDescriptorSource();
      fileDescriptorSource.addProtoFiles(classpathResources);
      registerProtoFiles(fileDescriptorSource);
   }
View Full Code Here

   }


   @Override
   public FileDescriptorSource readObject(ObjectInput input) throws IOException, ClassNotFoundException {
      FileDescriptorSource fileDescriptorSource = new FileDescriptorSource();
      int size = UnsignedNumeric.readUnsignedInt(input);
      for (int i = 0; i < size; i++) {
         String name = input.readUTF();
         int length = UnsignedNumeric.readUnsignedInt(input);
         byte[] compressed = (byte[]) input.readObject();
         char[] contents = decompress(compressed, length);
         fileDescriptorSource.addProtoFile(name, String.valueOf(contents));
      }
      return fileDescriptorSource;
   }
View Full Code Here

      if (registryListener == null) {
         synchronized (this) {
            if (registryListener == null) {
               registryListener = new ProtobufMetadataRegistryListener();
               clusterRegistry.addListener(REGISTRY_SCOPE, registryListener);
               FileDescriptorSource descriptorSource = getFileDescriptorSource();
               if (!descriptorSource.getFileDescriptors().isEmpty()) {
                  try {
                     serCtx.registerProtoFiles(descriptorSource);
                  } catch (Exception e) {
                     log.error(e);
                  }
View Full Code Here

   public void registerProtofiles(@Parameter(name = "fileNames", description = "names of the protofiles") String[] names,
                                  @Parameter(name = "fileContents", description = "content of the files") String[] contents)
           throws Exception {
      if (names.length != contents.length)
         throw new MBeanException(new IllegalArgumentException("invalid parameter sizes"));
      FileDescriptorSource fileDescriptorSource = getFileDescriptorSource();
      for (int i = 0; i < names.length; i++) {
         fileDescriptorSource.addProtoFile(names[i], contents[i]);
      }
      clusterRegistry.put(REGISTRY_SCOPE, REGISTRY_KEY, fileDescriptorSource);
   }
View Full Code Here

   }

   @ManagedOperation(description = "Registers a Protobuf definition file", displayName = "Register Protofile")
   public void registerProtofile(@Parameter(name = "fileName", description = "the name of the .proto file") String name,
                                 @Parameter(name = "contents", description = "contents of the file") String contents) throws Exception {
      FileDescriptorSource fileDescriptorSource = getFileDescriptorSource();
      fileDescriptorSource.addProtoFile(name, contents);

      clusterRegistry.put(REGISTRY_SCOPE, REGISTRY_KEY, fileDescriptorSource);
   }
View Full Code Here

      clusterRegistry.put(REGISTRY_SCOPE, REGISTRY_KEY, fileDescriptorSource);
   }

   @ManagedOperation(description = "Display a protobuf definition file", displayName = "Register Protofile")
   public String displayProtofile(@Parameter(name = "fileName", description = "the name of the .proto file") String name) {
      FileDescriptorSource fileDescriptorSource = clusterRegistry.get(REGISTRY_SCOPE, REGISTRY_KEY);
      if (fileDescriptorSource == null)
         return null;
      char[] data = fileDescriptorSource.getFileDescriptors().get(name);
      return data != null ? String.valueOf(data) : null;
   }
View Full Code Here

TOP

Related Classes of org.infinispan.protostream.FileDescriptorSource

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.