1 23 24 package com.sun.ejb.base.io; 25 26 import com.sun.enterprise.util.ObjectInputStreamWithLoader; 27 import java.io.InputStream ; 28 import java.io.IOException ; 29 import java.io.StreamCorruptedException ; 30 import java.rmi.Remote ; 31 32 import java.util.logging.*; 33 import com.sun.logging.*; 34 import java.lang.reflect.Proxy ; 35 import java.lang.reflect.Modifier ; 36 37 import com.sun.enterprise.Switch; 38 import com.sun.corba.ee.spi.presentation.rmi.StubAdapter; 39 import com.sun.ejb.spi.io.SerializableObjectFactory; 40 41 46 class EJBObjectInputStream 47 extends ObjectInputStreamWithLoader 48 { 49 50 private static Logger _ejbLogger = 51 LogDomains.getLogger(LogDomains.EJB_LOGGER); 52 53 EJBObjectInputStream(InputStream in, ClassLoader cl, boolean resolve) 54 throws IOException , StreamCorruptedException 55 { 56 super(in, cl); 57 if (resolve == true) { 58 enableResolveObject(resolve); 59 } 60 } 61 62 protected Object resolveObject(Object obj) 63 throws IOException 64 { 65 try { 66 if ( StubAdapter.isStub(obj) ) { 67 Switch.getSwitch().getProtocolManager(). 69 connectObject((Remote )obj); 70 return obj; 71 } else if (obj instanceof SerializableObjectFactory) { 72 return ((SerializableObjectFactory) obj).createObject(); 73 } else { 74 return obj; 75 } 76 } catch (IOException ioEx ) { 77 _ejbLogger.log(Level.SEVERE, "ejb.resolve_object_exception", ioEx); 78 throw ioEx; 79 } catch (Exception ex) { 80 _ejbLogger.log(Level.SEVERE, "ejb.resolve_object_exception", ex); 81 IOException ioe = new IOException (); 82 ioe.initCause(ex); 83 throw ioe; 84 } 85 } 86 87 protected Class resolveProxyClass(String [] interfaces) 88 throws IOException , ClassNotFoundException 89 { 90 Class [] classObjs = new Class [interfaces.length]; 91 for (int i = 0; i < interfaces.length; i++) { 92 Class cl = Class.forName(interfaces[i], false, loader); 93 if ((cl.getModifiers() & Modifier.PUBLIC) == 0) { 96 return super.resolveProxyClass(interfaces); 97 } else { 98 classObjs[i] = cl; 99 } 100 } 101 try { 102 return Proxy.getProxyClass(loader, classObjs); 103 } catch (IllegalArgumentException e) { 104 throw new ClassNotFoundException (null, e); 105 } 106 } 107 } 108 | Popular Tags |