Commit d0f20e90 authored by Guus der Kinderen's avatar Guus der Kinderen

Merge pull request #590 from guusdk/OF-1125

OF-1125: StreamID should be Cacheable.
parents baa79d57 df5db065
......@@ -23,6 +23,9 @@ package org.jivesoftware.openfire.spi;
import org.apache.commons.lang.StringEscapeUtils;
import org.jivesoftware.openfire.StreamID;
import org.jivesoftware.openfire.StreamIDFactory;
import org.jivesoftware.util.cache.CacheSizes;
import org.jivesoftware.util.cache.Cacheable;
import org.jivesoftware.util.cache.CannotCalculateSizeException;
import java.math.BigInteger;
import java.security.SecureRandom;
......@@ -54,7 +57,7 @@ public class BasicStreamIDFactory implements StreamIDFactory {
return new BasicStreamID(name);
}
private static class BasicStreamID implements StreamID {
private static class BasicStreamID implements StreamID, Cacheable {
String id;
public BasicStreamID(String id) {
......@@ -86,5 +89,15 @@ public class BasicStreamIDFactory implements StreamIDFactory {
if ( o == null || getClass() != o.getClass() ) return false;
return id.equals( ((BasicStreamID) o).id );
}
@Override
public int getCachedSize() throws CannotCalculateSizeException
{
// 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(id); // id
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