Skip to content

Commit

Permalink
ISPN-6056 Improve ReplicableCommand marshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
pruivo committed Jan 28, 2016
1 parent 3448291 commit 16c64ed
Show file tree
Hide file tree
Showing 82 changed files with 2,154 additions and 743 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package org.infinispan.commons.marshall;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.OutputStream;

/**
* Class that extends {@link InputStream} and implements {@link ObjectInput}.
* <p>
* All the methods delegates to a {@link ObjectInput} implementation.
*
* @author Pedro Ruivo
* @since 8.2
*/
public class DelegatingObjectInput extends InputStream implements ObjectInput {

protected final ObjectInput objectInput;

public DelegatingObjectInput(ObjectInput objectInput) {
this.objectInput = objectInput;
}

@Override
public Object readObject() throws ClassNotFoundException, IOException {
return objectInput.readObject();
}

@Override
public int read() throws IOException {
return objectInput.read();
}

@Override
public int read(byte[] b) throws IOException {
return objectInput.read(b);
}

@Override
public int read(byte[] b, int off, int len) throws IOException {
return objectInput.read(b, off, len);
}

@Override
public long skip(long n) throws IOException {
return objectInput.skip(n);
}

@Override
public int available() throws IOException {
return objectInput.available();
}

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

@Override
public void readFully(byte[] b) throws IOException {
objectInput.readFully(b);
}

@Override
public void readFully(byte[] b, int off, int len) throws IOException {
objectInput.readFully(b, off, len);
}

@Override
public int skipBytes(int n) throws IOException {
return objectInput.skipBytes(n);
}

@Override
public boolean readBoolean() throws IOException {
return objectInput.readBoolean();
}

@Override
public byte readByte() throws IOException {
return objectInput.readByte();
}

@Override
public int readUnsignedByte() throws IOException {
return objectInput.readUnsignedByte();
}

@Override
public short readShort() throws IOException {
return objectInput.readShort();
}

@Override
public int readUnsignedShort() throws IOException {
return objectInput.readUnsignedShort();
}

@Override
public char readChar() throws IOException {
return objectInput.readChar();
}

@Override
public int readInt() throws IOException {
return objectInput.readInt();
}

@Override
public long readLong() throws IOException {
return objectInput.readLong();
}

@Override
public float readFloat() throws IOException {
return objectInput.readFloat();
}

@Override
public double readDouble() throws IOException {
return objectInput.readDouble();
}

@Override
public String readLine() throws IOException {
return objectInput.readLine();
}

@Override
public String readUTF() throws IOException {
return objectInput.readUTF();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package org.infinispan.commons.marshall;

import java.io.IOException;
import java.io.ObjectOutput;
import java.io.OutputStream;

/**
* Class that extends {@link OutputStream} and implements {@link ObjectOutput}.
* <p>
* All the methods delegates to a {@link ObjectOutput} implementation.
*
* @author Pedro Ruivo
* @since 8.2
*/
public class DelegatingObjectOutput extends OutputStream implements ObjectOutput {

protected final ObjectOutput objectOutput;

public DelegatingObjectOutput(ObjectOutput objectOutput) {
this.objectOutput = objectOutput;
}

@Override
public void writeObject(Object obj) throws IOException {
objectOutput.writeObject(obj);
}

@Override
public void write(int b) throws IOException {
objectOutput.write(b);
}

@Override
public void write(byte[] b) throws IOException {
objectOutput.write(b);
}

@Override
public void write(byte[] b, int off, int len) throws IOException {
objectOutput.write(b, off, len);
}

@Override
public void flush() throws IOException {
objectOutput.flush();
}

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

@Override
public void writeBoolean(boolean v) throws IOException {
objectOutput.writeBoolean(v);
}

@Override
public void writeByte(int v) throws IOException {
objectOutput.writeByte(v);
}

@Override
public void writeShort(int v) throws IOException {
objectOutput.writeShort(v);
}

@Override
public void writeChar(int v) throws IOException {
objectOutput.writeChar(v);
}

@Override
public void writeInt(int v) throws IOException {
objectOutput.writeInt(v);
}

@Override
public void writeLong(long v) throws IOException {
objectOutput.writeLong(v);
}

@Override
public void writeFloat(float v) throws IOException {
objectOutput.writeFloat(v);
}

@Override
public void writeDouble(double v) throws IOException {
objectOutput.writeDouble(v);
}

@Override
public void writeBytes(String s) throws IOException {
objectOutput.writeBytes(s);
}

@Override
public void writeChars(String s) throws IOException {
objectOutput.writeChars(s);
}

@Override
public void writeUTF(String s) throws IOException {
objectOutput.writeUTF(s);
}
}

0 comments on commit 16c64ed

Please sign in to comment.