1 7 8 package com.sun.corba.se.impl.interceptors; 9 10 import java.util.Iterator ; 11 12 import org.omg.IOP.TaggedComponent ; 13 14 import org.omg.CORBA.BAD_INV_ORDER ; 15 import org.omg.CORBA.BAD_PARAM ; 16 import org.omg.CORBA.INTERNAL ; 17 import org.omg.CORBA.CompletionStatus ; 18 import org.omg.CORBA.INV_POLICY ; 19 import org.omg.CORBA.NO_IMPLEMENT ; 20 import org.omg.CORBA.Policy ; 21 import org.omg.CORBA.LocalObject ; 22 23 import org.omg.PortableInterceptor.IORInfo ; 24 import org.omg.PortableInterceptor.ObjectReferenceTemplate ; 25 import org.omg.PortableInterceptor.ObjectReferenceFactory ; 26 27 import com.sun.corba.se.spi.orb.ORB ; 28 29 import com.sun.corba.se.spi.oa.ObjectAdapter; 30 31 import com.sun.corba.se.spi.legacy.interceptor.IORInfoExt; 32 import com.sun.corba.se.spi.legacy.interceptor.UnknownType; 33 34 import com.sun.corba.se.spi.ior.IORTemplate; 35 import com.sun.corba.se.spi.ior.TaggedProfileTemplate; 36 import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder ; 37 38 import com.sun.corba.se.spi.logging.CORBALogDomains ; 39 40 import com.sun.corba.se.impl.logging.InterceptorsSystemException ; 41 import com.sun.corba.se.impl.logging.OMGSystemException ; 42 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 43 44 48 public final class IORInfoImpl 49 extends LocalObject 50 implements IORInfo , IORInfoExt 51 { 52 55 private static final int STATE_INITIAL = 0 ; 57 58 private static final int STATE_ESTABLISHED = 1 ; 60 61 private static final int STATE_DONE = 2 ; 63 64 private int state = STATE_INITIAL ; 66 67 private ObjectAdapter adapter; 69 70 private ORB orb ; 71 72 private ORBUtilSystemException orbutilWrapper ; 73 private InterceptorsSystemException wrapper ; 74 private OMGSystemException omgWrapper ; 75 76 80 IORInfoImpl( ObjectAdapter adapter ) { 81 this.orb = adapter.getORB() ; 82 83 orbutilWrapper = ORBUtilSystemException.get( orb, 84 CORBALogDomains.RPC_PROTOCOL ) ; 85 wrapper = InterceptorsSystemException.get( orb, 86 CORBALogDomains.RPC_PROTOCOL ) ; 87 omgWrapper = OMGSystemException.get( orb, 88 CORBALogDomains.RPC_PROTOCOL ) ; 89 90 this.adapter = adapter; 91 } 92 93 110 public Policy get_effective_policy (int type) { 111 checkState( STATE_INITIAL, STATE_ESTABLISHED ) ; 112 113 return adapter.getEffectivePolicy( type ); 114 } 115 116 126 public void add_ior_component (TaggedComponent tagged_component) { 127 checkState( STATE_INITIAL ) ; 128 129 if( tagged_component == null ) nullParam(); 130 addIORComponentToProfileInternal( tagged_component, 131 adapter.getIORTemplate().iterator()); 132 } 133 134 150 public void add_ior_component_to_profile ( 151 TaggedComponent tagged_component, int profile_id ) 152 { 153 checkState( STATE_INITIAL ) ; 154 155 if( tagged_component == null ) nullParam(); 156 addIORComponentToProfileInternal( 157 tagged_component, adapter.getIORTemplate().iteratorById( 158 profile_id ) ); 159 } 160 161 167 public int getServerPort(String type) 168 throws UnknownType 169 { 170 checkState( STATE_INITIAL, STATE_ESTABLISHED ) ; 171 172 int port = 173 orb.getLegacyServerSocketManager() 174 .legacyGetTransientOrPersistentServerPort(type); 175 if (port == -1) { 176 throw new UnknownType(); 177 } 178 return port; 179 } 180 181 public ObjectAdapter getObjectAdapter() 182 { 183 return adapter; 184 } 185 186 public int manager_id() 187 { 188 checkState( STATE_INITIAL, STATE_ESTABLISHED) ; 189 190 return adapter.getManagerId() ; 191 } 192 193 public short state() 194 { 195 checkState( STATE_INITIAL, STATE_ESTABLISHED) ; 196 197 return adapter.getState() ; 198 } 199 200 public ObjectReferenceTemplate adapter_template() 201 { 202 checkState( STATE_ESTABLISHED) ; 203 204 216 return adapter.getAdapterTemplate() ; 217 } 218 219 public ObjectReferenceFactory current_factory() 220 { 221 checkState( STATE_ESTABLISHED) ; 222 223 return adapter.getCurrentFactory() ; 224 } 225 226 public void current_factory( ObjectReferenceFactory factory ) 227 { 228 checkState( STATE_ESTABLISHED) ; 229 230 adapter.setCurrentFactory( factory ) ; 231 } 232 233 237 private void addIORComponentToProfileInternal( 238 TaggedComponent tagged_component, Iterator iterator ) 239 { 240 TaggedComponentFactoryFinder finder = 243 orb.getTaggedComponentFactoryFinder(); 244 Object newTaggedComponent = finder.create( orb, tagged_component ); 245 246 boolean found = false; 249 while( iterator.hasNext() ) { 250 found = true; 251 TaggedProfileTemplate taggedProfileTemplate = 252 (TaggedProfileTemplate)iterator.next(); 253 taggedProfileTemplate.add( newTaggedComponent ); 254 } 255 256 if( !found ) { 259 throw omgWrapper.invalidProfileId() ; 260 } 261 } 262 263 267 private void nullParam() 268 { 269 throw orbutilWrapper.nullParam() ; 270 } 271 272 274 private void checkState( int expectedState ) 275 { 276 if (expectedState != state) 277 throw wrapper.badState1( new Integer (expectedState), new Integer (state) ) ; 278 } 279 280 private void checkState( int expectedState1, int expectedState2 ) 281 { 282 if ((expectedState1 != state) && (expectedState2 != state)) 283 throw wrapper.badState2( new Integer (expectedState1), 284 new Integer (expectedState2), new Integer (state) ) ; 285 } 286 287 void makeStateEstablished() 288 { 289 checkState( STATE_INITIAL ) ; 290 291 state = STATE_ESTABLISHED ; 292 } 293 294 void makeStateDone() 295 { 296 checkState( STATE_ESTABLISHED ) ; 297 298 state = STATE_DONE ; 299 } 300 } 301 | Popular Tags |