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

org.infinispan.io.WritableGridFileChannel Maven / Gradle / Ivy

There is a newer version: 15.1.0.Dev04
Show newest version
package org.infinispan.io;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.ClosedChannelException;
import java.nio.channels.WritableByteChannel;

import org.infinispan.Cache;

/**
 * @author Marko Luksa
 * @deprecated since 10.0
 */
@Deprecated
public class WritableGridFileChannel implements WritableByteChannel {

   private final GridOutputStream gridOutputStream;
   private final WritableByteChannel delegate;

   WritableGridFileChannel(GridFile file, Cache cache, boolean append) {
      this.gridOutputStream = new GridOutputStream(file, append, cache);
      this.delegate = Channels.newChannel(gridOutputStream);
   }

   @Override
   public int write(ByteBuffer src) throws IOException {
      checkOpen();
      return delegate.write(src);
   }

   public void flush() throws IOException {
      gridOutputStream.flush();
   }

   @Override
   public boolean isOpen() {
      return delegate.isOpen();
   }

   @Override
   public void close() throws IOException {
      delegate.close();
   }

   private void checkOpen() throws ClosedChannelException {
      if (!isOpen()) {
         throw new ClosedChannelException();
      }
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy