1 7 8 package com.sun.corba.se.spi.orb; 9 10 import java.util.Map ; 11 import java.util.HashMap ; 12 import java.util.Properties ; 13 import java.util.concurrent.ConcurrentHashMap ; 14 import java.util.logging.Logger ; 15 16 import java.security.AccessController ; 17 import java.security.PrivilegedAction ; 18 19 import org.omg.CORBA.TCKind ; 20 21 import com.sun.corba.se.pept.broker.Broker ; 22 import com.sun.corba.se.pept.transport.ByteBufferPool; 23 24 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry ; 25 import com.sun.corba.se.spi.protocol.ClientDelegateFactory ; 26 import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher ; 27 import com.sun.corba.se.spi.protocol.CorbaMessageMediator ; 28 import com.sun.corba.se.spi.protocol.PIHandler ; 29 import com.sun.corba.se.spi.resolver.LocalResolver ; 30 import com.sun.corba.se.spi.resolver.Resolver ; 31 import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory ; 32 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo; 33 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager; 34 import com.sun.corba.se.spi.monitoring.MonitoringConstants; 35 import com.sun.corba.se.spi.monitoring.MonitoringManager; 36 import com.sun.corba.se.spi.monitoring.MonitoringManagerFactory; 37 import com.sun.corba.se.spi.monitoring.MonitoringFactories; 38 39 import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder ; 40 import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder ; 41 import com.sun.corba.se.spi.ior.ObjectKey ; 42 import com.sun.corba.se.spi.ior.ObjectKeyFactory ; 43 import com.sun.corba.se.spi.ior.IOR ; 44 45 import com.sun.corba.se.spi.orbutil.closure.Closure ; 46 47 import com.sun.corba.se.spi.orb.Operation ; 48 import com.sun.corba.se.spi.orb.ORBData ; 49 import com.sun.corba.se.spi.orb.ORBVersion ; 50 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager; 51 52 import com.sun.corba.se.spi.oa.OAInvocationInfo ; 53 import com.sun.corba.se.spi.transport.CorbaTransportManager; 54 55 import com.sun.corba.se.spi.logging.LogWrapperFactory ; 56 import com.sun.corba.se.spi.logging.LogWrapperBase ; 57 import com.sun.corba.se.spi.logging.CORBALogDomains ; 58 59 import com.sun.corba.se.spi.copyobject.CopierManager ; 60 61 import com.sun.corba.se.spi.presentation.rmi.PresentationManager ; 62 import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults ; 63 64 import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry ; 65 66 import com.sun.corba.se.impl.corba.TypeCodeImpl ; 68 import com.sun.corba.se.impl.corba.TypeCodeFactory ; 69 70 import com.sun.corba.se.impl.orbutil.ORBConstants ; 72 73 import com.sun.corba.se.impl.oa.poa.BadServerIdHandler ; 74 75 import com.sun.corba.se.impl.transport.ByteBufferPoolImpl; 76 77 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 78 import com.sun.corba.se.impl.logging.OMGSystemException ; 79 80 import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl ; 81 82 import com.sun.corba.se.impl.orbutil.ORBClassLoader ; 83 84 public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB 85 implements Broker, TypeCodeFactory 86 { 87 97 public static boolean ORBInitDebug = false; 101 102 public boolean transportDebugFlag = false ; 107 public boolean subcontractDebugFlag = false ; 108 public boolean poaDebugFlag = false ; 109 public boolean poaConcurrencyDebugFlag = false ; 110 public boolean poaFSMDebugFlag = false ; 111 public boolean orbdDebugFlag = false ; 112 public boolean namingDebugFlag = false ; 113 public boolean serviceContextDebugFlag = false ; 114 public boolean transientObjectManagerDebugFlag = false ; 115 public boolean giopVersionDebugFlag = false; 116 public boolean shutdownDebugFlag = false; 117 public boolean giopDebugFlag = false; 118 public boolean invocationTimingDebugFlag = false ; 119 120 protected static ORBUtilSystemException staticWrapper ; 123 protected ORBUtilSystemException wrapper ; 124 protected OMGSystemException omgWrapper ; 125 126 private Map typeCodeMap ; 130 131 private TypeCodeImpl[] primitiveTypeCodeConstants ; 132 133 ByteBufferPool byteBufferPool; 135 136 public abstract boolean isLocalHost( String hostName ) ; 139 public abstract boolean isLocalServerId( int subcontractId, int serverId ) ; 140 141 public abstract OAInvocationInfo peekInvocationInfo() ; 143 public abstract void pushInvocationInfo( OAInvocationInfo info ) ; 144 public abstract OAInvocationInfo popInvocationInfo() ; 145 146 public abstract CorbaTransportManager getCorbaTransportManager(); 147 public abstract LegacyServerSocketManager getLegacyServerSocketManager(); 148 149 private Map wrapperMap ; 153 154 private static Map staticWrapperMap = new ConcurrentHashMap (); 155 156 private MonitoringManager monitoringManager; 157 158 protected static PresentationManager globalPM = null ; 164 165 static { 166 staticWrapper = ORBUtilSystemException.get( 167 CORBALogDomains.RPC_PRESENTATION ) ; 168 169 boolean useDynamicStub = 170 ((Boolean )AccessController.doPrivileged( 171 new PrivilegedAction () { 172 public java.lang.Object run() { 173 return Boolean.valueOf( Boolean.getBoolean ( 174 ORBConstants.USE_DYNAMIC_STUB_PROPERTY ) ) ; 175 } 176 } 177 )).booleanValue() ; 178 179 PresentationManager.StubFactoryFactory dynamicStubFactoryFactory = 180 (PresentationManager.StubFactoryFactory)AccessController.doPrivileged( 181 new PrivilegedAction () { 182 public java.lang.Object run() { 183 PresentationManager.StubFactoryFactory sff = 184 PresentationDefaults.getProxyStubFactoryFactory() ; 185 186 String className = System.getProperty( 187 ORBConstants.DYNAMIC_STUB_FACTORY_FACTORY_CLASS, 188 "com.sun.corba.se.impl.presentation.rmi.bcel.StubFactoryFactoryBCELImpl" ) ; 189 190 try { 191 Class cls = ORBClassLoader.loadClass( className ) ; 193 sff = (PresentationManager.StubFactoryFactory)cls.newInstance() ; 194 } catch (Exception exc) { 195 staticWrapper.errorInSettingDynamicStubFactoryFactory( 197 exc, className ) ; 198 } 199 200 return sff ; 201 } 202 } 203 ) ; 204 205 globalPM = new PresentationManagerImpl( useDynamicStub ) ; 206 globalPM.setStubFactoryFactory( false, 207 PresentationDefaults.getStaticStubFactoryFactory() ) ; 208 globalPM.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ; 209 } 210 211 213 public static PresentationManager getPresentationManager() 214 { 215 return globalPM ; 216 } 217 218 222 public static PresentationManager.StubFactoryFactory 223 getStubFactoryFactory() 224 { 225 boolean useDynamicStubs = globalPM.useDynamicStubs() ; 226 return globalPM.getStubFactoryFactory( useDynamicStubs ) ; 227 } 228 229 protected ORB() 230 { 231 wrapperMap = new ConcurrentHashMap (); 234 wrapper = ORBUtilSystemException.get( this, 235 CORBALogDomains.RPC_PRESENTATION ) ; 236 omgWrapper = OMGSystemException.get( this, 237 CORBALogDomains.RPC_PRESENTATION ) ; 238 239 typeCodeMap = new HashMap (); 240 241 primitiveTypeCodeConstants = new TypeCodeImpl[] { 242 new TypeCodeImpl(this, TCKind._tk_null), 243 new TypeCodeImpl(this, TCKind._tk_void), 244 new TypeCodeImpl(this, TCKind._tk_short), 245 new TypeCodeImpl(this, TCKind._tk_long), 246 new TypeCodeImpl(this, TCKind._tk_ushort), 247 new TypeCodeImpl(this, TCKind._tk_ulong), 248 new TypeCodeImpl(this, TCKind._tk_float), 249 new TypeCodeImpl(this, TCKind._tk_double), 250 new TypeCodeImpl(this, TCKind._tk_boolean), 251 new TypeCodeImpl(this, TCKind._tk_char), 252 new TypeCodeImpl(this, TCKind._tk_octet), 253 new TypeCodeImpl(this, TCKind._tk_any), 254 new TypeCodeImpl(this, TCKind._tk_TypeCode), 255 new TypeCodeImpl(this, TCKind._tk_Principal), 256 new TypeCodeImpl(this, TCKind._tk_objref), 257 null, null, null, new TypeCodeImpl(this, TCKind._tk_string), 261 null, null, null, null, new TypeCodeImpl(this, TCKind._tk_longlong), 266 new TypeCodeImpl(this, TCKind._tk_ulonglong), 267 new TypeCodeImpl(this, TCKind._tk_longdouble), 268 new TypeCodeImpl(this, TCKind._tk_wchar), 269 new TypeCodeImpl(this, TCKind._tk_wstring), 270 new TypeCodeImpl(this, TCKind._tk_fixed), 271 new TypeCodeImpl(this, TCKind._tk_value), 272 new TypeCodeImpl(this, TCKind._tk_value_box), 273 new TypeCodeImpl(this, TCKind._tk_native), 274 new TypeCodeImpl(this, TCKind._tk_abstract_interface) 275 } ; 276 277 monitoringManager = 278 MonitoringFactories.getMonitoringManagerFactory( ). 279 createMonitoringManager( 280 MonitoringConstants.DEFAULT_MONITORING_ROOT, 281 MonitoringConstants.DEFAULT_MONITORING_ROOT_DESCRIPTION); 282 } 283 284 public TypeCodeImpl get_primitive_tc(int kind) 286 { 287 try { 288 return primitiveTypeCodeConstants[kind] ; 289 } catch (Throwable t) { 290 throw wrapper.invalidTypecodeKind( t, new Integer (kind) ) ; 291 } 292 } 293 294 public synchronized void setTypeCode(String id, TypeCodeImpl code) 295 { 296 typeCodeMap.put(id, code); 297 } 298 299 public synchronized TypeCodeImpl getTypeCode(String id) 300 { 301 return (TypeCodeImpl)typeCodeMap.get(id); 302 } 303 304 public MonitoringManager getMonitoringManager( ) { 305 return monitoringManager; 306 } 307 308 public abstract void set_parameters( Properties props ) ; 315 316 public abstract ORBVersion getORBVersion() ; 318 public abstract void setORBVersion( ORBVersion version ) ; 319 320 public abstract IOR getFVDCodeBaseIOR() ; 322 323 329 public abstract void handleBadServerId( ObjectKey okey ) ; 330 public abstract void setBadServerIdHandler( BadServerIdHandler handler ) ; 331 public abstract void initBadServerIdHandler() ; 332 333 public abstract void notifyORB() ; 334 335 public abstract PIHandler getPIHandler() ; 336 337 public abstract void checkShutdownState(); 338 339 public abstract boolean isDuringDispatch() ; 342 public abstract void startingDispatch(); 343 public abstract void finishedDispatch(); 344 345 348 public abstract int getTransientServerId(); 349 350 public abstract ServiceContextRegistry getServiceContextRegistry() ; 351 352 public abstract RequestDispatcherRegistry getRequestDispatcherRegistry(); 353 354 public abstract ORBData getORBData() ; 355 356 public abstract void setClientDelegateFactory( ClientDelegateFactory factory ) ; 357 358 public abstract ClientDelegateFactory getClientDelegateFactory() ; 359 360 public abstract void setCorbaContactInfoListFactory( CorbaContactInfoListFactory factory ) ; 361 362 public abstract CorbaContactInfoListFactory getCorbaContactInfoListFactory() ; 363 364 366 369 public abstract void setResolver( Resolver resolver ) ; 370 371 374 public abstract Resolver getResolver() ; 375 376 379 public abstract void setLocalResolver( LocalResolver resolver ) ; 380 381 384 public abstract LocalResolver getLocalResolver() ; 385 386 389 public abstract void setURLOperation( Operation stringToObject ) ; 390 391 394 public abstract Operation getURLOperation() ; 395 396 398 public abstract void setINSDelegate( CorbaServerRequestDispatcher insDelegate ) ; 399 400 402 405 public abstract TaggedComponentFactoryFinder getTaggedComponentFactoryFinder() ; 406 public abstract IdentifiableFactoryFinder getTaggedProfileFactoryFinder() ; 407 public abstract IdentifiableFactoryFinder getTaggedProfileTemplateFactoryFinder() ; 408 409 public abstract ObjectKeyFactory getObjectKeyFactory() ; 410 public abstract void setObjectKeyFactory( ObjectKeyFactory factory ) ; 411 412 414 417 public Logger getLogger( String domain ) 418 { 419 ORBData odata = getORBData() ; 420 421 String ORBId ; 431 if (odata == null) 432 ORBId = "_INITIALIZING_" ; 433 else { 434 ORBId = odata.getORBId() ; 435 if (ORBId.equals("")) 436 ORBId = "_DEFAULT_" ; 437 } 438 439 return getCORBALogger( ORBId, domain ) ; 440 } 441 442 public static Logger staticGetLogger( String domain ) 443 { 444 return getCORBALogger( "_CORBA_", domain ) ; 445 } 446 447 private static Logger getCORBALogger( String ORBId, String domain ) 448 { 449 String fqLogDomain = CORBALogDomains.TOP_LEVEL_DOMAIN + "." + 450 ORBId + "." + domain; 451 452 return Logger.getLogger( fqLogDomain, ORBConstants.LOG_RESOURCE_FILE ); 453 } 454 455 458 public LogWrapperBase getLogWrapper( String logDomain, 459 String exceptionGroup, LogWrapperFactory factory ) 460 { 461 StringPair key = new StringPair( logDomain, exceptionGroup ) ; 462 463 LogWrapperBase logWrapper = (LogWrapperBase)wrapperMap.get( key ); 464 if (logWrapper == null) { 465 logWrapper = factory.create( getLogger( logDomain ) ); 466 wrapperMap.put( key, logWrapper ); 467 } 468 469 return logWrapper; 470 } 471 472 475 public static LogWrapperBase staticGetLogWrapper( String logDomain, 476 String exceptionGroup, LogWrapperFactory factory ) 477 { 478 StringPair key = new StringPair( logDomain, exceptionGroup ) ; 479 480 LogWrapperBase logWrapper = (LogWrapperBase)staticWrapperMap.get( key ); 481 if (logWrapper == null) { 482 logWrapper = factory.create( staticGetLogger( logDomain ) ); 483 staticWrapperMap.put( key, logWrapper ); 484 } 485 486 return logWrapper; 487 } 488 489 public ByteBufferPool getByteBufferPool() 494 { 495 if (byteBufferPool == null) 496 byteBufferPool = new ByteBufferPoolImpl(this); 497 498 return byteBufferPool; 499 } 500 501 public abstract void setThreadPoolManager(ThreadPoolManager mgr); 502 503 public abstract ThreadPoolManager getThreadPoolManager(); 504 505 public abstract CopierManager getCopierManager() ; 506 } 507 508 510 | Popular Tags |