8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.corba.se.spi.orb;
27
28 import java.util.Map ;
29 import java.util.HashMap ;
30 import java.util.Properties ;
31 import java.util.concurrent.ConcurrentHashMap;
32 import java.util.logging.Logger ;
33
34 import java.security.AccessController ;
35 import java.security.PrivilegedAction ;
36
37 import org.omg.CORBA.TCKind ;
38
39 import com.sun.corba.se.pept.broker.Broker ;
40 import com.sun.corba.se.pept.transport.ByteBufferPool;
41
42 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry ;
43 import com.sun.corba.se.spi.protocol.ClientDelegateFactory ;
44 import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher ;
45 import com.sun.corba.se.spi.protocol.PIHandler ;
46 import com.sun.corba.se.spi.resolver.LocalResolver ;
47 import com.sun.corba.se.spi.resolver.Resolver ;
185 PresentationDefaults.getStaticStubFactoryFactory() ) ;
186 pm.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ;
187 return pm;
188 }
189
190 public void destroy() {
191 wrapper = null;
192 omgWrapper = null;
193 typeCodeMap = null;
194 primitiveTypeCodeConstants = null;
195 byteBufferPool = null;
196 }
197
198 /**
199 * Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific
200 * AppContext to hold it. Creates and records one if needed.
201 */
202 public static PresentationManager getPresentationManager()
203 {
204 SecurityManager sm = System.getSecurityManager();
205 sun.misc.JavaAWTAccess javaAwtAccess = sun.misc.SharedSecrets.getJavaAWTAccess();
206 if (sm != null && javaAwtAccess != null) {
207 final Object appletContext = javaAwtAccess.getAppletContext();
208 if (appletContext != null) {
209 return pmContexts.computeIfAbsent(appletContext,
210 x -> setupPresentationManager());
211 }
212 }
213
214 // No security manager or AppletAppContext
215 return Holder.defaultPresentationManager;
216 }
217
218 /** Get the appropriate StubFactoryFactory. This
219 * will be dynamic or static depending on whether
220 * com.sun.CORBA.ORBUseDynamicStub is true or false.
221 */
222 public static PresentationManager.StubFactoryFactory
223 getStubFactoryFactory()
224 {
225 PresentationManager gPM = getPresentationManager();
226 boolean useDynamicStubs = gPM.useDynamicStubs() ;
227 return gPM.getStubFactoryFactory( useDynamicStubs ) ;
228 }
229
230 protected ORB()
231 {
|
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.corba.se.spi.orb;
27
28 import java.lang.reflect.Method;
29 import java.util.Map ;
30 import java.util.HashMap ;
31 import java.util.Properties ;
32 import java.util.concurrent.ConcurrentHashMap;
33 import java.util.logging.Logger ;
34
35 import java.security.AccessController ;
36 import java.security.PrivilegedAction ;
37
38 import org.omg.CORBA.TCKind ;
39
40 import com.sun.corba.se.pept.broker.Broker ;
41 import com.sun.corba.se.pept.transport.ByteBufferPool;
42
43 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry ;
44 import com.sun.corba.se.spi.protocol.ClientDelegateFactory ;
45 import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher ;
46 import com.sun.corba.se.spi.protocol.PIHandler ;
47 import com.sun.corba.se.spi.resolver.LocalResolver ;
48 import com.sun.corba.se.spi.resolver.Resolver ;
186 PresentationDefaults.getStaticStubFactoryFactory() ) ;
187 pm.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ;
188 return pm;
189 }
190
191 public void destroy() {
192 wrapper = null;
193 omgWrapper = null;
194 typeCodeMap = null;
195 primitiveTypeCodeConstants = null;
196 byteBufferPool = null;
197 }
198
199 /**
200 * Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific
201 * AppContext to hold it. Creates and records one if needed.
202 */
203 public static PresentationManager getPresentationManager()
204 {
205 SecurityManager sm = System.getSecurityManager();
206
207 if (sm != null) {
208 PresentationManager pm = AccessController.doPrivileged(
209 (PrivilegedAction<PresentationManager>) () -> {
210 try {
211 Class<?> c = Class.forName("jdk.internal.misc.SharedSecrets");
212 Method m = c.getDeclaredMethod("getJavaAWTAccess");
213 final Object javaAwtAccess = m.invoke(null);
214
215 if (sm != null && javaAwtAccess != null) {
216 c = Class.forName("jdk.internal.misc.JavaAWTAccess");
217 m = c.getDeclaredMethod("getAppletContext");
218
219 final Object appletContext = m.invoke(javaAwtAccess);
220 if (appletContext != null) {
221 return pmContexts.computeIfAbsent(appletContext,
222 x -> setupPresentationManager());
223 }
224 }
225 return null;
226 } catch (ReflectiveOperationException x) {
227 throw new InternalError(x);
228 }
229 });
230
231 if (pm != null)
232 return pm;
233 }
234
235 // No security manager or AppletAppContext
236 return Holder.defaultPresentationManager;
237 }
238
239 /** Get the appropriate StubFactoryFactory. This
240 * will be dynamic or static depending on whether
241 * com.sun.CORBA.ORBUseDynamicStub is true or false.
242 */
243 public static PresentationManager.StubFactoryFactory
244 getStubFactoryFactory()
245 {
246 PresentationManager gPM = getPresentationManager();
247 boolean useDynamicStubs = gPM.useDynamicStubs() ;
248 return gPM.getStubFactoryFactory( useDynamicStubs ) ;
249 }
250
251 protected ORB()
252 {
|