/* */ package org.jboss.proxy.ejb;
/* */
/* */ import java.io.IOException;
/* */ import java.io.ObjectInputStream;
/* */ import java.io.ObjectOutputStream;
/* */ import java.rmi.RemoteException;
/* */ import java.security.AccessController;
/* */ import java.security.PrivilegedAction;
/* */ import javax.ejb.EJBHome;
/* */ import javax.ejb.HomeHandle;
/* */ import javax.ejb.spi.HandleDelegate;
/* */ import javax.rmi.CORBA.Stub;
/* */ import javax.rmi.PortableRemoteObject;
/* */ import org.jboss.iiop.CorbaORB;
/* */ import org.jboss.proxy.ejb.handle.HandleDelegateImpl;
/* */ import org.omg.CORBA.ORB;
/* */ import org.omg.CORBA.portable.ObjectImpl;
/* */
/* */ public class HomeHandleImplIIOP
/* */ implements HomeHandle
/* */ {
/* */ static final long serialVersionUID = 8652819695513956661L;
/* 59 */ static final boolean oldSerialization = ((Boolean)AccessController.doPrivileged(new PrivilegedAction()
/* */ {
/* */ public Boolean run()
/* */ {
/* */ try
/* */ {
/* 65 */ return Boolean.valueOf(Boolean.getBoolean("org.jboss.proxy.ejb.old.homehandle.serialization"));
/* */ }
/* */ catch (Exception ignored) {
/* */ }
/* 69 */ return Boolean.valueOf(false);
/* */ }
/* */ })).booleanValue();
/* */ private String ior;
/* 82 */ private transient Class<?> stubClass = EJBHome.class;
/* */
/* */ public HomeHandleImplIIOP(String ior)
/* */ {
/* 91 */ this.ior = ior;
/* */ }
/* */
/* */ public HomeHandleImplIIOP(EJBHome home)
/* */ {
/* 101 */ this((org.omg.CORBA.Object)home);
/* */ }
/* */
/* */ public HomeHandleImplIIOP(org.omg.CORBA.Object home)
/* */ {
/* 111 */ this.ior = CorbaORB.getInstance().object_to_string(home);
/* 112 */ this.stubClass = home.getClass();
/* */ }
/* */
/* */ public EJBHome getEJBHome()
/* */ throws RemoteException
/* */ {
/* */ try
/* */ {
/* 129 */ org.omg.CORBA.Object obj = CorbaORB.getInstance().string_to_object(this.ior);
/* 130 */ return narrow(obj);
/* */ }
/* */ catch (RemoteException e)
/* */ {
/* 134 */ throw e;
/* */ }
/* */ catch (Exception e) {
/* */ }
/* 138 */ throw new RemoteException("Could not get EJBHome from HomeHandle", e);
/* */ }
/* */
/* */ private EJBHome narrow(org.omg.CORBA.Object obj)
/* */ throws ClassCastException, RemoteException
/* */ {
/* 145 */ if (obj == null) {
/* 146 */ return null;
/* */ }
/* */
/* 149 */ if (this.stubClass.isAssignableFrom(obj.getClass())) {
/* 150 */ return (EJBHome)obj;
/* */ }
/* */
/* 153 */ if (this.stubClass == EJBHome.class) {
/* 154 */ return (EJBHome)PortableRemoteObject.narrow(obj, EJBHome.class);
/* */ }
/* */
/* */ try
/* */ {
/* 159 */ Stub stub = (Stub)this.stubClass.newInstance();
/* 160 */ stub._set_delegate(((ObjectImpl)obj)._get_delegate());
/* 161 */ return (EJBHome)stub;
/* */ }
/* */ catch (Exception e) {
/* */ }
/* 165 */ throw new RemoteException("Error creating stub", e);
/* */ }
/* */
/* */ private void writeObject(ObjectOutputStream oostream)
/* */ throws IOException
/* */ {
/* 171 */ if (oldSerialization)
/* */ {
/* 173 */ oostream.defaultWriteObject();
/* */ }
/* */ else
/* */ {
/* 177 */ HandleDelegate delegate = HandleDelegateImpl.getDelegate();
/* 178 */ delegate.writeEJBHome(getEJBHome(), oostream);
/* */ }
/* */ }
/* */
/* */ private void readObject(ObjectInputStream oistream) throws IOException, ClassNotFoundException
/* */ {
/* 184 */ if (oldSerialization)
/* */ {
/* 186 */ oistream.defaultReadObject();
/* 187 */ this.stubClass = EJBHome.class;
/* */ }
/* */ else
/* */ {
/* 191 */ HandleDelegate delegate = HandleDelegateImpl.getDelegate();
/* 192 */ EJBHome obj = delegate.readEJBHome(oistream);
/* 193 */ this.ior = CorbaORB.getInstance().object_to_string((org.omg.CORBA.Object)obj);
/* 194 */ this.stubClass = obj.getClass();
/* */ }
/* */ }
/* */ }
/* Location: /home/mnovotny/projects/EMBEDDED_JBOSS_BETA3_COMMUNITY/embedded/output/lib/embedded-jboss/lib/jboss-embedded-all.jar
* Qualified Name: org.jboss.proxy.ejb.HomeHandleImplIIOP
* JD-Core Version: 0.6.0
*/