2 Copyright (C) 2005, 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package org.omg.CORBA;
41 import gnu.CORBA.OrbFocused;
42 import gnu.CORBA.ObjectCreator;
43 import gnu.CORBA.OrbRestricted;
44 import gnu.CORBA.typecodes.FixedTypeCode;
45 import gnu.CORBA.typecodes.GeneralTypeCode;
46 import gnu.CORBA.typecodes.RecordTypeCode;
47 import gnu.CORBA.typecodes.RecursiveTypeCode;
49 import org.omg.CORBA.ORBPackage.InconsistentTypeCode;
50 import org.omg.PortableInterceptor.ObjectReferenceTemplate;
52 import java.applet.Applet;
54 import java.io.BufferedInputStream;
56 import java.io.FileInputStream;
57 import java.io.IOException;
59 import java.util.Properties;
62 * A central class in CORBA implementation, responsible for sending and handling
63 * remote invocations. ORB also works as a factory for creating instances of
64 * certain CORBA classes.
66 * Despite the core library contains the fully working CORBA implementation, it
67 * also provides a simple way to plug-in the alternative CORBA support. This is
68 * done by replacing the ORB. The alternative ORB can be specified via
69 * properties, passed to ORB.Init(...).
71 * When creating an ORB instance, the class name is searched in the following
74 * 1. Applet parameter or application string array, if any.<br>
75 * 2. The properties parameter, if any.<br>
76 * 3. The System properties.<br>
77 * 4. The orb.properties file located in the user.home directory (if any).<br>
78 * 5. The orb.properties file located in the java.home/lib directory (if any).
81 * The supported properties are: <table border="1">
83 * <td> org.omg.CORBA.ORBClass</td>
84 * <td>The class, implementing the functional ORB, returned by
85 * {@link #init(Applet, Properties)} or {@link #init(String[], Properties)}
89 * <td>org.omg.CORBA.ORBSingletonClass</td>
90 * <td>The class, implementing the restricted ORB, returned by {@link #init()}.
94 * <td>org.omg.CORBA.ORBInitRef</td>
95 * <td>Specifies the initial reference, accessible by name with the method
96 * {@link #resolve_initial_references(String)}.</td>
99 * <td>org.omg.CORBA.ORBid</td>
100 * <td>Specifies the name (ORB Id) of this ORB. The ORB Id is later accessible
101 * by {@link ObjectReferenceTemplate#orb_id}. The default value includes the
102 * hashcode of the ORB instance that is normally different for each ORB.
106 * <td>org.omg.CORBA.ServerId</td>
107 * <td>Specifies the name (Server Id) of this server. This property assigns
108 * value to the <i>static</i> field, ensuring that all ORB's on the same jre
109 * have the same Server Id. It is normally set as the system property. The
110 * server Id is later accessible as {@link ObjectReferenceTemplate#server_id}.
114 * <td>gnu.CORBA.ListenerPort</td>
115 * <td>Specifies that this ORB should serve all its objects on a single port
116 * (for example, "1234") or on a specified port range (for example,
117 * "1100-1108"). The property is used when working with firewals and serves as a
118 * replacement for the proprietary properties like com.ibm.CORBA.ListenerPort
119 * or com.sun.CORBA.POA.ORBPersistentServerPort. The specified port or range
120 * should not overlap with the values, specified for other ORB's.
124 * <td>gnu.Corba.SocketFactory</td>
125 * <td>Sets the user-defined server and client socket factory for the ORB being
126 * currently instantiated. Serves as a replacement of the proprietary
127 * property com.sun.CORBA.connection.ORBSocketFactoryClass. To have multiple
128 * types of sockets, instantiate several ORB's with this property each time
129 * set to the different value.
130 * The factory must implement gnu.CORBA.interfaces.SocketFactory.
134 * <p>The command line accepts the same properties as a keys. When
135 * specifying in the command line, the prefix org.omg.CORBA can be omitted, for
136 * instance<code> -ORBInitRef NameService=IOR:aabbccdd....</code>
139 * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
141 public abstract class ORB
144 * By default, {@link #init(String[], Properties)} and
145 * {@link #init(Applet, Properties)} return
146 * the built-in fully functional ORB is returned. If the
147 * <code>props</code> contains the property org.omg.CORBA.ORBClass,
148 * the value of this property is used as a class name to instantiate
149 * a user-defined ORB.
151 private static final String FUNCTIONAL_ORB = "org.omg.CORBA.ORBClass";
154 * The name of the restricted ORB property.
156 private static final String RESTRICTED_ORB =
157 "org.omg.CORBA.ORBSingletonClass";
159 private static final String LISTENER_PORT =
160 OrbFocused.LISTENER_PORT;
163 * The class, implementing the default fully functional ORB.
165 private static final String DEFAULT_FUNCTIONAL_ORB =
166 gnu.CORBA.Poa.ORB_1_4.class.getName();
168 private static final String DEFAULT_FOCUSED_ORB =
169 gnu.CORBA.OrbFocused.class.getName();
171 // There is no need for name of the default restricted ORB as it is
172 // singleton and it is more effectively referred directly.
175 * Connect the given CORBA object to this ORB. After the object is
176 * connected, it starts receiving remote invocations via this ORB.
178 * The OMG group recommends to use Portable Object Adapter (POA) instead
179 * of calling this method.
181 * This method is implemented in the derived Gnu Classpah classes,
182 * returned by ORB.init(..). In this abstract class, the implementation
183 * just throws {@link NO_IMPLEMENT}.
185 * @param object the org.omg.CORBA.Object to connect.
187 public void connect(org.omg.CORBA.Object object)
189 throw new NO_IMPLEMENT();
193 * Disconnect the given CORBA object from this ORB. The object will be
194 * no longer receiving the remote invocations. In response to the
195 * remote invocation on this object, the ORB will send the
196 * exception {@link OBJECT_NOT_EXIST}. The object, however, is not
197 * destroyed and can receive the local invocations.
199 * This method is implemented in the derived Gnu Classpah classes,
200 * returned by ORB.init(..). In this abstract class, the implementation
201 * just throws {@link NO_IMPLEMENT}.
203 * @param object the object to disconnect.
205 public void disconnect(org.omg.CORBA.Object object)
207 throw new NO_IMPLEMENT();
211 * Create a typecode, representing a tree-like structure.
212 * This structure contains a member that is a sequence of the same type,
213 * as the structure itself. You can imagine as if the folder definition
214 * contains a variable-length array of the enclosed (nested) folder
215 * definitions. In this way, it is possible to have a tree like
216 * structure that can be transferred via CORBA CDR stream.
218 * @deprecated It is easier and clearler to use a combination of
219 * create_recursive_tc and create_sequence_tc instead.
221 * @param bound the maximal expected number of the nested components
222 * on each node; 0 if not limited.
224 * @param offset the position of the field in the returned structure
225 * that contains the sequence of the structures of the same field.
226 * The members before this field are intialised using parameterless
227 * StructMember constructor.
229 * @return a typecode, defining a stucture, where a member at the
230 * <code>offset</code> position defines an array of the identical
233 * @see #create_recursive_tc(String)
234 * @see #create_sequence_tc(int, TypeCode)
236 public abstract TypeCode create_recursive_sequence_tc(int bound, int offset);
239 * Create alias typecode for the given typecode.
241 public abstract TypeCode create_alias_tc(String id, String name,
246 * Create an instance of the CORBA {@link Any} with the type, intialised
247 * to {@link TCKind#tk_null}
249 public abstract Any create_any();
252 * Create a typecode, defining an array of the given elements.
254 * @param length the size of array
255 * @param element_type the array component type.
257 * @return the corresponding typecode.
259 public abstract TypeCode create_array_tc(int length, TypeCode element_type);
262 * Creates an empty CORBA <code>ContextList</code>.
264 * @return the newly created context list.
266 public abstract ContextList create_context_list();
269 * The support for {@link DynAny} and derived interfaces
270 * has never been implemented in Sun's java releases,
271 * at least till v1.4 inclusive.
273 * Since v1.4 this stil missing implementation was replaced
274 * by the new DynamicAny package.
276 * @throws NO_IMPLEMENT, always.
278 public DynAny create_basic_dyn_any(org.omg.CORBA.TypeCode t)
279 throws InconsistentTypeCode
281 throw new NO_IMPLEMENT();
286 * The support for {@link DynAny} and derived interfaces
287 * has never been implemented in Sun's java releases,
288 * at least till v1.4 inclusive.
290 * Since v1.4 this stil missing implementation was replaced
291 * by the new DynamicAny package.
293 * @throws NO_IMPLEMENT, always.
295 public DynAny create_dyn_any(org.omg.CORBA.Any a)
297 throw new NO_IMPLEMENT();
302 * The support for {@link DynArray}
303 * has never been implemented in Sun's java releases,
304 * at least till v1.4 inclusive.
306 * Since v1.4 this stil missing implementation was replaced
307 * by the new DynamicAny package.
309 * @throws NO_IMPLEMENT, always.
311 public DynArray create_dyn_array(org.omg.CORBA.TypeCode t)
312 throws InconsistentTypeCode
314 throw new NO_IMPLEMENT();
319 * The support for {@link DynEnum}
320 * has never been implemented in Sun's java releases,
321 * at least till v1.4 inclusive.
323 * Since v1.4 this stil missing implementation was replaced
324 * by the new DynamicAny package.
326 * @throws NO_IMPLEMENT, always.
328 public DynEnum create_dyn_enum(org.omg.CORBA.TypeCode t)
329 throws InconsistentTypeCode
331 throw new NO_IMPLEMENT();
336 * The support for {@link DynSequence}
337 * has never been implemented in Sun's java releases,
338 * at least till v1.4 inclusive.
340 * Since v1.4 this stil missing implementation was replaced
341 * by the new DynamicAny package.
343 * @throws NO_IMPLEMENT, always.
345 public DynSequence create_dyn_sequence(org.omg.CORBA.TypeCode t)
346 throws InconsistentTypeCode
348 throw new NO_IMPLEMENT();
353 * The support for {@link DynStruct} and derived interfaces
354 * has never been implemented in Sun's java releases,
355 * at least till v1.4 inclusive.
357 * Since v1.4 this stil missing implementation was replaced
358 * by the new DynamicAny package.
360 * @throws NO_IMPLEMENT, always.
362 public DynStruct create_dyn_struct(org.omg.CORBA.TypeCode t)
363 throws InconsistentTypeCode
365 throw new NO_IMPLEMENT();
370 * The support for {@link DynUnion} and derived interfaces
371 * has never been implemented in Sun's java releases,
372 * at least till v1.4 inclusive.
374 * Since v1.4 this stil missing implementation was replaced
375 * by the new DynamicAny package.
377 * @throws NO_IMPLEMENT, always.
379 public DynUnion create_dyn_union(org.omg.CORBA.TypeCode t)
380 throws InconsistentTypeCode
382 throw new NO_IMPLEMENT();
387 * Create a typecode, defining the given enumeration.
390 * @param name the name.
391 * @param members the memebers
392 * @return the created enumeration.
394 public abstract TypeCode create_enum_tc(String id, String name,
399 * Create an environment (container for exceptions).
401 * @return the created container.
403 public abstract Environment create_environment();
406 * Creates an empty exception list.
408 * @return the newly created list.
410 public abstract ExceptionList create_exception_list();
413 * Create the exception typecode.
415 * @param id the id of exception.
416 * @param name the name of exception.
417 * @param members the members of exception.
419 public abstract TypeCode create_exception_tc(String id, String name,
420 StructMember[] members
424 * Creates a TypeCode object for CORBA <code>fixed</code> that is
425 * mapped to java {@link java.math.BigDecimal}.
427 * @param digits the number of digits in that <code>fixed</code>.
428 * @param scale the number of digits after the decimal point.
430 * @return the corresponding TypeCode.
432 public TypeCode create_fixed_tc(short digits, short scale)
434 FixedTypeCode r = new FixedTypeCode();
441 * Creates a typecode, representing the IDL interface.
443 * @param id the interface repository id.
444 * @param name the interface name.
446 * @return the created typecode.
448 public abstract TypeCode create_interface_tc(String id, String name);
451 * Create an instance of a new {@link NVList}.
453 * @param count the initial size of the list. If more elements are added,
454 * the list automatically expands.
456 * @return the created list.
458 public abstract NVList create_list(int count);
461 * Create a new named value.
463 * @param name the name of the named value
464 * @param any the content of the named value.
465 * @param flags the flags of the named value
467 * @return the named value.
469 public abstract NamedValue create_named_value(String name, Any any, int flags);
472 * Send multiple prepared requests one way, do not caring about the answer.
473 * The messages, containing requests, will be marked, indicating that
474 * the sender is not expecting to get a reply.
476 * @param requests the prepared array of requests.
478 * @see Request#send_oneway()
480 public abstract void send_multiple_requests_oneway(Request[] requests);
483 * Send multiple prepared requests expecting to get a reply. All requests
484 * are send in parallel, each in its own separate thread. When the
485 * reply arrives, it is stored in the agreed fields of the corresponing
486 * request data structure. If this method is called repeatedly,
487 * the new requests are added to the set of the currently sent requests,
488 * but the old set is not discarded.
490 * @param requests the prepared array of requests.
492 * @see #poll_next_response()
493 * @see #get_next_response()
494 * @see Request#send_deferred()
496 public abstract void send_multiple_requests_deferred(Request[] requests);
499 * Find if any of the requests that have been previously sent with
500 * {@link #send_multiple_requests_deferred}, have a response yet.
502 * @return true if there is at least one response to the previously
503 * sent request, false otherwise.
505 public abstract boolean poll_next_response();
508 * Get the next instance with a response being received. If all currently
509 * sent responses not yet processed, this method pauses till at least one of
510 * them is complete. If there are no requests currently sent, the method
511 * pauses till some request is submitted and the response is received.
512 * This strategy is identical to the one accepted by Suns 1.4 ORB
515 * @return the previously sent request that now contains the received
518 * @throws WrongTransaction If the method was called from the transaction
519 * scope different than the one, used to send the request. The exception
520 * can be raised only if the request is implicitly associated with some
521 * particular transaction.
523 public abstract Request get_next_response()
524 throws WrongTransaction;
527 * Create a new CDR output stream, where the parameter values can be written
528 * during the method invocation.
530 * @return a stream to write values into.
532 public abstract org.omg.CORBA.portable.OutputStream create_output_stream();
535 * This should create the list, initialised with the argument descriptions
536 * for the given operation definition (CORBA <code>OperationDef</code>).
537 * The information should be obtained from the interface repository.
538 * However this method is oficially documented as not implemented at least
539 * till v1.4 inclusive.
541 * @param operation_definition the operation definition, must be
542 * CORBA <code>OperationDef</code>.
546 * @throws NO_IMPLEMENT, always.
548 public NVList create_operation_list(Object operation_definition)
550 throw new NO_IMPLEMENT();
554 * <p>Creates the new policy of the specified type, having the given value.
555 * This method looks for the policy factory that was previously registered
556 * during ORB initialization by
557 * {@link org.omg.PortableInterceptor#ORBInitialiser}.
559 * If the suitable factory is found, this factory creates the requested policy,
560 * otherwise the PolicyError is thrown.
562 * The POA policies should be created by POA, not by this method.
564 * @param type the policy type.
565 * @param value the policy value, wrapped into Any.
567 * @throws PolicyError if the ORB fails to instantiate the policy object.
569 * @throws NO_IMPLEMENT always (in this class). Overridden in derived classes
570 * returned by ORB.init(..).
572 * @see org.omg.PortableInterceptor.ORBInitInfoOperations#register_policy_factory
573 * @see org.omg.PortableInterceptor.PolicyFactoryOperations
575 public Policy create_policy(int type, Any value)
578 throw new NO_IMPLEMENT();
582 * Create typecode, defining the sequence of the elements, having
585 * @param bound the maximal length of the sequence, 0 if not restricted.
587 * @param element_type the sequence element type.
589 * @return the typecode.
591 public abstract TypeCode create_sequence_tc(int bound, TypeCode element_type);
594 * Create a TypeCode, representing the CORBA <code>string</code>.
596 * @param bound the maximal length of the string, 0 is unlimited.
598 * @return the corresponding string typecode.
600 public abstract TypeCode create_string_tc(int bound);
603 * Create the typecode, defining the given IDL structure.
605 * The TypeCode object is initialized with the given id, name, and members.
606 * @param id the Id of this type.
607 * @param name the name of this type.
608 * @param members the member list.
610 * @return the typecode.
612 public abstract TypeCode create_struct_tc(String id, String name,
613 StructMember[] members
617 * Create the typecode, defining the given IDL union.
619 * The TypeCode object is initialized with the given id, name, discriminator
622 * @param id the Id of this type.
623 * @param name the name of this type.
624 * @param discriminator the union discriminator.
625 * @param members the member list.
627 * @return the typecode.
629 public abstract TypeCode create_union_tc(String id, String name,
630 TypeCode discriminator,
631 UnionMember[] members
635 * Create a TypeCode, representing the CORBA <code>wstring</code>.
637 * @param bound the maximal length of the string, 0 is unlimited.
639 * @return the corresponding string typecode.
641 public abstract TypeCode create_wstring_tc(int bound);
644 * Create a typecode for an abstract interface. The abstract interface
645 * can be either CORBA object or CORBA value type.
647 * @param id the id of the abstract interface.
648 * @param name the name of the abstract interface.
650 * @return the created typecode.
652 public TypeCode create_abstract_interface_tc(String id, String name)
654 GeneralTypeCode t = new GeneralTypeCode(TCKind.tk_abstract_interface);
661 * Create a typecode for a native interface.
663 * @param id the id of the native interface.
664 * @param name the name of the native interface.
666 * @return the created typecode.
668 public TypeCode create_native_tc(String id, String name)
670 GeneralTypeCode t = new GeneralTypeCode(TCKind.tk_native);
678 * Create a typecode which serves as a placeholder for typcode, containing
681 * @param id the id of the recursive typecode, for that this typecode
682 * serves as a placeholder.
684 public TypeCode create_recursive_tc(String id)
686 return new RecursiveTypeCode(id);
690 * Create value box typecode.
692 public TypeCode create_value_box_tc(String id, String name,
696 GeneralTypeCode t = new GeneralTypeCode(TCKind.tk_value_box);
699 t.setContentType(boxed_type);
704 * Create IDL value type code.
706 public TypeCode create_value_tc(String id, String name, short type_modifier,
707 TypeCode concrete_base, ValueMember[] members
710 RecordTypeCode r = new RecordTypeCode(TCKind.tk_value);
713 r.setTypeModifier(type_modifier);
714 r.setConcreteBase_type(concrete_base);
716 for (int i = 0; i < members.length; i++)
718 r.add(members [ i ]);
725 * This should return the information, related to the current thread.
726 * The information is needed, for instance, to get the current object
727 * from the code that serves several objects in parallel threads.
728 * The {@link Current} is very general interface, with no fields and
729 * operations defined. This method is not implemented in Suns
730 * releases at least till v1.5 inclusive. To obtain the
731 * {@link org.omg.PortableServer.Current}, use
732 * {@link #resolve_initial_references}, passing "POACurrent".
734 * @deprecated since 1.2, use {@link #resolve_initial_references}.
738 * @throws NO_IMPLEMENT always.
740 public Current get_current()
742 throw new NO_IMPLEMENT();
746 * This should return the information about the CORBA facilities and
747 * services, available from this ORB. However this method is oficially
748 * documented as not implemented at least till v1.5 inclusive.
750 * @param service_type a type of the service being requested. The OMG
751 * specification currently defines only one value, 1, for security
754 * @param service_info a holder, where the returned information should
757 * @return should return true if the service information is available
758 * from the ORB, but this method never returns.
760 * @throws NO_IMPLEMENT always.
762 public boolean get_service_information(short service_type,
763 ServiceInformationHolder service_info
766 throw new NO_IMPLEMENT();
770 * Get the default context of this ORB. This is an initial root of all
773 * The default method returns a new context with the empty name and
776 * @return the default context of this ORB.
778 * @throws NO_IMPLEMENT for the Singleton ORB, returned by
779 * the parameterless {@link #init()}.
781 public abstract Context get_default_context();
784 * Return thg typecode, representing the given primitive object type.
786 * @param tcKind the kind of the primitive typecode.
788 * @return the typecode of the primitve typecode.
790 public abstract TypeCode get_primitive_tc(TCKind tcKind);
793 * Returns so-called Singleton ORB, a highly restricted version
794 * that cannot communicate over network. This ORB is provided
795 * for the potentially malicious applets with heavy security restrictions.
797 * The returned Singleton ORB can only create typecodes,
798 * {@link Any}, {@link ContextList}, {@link NVList} and
799 * {@link org.omg.CORBA.portable.OutputStream} that writes to an
802 * All other methods throw the {@link NO_IMPLEMENT} exception, additionally
803 * printing the error message about the potential attempt to violate
804 * the security rules.
806 * The implementing ORB class, used in this method, is found as described
809 * @return the working derivative of ORB, implementing the methods
810 * of this abstract class.
812 public static ORB init()
814 String orb_cn = getCumulatedProperty(null, RESTRICTED_ORB);
816 return OrbRestricted.Singleton;
818 return createORB(null, orb_cn);
822 * Creates the working instance of ORB for an applet.
824 * By default the built-in fully functional ORB is returned. The ORB class
825 * is found as described in the header of this class.
827 * @param applet the applet. The property org.omg.CORBA.ORBClass,
828 * if present, defines the used ORB implementation class. If this
829 * property is not present, the ORB class is found as described in the
832 * @param props the properties, may be <code>null</code>.
834 * @return a newly created functional derivative of this abstract class.
836 public static ORB init(Applet applet, Properties props)
838 String ocn = applet.getParameter(FUNCTIONAL_ORB);
839 String lp = applet.getParameter(LISTENER_PORT);
841 if (ocn==null && lp!=null)
842 ocn = DEFAULT_FOCUSED_ORB;
844 ORB orb = createORB(props, ocn);
845 orb.set_parameters(applet, props);
851 * Creates the working instance of ORB for a standalone application.
853 * By default the built-in fully functional ORB is returned. The ORB class is
854 * found as described in the header of this class.
856 * @param args the parameters, passed to the applications
857 * <code>main(String[] args)</code> method, may be <code>null</code>. The
858 * parameter -org.omg.CORBA.ORBClass <class name> if present, defines the used
859 * ORB implementation class. If this property is not present, the ORB class is
860 * found as described in the class header.
862 * @param props application specific properties, may be <code>null</code>.
864 * @return a newly created functional derivative of this abstract class.
866 public static ORB init(String[] args, Properties props)
871 String orbKey = "-" + FUNCTIONAL_ORB;
872 String lpKey = "-" + LISTENER_PORT;
875 if (args.length >= 2)
877 for (int i = 0; i < args.length - 1; i++)
879 if (args[i].equals(orbKey))
881 if (args[i].equals(lpKey))
886 if (lp != null && ocn == null)
887 ocn = DEFAULT_FOCUSED_ORB;
889 ORB orb = createORB(props, ocn);
891 orb.set_parameters(args, props);
896 * List the initially available CORBA objects (services).
898 * @return a list of services.
900 * @see #resolve_initial_references(String)
902 public abstract String[] list_initial_services();
905 * Find and return the easily accessible CORBA object, addressed
906 * by name. The returned object is typically casted to the more
907 * specific reference using the <code>narrow(Object)</code> method
908 * of its helper. The method resolves the following string values,
909 * returning the working objects:
910 * <table border="1"><tr><th>String</th><th>Object class</th>
911 * <th>Object use</th></tr>
913 * <tr><td>NameService</td><td>{@link org.omg.CosNaming.NamingContextExt}</td>
914 * <td>Finds (usually remote) object by its name.</td></tr>
916 * <tr><td>RootPOA</td><td>{@link org.omg.PortableServer.POA}</td>
917 * <td>Holds the POA tree for this ORB, where since 1.4 all servants
918 * should be connected.</td></tr>
920 * <tr><td>RootPOAManager</td><td>{@link org.omg.PortableServer.POAManager}
921 * </td><td>Regulates (suspends/resumes) the root POA
924 * <tr><td>POACurrent</td><td>{@link org.omg.PortableServer.Current}
925 * </td><td>Informs the current thread about the Id and POA of the
926 * object being currently served (the methods of
927 * <code>Current</code> return different values for
928 * different threads).
931 * <tr><td>CodecFactory</td><td>{@link org.omg.IOP.Codec}</td>
932 * <td>Encodes/decodes IDL data types into/from byte arrays.</td>
935 * <tr><td>DynAnyFactory</td><td>{@link org.omg.DynamicAny.DynAnyFactory}</td>
936 * <td>Creates DynAny's.</td>
939 * <tr><td>PICurrent</td><td>{@link org.omg.PortableInterceptor.Current}</td>
940 * <td>Contains multiple slots where an interceptor can rememeber the
941 * request - specific values between subsequent
942 * calls of the interceptor methods.</td>
947 * @param name the object name.
949 * @throws org.omg.CORBA.ORBPackage.InvalidName if the given name
950 * is not associated with the known object.
952 public abstract Object resolve_initial_references(String name)
953 throws org.omg.CORBA.ORBPackage.InvalidName;
956 * Get the IOR reference string for the given object.
957 * IOR can be compared with the Internet address for a web page,
958 * it provides means to locate the CORBA service on the web.
959 * IOR contains the host address, port number, the object identifier
960 * (key) inside the server, the communication protocol version,
961 * supported charsets and so on.
963 * @param forObject the CORBA object
964 * @return the object IOR representation.
965 * @see #string_to_object(String)
967 public abstract String object_to_string(Object forObject);
970 * This should perform the implementation dependent unit of work in the
973 * This method is part of the support for the distribute use of the
974 * single execution thread.
976 * Same as in Suns releases at least till 1.4 inclusive,
977 * the distribute use of the single thread is not implemented.
978 * Use multiple threads, provided by jre.
980 * The method returns without action.
982 public void perform_work()
987 * Checks if the ORB needs the main thread to perform some work.
988 * The method should return true if the ORB needs the main thread,
989 * and false if it does not.
991 * This method is part of the support for the distribute use of the
992 * single execution thread.
994 * Same as in Suns releases at least till 1.4 inclusive,
995 * the distributed use of the single thread is not implemented.
996 * Use multiple threads, provided by jre.
998 * @return false, always.
1000 public boolean work_pending()
1006 * <p>Find and return the CORBA object, addressed by the given
1007 * string representation. The object can be (an usually is)
1008 * located on a remote computer, possibly running a different
1009 * (not necessary java) CORBA implementation. The returned
1010 * object is typically casted to the more specific reference
1011 * using the <code>narrow(Object)</code> method of its helper.
1013 * This function supports the following input formats:<br>
1014 * 1. IOR reference (<b>ior:</b>nnnnn ..), usually computer generated.<br>
1015 * 2. <b>corbaloc:</b>[<b>iiop</b>][version.subversion<b>@</b>]<b>:</b>host[<b>:</b>port]<b>/</b><i>key</i>
1016 * defines similar information as IOR reference, but is more human readable.
1017 * This type of reference may also contain multiple addresses (see
1018 * OMG documentation for complete format).<br>
1019 * 3. <b>corbaloc:rir:/</b><i>name</i> defines internal reference on this
1020 * ORB that is resolved using {@link #resolve_initial_references}, passing
1021 * the given <i>name</i> as parameter.<br>
1022 * 4. <b>corbaname:rir:#</b><i>name</i> states that the given <i>name</i>
1023 * must be resolved using the naming service, default for this ORB.<br>
1024 * 5. <b>corbaname:</b>[<b>iiop</b>][version.subversion<b>@</b>]<b>:</b>host[<b>:</b>port]<b>#</b><i>name</i>
1025 * states that the <i>name</i> must be resolved using the naming service
1026 * that runs on the given host at the given port. The ORB expects to find
1027 * there the {@link org.omg.CosNaming.NamingContext} under the key
1029 * 7. file://[file name] Read the object definition string from the
1031 * 8. http://[url] Read the object definition string from the provided
1033 * 9. ftp://[url] Read the object definition string from the provided
1036 * <p>The default port is always 2809. The default iiop version is 1.0
1037 * that now may not always be supported, so we would recommend to specify
1038 * the version explicitly.</p>
1040 * The examples of the corbaloc and corbaname addresses:<br>
1041 * corbaname:rir:#xobj - ask local naming service for "xobj".<br>
1042 * corbaname:rir:/NameService#xobj - same (long form).<br>
1043 * corbaname:iiop:1.2@localhost:900#xobj - same, assuming that the naming
1044 * service runs at port 900 on the local host and supports iiop 1.2.<br>
1045 * corbaname:iiop:localhost#xobj - same, assuming that the naming
1046 * service runs at port 2809 on the local host and supports iiop 1.0.<br>
1047 * corbaloc::gnu.xxx.yy/Prod/TradingService - the object exists on the
1048 * host gnu.xxx.yy, port 2809 having the key "Prod/TradingService". Its ORB
1049 * supports iiop 1.0.<br>
1050 * corbaloc::gnu.xxx.yy/Prod/TradingService:801 - the object exists on the
1051 * host gnu.xxx.yy, port 801 having the key "Prod/TradingService". Its ORB
1052 * supports iiop 1.0 (iiop keyword ommitted).<br>
1053 * corbaloc:iiop:1.1@gnu.xxx.yy/Prod/TradingService - the object exists on the
1054 * host gnu.xxx.yy, port 801 having the key "Prod/TradingService". Its ORB
1055 * supports iiop 1.1.<br>
1056 * corbaloc:rir:/NameService - the default naming service.
1058 * @param IOR the object IOR representation string.
1060 * @return the found CORBA object.
1062 * @throws BAD_PARAM if the string being parsed is invalid.
1063 * @throws DATA_CONVERSION if the string being parsed contains unsupported
1064 * prefix or protocol.
1066 * @see #object_to_string(org.omg.CORBA.Object)
1068 public abstract Object string_to_object(String IOR);
1071 * Start listening on the input socket. This method
1072 * blocks the current thread until {@link #shutdown(boolean)}
1073 * is called and shutdown process is completed.
1080 * Shutdown the ORB server.
1082 * @param wait_for_completion if true, the current thread is
1083 * suspended untile the shutdown process is complete.
1085 public void shutdown(boolean wait_for_completion)
1090 * Destroy this server, releasing the occupied resources.
1091 * The default method returns without action.
1093 public void destroy()
1098 * Set the ORB parameters. This method is normally called from
1099 * {@link #init(String[], Properties)}.
1101 * @param para the parameters, that were passed as the parameters
1102 * to the <code>main(String[] args)</code> method of the current standalone
1105 * @param props application specific properties that were passed
1106 * as a second parameter in {@link #init(String[], Properties)}).
1107 * Can be <code>null</code>.
1109 protected abstract void set_parameters(String[] para, Properties props);
1112 * Set the ORB parameters. This method is normally called from
1113 * {@link #init(Applet, Properties)}.
1115 * @param app the current applet.
1117 * @param props application specific properties, passed as the second
1118 * parameter in {@link #init(Applet, Properties)}.
1119 * Can be <code>null</code>.
1121 protected abstract void set_parameters(Applet app, Properties props);
1124 * Get the property with the given name, searching in the standard
1125 * places for the ORB properties.
1127 private static String getCumulatedProperty(Properties props, String property)
1129 String orb_cn = null;
1132 orb_cn = props.getProperty(property, null);
1135 orb_cn = System.getProperty(property, null);
1138 orb_cn = checkFile(property, "user.home", null);
1141 orb_cn = checkFile(property, "java.home", "lib");
1147 * Check if the property is defined in the existsting file orb.properties.
1149 * @param property the property
1150 * @param dir the system property, defining the folder where the
1151 * file could be expected.
1152 * @param subdir subfolder where to look for the file.
1154 * @return the property value, null if not found or file does not exist.
1156 private static String checkFile(String property, String dir, String subdir)
1160 File f = new File(dir);
1165 f = new File(f, subdir);
1167 f = new File(f, "orb.properties");
1172 Properties p = new Properties();
1173 p.load(new BufferedInputStream(new FileInputStream(f)));
1175 return p.getProperty(property, null);
1177 catch (IOException ex)
1184 * Create ORB when its name is possibly known.
1186 * @param props properties, possibly containing the ORB name.
1187 * @param orbClassName the direct ORB class name, overriding other possible
1188 * locations, or null if not specified.
1190 private static ORB createORB(Properties props, String orbClassName)
1194 if (orbClassName == null)
1196 orbClassName = getCumulatedProperty(props, FUNCTIONAL_ORB);
1198 if (orbClassName == null)
1200 String lp = getCumulatedProperty(props, LISTENER_PORT);
1202 orbClassName = DEFAULT_FOCUSED_ORB;
1204 orbClassName = DEFAULT_FUNCTIONAL_ORB;
1210 orb = (ORB) ObjectCreator.forName(orbClassName).newInstance();
1212 catch (ClassNotFoundException ex)
1214 noORB(orbClassName, ex);
1216 catch (IllegalAccessException ex)
1218 noORB(orbClassName, ex);
1220 catch (InstantiationException ex)
1222 noORB(orbClassName, ex);
1229 * Throw the runtime exception.
1231 * @param orb_c the ORB class name.
1232 * @param why the explaining chained exception.
1234 private static void noORB(String orb_c, Throwable why)
1236 throw new RuntimeException("The ORB " + orb_c + " cannot be instantiated.",