1 <HTML>
2 <HEAD>
3 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
4 <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en]C-gatewaynet (WinNT; U)
5 [Netscape]">
6 <TITLE>package</TITLE>
7 <!--
8 /*
9 * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
10 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11 *
12 * This code is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License version 2 only, as
14 * published by the Free Software Foundation. Oracle designates this
15 * particular file as subject to the "Classpath" exception as provided
16 * by Oracle in the LICENSE file that accompanied this code.
17 *
18 * This code is distributed in the hope that it will be useful, but WITHOUT
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * version 2 for more details (a copy is included in the LICENSE file that
22 * accompanied this code).
23 *
24 * You should have received a copy of the GNU General Public License version
25 * 2 along with this work; if not, write to the Free Software Foundation,
26 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 *
28 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
29 * or visit www.oracle.com if you need additional information or have any
56 <H2>
57 The <tt>ORB</tt> Class</H2>
58
59 <P>An ORB handles (or brokers) method invocations between a client and
60 the method's implementation on a server. Because the client and server
61 may be anywhere on a network, and because the invocation and implementation
62 may be written in different programming languages, an ORB does a great
63 deal of work behind the scenes to accomplish this communication.
64
65 <P>Most of what an ORB does is completely transparent to the user, and a major
66 portion of the <TT>CORBA</TT> package consists of classes used by the ORB
67 behind the scenes. The result is that most programmers will use only a
68 small part of this package directly. In fact, most programmers will use
69 only a few methods from the <TT>ORB</TT> class, some exceptions, and
70 occasionally,
71 a holder class.
72 <H3>
73 <TT>ORB</TT> Methods</H3>
74
75 <P>Before an application can enter the CORBA environment, it must first:
76 <P>
77 <UL>
78 <LI>Be initialized into the ORB and possibly the object adapter (POA) environments.
79 <LI>Get references to ORB object (for use in future ORB operations)
80 and perhaps other objects (including the root POA or some Object Adapter objects).
81 </UL>
82 <P>The following operations are provided to initialize applications and obtain
83 the appropriate object references:
84 <P>
85 <UL>
86 <LI>Operations providing access to the ORB, which are discussed in this
87 section.
88 <LI>Operations providing access to Object Adapters, Interface Repository,
89 Naming Service, and other Object Services. These operations are described
90 in <a href="#adv"><em>Other Classes</em></a>.
91 </UL>
92 <P>
93 When an application requires a CORBA environment it needs a mechanism to
94 get an ORB object reference and possibly an OA object reference
95 (such as the root POA). This serves two purposes. First, it initializes
96 an application into the ORB and OA environments. Second, it returns the
97 ORB object reference and the OA object reference to the application
98 for use in future ORB and OA operations.
99
100 <P>In order to obtain an ORB object reference, applications call
101 the <tt>ORB.init</tt> operation. The parameters to the call can comprise an
102 identifier for the ORB for which the object reference is required,
103 and an arg_list, which is used to allow environment-specific data to be
104 passed into the call.
105
106 <P>These are the <TT>ORB</TT> methods
107 that provide access to the ORB:
108 <UL>
109 <LI>
110 <TT><bold>init</bold>()</TT>
111
112 <LI>
113 <TT><bold>init</bold>(String [] args, Properties props)</TT>
114
115 <LI>
116 <TT><bold>init</bold>(Applet app, Properties props)</TT>
117 </UL>
118
119 <P>Using the <tt>init()</tt> method without parameters initiates
120 a singleton ORB, which can only
121 give typecode creation <tt>any</tt>s needed in code generated
122 in Helper classes by <tt>idlj</tt>.
123
124 <P>Applications require a portable means by which to obtain their
125 initial object references. References are required for the root
126 POA, POA Current, Interface Repository, and various Object Services
127 instances. The functionality required by the application is similar
128 to that provided by the Naming Service. However, the OMG does not
129 want to mandate that the Naming Service be made available to all
130 applications in order that they may be portably initialized.
131 Consequently, the operations shown in this section provide a
132 simplified, local version of the Naming Service that applications
133 can use to obtain a small, defined set of object references which
134 are essential to its operation. Because only a small well-defined
135 set of objects are expected with this mechanism, the naming context
136 can be flattened to be a single-level name space. This simplification
137 results in only two operations being defined to achieve the functionality
138 required.
139
140 <P>Initial references are obtained via two operations provided in
141 the ORB object interface, providing facilities to list and
142 resolve initial object references. These are:
143 <UL>
144 <LI>
145 <TT><bold>resolve_initial_references</bold>(String name)</TT>
146 <LI>
147 <TT><bold>list_initial_services</bold>()</TT>
148 <LI>
149 <TT><bold>register_initial_reference</bold>(String id,
150 org.omg.CORBA.Object obj)</TT>
151 </UL>
152
153 <P>An example that uses some of these methods is <A
154 HREF="{@docRoot}/../technotes/guides/idl/GShome.html">
155 <em>Getting Started with Java IDL</em></A>.
156
157 <H2>
158 Exceptions</H2>
159 Exceptions in Java IDL are similar to those in any code written in the
160 Java programming language. If a method is defined to throw an exception,
161 then any code using that method must have a <TT>try</TT>/<TT>catch</TT>
162 block and handle that exception when it is thrown.
163
164 <P>The documentation on <A
165 HREF="{@docRoot}/../technotes/guides/idl/jidlExceptions.html"><em>Java
166 IDL exceptions</em></A> has more information and explains the difference between
167 system exceptions and user-defined exceptions.
168
169 <P>The following is a list of the system exceptions (which are unchecked
261 the <tt><a href="portable/Streamable.html">org.omg.CORBA.portable.Streamable</a>
262 </tt> interface.
263
264 <P>Holder classes are named by appending "Holder" to the name of the type.
265 The name of the type refers to its name in the Java programming language. For
266 example, a holder class for the interface named <tt>Account</tt> in the Java programming
267 language would be named <tt>AccountHolder</tt>.
268
269
270 <P>Holder classes are available for all of the basic IDL
271 datatypes in the <tt>org.omg.CORBA</tt> package. So, for example,
272 there are already-defined classes for <tt>LongHolder</tt>, <tt>ShortHolder</tt>,
273 <tt>FloatHolder</tt>, and so on. Classes are also generated for
274 all named user-defined IDL types except those defined by <tt>typedefs</tt>.
275 (Note that in this context user defined includes types that are
276 defined in OMG specifications such as those for the Interface
277 Repository, and other OMG services.)
278
279
280 <P>Each holder class has:
281 <P>
282 <UL>
283 <LI>a constructor from an instance
284 <LI>a default constructor
285 <LI>a public instance member, <tt>value</tt> which is the typed value.
286 <LI>a method for reading an input stream and assigning the contents to the
287 type's <tt>value</tt> field
288 <LI>a method for writing the value of the <tt>value</tt> field to an output stream
289 <LI>a method for getting the typecode of the type
290 </UL>
291
292 <P>The default constructor sets the value field to the default value for the
293 type as defined by the Java language:
294 <P>
295 <UL>
296 <LI><tt>false</tt> for boolean
297 <LI><tt>0</tt> for numeric and char types
298 <LI><tt>null</tt> for strings and object references
299 </UL>
300
301
302
303 <P>
304 As an example, if the interface <code>Account</code>, defined in OMG IDL,
305 were mapped to the Java programming language, the following holder class
306 would be generated:
307 <PRE>
308 public final class AccountHolder implements
309 org.omg.CORBA.portable.Streamable
310 {
311 // field that holds an Account object
312 public Account value = null;
313
314 // default constructor
374 </TT> <TT>ServiceInformationHolder
375 </TT> <TT>ShortHolder
376 </TT> <TT>ShortSeqHolder
377 </TT> <TT>StringHolder
378 </TT> <TT>StringSeqHolder
379 </TT> <TT>TypeCodeHolder
380 </TT> <TT>ULongLongSeqHolder
381 </TT> <TT>ULongSeqHolder
382 </TT> <TT>UnknownUserExceptionHolder
383 </TT> <TT>UShortSeqHolder
384 </TT> <TT>ValueBaseHolder
385 </TT> <TT>WCharSeqHolder
386 </TT> <TT>WrongTransactionHolder
387 </TT> <TT>WStringSeqHolder</TT>
388
389 </PRE>
390
391 <h2>Helper Classes </h2>
392 <P>Helper files supply several static methods needed to manipulate the type.
393 These include:
394 <P>
395 <UL>
396 <LI><tt>Any</tt> insert and extract operations for the type
397 <LI>getting the repository id
398 <LI>getting the typecode
399 <LI>reading and writing the type from and to a stream
400 <LI>implement the <code>ValueHelper</code> interface (if it is a user-defined
401 value type)
402 </UL>
403
404 <P>The helper class for a mapped IDL interface or abstract interface
405 also include narrow operation(s). The static narrow method allows
406 an <tt>org.omg.CORBA.Object</tt> to be narrowed to the object reference
407 of a more specific type. The IDL exception <tt>CORBA.BAD_PARAM</tt>
408 is thrown if the narrow fails because the object reference does not
409 support the requested type. A different system exception is raised
410 to indicate other kinds of errors. Trying to narrow a <tt>null</tt> will always
411 succeed with a return value of <tt>null</tt>. Generally, the only helper method an application programmer uses is
412 the <code>narrow</code> method. The other methods are normally used behind
413 the scenes and are transparent to the programmer.
414
438 or a <code>java.lang.Object</code> object. This object must be cast to its
439 more specific type before it can be operated on. For example, an
440 <code>Account</code> object will be returned as a generic object and must
441 be narrowed to an <code>Account</code> object so that <code>Account</code>
442 methods may be called on it.
443 <P>
444 The <code>narrow</code> method has two forms, one that takes an
445 <code>org.omg.CORBA.Object</code> object and one that takes a
446 <code>java.lang.Object</code> object. Whether the interface is abstract or
447 not determines which <code>narrow</code> method its helper class will provide.
448 The helper class for an interface
449 that is not abstract will have a <code>narrow</code> method that takes a CORBA
450 object, whereas the <code>narrow</code> method for an interface that is abstract
451 will
452 take an object in the Java programming language. The helper class for a
453 non-abstract interface that has at least one abstract base interface will provide
454 both versions of the <code>narrow</code> method.
455 <P>The <A HREF="{@docRoot}/../technotes/guides/idl/jidlExample.html"><em>Hello World</em></A>
456 tutorial uses a <tt>narrow</tt> method that looks
457 like this:
458 <P>
459 <PRE>
460 // create and initialize the ORB
461 ORB orb = ORB.init(args, null);
462
463 // get the root naming context
464 org.omg.CORBA.Object objRef =
465 orb.resolve_initial_references("NameService");
466 // Use NamingContextExt instead of NamingContext. This is
467 // part of latest Inter-Operable naming Service.
468 NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
469
470 // resolve the Object Reference in Naming
471 String name = "Hello";
472 helloImpl = HelloHelper.narrow(ncRef.resolve_str(name));
473 </PRE>
474
475 <a name="basic"></a>
476 <h3>Example of a Basic Helper Class</h3>
477 A basic helper class, for purposes of this explanation, is one with
478 the methods that are provided by every helper class, plus a <code>narrow</code>
537 // converts (narrows) an Object to an Account object
538 public static Account narrow (org.omg.CORBA.Object obj)
539 {
540 if (obj == null)
541 return null;
542 else if (obj instanceof Account)
543 return (Account)obj;
544 else if (!obj._is_a (id ()))
545 throw new org.omg.CORBA.BAD_PARAM ();
546 else
547 {
548 org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
549 _AccountStub stub = new _AccountStub ();
550 stub._set_delegate(delegate);
551 return stub;
552 }
553 }
554
555 }
556 </PRE>
557 <P>
558
559 <h3>Value Type Helper Classes</h3>
560 A helper class for a value type includes different renderings of
561 the same methods generated for non-value type methods. The main difference
562 is that value types are types that can be
563 passed by value as parameters or return values of a method, which means that
564 they must be serializable.
565 <P>Assuming that <code>Address</code> is a value type, the
566 <code>AddressHelper</code> class will look like this:
567 <pre>
568 abstract public class AddressHelper
569 {
570 private static String _id = "IDL:Address:1.0";
571
572 // same as for non-value type
573 public static void insert (org.omg.CORBA.Any a, Address that)
574 {
575 org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
576 a.type (type ());
577 write (out, that);
827 <LI>
828 <TT>CTX_RESTRICT_SCOPE</TT>
829 </UL>
830
831 <H2>
832 Interface Repository Interfaces and Classes</H2>
833 A fourth group contains the Interface Repository interfaces and classes,
834 which are generated by the <TT>idlj</TT> compiler from the OMG IDL
835 interface <TT>ir.idl</TT>. The purpose of the Interface Repository is to
836 identify the interfaces stored in it so that they can be accessed by an
837 ORB. Each module, type, interface, attribute, operation, parameter, exception,
838 constant, and so on is described completely by the Interface Repository
839 API.
840
841 <P>An ORB does not require that there be an interface repository, and Java
842 IDL does not include one. Even though this release does not include an
843 implementation of an interface repository, the following IR classes and
844 interfaces have been included for the purpose of creating typecodes (see
845 create_value_tc, create_struct_tc, create_union_tc and create_exception_tc
846 methods in interface org.omg.CORBA.ORB):
847 <BR>&nbs
848 <UL>
849 <LI>
850 IRObject
851
852 <LI>
853 IDLType
854
855 <LI>
856 DefinitionKind
857
858 <LI>
859 StructMember
860
861 <LI>
862 UnionMember
863
864 <LI>
865 ValueMember
866 </UL>
867 <!-- End Page Data -->
876
877
878
879
880 <P><A NAME="unimpl"></A>
881 <H1>
882 CORBA Features Not Implemented in Java IDL</H1>
883
884 <P>Some of the API included in <TT>org.omg</TT> subpackages is provided for
885 conformance with the current OMG CORBA specification but is not implemented
886 in Sun's release of the JDK<SUP><FONT SIZE=-2>TM</FONT></SUP>. This enables
887 other JDK licensees to provide implementations of this API in standard
888 extensions and products.
889
890 <P><A NAME="NO_IMPLEMENT"></A>
891 <h2>Features That Throw NO_IMPLEMENT</h2>
892
893 <P>Some of the API included in <TT>org.omg</TT> subpackages throw
894 <tt>NO_IMPLEMENT</tt> exceptions for various reasons. Among these reasons
895 are:
896 <P>
897 <UL>
898 <LI>In some cases, for example <tt>LocalObject</tt>, the complete
899 implementation according to the specification indicates that
900 these API should throw <tt>NO_IMPLEMENT</tt>.
901 <P>
902 <LI>In most cases, for example methods in <tt>ORB.java</tt>,
903 methods that throw
904 <tt>NO_IMPLEMENT</tt> are actually implemented in subclasses
905 elsewhere in the ORB code.
906 <P>
907 <LI>In some cases, for example <tt>_get_interface_def()</tt>
908 and <tt>_get_interface</tt>, API are really not yet implemented.
909 </UL>
910
911
912
913
914 <H2>
915 General Summary of Features or API Not Implemented in This Release:</H2>
916
917 <UL>
918 <LI>
919 Interface Repository. An Interface Repository is not required for normal
920 operation of Java IDL.
921
922 <LI>
923 Java IDL does not support <TT>long double</TT>.
924
925
926 <LI>
|
1 <HTML>
2 <HEAD>
3 <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
4 <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en]C-gatewaynet (WinNT; U)
5 [Netscape]">
6 <TITLE>package</TITLE>
7 <!--
8 /*
9 * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
10 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11 *
12 * This code is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License version 2 only, as
14 * published by the Free Software Foundation. Oracle designates this
15 * particular file as subject to the "Classpath" exception as provided
16 * by Oracle in the LICENSE file that accompanied this code.
17 *
18 * This code is distributed in the hope that it will be useful, but WITHOUT
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * version 2 for more details (a copy is included in the LICENSE file that
22 * accompanied this code).
23 *
24 * You should have received a copy of the GNU General Public License version
25 * 2 along with this work; if not, write to the Free Software Foundation,
26 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 *
28 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
29 * or visit www.oracle.com if you need additional information or have any
56 <H2>
57 The <tt>ORB</tt> Class</H2>
58
59 <P>An ORB handles (or brokers) method invocations between a client and
60 the method's implementation on a server. Because the client and server
61 may be anywhere on a network, and because the invocation and implementation
62 may be written in different programming languages, an ORB does a great
63 deal of work behind the scenes to accomplish this communication.
64
65 <P>Most of what an ORB does is completely transparent to the user, and a major
66 portion of the <TT>CORBA</TT> package consists of classes used by the ORB
67 behind the scenes. The result is that most programmers will use only a
68 small part of this package directly. In fact, most programmers will use
69 only a few methods from the <TT>ORB</TT> class, some exceptions, and
70 occasionally,
71 a holder class.
72 <H3>
73 <TT>ORB</TT> Methods</H3>
74
75 <P>Before an application can enter the CORBA environment, it must first:
76 <UL>
77 <LI>Be initialized into the ORB and possibly the object adapter (POA) environments.
78 <LI>Get references to ORB object (for use in future ORB operations)
79 and perhaps other objects (including the root POA or some Object Adapter objects).
80 </UL>
81 <P>The following operations are provided to initialize applications and obtain
82 the appropriate object references:
83 <UL>
84 <LI>Operations providing access to the ORB, which are discussed in this
85 section.
86 <LI>Operations providing access to Object Adapters, Interface Repository,
87 Naming Service, and other Object Services. These operations are described
88 in <a href="#adv"><em>Other Classes</em></a>.
89 </UL>
90 <P>
91 When an application requires a CORBA environment it needs a mechanism to
92 get an ORB object reference and possibly an OA object reference
93 (such as the root POA). This serves two purposes. First, it initializes
94 an application into the ORB and OA environments. Second, it returns the
95 ORB object reference and the OA object reference to the application
96 for use in future ORB and OA operations.
97
98 <P>In order to obtain an ORB object reference, applications call
99 the <tt>ORB.init</tt> operation. The parameters to the call can comprise an
100 identifier for the ORB for which the object reference is required,
101 and an arg_list, which is used to allow environment-specific data to be
102 passed into the call.
103
104 <P>These are the <TT>ORB</TT> methods
105 that provide access to the ORB:
106 <UL>
107 <LI>
108 <TT><b>init</b>()</TT>
109
110 <LI>
111 <TT><b>init</b>(String [] args, Properties props)</TT>
112
113 <LI>
114 <TT><b>init</b>(Applet app, Properties props)</TT>
115 </UL>
116
117 <P>Using the <tt>init()</tt> method without parameters initiates
118 a singleton ORB, which can only
119 give typecode creation <tt>any</tt>s needed in code generated
120 in Helper classes by <tt>idlj</tt>.
121
122 <P>Applications require a portable means by which to obtain their
123 initial object references. References are required for the root
124 POA, POA Current, Interface Repository, and various Object Services
125 instances. The functionality required by the application is similar
126 to that provided by the Naming Service. However, the OMG does not
127 want to mandate that the Naming Service be made available to all
128 applications in order that they may be portably initialized.
129 Consequently, the operations shown in this section provide a
130 simplified, local version of the Naming Service that applications
131 can use to obtain a small, defined set of object references which
132 are essential to its operation. Because only a small well-defined
133 set of objects are expected with this mechanism, the naming context
134 can be flattened to be a single-level name space. This simplification
135 results in only two operations being defined to achieve the functionality
136 required.
137
138 <P>Initial references are obtained via two operations provided in
139 the ORB object interface, providing facilities to list and
140 resolve initial object references. These are:
141 <UL>
142 <LI>
143 <TT><b>resolve_initial_references</b>(String name)</TT>
144 <LI>
145 <TT><b>list_initial_services</b>()</TT>
146 <LI>
147 <TT><b>register_initial_reference</b>(String id,
148 org.omg.CORBA.Object obj)</TT>
149 </UL>
150
151 <P>An example that uses some of these methods is <A
152 HREF="{@docRoot}/../technotes/guides/idl/GShome.html">
153 <em>Getting Started with Java IDL</em></A>.
154
155 <H2>
156 Exceptions</H2>
157 Exceptions in Java IDL are similar to those in any code written in the
158 Java programming language. If a method is defined to throw an exception,
159 then any code using that method must have a <TT>try</TT>/<TT>catch</TT>
160 block and handle that exception when it is thrown.
161
162 <P>The documentation on <A
163 HREF="{@docRoot}/../technotes/guides/idl/jidlExceptions.html"><em>Java
164 IDL exceptions</em></A> has more information and explains the difference between
165 system exceptions and user-defined exceptions.
166
167 <P>The following is a list of the system exceptions (which are unchecked
259 the <tt><a href="portable/Streamable.html">org.omg.CORBA.portable.Streamable</a>
260 </tt> interface.
261
262 <P>Holder classes are named by appending "Holder" to the name of the type.
263 The name of the type refers to its name in the Java programming language. For
264 example, a holder class for the interface named <tt>Account</tt> in the Java programming
265 language would be named <tt>AccountHolder</tt>.
266
267
268 <P>Holder classes are available for all of the basic IDL
269 datatypes in the <tt>org.omg.CORBA</tt> package. So, for example,
270 there are already-defined classes for <tt>LongHolder</tt>, <tt>ShortHolder</tt>,
271 <tt>FloatHolder</tt>, and so on. Classes are also generated for
272 all named user-defined IDL types except those defined by <tt>typedefs</tt>.
273 (Note that in this context user defined includes types that are
274 defined in OMG specifications such as those for the Interface
275 Repository, and other OMG services.)
276
277
278 <P>Each holder class has:
279 <UL>
280 <LI>a constructor from an instance
281 <LI>a default constructor
282 <LI>a public instance member, <tt>value</tt> which is the typed value.
283 <LI>a method for reading an input stream and assigning the contents to the
284 type's <tt>value</tt> field
285 <LI>a method for writing the value of the <tt>value</tt> field to an output stream
286 <LI>a method for getting the typecode of the type
287 </UL>
288
289 <P>The default constructor sets the value field to the default value for the
290 type as defined by the Java language:
291 <UL>
292 <LI><tt>false</tt> for boolean
293 <LI><tt>0</tt> for numeric and char types
294 <LI><tt>null</tt> for strings and object references
295 </UL>
296
297
298
299 <P>
300 As an example, if the interface <code>Account</code>, defined in OMG IDL,
301 were mapped to the Java programming language, the following holder class
302 would be generated:
303 <PRE>
304 public final class AccountHolder implements
305 org.omg.CORBA.portable.Streamable
306 {
307 // field that holds an Account object
308 public Account value = null;
309
310 // default constructor
370 </TT> <TT>ServiceInformationHolder
371 </TT> <TT>ShortHolder
372 </TT> <TT>ShortSeqHolder
373 </TT> <TT>StringHolder
374 </TT> <TT>StringSeqHolder
375 </TT> <TT>TypeCodeHolder
376 </TT> <TT>ULongLongSeqHolder
377 </TT> <TT>ULongSeqHolder
378 </TT> <TT>UnknownUserExceptionHolder
379 </TT> <TT>UShortSeqHolder
380 </TT> <TT>ValueBaseHolder
381 </TT> <TT>WCharSeqHolder
382 </TT> <TT>WrongTransactionHolder
383 </TT> <TT>WStringSeqHolder</TT>
384
385 </PRE>
386
387 <h2>Helper Classes </h2>
388 <P>Helper files supply several static methods needed to manipulate the type.
389 These include:
390 <UL>
391 <LI><tt>Any</tt> insert and extract operations for the type
392 <LI>getting the repository id
393 <LI>getting the typecode
394 <LI>reading and writing the type from and to a stream
395 <LI>implement the <code>ValueHelper</code> interface (if it is a user-defined
396 value type)
397 </UL>
398
399 <P>The helper class for a mapped IDL interface or abstract interface
400 also include narrow operation(s). The static narrow method allows
401 an <tt>org.omg.CORBA.Object</tt> to be narrowed to the object reference
402 of a more specific type. The IDL exception <tt>CORBA.BAD_PARAM</tt>
403 is thrown if the narrow fails because the object reference does not
404 support the requested type. A different system exception is raised
405 to indicate other kinds of errors. Trying to narrow a <tt>null</tt> will always
406 succeed with a return value of <tt>null</tt>. Generally, the only helper method an application programmer uses is
407 the <code>narrow</code> method. The other methods are normally used behind
408 the scenes and are transparent to the programmer.
409
433 or a <code>java.lang.Object</code> object. This object must be cast to its
434 more specific type before it can be operated on. For example, an
435 <code>Account</code> object will be returned as a generic object and must
436 be narrowed to an <code>Account</code> object so that <code>Account</code>
437 methods may be called on it.
438 <P>
439 The <code>narrow</code> method has two forms, one that takes an
440 <code>org.omg.CORBA.Object</code> object and one that takes a
441 <code>java.lang.Object</code> object. Whether the interface is abstract or
442 not determines which <code>narrow</code> method its helper class will provide.
443 The helper class for an interface
444 that is not abstract will have a <code>narrow</code> method that takes a CORBA
445 object, whereas the <code>narrow</code> method for an interface that is abstract
446 will
447 take an object in the Java programming language. The helper class for a
448 non-abstract interface that has at least one abstract base interface will provide
449 both versions of the <code>narrow</code> method.
450 <P>The <A HREF="{@docRoot}/../technotes/guides/idl/jidlExample.html"><em>Hello World</em></A>
451 tutorial uses a <tt>narrow</tt> method that looks
452 like this:
453 <PRE>
454 // create and initialize the ORB
455 ORB orb = ORB.init(args, null);
456
457 // get the root naming context
458 org.omg.CORBA.Object objRef =
459 orb.resolve_initial_references("NameService");
460 // Use NamingContextExt instead of NamingContext. This is
461 // part of latest Inter-Operable naming Service.
462 NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
463
464 // resolve the Object Reference in Naming
465 String name = "Hello";
466 helloImpl = HelloHelper.narrow(ncRef.resolve_str(name));
467 </PRE>
468
469 <a name="basic"></a>
470 <h3>Example of a Basic Helper Class</h3>
471 A basic helper class, for purposes of this explanation, is one with
472 the methods that are provided by every helper class, plus a <code>narrow</code>
531 // converts (narrows) an Object to an Account object
532 public static Account narrow (org.omg.CORBA.Object obj)
533 {
534 if (obj == null)
535 return null;
536 else if (obj instanceof Account)
537 return (Account)obj;
538 else if (!obj._is_a (id ()))
539 throw new org.omg.CORBA.BAD_PARAM ();
540 else
541 {
542 org.omg.CORBA.portable.Delegate delegate = ((org.omg.CORBA.portable.ObjectImpl)obj)._get_delegate ();
543 _AccountStub stub = new _AccountStub ();
544 stub._set_delegate(delegate);
545 return stub;
546 }
547 }
548
549 }
550 </PRE>
551
552 <h3>Value Type Helper Classes</h3>
553 A helper class for a value type includes different renderings of
554 the same methods generated for non-value type methods. The main difference
555 is that value types are types that can be
556 passed by value as parameters or return values of a method, which means that
557 they must be serializable.
558 <P>Assuming that <code>Address</code> is a value type, the
559 <code>AddressHelper</code> class will look like this:
560 <pre>
561 abstract public class AddressHelper
562 {
563 private static String _id = "IDL:Address:1.0";
564
565 // same as for non-value type
566 public static void insert (org.omg.CORBA.Any a, Address that)
567 {
568 org.omg.CORBA.portable.OutputStream out = a.create_output_stream ();
569 a.type (type ());
570 write (out, that);
820 <LI>
821 <TT>CTX_RESTRICT_SCOPE</TT>
822 </UL>
823
824 <H2>
825 Interface Repository Interfaces and Classes</H2>
826 A fourth group contains the Interface Repository interfaces and classes,
827 which are generated by the <TT>idlj</TT> compiler from the OMG IDL
828 interface <TT>ir.idl</TT>. The purpose of the Interface Repository is to
829 identify the interfaces stored in it so that they can be accessed by an
830 ORB. Each module, type, interface, attribute, operation, parameter, exception,
831 constant, and so on is described completely by the Interface Repository
832 API.
833
834 <P>An ORB does not require that there be an interface repository, and Java
835 IDL does not include one. Even though this release does not include an
836 implementation of an interface repository, the following IR classes and
837 interfaces have been included for the purpose of creating typecodes (see
838 create_value_tc, create_struct_tc, create_union_tc and create_exception_tc
839 methods in interface org.omg.CORBA.ORB):
840 <BR>
841 <UL>
842 <LI>
843 IRObject
844
845 <LI>
846 IDLType
847
848 <LI>
849 DefinitionKind
850
851 <LI>
852 StructMember
853
854 <LI>
855 UnionMember
856
857 <LI>
858 ValueMember
859 </UL>
860 <!-- End Page Data -->
869
870
871
872
873 <P><A NAME="unimpl"></A>
874 <H1>
875 CORBA Features Not Implemented in Java IDL</H1>
876
877 <P>Some of the API included in <TT>org.omg</TT> subpackages is provided for
878 conformance with the current OMG CORBA specification but is not implemented
879 in Sun's release of the JDK<SUP><FONT SIZE=-2>TM</FONT></SUP>. This enables
880 other JDK licensees to provide implementations of this API in standard
881 extensions and products.
882
883 <P><A NAME="NO_IMPLEMENT"></A>
884 <h2>Features That Throw NO_IMPLEMENT</h2>
885
886 <P>Some of the API included in <TT>org.omg</TT> subpackages throw
887 <tt>NO_IMPLEMENT</tt> exceptions for various reasons. Among these reasons
888 are:
889 <UL>
890 <LI>In some cases, for example <tt>LocalObject</tt>, the complete
891 implementation according to the specification indicates that
892 these API should throw <tt>NO_IMPLEMENT</tt>.
893
894 <LI>In most cases, for example methods in <tt>ORB.java</tt>,
895 methods that throw
896 <tt>NO_IMPLEMENT</tt> are actually implemented in subclasses
897 elsewhere in the ORB code.
898
899 <LI>In some cases, for example <tt>_get_interface_def()</tt>
900 and <tt>_get_interface</tt>, API are really not yet implemented.
901 </UL>
902
903
904
905
906 <H2>
907 General Summary of Features or API Not Implemented in This Release:</H2>
908
909 <UL>
910 <LI>
911 Interface Repository. An Interface Repository is not required for normal
912 operation of Java IDL.
913
914 <LI>
915 Java IDL does not support <TT>long double</TT>.
916
917
918 <LI>
|