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 SerializableProvider extends BaseProvider {
13: public static class Util {
14: public static boolean isSerializable(Object obj, ClassLoader cl) {
15: Iterator iter = ProviderUtils.getProviders(
16: SerializableProvider.class, cl).iterator();
17: while (iter.hasNext()) {
18: SerializableProvider sp = (SerializableProvider) iter
19: .next();
20: try {
21: return sp.isSerializable(obj);
22: } catch (RuntimeException rte) {
23: return false;
24: } catch (LinkageError le) {
25: // skip: not using required ClassLoader for this object; try another plugin implementation
26: }
27: }
28: // we should never get to this point!
29: throw new IllegalStateException(
30: "Can't find any working " + SerializableProvider.class.getName() + " for object " + obj);//$NON-NLS-1$//$NON-NLS-2$
31: }
32: }
33:
34: /**
35: * @param obj
36: * @return true if obj is Serializable, false otherwise
37: */
38: public boolean isSerializable(Object obj);
39: }
|