01: /**
02: *
03: */package clime.messadmin.providers.spi;
04:
05: import java.util.Iterator;
06:
07: import clime.messadmin.providers.ProviderUtils;
08:
09: /**
10: * @author Cédrik LIME
11: */
12: public interface SizeOfProvider extends BaseProvider {
13: public static class Util {
14: public static long getObjectSize(Object objectToSize,
15: ClassLoader cl) {
16: long currentItemSize = -1;
17: Iterator iterProv = ProviderUtils.getProviders(
18: SizeOfProvider.class, cl).iterator();
19: while (currentItemSize < 0 && iterProv.hasNext()) {
20: SizeOfProvider provider = (SizeOfProvider) iterProv
21: .next();
22: try {
23: currentItemSize = provider.sizeof(objectToSize);
24: } catch (RuntimeException rte) {
25: } catch (LinkageError le) {
26: }
27: }
28: return currentItemSize;
29: }
30: }
31:
32: /**
33: * @param objectToSize
34: * @return size of objectToSize in bytes, or -1 in case of error
35: */
36: public long sizeof(Object objectToSize);
37: }
|