1 4 package org.oddjob.jmx; 5 6 import java.io.Serializable ; 7 8 import org.oddjob.OddjobException; 9 import org.oddjob.arooa.registry.ComponentRegistry; 10 import org.oddjob.framework.Exportable; 11 import org.oddjob.framework.Transportable; 12 import org.oddjob.framework.OddjobRemoteException; 13 14 17 public class Utils { 18 19 26 public static String [] classArray2StringArray(Class [] classes) { 27 String [] strings = new String [classes.length]; 28 for (int i = 0; i < classes.length; ++i) { 29 strings[i] = classes[i].getName(); 30 } 31 return strings; 32 } 33 34 public static Serializable [] export(Object [] objects) 35 throws OddjobRemoteException { 36 if (objects == null) { 37 return null; 38 } 39 Serializable [] results = new Serializable [objects.length]; 40 for (int i = 0; i < objects.length; ++i) { 41 results[i] = export(objects[i]); 42 } 43 return results; 44 } 45 46 public static Serializable export(Object object) { 47 if (object == null) { 48 return null; 49 } 50 if (object instanceof Exportable) { 51 return ((Exportable) object).exportTransportable(); 52 } 53 else if (object instanceof Serializable ){ 54 return (Serializable ) object; 55 } 56 else { 57 throw new OddjobException("Not serializable [" + object.getClass() + "]"); 58 } 59 } 60 61 public static Object [] importResolve(Object [] objects, ComponentRegistry componentRegistry) { 62 if (objects == null) { 63 return null; 64 } 65 Object [] results = new Object [objects.length]; 66 for (int i = 0; i < objects.length; ++i) { 67 results[i] = importResolve(objects[i], componentRegistry); 68 } 69 return results; 70 } 71 72 73 public static Object importResolve(Object object, ComponentRegistry componentRegistry) { 74 if (object == null) { 75 return null; 76 } 77 if (object instanceof Transportable) { 78 return ((Transportable) object).importResolve(componentRegistry); 79 } 80 else { 81 return object; 82 } 83 } 84 85 86 87 } 88 | Popular Tags |