1 25 package org.objectweb.jonas_lib.naming; 26 27 import java.rmi.Remote ; 28 import java.rmi.RemoteException ; 29 30 import javax.rmi.CORBA.Tie ; 31 import javax.rmi.CORBA.Util ; 32 33 import org.jacorb.poa.RequestProcessor; 34 import org.omg.PortableServer.Servant ; 35 36 import org.objectweb.carol.jndi.ns.JacORBCosNaming; 37 import org.objectweb.carol.jndi.spi.JacORBIIOPContext; 38 39 import org.objectweb.jonas_ejb.container.JHome; 40 import org.objectweb.jonas_ejb.container.JRemote; 41 42 46 public class JacORBPRODelegate extends org.objectweb.carol.rmi.multi.JacORBPRODelegate { 47 48 49 56 public void exportObject(Remote obj) throws RemoteException { 57 58 try { 61 unexportObject(obj); 62 } catch (Exception eee) { 63 } 65 66 67 try { 68 super.exportObject(obj); 69 } catch (Exception ee) { 70 } 72 73 74 if (obj instanceof JHome || obj instanceof JRemote || obj.getClass().getName().indexOf("org.objectweb") != -1 || obj.getClass().getName().equals("javax.management.remote.rmi.RMIConnectionImpl")) { 76 77 Tie theTie = Util.getTie(obj); 78 79 if (theTie != null) { 81 theTie.orb(JacORBCosNaming.getOrb()); 82 } 83 } 84 85 86 87 } 88 89 97 public Object narrow(Object narrowFrom, Class narrowTo) throws ClassCastException { 98 ClassLoader old = Thread.currentThread().getContextClassLoader(); 100 101 try { 102 Thread currentThread = Thread.currentThread(); 104 if (currentThread != null && (currentThread instanceof RequestProcessor)) { 105 RequestProcessor rp = (RequestProcessor) currentThread; 106 if (rp != null) { 107 Servant servant = rp.getServant(); 108 if (servant != null) { 109 Tie tie = null; 110 if (servant instanceof Tie ) { 111 tie = (Tie ) servant; 112 Remote target = tie.getTarget(); 113 if (target instanceof JHome) { 114 JHome jHome = (JHome) target; 115 ClassLoader cll = jHome.getBf().myClassLoader(); 116 Thread.currentThread().setContextClassLoader(cll); 117 } else if (target instanceof JRemote) { 118 JRemote jRemote = (JRemote) target; 119 ClassLoader cll = jRemote.getBf().myClassLoader(); 120 Thread.currentThread().setContextClassLoader(cll); 121 } 122 } 123 } 124 } 125 } 126 } catch (Exception e) { 127 } catch (Error e) { 129 } 131 132 Object narrowResult = null; 134 try { 135 narrowResult = super.narrow(narrowFrom, narrowTo); 136 } finally { 137 Thread.currentThread().setContextClassLoader(old); 139 } 140 141 return narrowResult; 142 } 143 144 } | Popular Tags |