1 7 8 package com.sun.corba.se.impl.oa.toa ; 9 10 import java.util.Map ; 11 import java.util.HashMap ; 12 13 import org.omg.CORBA.INTERNAL ; 14 import org.omg.CORBA.CompletionStatus ; 15 16 import com.sun.corba.se.spi.oa.ObjectAdapterFactory ; 17 import com.sun.corba.se.spi.oa.ObjectAdapter ; 18 19 import com.sun.corba.se.spi.orb.ORB ; 20 21 import com.sun.corba.se.spi.ior.ObjectAdapterId ; 22 23 import com.sun.corba.se.impl.oa.toa.TOAImpl ; 24 import com.sun.corba.se.impl.oa.toa.TransientObjectManager ; 25 26 import com.sun.corba.se.impl.javax.rmi.CORBA.Util ; 27 28 import com.sun.corba.se.impl.ior.ObjectKeyTemplateBase ; 29 30 import com.sun.corba.se.spi.logging.CORBALogDomains ; 31 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 32 33 public class TOAFactory implements ObjectAdapterFactory 34 { 35 private ORB orb ; 36 private ORBUtilSystemException wrapper ; 37 38 private TOAImpl toa ; 39 private Map codebaseToTOA ; 40 private TransientObjectManager tom ; 41 42 public ObjectAdapter find ( ObjectAdapterId oaid ) 43 { 44 if (oaid.equals( ObjectKeyTemplateBase.JIDL_OAID ) ) 45 return getTOA() ; 48 else 49 throw wrapper.badToaOaid() ; 50 } 51 52 public void init( ORB orb ) 53 { 54 this.orb = orb ; 55 wrapper = ORBUtilSystemException.get( orb, 56 CORBALogDomains.OA_LIFECYCLE ) ; 57 tom = new TransientObjectManager( orb ) ; 58 codebaseToTOA = new HashMap () ; 59 } 60 61 public void shutdown( boolean waitForCompletion ) 62 { 63 if (Util.instance != null) { 64 Util.instance.unregisterTargetsForORB(orb); 65 } 66 } 67 68 public synchronized TOA getTOA( String codebase ) 69 { 70 TOA toa = (TOA)(codebaseToTOA.get( codebase )) ; 71 if (toa == null) { 72 toa = new TOAImpl( orb, tom, codebase ) ; 73 74 codebaseToTOA.put( codebase, toa ) ; 75 } 76 77 return toa ; 78 } 79 80 public synchronized TOA getTOA() 81 { 82 if (toa == null) 83 toa = new TOAImpl( orb, tom, null ) ; 87 88 return toa ; 89 } 90 91 public ORB getORB() 92 { 93 return orb ; 94 } 95 } ; 96 97 | Popular Tags |