1 /* |
1 /* |
2 * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
33 import java.io.File; |
33 import java.io.File; |
34 import java.io.FileInputStream; |
34 import java.io.FileInputStream; |
35 |
35 |
36 import java.security.AccessController; |
36 import java.security.AccessController; |
37 import java.security.PrivilegedAction; |
37 import java.security.PrivilegedAction; |
|
38 |
|
39 import sun.reflect.misc.ReflectUtil; |
38 |
40 |
39 /** |
41 /** |
40 * A class providing APIs for the CORBA Object Request Broker |
42 * A class providing APIs for the CORBA Object Request Broker |
41 * features. The <code>ORB</code> class also provides |
43 * features. The <code>ORB</code> class also provides |
42 * "pluggable ORB implementation" APIs that allow another vendor's ORB |
44 * "pluggable ORB implementation" APIs that allow another vendor's ORB |
287 className = getPropertyFromFile(ORBSingletonClassKey); |
289 className = getPropertyFromFile(ORBSingletonClassKey); |
288 if ((className == null) || |
290 if ((className == null) || |
289 (className.equals("com.sun.corba.se.impl.orb.ORBSingleton"))) { |
291 (className.equals("com.sun.corba.se.impl.orb.ORBSingleton"))) { |
290 singleton = new com.sun.corba.se.impl.orb.ORBSingleton(); |
292 singleton = new com.sun.corba.se.impl.orb.ORBSingleton(); |
291 } else { |
293 } else { |
292 singleton = create_impl(className); |
294 singleton = create_impl_with_systemclassloader(className); |
293 } |
295 } |
294 } |
296 } |
295 return singleton; |
297 return singleton; |
296 } |
298 } |
297 |
299 |
|
300 private static ORB create_impl_with_systemclassloader(String className) { |
|
301 |
|
302 try { |
|
303 ReflectUtil.checkPackageAccess(className); |
|
304 ClassLoader cl = ClassLoader.getSystemClassLoader(); |
|
305 Class<org.omg.CORBA.ORB> orbBaseClass = org.omg.CORBA.ORB.class; |
|
306 Class<?> singletonOrbClass = Class.forName(className, true, cl).asSubclass(orbBaseClass); |
|
307 return (ORB)singletonOrbClass.newInstance(); |
|
308 } catch (Throwable ex) { |
|
309 SystemException systemException = new INITIALIZE( |
|
310 "can't instantiate default ORB implementation " + className); |
|
311 systemException.initCause(ex); |
|
312 throw systemException; |
|
313 } |
|
314 } |
|
315 |
298 private static ORB create_impl(String className) { |
316 private static ORB create_impl(String className) { |
299 |
|
300 ClassLoader cl = Thread.currentThread().getContextClassLoader(); |
317 ClassLoader cl = Thread.currentThread().getContextClassLoader(); |
301 if (cl == null) |
318 if (cl == null) |
302 cl = ClassLoader.getSystemClassLoader(); |
319 cl = ClassLoader.getSystemClassLoader(); |
303 |
320 |
304 try { |
321 try { |
305 return (ORB) Class.forName(className, true, cl).newInstance(); |
322 ReflectUtil.checkPackageAccess(className); |
|
323 Class<org.omg.CORBA.ORB> orbBaseClass = org.omg.CORBA.ORB.class; |
|
324 Class<?> orbClass = Class.forName(className, true, cl).asSubclass(orbBaseClass); |
|
325 return (ORB)orbClass.newInstance(); |
306 } catch (Throwable ex) { |
326 } catch (Throwable ex) { |
307 SystemException systemException = new INITIALIZE( |
327 SystemException systemException = new INITIALIZE( |
308 "can't instantiate default ORB implementation " + className); |
328 "can't instantiate default ORB implementation " + className); |
309 systemException.initCause(ex); |
329 systemException.initCause(ex); |
310 throw systemException; |
330 throw systemException; |
571 // so lets check if it has a create_operation_list(OperationDef oper) |
589 // so lets check if it has a create_operation_list(OperationDef oper) |
572 // method. |
590 // method. |
573 try { |
591 try { |
574 // First try to load the OperationDef class |
592 // First try to load the OperationDef class |
575 String opDefClassName = "org.omg.CORBA.OperationDef"; |
593 String opDefClassName = "org.omg.CORBA.OperationDef"; |
576 Class opDefClass = null; |
594 Class<?> opDefClass = null; |
577 |
595 |
578 ClassLoader cl = Thread.currentThread().getContextClassLoader(); |
596 ClassLoader cl = Thread.currentThread().getContextClassLoader(); |
579 if ( cl == null ) |
597 if ( cl == null ) |
580 cl = ClassLoader.getSystemClassLoader(); |
598 cl = ClassLoader.getSystemClassLoader(); |
581 // if this throws a ClassNotFoundException, it will be caught below. |
599 // if this throws a ClassNotFoundException, it will be caught below. |
582 opDefClass = Class.forName(opDefClassName, true, cl); |
600 opDefClass = Class.forName(opDefClassName, true, cl); |
583 |
601 |
584 // OK, we loaded OperationDef. Now try to get the |
602 // OK, we loaded OperationDef. Now try to get the |
585 // create_operation_list(OperationDef oper) method. |
603 // create_operation_list(OperationDef oper) method. |
586 Class[] argc = { opDefClass }; |
604 Class<?>[] argc = { opDefClass }; |
587 java.lang.reflect.Method meth = |
605 java.lang.reflect.Method meth = |
588 this.getClass().getMethod("create_operation_list", argc); |
606 this.getClass().getMethod("create_operation_list", argc); |
589 |
607 |
590 // OK, the method exists, so invoke it and be happy. |
608 // OK, the method exists, so invoke it and be happy. |
591 java.lang.Object[] argx = { oper }; |
609 java.lang.Object[] argx = { oper }; |