KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > oa > toa > TOAFactory


1 /*
2  * @(#)TOAFactory.java 1.17 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.impl.oa.toa ;
9
10 import java.util.Map JavaDoc ;
11 import java.util.HashMap JavaDoc ;
12
13 import org.omg.CORBA.INTERNAL JavaDoc ;
14 import org.omg.CORBA.CompletionStatus JavaDoc ;
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 JavaDoc codebaseToTOA ;
40     private TransientObjectManager tom ;
41
42     public ObjectAdapter find ( ObjectAdapterId oaid )
43     {
44     if (oaid.equals( ObjectKeyTemplateBase.JIDL_OAID ) )
45         // Return the dispatch-only TOA, which can dispatch
46
// request for objects created by any TOA.
47
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 JavaDoc() ;
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 JavaDoc 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         // The dispatch-only TOA is not used for creating
84
// objrefs, so its codebase can be null (and must
85
// be, since we do not have a servant at this point)
86
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