1 25 26 package org.objectweb.jonas_ejb.svc; 27 28 import java.io.IOException ; 29 import java.io.Serializable ; 30 import java.rmi.Remote ; 31 import java.rmi.RemoteException ; 32 import java.util.logging.Level ; 33 import java.util.logging.Logger ; 34 35 import javax.ejb.EJBObject ; 36 import javax.ejb.Handle ; 37 import javax.ejb.spi.HandleDelegate ; 38 import javax.naming.NamingException ; 39 import javax.rmi.PortableRemoteObject ; 40 import javax.rmi.CORBA.Util ; 41 42 import org.omg.PortableServer.Servant ; 43 47 public class JHandleIIOP implements Handle , Serializable { 48 49 52 private static Logger logger = Logger.getLogger("org.objectweb.jonas_ejb.svc"); 53 54 58 private String ior = null; 59 60 64 public JHandleIIOP(Remote r) { 65 try { 66 logger.log(Level.FINE, "r=" + r); 67 Servant servant = (Servant ) Util.getTie(r); 68 org.omg.CORBA.Object o = servant._this_object(); 69 this.ior = Utility.getORB().object_to_string(o); 70 logger.log(Level.FINE, "ior=" + ior); 71 } catch (Exception e) { 72 logger.log(Level.SEVERE, "cannot get Handle: ", e); 73 } 74 } 75 76 82 public EJBObject getEJBObject() throws RemoteException { 83 logger.log(Level.FINE, ""); 84 try { 85 return (EJBObject ) PortableRemoteObject.narrow(Utility.getORB().string_to_object(ior), EJBObject .class); 86 } catch (Exception e) { 87 throw new RemoteException ("JHandle.getEJBObject(): " + e, e); 88 } 89 } 90 91 97 private void writeObject(java.io.ObjectOutputStream out) 98 throws IOException { 99 HandleDelegate hdld; 100 logger.log(Level.FINE, ""); 101 try { 102 hdld = Utility.getHandleDelegate(); 103 } catch (NamingException e) { 104 throw new IOException ("Cannot get HandleDelegate"); 105 } 106 hdld.writeEJBObject(getEJBObject(), out); 107 } 108 109 116 private void readObject(java.io.ObjectInputStream in) 117 throws IOException , ClassNotFoundException { 118 HandleDelegate hdld; 119 logger.log(Level.FINE, ""); 120 try { 121 hdld = Utility.getHandleDelegate(); 122 } catch (NamingException e) { 123 throw new IOException ("Cannot get HandleDelegate"); 124 } 125 EJBObject obj = hdld.readEJBObject(in); 126 try { 127 this.ior = Utility.getORB().object_to_string((org.omg.CORBA.Object ) obj); 128 129 } catch (Exception e) { 130 throw new RemoteException ("JHandle.readObject(): " + e, e); 131 } 132 } 133 134 } 135 136 | Popular Tags |