Commit efaa0b1b authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Added Cacheable interface.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3467 b35dd754-fafc-0310-a699-88a17e54d16e
parent df4ec5d5
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
*/ */
package org.jivesoftware.wildfire.filetransfer; package org.jivesoftware.wildfire.filetransfer;
import org.jivesoftware.util.CacheSizes;
import org.jivesoftware.util.Cacheable;
import java.net.Socket; import java.net.Socket;
import java.util.concurrent.Future; import java.util.concurrent.Future;
...@@ -16,7 +19,7 @@ import java.util.concurrent.Future; ...@@ -16,7 +19,7 @@ import java.util.concurrent.Future;
* Tracks the different connections related to a file transfer. There are two connections, the * Tracks the different connections related to a file transfer. There are two connections, the
* initiator and the target and when both connections are completed the transfer can begin. * initiator and the target and when both connections are completed the transfer can begin.
*/ */
public class ProxyTransfer { public class ProxyTransfer implements Cacheable {
private String initiatorJID; private String initiatorJID;
...@@ -97,4 +100,16 @@ public class ProxyTransfer { ...@@ -97,4 +100,16 @@ public class ProxyTransfer {
public void setTransferFuture(Future<?> future) { public void setTransferFuture(Future<?> future) {
this.future = future; this.future = future;
} }
public int getCachedSize() {
// Approximate the size of the object in bytes by calculating the size
// of each field.
int size = 0;
size += CacheSizes.sizeOfObject(); // overhead of object
size += CacheSizes.sizeOfString(initiatorJID);
size += CacheSizes.sizeOfString(targetJID);
size += CacheSizes.sizeOfString(transferDigest);
size += CacheSizes.sizeOfString(transferSession);
return size;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment