narrow() method for interface helper classesmodule, interface, struct, enum, typedef, attribute, operation.Example IDL:
module HelloApp {
interface Hello {
string sayHello();
oneway void shutdown();
};
};
Each IDL construct maps to a Java construct as per the CORBA specifications.
| IDL Construct | Java Mapping |
|---|---|
interface |
A Java interface extending org.omg.CORBA.Object |
struct |
A final Java class with public fields |
enum |
A Java class with constant fields |
exception |
A Java class extending org.omg.CORBA.UserException |
typedef |
No direct mapping (resolved to base type) |
module |
A Java package |
idlj CompilerCompile your .idl file using the idlj compiler:
idlj -fall Hello.idl
This generates:
An interface for client applications.
Implements _Hello.java, marshals requests to the remote object.
Abstract base class for the servant. You override it to implement business logic.
Provides helper methods like:
Hello narrow(org.omg.CORBA.Object obj); void insert(Any a, Hello that); Hello extract(Any a);
Used for out and inout parameters.
You write a class that extends HelloPOA and implements the sayHello() method.
public class HelloImpl extends HelloPOA {
public String sayHello() {
return "Hello, world!";
}
public void shutdown() {
orb.shutdown(false);
}
}
Use ORB.init(args, null) and bind the servant in the CORBA Naming Service. Then, use the stub on the client side.
| IDL Type | Java Type |
|---|---|
short |
short |
long |
int |
long long |
long |
float |
float |
double |
double |
boolean |
boolean |
char |
char |
string |
java.lang.String |
any |
org.omg.CORBA.Any |
Object |
org.omg.CORBA.Object |
Create a visual mapping flow:
IDL Hello.idl
↓
idlj compiler
↓
Java Interfaces + Stubs + Skeletons
↓
Implement HelloPOA.java → Run ORB server
↓
Use _HelloStub.java in the client via Naming Service
Use logging or IDE breakpoints to trace: