1 9 package org.ozoneDB.core; 10 11 import org.ozoneDB.*; 12 import org.ozoneDB.core.DbRemote.ProxyObjectGate; 13 14 import java.lang.reflect.*; 15 16 25 public final class ResultConverter extends Object { 26 27 28 public static void updateProxyLinks( Object obj, OzoneInterface db ) throws Exception { 29 String name = obj != null ? obj.getClass().getName() : "(null)"; 30 System.out.println( "*** Proxy test: " + name ); 31 32 if (obj == null) { 33 } else if (obj instanceof OzoneProxy) { 35 ((OzoneProxy)obj).link = db; 36 System.out.println( " *** link changed *** " + db ); 37 } else { 38 Class cl = obj.getClass(); 39 int mdf = cl.getModifiers(); 40 if (Modifier.isTransient( mdf ) || Modifier.isStatic( mdf ) || Modifier.isFinal( mdf )) { 41 } else if (cl.isPrimitive()) { 43 } else if (cl.isArray()) { 45 int len = Array.getLength( obj ); 46 for (int j = 0; j < len; j++) { 47 Object member = Array.get( obj, j ); 48 updateProxyLinks( member, db ); 49 } 50 } else { 51 Field[] fields = cl.getFields(); 52 for (int i = 0; i < fields.length; i++) { 53 Object member = fields[i].get( obj ); 55 updateProxyLinks( member, db ); 56 } 57 } 58 } 59 } 60 61 65 public static Object substituteOzoneCompatibles(Object obj) { 66 return substituteOzoneCompatibles(obj,null); 67 } 68 69 77 public static Object substituteOzoneCompatibles(Object obj,ProxyObjectGate proxyObjectGate) { 78 81 if (obj instanceof OzoneCompatible) { 84 OzoneProxy proxy = ((OzoneCompatible)obj).container().ozoneProxy(); 86 87 if (proxyObjectGate!=null) { 88 proxyObjectGate.addObjectReferencedByClient(proxy); 89 } 90 91 return proxy; 92 } 94 95 if (proxyObjectGate!=null) { if (obj instanceof OzoneProxy) { 97 proxyObjectGate.addObjectReferencedByClient((OzoneProxy) obj); 98 } 99 } 100 return obj; 101 } 102 } 103 | Popular Tags |