changeset 82:7eb471f1efdd

7141694: Improving CORBA internals Reviewed-by: coffeys, ahgross
author mbankal
date Thu, 13 Dec 2012 03:08:11 -0800
parents 58fdb67fcacc
children 1260b4e54a23
files src/share/classes/com/sun/corba/se/spi/orb/ORB.java
diffstat 1 files changed, 21 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/corba/se/spi/orb/ORB.java	Tue Nov 06 15:50:14 2012 +0000
+++ b/src/share/classes/com/sun/corba/se/spi/orb/ORB.java	Thu Dec 13 03:08:11 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -98,6 +98,7 @@
 import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl ;
 
 import com.sun.corba.se.impl.orbutil.ORBClassLoader ;
+import sun.awt.AppContext;
 
 public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB
     implements Broker, TypeCodeFactory
@@ -173,14 +174,7 @@
 
     private MonitoringManager monitoringManager;
 
-    // There is only one instance of the PresentationManager
-    // that is shared between all ORBs.  This is necessary
-    // because RMI-IIOP requires the PresentationManager in
-    // places where no ORB is available, so the PresentationManager
-    // must be global.  It is initialized here as well.
-    protected static PresentationManager globalPM = null ;
-
-    static {
+    private static PresentationManager setupPresentationManager() {
         staticWrapper = ORBUtilSystemException.get(
             CORBALogDomains.RPC_PRESENTATION ) ;
 
@@ -220,17 +214,26 @@
                 }
             ) ;
 
-        globalPM = new PresentationManagerImpl( useDynamicStub ) ;
-        globalPM.setStubFactoryFactory( false,
+        PresentationManager pm = new PresentationManagerImpl( useDynamicStub ) ;
+        pm.setStubFactoryFactory( false,
             PresentationDefaults.getStaticStubFactoryFactory() ) ;
-        globalPM.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ;
+        pm.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ; 
+        return pm;
     }
 
-    /** Get the single instance of the PresentationManager
+    /**
+     * Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific 
+     * AppContext to hold it. Creates and records one if needed.
      */
-    public static PresentationManager getPresentationManager()
+    public static PresentationManager getPresentationManager() 
     {
-        return globalPM ;
+        AppContext ac = AppContext.getAppContext();
+        PresentationManager pm = (PresentationManager) ac.get(PresentationManager.class);
+        if (pm == null) {
+            pm = setupPresentationManager();
+            ac.put(PresentationManager.class, pm);
+        }
+        return pm;
     }
 
     /** Get the appropriate StubFactoryFactory.  This
@@ -240,8 +243,9 @@
     public static PresentationManager.StubFactoryFactory
         getStubFactoryFactory()
     {
-        boolean useDynamicStubs = globalPM.useDynamicStubs() ;
-        return globalPM.getStubFactoryFactory( useDynamicStubs ) ;
+        PresentationManager gPM = getPresentationManager();
+        boolean useDynamicStubs = gPM.useDynamicStubs() ;
+        return gPM.getStubFactoryFactory( useDynamicStubs ) ;
     }
 
     protected ORB()