|
This is a document that attempts to answer many of the questions you may have about Java IDL. We will continue to update this document with your questions as we receive them. If you do not find your question answered here, send email to javaidl@eng.sun.com.
What is the thread model supported by the JDK 1.4 CORBA implementation?
Can I use the Java IDL ORB with a C++ CORBA server? (interoperability)
What is the difference between the idltojava compiler and the idlj compiler?
What are my options for developing CORBA applications using Java?
You can download the idltojava compiler for JDK 1.2 from htt p://developer.java.sun.com/developer/earlyAccess/jdk12/idltojava.html. However, I highly recommend that you consider downloading Java 2 Platform, Standard Edition (J2SE), version 1.4, which includes the latest version of the IDL-to-Java compiler, idlj. When J2SE is installed, idlj will be located in the bin directory.
Many of the problems we have seen related to running the idltojava compiler can be fixed by using the latest version of the IDL-to-Java compiler, idlj, which is available with the download of the JavaTM 2 Platform, Standard Edition, v1.4.
The idltojava compiler in JDK 1.2 is hard-coded to use a default preprocessor. On Windows machines, it uses the MicroSoft Visual C++ preprocessor. You can change the preprocessor that the idltojava compiler uses by setting two environment variables: CPP and CPARGS. Set CPP to the full pathname of the preprocessor you want to use. Set CPARGS to the complete list of arguments to be passed to the preprocessor. You can also turn off the preprocessor by adding -fno-cpp to the idltojava command line.
More information is available in the idltojava reference page that is downloaded with the idltojava compiler.
We recommend upgrading to the latest version of the IDL to Java compiler, idlj. Version 1.4 of J2SE, includes a version of the IDL-to-Java compiler which is 100% pure Java, so no preprocessor is necessary. The IDL-to-Java compiler, idlj, is included with the download of J2SE v.1.4. For information on the enhancements to Java IDL that are supported in v.1.4, follow the link to Java(TM) IDL: Changes in CORBA Features Between J2SE 1.3 and J2SE 1.4. To download version 1.4 of the Java 2 Platform, Standard Edition, link to http://java.sun.com/j2se/1.4/download.html. To learn more about Java IDL, link to the Java IDL page for J2SE v 1.4.
The most common reason for this error when running HelloServer (and also HelloClient) from the Java IDL tutorial is when a space is added between quotation marks in the following line of code:
NameComponent nc = new NameComponent("Hello", "");There should be no spaces between the quotation marks. Without spaces, this value is passed as a null. With a space between the quotations, a space character is passed.
The idlj compiler now generates server-side mappings based on the POA Inheritance Model. For compatibility with existing applications, a new flag has been added to the idlj compiler to allow it to generate server-side mappings based on the ImplBase Inheritance Model, -oldImplBase. Existing applications that need to talk to servers created in J2SE 1.3 or prior may need to update their MAKEFILE so that this flag is used, however, new applications that have no such requirements should not generate these deprecated mappings.
On Red Hat Linux installations InetAddress.getLocalHost() may return an InetAddress corresponding to the loopback address (127.0.0.1). This arises because the default installation creates an association in /etc/hosts between the hostname of the machine and the loopback address. To ensure that InetAddress.getLocalHost() returns the actual host address, update the /etc/hosts file or the name service configuration file (/etc/nsswitch.conf) to query dns or nis before searching hosts.
First of all, these files aren't "missing" from the JAR file. You obtain a reference to the rootPOA by creating the first rootPOA object as shown in the Java IDL tutorial, which can be found online at http://java.sun.com/j2se/1.4/docs/guide/idl/jidlExample.html:public static void main(String args[]) { try{ // create and initialize the ORB ORB orb = ORB.init(args, null); // get reference to rootpoa & activate the POAManager POA rootpoa = (POA)orb.resolve_initial_references("RootPOA"); rootpoa.the_POAManager().activate(); // create servant and register it with the ORB HelloImpl helloImpl = new HelloImpl(); helloImpl.setORB(orb); // get object reference from the servant org.omg.CORBA.Object ref = rootpoa.servant_to_reference(helloImpl); Hello href = HelloHelper.narrow(ref); // ...
The Java CORBA ORB shipped in J2SE is multi-threaded. On the server side, we have a thread pool such that each incoming request is handled by a separate thread. If all the pool's threads are in use when a new request comes in, a new thread is created and added to the pool. The thread is returned to the pool after the request is finished.
The Java CORBA ORB is threaded to allow scalability and concurrent request processing. The SINGLE_THREAD option for the POA theading policy is not supported.
The threading model for the Java CORBA ORB is implicit: the user does not set the thread policy for the ORB. There are no external, user-level APIs exposed for controlling the threading model or the number of threads.
No, it does not. If you need an events service, you can implement one, purchase one off the shelf, or search for one freely available to start things off with.
You need to use the -ORBInitialHost <Host Name where Name Service is Launched> option when starting the client and/or server (whichever is not running on the same machine as the name server). This way the client and server know where to find the Name Service. As example can be found on the Web at http://java.sun.com/j2se/1.4/docs/guide/idl/tuto rial/jidl2machines.html.
With the idlj compiler in J2SE 1.3, we are CORBA 2.3 compliant in some areas but not in others. In J2SE 1.4, we are more compliant with CORBA 2.3. See the CORBA compliance statement at http://java.sun.com/j2se/1 .4/docs/api/org/omg/CORBA/doc-files/compliance.html.RMI-IIOP also mostly comforms to CORBA/IIOP 2.3.1, with GIOP 1.2 support along the lines of compliance with CORBA 2.3.
The Java IDL ORB is an ORB completely written in Java. The idlj compiler generates code that follows the conventions definded in the IDL to Java Language Mapping Specification. The Java ORB does not provide a compiler that generates code in any languages other than the Java platform. If you want to test interoperability between the Java ORB and an ORB written in another language (such as C++), you will need to find an ORB written in that language and a compiler that conforms to the specific language mapping. Language mapping specifications are available from the Object Management Group Web site at http://www.omg.org/technology/documents/formal/corba_language_mapping_speci fica.htm. A user who wants to use the Java platform on one side and C++ on the other will only share the IDL. You will have to use your C++ ORB's tools to generate the stubs and skeletons for use with the C++ ORB, but you don't have to change the IDL at all. To find a vendor that provides a CORBA ORB and a language mapping compiler in the language you are working with, search the Web for "C++ CORBA ORB", or equivalent.Although it is true that ORBs written in different languages should be able to talk to each other, we haven't tested the interoperability of the Java ORB with other vendor's ORBs.
To use a different ORB than the Java CORBA ORB in your application, you can set the org.omg.CORBA.ORBClass property to the ORB of your choice. For example, to explicitly set the ORB to the POA ORB, you would set the property as follows in your code:
public class MyApp { public static void main( String args[] ) { Properties properties = System.getProperties(); properties.put( "org.omg.CORBA.ORBClass", "com.sun.corba.se.internal.POA.POAORB" ); try { ORB orb = ORB.init( args, properties); ...Replace the path to the POA ORB with the ORB of your choice.
We haven't tested the interoperability of the Java ORB with other vendor's ORBs.
First, we have not done compatibility testing with any other ORBs from andy other vendors.
Second, try this. Convert the Interoperable Object References (IOR) on the ORBIX server to a string using the ORB.object_to_string() method. Write that string to a file.
On the client side, read that string and convert it to an object reference using the ORB.string_to_object() method, then try communicating with it.
To communicate with the Java IDL Naming Service or ORBIX Name Server, you must use Interoperable Naming Service (INS) or by stringifying RootNamingContext's reference as explained above.
The following list provides a summary of changes that occurred in Java IDL between the release of JDK 1.2 and J2SE v.1.3. For more detail, read Java IDL: Changes between JDK 1.2 and J2SE v1.3. For changes between J2SE 1.3 and J2SE 1.4, see Java IDL: Changes between J2SE 1.3 and 1.4.
New IDL-to-Java compiler, idlj, is 100% Pure Java, so no preprocessor is necessary when compiling IDL files.
More IDL-to-Java compiler options. See the reference documentation for the IDL-to-Java compiler for a list of options.
Mapping for interfaces is supported. In accordance with the OMG IDL to Java Language Mapping Specification, Section 1.12, Mapping for Interfaces, the signature interface no longer contains the method that corresponds to the interface defined in the IDL file. Instead, the operations interface, <interface>Operations.java, is generated in the <module> subdirectory and contains the methods defined by the interface.
Support for Java mapping to IDL value types.
CORBA technology as part of the Java 2 platform consists of an Object Request Broker (ORB) written in Java (with a small bit of native code), the RMI programming model, and the IDL programming model.
The "magic" that gives us the cross-language, cross-vendor interoperability is the Internet InterORB Protocol, or IIOP. IIOP can be a transport protocol for distributed applications written in either IDL or Java RMI. IIOP allows distributed objects to conform to OMG's CORBA specification.
When using the IDL programming model, the interface is everything! It defines the points of entry that can be called from a remote process, such as the types of arguments the called procedure will accept, or the value/output parameter of information returned. Using IDL, the programmer can make the entry points and datatypes that pass between communicating processes act like a standard language.
CORBA is a language-neutral system in which the argument values or return values are limited to what can be represented in the involved implementaton languages. In CORBA, object orienation is limited only to objects that can be passed by reference (the object code itself cannot be passed from machine-to-machine) or are predefined in the overall framework. Passed and returned types must be those declared in the interface.
With RMI, the IDL and the implementation language are the same thing, so you don't have to worry about mapping from one to the other. Language-level objects (the code itself) can be passed from one process to the next. Values can be returned by their actual type, not the declared type. Or, you can compile the interfaces to generate IIOP-compliant stubs and skeletons to talk to objects written on other machines in other CORBA-compliant languages.
This is a fundamental question and it's important to understand the distinction between these two ways of integrating the Java programming language with CORBA.
Java IDL is for CORBA programmers who want to program in the Java programming language based on interfaces defined in CORBA Interface Definition Language (IDL). This is "business as usual" CORBA programming, supporting Java in exactly the same way as other languages like C++ or COBOL.
RMI-IIOP (Remote Method Invocation over Internet Inter-ORB Protocol) is for Java programmers who want to program to the RMI interfaces, but use IIOP as the underlying transport. RMI-IIOP provides interoperability with other CORBA objects implemented in various languages - but only if all the remote interfaces are originally defined as Java RMI interfaces. It is of particular interest to programmers using Enterprise JavaBeans (EJB), since the remote object model for EJBs is RMI-based.
There are several scenarios that will define how you will want to create distributed CORBA applications. Here are some of them:
Java IDL! If you have been developing CORBA applications using IDL for some time, you will probably want to stay in this environment. Create the interfaces using IDL, and define the client and server applications using the Java programming language to take advantage of its "Write Once, Run AnywhereTM" portability, its highly productive implementation environment, and its very robust platform.
RMI-JRMP! If all of your applications are written in the Java programming language, you will probably want to use Java RMI to enable communication between Java objects on different virtual machines and different physical machines. Using Java RMI without its IIOP option leverages its strengths of code portability, security, and garbage collection.
RMI-IIOP! If you are writing most of your new applications using the Java programming language, but need to maintain legacy applications written in other programming languages as well, you will probably want to use Java RMI with its IIOP compiler option.
Send questions or comments to: JavaIDL@eng.sun.com. |
Java Software |