@Test void defaultMethod() { final ClassLoader loader = Thread.currentThread().getContextClassLoader(); final JavaProxyEnricherFactory factory = new JavaProxyEnricherFactory(); final SomeDefault proxyBased = SomeDefault.class .cast(factory .asSerializable(loader, getClass().getSimpleName(), SomeDefault.class.getName(), new SomeDefault() { @Override public String get() { return "ok"; } })); assertEquals("ok", proxyBased.get()); }
public Object asSerializable(final ClassLoader loader, final String plugin, final String key, final Object instanceToWrap) { final Class<?>[] interfaces = instanceToWrap.getClass().getInterfaces(); final boolean isSerializable = Stream.of(interfaces).anyMatch(i -> i == Serializable.class || i == Externalizable.class); if (isSerializable && !instanceToWrap.getClass().getName().startsWith("org.apache.johnzon.core.")) { return instanceToWrap; } final Class[] api = isSerializable ? interfaces : Stream.concat(Stream.of(Serializable.class), Stream.of(interfaces)).toArray(Class[]::new); return Proxy .newProxyInstance(selectLoader(api, loader), api, new DelegatingSerializableHandler(instanceToWrap, plugin, key)); }
JavaProxyEnricherFactory { public Object asSerializable(final ClassLoader loader, final String plugin, final String key, final Object instanceToWrap) { final Class<?>[] interfaces = instanceToWrap.getClass().getInterfaces(); final boolean isSerializable = Stream.of(interfaces).anyMatch(i -> i == Serializable.class || i == Externalizable.class); if (isSerializable && !instanceToWrap.getClass().getName().startsWith("org.apache.johnzon.core.")) { return instanceToWrap; } final Class[] api = isSerializable ? interfaces : Stream.concat(Stream.of(Serializable.class), Stream.of(interfaces)).toArray(Class[]::new); return Proxy .newProxyInstance(selectLoader(api, loader), api, new DelegatingSerializableHandler(instanceToWrap, plugin, key)); } }
JavaProxyEnricherFactory { public Object asSerializable(final ClassLoader loader, final String plugin, final String key, final Object instanceToWrap) { final Class<?>[] interfaces = instanceToWrap.getClass().getInterfaces(); final boolean isSerializable = Stream.of(interfaces).anyMatch(i -> i == Serializable.class || i == Externalizable.class); if (isSerializable && !instanceToWrap.getClass().getName().startsWith("org.apache.johnzon.core.")) { return instanceToWrap; } final Class[] api = isSerializable ? interfaces : Stream.concat(Stream.of(Serializable.class), Stream.of(interfaces)).toArray(Class[]::new); return Proxy .newProxyInstance(selectLoader(api, loader), api, new DelegatingSerializableHandler(instanceToWrap, plugin, key)); }  }
JavaProxyEnricherFactory { public Object asSerializable(final ClassLoader loader, final String plugin, final String key, final Object instanceToWrap) { final Class<?>[] interfaces = instanceToWrap.getClass().getInterfaces(); final boolean isSerializable = Stream.of(interfaces).anyMatch(i -> i == Serializable.class || i == Externalizable.class); if (isSerializable && !instanceToWrap.getClass().getName().startsWith("org.apache.johnzon.core.")) { return instanceToWrap; } final Class[] api = isSerializable ? interfaces : Stream.concat(Stream.of(Serializable.class), Stream.of(interfaces)).toArray(Class[]::new); return Proxy .newProxyInstance(selectLoader(api, loader), api, new DelegatingSerializableHandler(instanceToWrap, plugin, key)); }  Object asSerializable(final ClassLoader loader, final String plugin, final String key,
            final Object instanceToWrap); }
JavaProxyEnricherFactory { public Object asSerializable(final ClassLoader loader, final String plugin, final String key, final Object instanceToWrap) { final Class<?>[] interfaces = instanceToWrap.getClass().getInterfaces(); final boolean isSerializable = Stream.of(interfaces).anyMatch(i -> i == Serializable.class || i == Externalizable.class); if (isSerializable && !instanceToWrap.getClass().getName().startsWith("org.apache.johnzon.core.")) { return instanceToWrap; } final Class[] api = isSerializable ? interfaces : Stream.concat(Stream.of(Serializable.class), Stream.of(interfaces)).toArray(Class[]::new); return Proxy .newProxyInstance(selectLoader(api, loader), api, new DelegatingSerializableHandler(instanceToWrap, plugin, key)); }  Object asSerializable(final ClassLoader loader, final String plugin, final String key,
            final Object instanceToWrap);  }