All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.manager.impl.ReplicableCommandRunnable Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.manager.impl;

import org.infinispan.commands.ReplicableCommand;
import org.infinispan.context.InvocationContext;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.concurrent.Callable;

/**
 * Replicable Command that runs the given Runnable
 *
 * @author wburns
 * @since 8.2
 */
public class ReplicableCommandRunnable implements ReplicableCommand {

   public static final byte COMMAND_ID = 59;

   private Runnable runnable;

   public ReplicableCommandRunnable() {

   }

   public ReplicableCommandRunnable(Runnable runnable) {
      this.runnable = runnable;
   }

   @Override
   public Object perform(InvocationContext ctx) throws Throwable {
      runnable.run();
      return null;
   }

   @Override
   public byte getCommandId() {
      return COMMAND_ID;
   }

   @Override
   public void readFrom(ObjectInput input) throws IOException, ClassNotFoundException {
      runnable = (Runnable) input.readObject();
   }

   @Override
   public void writeTo(ObjectOutput output) throws IOException {
      output.writeObject(runnable);
   }

   @Override
   public boolean isReturnValueExpected() {
      return false;
   }

   @Override
   public boolean canBlock() {
      return true;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy