1 22 package org.jboss.proxy.ejb; 23 24 import java.io.IOException ; 25 import java.io.ObjectInputStream ; 26 import java.io.ObjectOutputStream ; 27 import java.io.Serializable ; 28 import java.rmi.RemoteException ; 29 import javax.ejb.EJBObject ; 30 import javax.ejb.Handle ; 31 import javax.ejb.spi.HandleDelegate ; 32 import javax.rmi.PortableRemoteObject ; 33 34 import org.jboss.iiop.CorbaORB; 35 import org.jboss.proxy.ejb.handle.HandleDelegateImpl; 36 37 45 public class HandleImplIIOP implements Handle , Serializable 46 { 47 48 static final long serialVersionUID = -501170775289648475L; 49 50 54 private String ior; 55 56 61 public HandleImplIIOP(String ior) 62 { 63 this.ior = ior; 64 } 65 66 71 public HandleImplIIOP(EJBObject obj) 72 { 73 this((org.omg.CORBA.Object )obj); 74 } 75 76 81 public HandleImplIIOP(org.omg.CORBA.Object obj) 82 { 83 this.ior = CorbaORB.getInstance().object_to_string(obj); 84 } 85 86 88 90 97 public EJBObject getEJBObject() 98 throws RemoteException 99 { 100 try 101 { 102 return (EJBObject )PortableRemoteObject.narrow( 103 CorbaORB.getInstance().string_to_object(ior), 104 EJBObject .class); 105 } 106 catch (Exception e) 107 { 108 throw new RemoteException ("Could not get EJBObject from Handle"); 109 } 110 } 111 112 private void writeObject(ObjectOutputStream oostream) throws IOException 113 { 114 HandleDelegate delegate = HandleDelegateImpl.getDelegate(); 115 delegate.writeEJBObject(getEJBObject(), oostream); 116 } 117 118 private void readObject(ObjectInputStream oistream) throws IOException , ClassNotFoundException 119 { 120 HandleDelegate delegate = HandleDelegateImpl.getDelegate(); 121 EJBObject obj = delegate.readEJBObject(oistream); 122 this.ior = CorbaORB.getInstance().object_to_string((org.omg.CORBA.Object ) obj); 123 } 124 } 125 | Popular Tags |