1 28 29 package com.caucho.ejb.hessian; 30 31 import com.caucho.ejb.AbstractEJBHome; 32 import com.caucho.ejb.AbstractEJBObject; 33 import com.caucho.ejb.AbstractServer; 34 import com.caucho.hessian.io.AbstractHessianOutput; 35 import com.caucho.hessian.io.AbstractSerializer; 36 37 import javax.ejb.EJBHome ; 38 import javax.ejb.HomeHandle ; 39 import java.io.IOException ; 40 41 public class HomeSerializer extends AbstractSerializer { 42 private static HomeSerializer _singleton = new HomeSerializer(); 43 44 static HomeSerializer create() 45 { 46 return _singleton; 47 } 48 49 public void writeObject(Object obj, AbstractHessianOutput out) 50 throws IOException 51 { 52 if (obj instanceof AbstractEJBHome) { 53 AbstractEJBHome ejbHome = (AbstractEJBHome) obj; 54 AbstractServer server = ejbHome.__caucho_getServer(); 55 56 out.writeRemote(server.getRemoteHomeClass().getName(), 57 server.getHandleEncoder("hessian").getURL()); 58 } 59 else if (obj instanceof AbstractEJBObject) { 60 AbstractEJBObject ejbObject = (AbstractEJBObject) obj; 61 AbstractServer server = ejbObject.__caucho_getServer(); 62 63 out.writeRemote(server.getRemoteHomeClass().getName(), 64 server.getHandleEncoder("hessian").getURL()); 65 } 66 else { 67 EJBHome ejbHome = (EJBHome) obj; 68 HomeHandle handle = ejbHome.getHomeHandle(); 69 70 Class api = ejbHome.getEJBMetaData().getHomeInterfaceClass(); 71 72 out.writeRemote(api.getName(), handle.toString()); 73 } 74 } 75 } 76 | Popular Tags |