public static Object getDepackageObject(Object object) { if (object == null) { return null; } if (!(object instanceof Proxy)) { return object; } InvocationHandler h = Proxy.getInvocationHandler((Proxy) object); ProxyDepackage depackage; synchronized (map) { depackage = map.get(h.getClass().getName()); } if (depackage == null) { throw new RuntimeException("Cannot proxy depackager for `" + h.getClass().getName() + "`."); } return depackage.depackage((Proxy) object); }
public static void register(ProxyDepackage depackage) { synchronized (map) { map.put(depackage.proxyName(), depackage); } }