Mon, 17 Dec 2012 07:43:20 -0800
7141694: Improving CORBA internals
Reviewed-by: coffeys, ahgross
src/share/classes/com/sun/corba/se/spi/orb/ORB.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/classes/com/sun/corba/se/spi/orb/ORB.java Tue Oct 30 17:15:13 2012 +0000 1.2 +++ b/src/share/classes/com/sun/corba/se/spi/orb/ORB.java Mon Dec 17 07:43:20 2012 -0800 1.3 @@ -98,6 +98,7 @@ 1.4 import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl ; 1.5 1.6 import com.sun.corba.se.impl.orbutil.ORBClassLoader ; 1.7 +import sun.awt.AppContext; 1.8 1.9 public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB 1.10 implements Broker, TypeCodeFactory 1.11 @@ -173,14 +174,7 @@ 1.12 1.13 protected MonitoringManager monitoringManager; 1.14 1.15 - // There is only one instance of the PresentationManager 1.16 - // that is shared between all ORBs. This is necessary 1.17 - // because RMI-IIOP requires the PresentationManager in 1.18 - // places where no ORB is available, so the PresentationManager 1.19 - // must be global. It is initialized here as well. 1.20 - protected static PresentationManager globalPM = null ; 1.21 - 1.22 - static { 1.23 + private static PresentationManager setupPresentationManager() { 1.24 staticWrapper = ORBUtilSystemException.get( 1.25 CORBALogDomains.RPC_PRESENTATION ) ; 1.26 1.27 @@ -220,10 +214,11 @@ 1.28 } 1.29 ) ; 1.30 1.31 - globalPM = new PresentationManagerImpl( useDynamicStub ) ; 1.32 - globalPM.setStubFactoryFactory( false, 1.33 + PresentationManager pm = new PresentationManagerImpl( useDynamicStub ) ; 1.34 + pm.setStubFactoryFactory( false, 1.35 PresentationDefaults.getStaticStubFactoryFactory() ) ; 1.36 - globalPM.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ; 1.37 + pm.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ; 1.38 + return pm; 1.39 } 1.40 1.41 public void destroy() { 1.42 @@ -234,11 +229,19 @@ 1.43 byteBufferPool = null; 1.44 } 1.45 1.46 - /** Get the single instance of the PresentationManager 1.47 + /** 1.48 + * Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific 1.49 + * AppContext to hold it. Creates and records one if needed. 1.50 */ 1.51 public static PresentationManager getPresentationManager() 1.52 { 1.53 - return globalPM ; 1.54 + AppContext ac = AppContext.getAppContext(); 1.55 + PresentationManager pm = (PresentationManager) ac.get(PresentationManager.class); 1.56 + if (pm == null) { 1.57 + pm = setupPresentationManager(); 1.58 + ac.put(PresentationManager.class, pm); 1.59 + } 1.60 + return pm; 1.61 } 1.62 1.63 /** Get the appropriate StubFactoryFactory. This 1.64 @@ -248,8 +251,9 @@ 1.65 public static PresentationManager.StubFactoryFactory 1.66 getStubFactoryFactory() 1.67 { 1.68 - boolean useDynamicStubs = globalPM.useDynamicStubs() ; 1.69 - return globalPM.getStubFactoryFactory( useDynamicStubs ) ; 1.70 + PresentationManager gPM = getPresentationManager(); 1.71 + boolean useDynamicStubs = gPM.useDynamicStubs() ; 1.72 + return gPM.getStubFactoryFactory( useDynamicStubs ) ; 1.73 } 1.74 1.75 protected ORB()