1 23 package com.sun.enterprise.naming; 24 25 import java.rmi.*; 26 import java.io.*; 27 import java.util.logging.*; 28 import com.sun.logging.*; 29 import com.sun.enterprise.util.*; 30 31 34 35 public class NamingUtils { 36 37 static Logger _logger=LogDomains.getLogger(LogDomains.JNDI_LOGGER); 38 39 42 43 public static Object makeCopyOfObject(Object obj) { 44 45 46 if ( obj instanceof Serializable ) { 47 try { 48 ByteArrayOutputStream bos = new ByteArrayOutputStream(); 50 ObjectOutputStream oos = new ObjectOutputStream(bos); 51 oos.writeObject(obj); 52 oos.flush(); 53 byte[] data = bos.toByteArray(); 54 oos.close(); 55 bos.close(); 56 57 ByteArrayInputStream bis = new ByteArrayInputStream(data); 59 ClassLoader cl = Thread.currentThread().getContextClassLoader(); 60 ObjectInputStream ois = new ObjectInputStreamWithLoader(bis,cl); 61 62 63 return ois.readObject(); 64 } catch ( Exception ex ) { 65 66 _logger.log(Level.SEVERE, 67 "enterprise_naming.excep_in_copymutableobj", ex); 68 69 RuntimeException re = 70 new RuntimeException ("Cant copy Serializable object:"); 71 re.initCause(ex); 72 throw re; 73 } 74 } 75 else { 76 return obj; 78 } 79 } 80 } 81 | Popular Tags |