1 /*
2 * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
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
268 * TypeCode</code> object for a <code>union</code>).
269 * <P>
270 * This method is not intended to be used by applets, and in the event
271 * that it is called in an applet environment, the ORB it returns
272 * is restricted so that it can be used only as a factory for
273 * <code>TypeCode</code> objects. Any <code>TypeCode</code> objects
274 * it produces can be safely shared among untrusted applets.
275 * <P>
276 * If an ORB is created using this method from an applet,
277 * a system exception will be thrown if
278 * methods other than those for
279 * creating <code>TypeCode</code> objects are invoked.
280 *
281 * @return the singleton ORB
282 */
283 public static synchronized ORB init() {
284 if (singleton == null) {
285 String className = getSystemProperty(ORBSingletonClassKey);
286 if (className == null)
287 className = getPropertyFromFile(ORBSingletonClassKey);
288 if (className == null) {
289 singleton = new com.sun.corba.se.impl.orb.ORBSingleton();
290 } else {
291 singleton = create_impl(className);
292 }
293 }
294 return singleton;
295 }
296
297 private static ORB create_impl(String className) {
298
299 ClassLoader cl = Thread.currentThread().getContextClassLoader();
300 if (cl == null)
301 cl = ClassLoader.getSystemClassLoader();
302
303 try {
304 return (ORB) Class.forName(className, true, cl).newInstance();
305 } catch (Throwable ex) {
306 SystemException systemException = new INITIALIZE(
307 "can't instantiate default ORB implementation " + className);
308 systemException.initCause(ex);
322 */
323 public static ORB init(String[] args, Properties props) {
324 //
325 // Note that there is no standard command-line argument for
326 // specifying the default ORB implementation. For an
327 // application you can choose an implementation either by
328 // setting the CLASSPATH to pick a different org.omg.CORBA
329 // and it's baked-in ORB implementation default or by
330 // setting an entry in the properties object or in the
331 // system properties.
332 //
333 String className = null;
334 ORB orb;
335
336 if (props != null)
337 className = props.getProperty(ORBClassKey);
338 if (className == null)
339 className = getSystemProperty(ORBClassKey);
340 if (className == null)
341 className = getPropertyFromFile(ORBClassKey);
342 if (className == null) {
343 orb = new com.sun.corba.se.impl.orb.ORBImpl();
344 } else {
345 orb = create_impl(className);
346 }
347
348 orb.set_parameters(args, props);
349 return orb;
350 }
351
352
353 /**
354 * Creates a new <code>ORB</code> instance for an applet. This
355 * method may be called from applets only and returns a new
356 * fully-functional <code>ORB</code> object each time it is called.
357 * @param app the applet; may be <code>null</code>
358 * @param props applet-specific properties; may be <code>null</code>
359 * @return the newly-created ORB instance
360 */
361 public static ORB init(Applet app, Properties props) {
362 String className;
363 ORB orb;
364
365 className = app.getParameter(ORBClassKey);
366 if (className == null && props != null)
367 className = props.getProperty(ORBClassKey);
368 if (className == null)
369 className = getSystemProperty(ORBClassKey);
370 if (className == null)
371 className = getPropertyFromFile(ORBClassKey);
372 if (className == null) {
373 orb = new com.sun.corba.se.impl.orb.ORBImpl();
374 } else {
375 orb = create_impl(className);
376 }
377
378 orb.set_parameters(app, props);
379 return orb;
380 }
381
382 /**
383 * Allows the ORB implementation to be initialized with the given
384 * parameters and properties. This method, used in applications only,
385 * is implemented by subclass ORB implementations and called
386 * by the appropriate <code>init</code> method to pass in its parameters.
387 *
388 * @param args command-line arguments for the application's <code>main</code>
389 * method; may be <code>null</code>
390 * @param props application-specific properties; may be <code>null</code>
391 */
392 abstract protected void set_parameters(String[] args, Properties props);
|
1 /*
2 * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation. Oracle designates this
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
268 * TypeCode</code> object for a <code>union</code>).
269 * <P>
270 * This method is not intended to be used by applets, and in the event
271 * that it is called in an applet environment, the ORB it returns
272 * is restricted so that it can be used only as a factory for
273 * <code>TypeCode</code> objects. Any <code>TypeCode</code> objects
274 * it produces can be safely shared among untrusted applets.
275 * <P>
276 * If an ORB is created using this method from an applet,
277 * a system exception will be thrown if
278 * methods other than those for
279 * creating <code>TypeCode</code> objects are invoked.
280 *
281 * @return the singleton ORB
282 */
283 public static synchronized ORB init() {
284 if (singleton == null) {
285 String className = getSystemProperty(ORBSingletonClassKey);
286 if (className == null)
287 className = getPropertyFromFile(ORBSingletonClassKey);
288 if ((className == null) ||
289 (className.equals("com.sun.corba.se.impl.orb.ORBSingleton"))) {
290 singleton = new com.sun.corba.se.impl.orb.ORBSingleton();
291 } else {
292 singleton = create_impl(className);
293 }
294 }
295 return singleton;
296 }
297
298 private static ORB create_impl(String className) {
299
300 ClassLoader cl = Thread.currentThread().getContextClassLoader();
301 if (cl == null)
302 cl = ClassLoader.getSystemClassLoader();
303
304 try {
305 return (ORB) Class.forName(className, true, cl).newInstance();
306 } catch (Throwable ex) {
307 SystemException systemException = new INITIALIZE(
308 "can't instantiate default ORB implementation " + className);
309 systemException.initCause(ex);
323 */
324 public static ORB init(String[] args, Properties props) {
325 //
326 // Note that there is no standard command-line argument for
327 // specifying the default ORB implementation. For an
328 // application you can choose an implementation either by
329 // setting the CLASSPATH to pick a different org.omg.CORBA
330 // and it's baked-in ORB implementation default or by
331 // setting an entry in the properties object or in the
332 // system properties.
333 //
334 String className = null;
335 ORB orb;
336
337 if (props != null)
338 className = props.getProperty(ORBClassKey);
339 if (className == null)
340 className = getSystemProperty(ORBClassKey);
341 if (className == null)
342 className = getPropertyFromFile(ORBClassKey);
343 if ((className == null) ||
344 (className.equals("com.sun.corba.se.impl.orb.ORBImpl"))) {
345 orb = new com.sun.corba.se.impl.orb.ORBImpl();
346 } else {
347 orb = create_impl(className);
348 }
349
350 orb.set_parameters(args, props);
351 return orb;
352 }
353
354
355 /**
356 * Creates a new <code>ORB</code> instance for an applet. This
357 * method may be called from applets only and returns a new
358 * fully-functional <code>ORB</code> object each time it is called.
359 * @param app the applet; may be <code>null</code>
360 * @param props applet-specific properties; may be <code>null</code>
361 * @return the newly-created ORB instance
362 */
363 public static ORB init(Applet app, Properties props) {
364 String className;
365 ORB orb;
366
367 className = app.getParameter(ORBClassKey);
368 if (className == null && props != null)
369 className = props.getProperty(ORBClassKey);
370 if (className == null)
371 className = getSystemProperty(ORBClassKey);
372 if (className == null)
373 className = getPropertyFromFile(ORBClassKey);
374 if ((className == null) ||
375 (className.equals("com.sun.corba.se.impl.orb.ORBImpl"))) {
376 orb = new com.sun.corba.se.impl.orb.ORBImpl();
377 } else {
378 orb = create_impl(className);
379 }
380
381 orb.set_parameters(app, props);
382 return orb;
383 }
384
385 /**
386 * Allows the ORB implementation to be initialized with the given
387 * parameters and properties. This method, used in applications only,
388 * is implemented by subclass ORB implementations and called
389 * by the appropriate <code>init</code> method to pass in its parameters.
390 *
391 * @param args command-line arguments for the application's <code>main</code>
392 * method; may be <code>null</code>
393 * @param props application-specific properties; may be <code>null</code>
394 */
395 abstract protected void set_parameters(String[] args, Properties props);
|