KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > spi > oa > ObjectAdapterBase


1 /*
2  * @(#)ObjectAdapterBase.java 1.40 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 package com.sun.corba.se.spi.oa ;
8
9 import org.omg.PortableInterceptor.ObjectReferenceTemplate JavaDoc ;
10 import org.omg.PortableInterceptor.ObjectReferenceFactory JavaDoc ;
11
12 import org.omg.CORBA.Policy JavaDoc ;
13
14 import org.omg.PortableInterceptor.ACTIVE JavaDoc ;
15
16 import com.sun.corba.se.spi.copyobject.ObjectCopierFactory ;
17 import com.sun.corba.se.spi.ior.IORFactories ;
18 import com.sun.corba.se.spi.ior.IORTemplate ;
19 import com.sun.corba.se.spi.ior.ObjectAdapterId;
20 import com.sun.corba.se.spi.ior.ObjectKeyTemplate ;
21 import com.sun.corba.se.spi.logging.CORBALogDomains ;
22 import com.sun.corba.se.spi.oa.OADestroyed ;
23 import com.sun.corba.se.spi.oa.ObjectAdapter ;
24 import com.sun.corba.se.spi.orb.ORB ;
25 import com.sun.corba.se.spi.protocol.PIHandler ;
26
27 import com.sun.corba.se.impl.logging.POASystemException ;
28 import com.sun.corba.se.impl.logging.OMGSystemException ;
29 import com.sun.corba.se.impl.oa.poa.Policies;
30
31 abstract public class ObjectAdapterBase extends org.omg.CORBA.LocalObject JavaDoc
32     implements ObjectAdapter
33 {
34     private ORB orb;
35
36     // Exception wrappers
37
private final POASystemException _iorWrapper ;
38     private final POASystemException _invocationWrapper ;
39     private final POASystemException _lifecycleWrapper ;
40     private final OMGSystemException _omgInvocationWrapper ;
41     private final OMGSystemException _omgLifecycleWrapper ;
42
43     // Data related to the construction of object references and
44
// supporting the Object Reference Template.
45
private IORTemplate iortemp;
46     private byte[] adapterId ;
47     private ObjectReferenceTemplate JavaDoc adapterTemplate ;
48     private ObjectReferenceFactory JavaDoc currentFactory ;
49    
50     public ObjectAdapterBase( ORB orb )
51     {
52     this.orb = orb ;
53     _iorWrapper = POASystemException.get( orb,
54         CORBALogDomains.OA_IOR ) ;
55     _lifecycleWrapper = POASystemException.get( orb,
56         CORBALogDomains.OA_LIFECYCLE ) ;
57     _omgLifecycleWrapper = OMGSystemException.get( orb,
58         CORBALogDomains.OA_LIFECYCLE ) ;
59     _invocationWrapper = POASystemException.get( orb,
60         CORBALogDomains.OA_INVOCATION ) ;
61     _omgInvocationWrapper = OMGSystemException.get( orb,
62         CORBALogDomains.OA_INVOCATION ) ;
63     }
64
65     public final POASystemException iorWrapper()
66     {
67     return _iorWrapper ;
68     }
69
70     public final POASystemException lifecycleWrapper()
71     {
72     return _lifecycleWrapper ;
73     }
74
75     public final OMGSystemException omgLifecycleWrapper()
76     {
77     return _omgLifecycleWrapper ;
78     }
79
80     public final POASystemException invocationWrapper()
81     {
82     return _invocationWrapper ;
83     }
84
85     public final OMGSystemException omgInvocationWrapper()
86     {
87     return _omgInvocationWrapper ;
88     }
89
90     /*
91      * This creates the complete template.
92      * When it is done, reference creation can proceed.
93      */

94     final public void initializeTemplate( ObjectKeyTemplate oktemp,
95     boolean notifyORB, Policies policies, String JavaDoc codebase,
96     String JavaDoc objectAdapterManagerId, ObjectAdapterId objectAdapterId)
97     {
98     adapterId = oktemp.getAdapterId() ;
99
100     iortemp = IORFactories.makeIORTemplate(oktemp) ;
101
102     // This calls acceptors which create profiles and may
103
// add tagged components to those profiles.
104
orb.getCorbaTransportManager().addToIORTemplate(
105             iortemp, policies,
106         codebase, objectAdapterManagerId, objectAdapterId);
107
108     adapterTemplate = IORFactories.makeObjectReferenceTemplate( orb,
109         iortemp ) ;
110     currentFactory = adapterTemplate ;
111
112     if (notifyORB) {
113         PIHandler pih = orb.getPIHandler() ;
114         if (pih != null)
115         // This runs the IORInterceptors.
116
pih.objectAdapterCreated( this ) ;
117     }
118
119     iortemp.makeImmutable() ;
120     }
121
122     final public org.omg.CORBA.Object JavaDoc makeObject( String JavaDoc repId, byte[] oid )
123     {
124     return currentFactory.make_object( repId, oid ) ;
125     }
126
127     final public byte[] getAdapterId()
128     {
129     return adapterId ;
130     }
131
132     final public ORB getORB()
133     {
134     return orb ;
135     }
136
137     abstract public Policy JavaDoc getEffectivePolicy( int type ) ;
138
139     final public IORTemplate getIORTemplate()
140     {
141     return iortemp ;
142     }
143
144     abstract public int getManagerId() ;
145
146     abstract public short getState() ;
147
148     final public ObjectReferenceTemplate JavaDoc getAdapterTemplate()
149     {
150     return adapterTemplate ;
151     }
152
153     final public ObjectReferenceFactory JavaDoc getCurrentFactory()
154     {
155     return currentFactory ;
156     }
157
158     final public void setCurrentFactory( ObjectReferenceFactory JavaDoc factory )
159     {
160     currentFactory = factory ;
161     }
162
163     abstract public org.omg.CORBA.Object JavaDoc getLocalServant( byte[] objectId ) ;
164
165     abstract public void getInvocationServant( OAInvocationInfo info ) ;
166
167     abstract public void returnServant() ;
168
169     abstract public void enter() throws OADestroyed ;
170
171     abstract public void exit() ;
172
173     abstract protected ObjectCopierFactory getObjectCopierFactory() ;
174
175     // Note that all current subclasses share the same implementation of this method,
176
// but overriding it would make sense for OAs that use a different InvocationInfo.
177
public OAInvocationInfo makeInvocationInfo( byte[] objectId )
178     {
179     OAInvocationInfo info = new OAInvocationInfo( this, objectId ) ;
180     info.setCopierFactory( getObjectCopierFactory() ) ;
181     return info ;
182     }
183
184     abstract public String JavaDoc[] getInterfaces( Object JavaDoc servant, byte[] objectId ) ;
185 }
186
Popular Tags