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

Implemented Cacheable interface.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8312 b35dd754-fafc-0310-a699-88a17e54d16e
parent 758618e7
......@@ -11,6 +11,8 @@
package org.jivesoftware.openfire.spi;
import org.jivesoftware.util.cache.CacheSizes;
import org.jivesoftware.util.cache.Cacheable;
import org.jivesoftware.util.cache.ExternalizableUtil;
import java.io.Externalizable;
......@@ -24,7 +26,7 @@ import java.io.ObjectOutput;
*
* @author Gaston Dombiak
*/
public class ClientRoute implements Externalizable {
public class ClientRoute implements Cacheable, Externalizable {
private byte[] nodeID;
private boolean available;
......@@ -38,6 +40,16 @@ public class ClientRoute implements Externalizable {
this.available = available;
}
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 += nodeID.length; // Node ID
size += CacheSizes.sizeOfBoolean(); // available
return size;
}
public void writeExternal(ObjectOutput out) throws IOException {
ExternalizableUtil.getInstance().writeByteArray(out, nodeID);
ExternalizableUtil.getInstance().writeBoolean(out, available);
......
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