1 23 package com.sun.enterprise.naming; 24 25 import javax.rmi.PortableRemoteObject ; 26 import java.rmi.*; 27 import java.util.*; 28 import java.io.*; 29 import javax.naming.*; 30 import com.sun.enterprise.util.ORBManager; 31 import org.omg.CosNaming.NamingContext ; 32 import org.omg.CosNaming.NameComponent ; 33 import org.omg.CosNaming.NamingContextHelper ; 34 import org.omg.PortableServer.POA ; 35 import org.omg.PortableServer.Servant ; 36 import org.omg.PortableServer.LifespanPolicyValue ; 37 import org.omg.CORBA.Policy ; 38 import org.omg.PortableServer.ImplicitActivationPolicyValue ; 39 import javax.rmi.CORBA.Tie ; 40 41 import java.util.logging.*; 42 import com.sun.logging.*; 43 44 49 50 public class RemoteSerialContextProviderImpl 51 extends SerialContextProviderImpl { 52 53 static public final String SERIAL_CONTEXT_PROVIDER_NAME = 54 "SerialContextProvider"; 55 56 57 private RemoteSerialContextProviderImpl(TransientContext rootContext) 58 throws RemoteException { 59 super(rootContext); 60 PortableRemoteObject.exportObject(this); 61 } 62 63 66 static public void initSerialContextProvider(TransientContext rootContext) 67 throws RemoteException { 68 try { 69 SerialContextProviderImpl impl = 70 new RemoteSerialContextProviderImpl(rootContext); 71 72 Tie servantsTie = javax.rmi.CORBA.Util.getTie(impl); 73 74 77 POA rootPOA = (POA ) 79 ORBManager.getORB().resolve_initial_references("RootPOA"); 80 81 Policy [] policy = new Policy [2]; 82 policy[0] = rootPOA.create_implicit_activation_policy( 83 ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION); 84 policy[1] = rootPOA.create_lifespan_policy( 85 LifespanPolicyValue.PERSISTENT); 86 87 POA poa = rootPOA.create_POA("SerialContextProviderPOA", null, 88 policy); 89 poa.the_POAManager().activate(); 90 org.omg.CORBA.Object provider = poa.servant_to_reference( 91 (Servant )servantsTie); 92 93 org.omg.CORBA.Object objRef = 95 ORBManager.getORB().resolve_initial_references("NameService"); 96 NamingContext ncRef = NamingContextHelper.narrow(objRef); 97 NameComponent nc = 98 new NameComponent (SERIAL_CONTEXT_PROVIDER_NAME, ""); 99 NameComponent path[] = {nc}; 100 ncRef.rebind(path, provider); 101 102 } catch (Exception ex) { 103 104 _logger.log(Level.SEVERE, 105 "enterprise_naming.excep_in_insertserialcontextprovider",ex); 106 107 RemoteException re = 108 new RemoteException("initSerialCtxProvider error"); 109 re.initCause(ex); 110 throw re; 111 } 112 } 113 114 public Object lookup(String name) 115 throws NamingException, RemoteException { 116 Object obj = super.lookup(name); 117 try { 120 if( obj instanceof Reference ) { 121 Reference ref = (Reference) obj; 122 if( ref.getFactoryClassName().equals 123 (NamingManagerImpl.IIOPOBJECT_FACTORY) ) { 124 125 Hashtable env = new Hashtable(); 126 org.omg.CORBA.ORB orb = ORBManager.getORB(); 127 env.put("java.naming.corba.orb", orb); 128 obj = javax.naming.spi.NamingManager.getObjectInstance 129 (obj, new CompositeName(name), null, env); 130 } 131 } 132 return obj; 133 } catch(RemoteException re) { 134 throw re; 135 } catch(Exception e) { 136 RemoteException re = new RemoteException("", e); 137 throw re; 138 139 } 140 } 141 } 142 | Popular Tags |