You can run an applet that uses RMI-IIOP. However, you need to set the permissions in Reflect and
Runtime. These permissions are set in the
java.policy file located in the JRE installed directory. The following is an example of how to set the permissions in the
java.policy file:
The java2iiop compiler lets you define interfaces and data types in Java, rather than IDL, that can then be used as interfaces and data types in CORBA. The compiler does not read Java source code (
java files) or IDL, but rather Java
bytecode (
class files). The compiler then generates IIOP-compliant stubs and skeletons needed to do all the marshalling and communication required for CORBA.
When you run the java2iiop compiler, it generates the same files as if you had written the interface in IDL. All primitive data types like the numeric types (
short,
int,
long,
float, and
double), string, CORBA objects or interface objects,
Any objects,
typecode objects are understood by the
java2iiop compiler and mapped to the corresponding IDL types.
You can use java2iiop on any Java class or interface. For example, if a Java interface adheres to one of the following rules:
then, java2iiop will translate the interface to a CORBA interface in IDL.
You must compile your Java classes before you can use the java2iiop compiler. Once you have generated bytecode, you can run
java2iiop to generate client stubs, server skeletons, and the associated auxiliary files.
When mapping IDL interfaces to Java classes, using the idl2java compiler, the interface name may use any of the generated classes suffixes (for example,
Helper,
Holder,
POA, and so on), and the
idl2java tool will handle the situation correctly by mangling the interface name (prefixing an underscore “_” to the identifier).
For example, if you define both a Foo and a
FooHolder interface in IDL,
idl2java will generate, amongst others,
Foo.java,
FooHolder.java,
_FooHolder.java, and
_FooHolderHolder.java files.
If you attempt to marshal a non-conforming class, an org.omg.CORBA.MARSHAL: Cannot marshal non-conforming value of class <class name> will be thrown. For instance, if you create the following two classes,
You will raise an org.omg.CORBA.MARSHAL exception when you attempt to marshal
val.
The Account interface extends the
java.rmi.Remote interface and is implemented by the
AccountImpl class.
The Client class (below) first creates all the specified
Account objects with the appropriate balances by creating
AccountData objects for each account and passing them to the AccountManager to create the accounts. It then confirms that the balance is correct on the created account. The client then queries the AccountManager for a list of all the accounts, and proceeds to credit $10.00 to each account. It then verifies if the new balance on the account is accurate.
Client stubs generated by java2iiop handle the marshalling of the Java primitive data types that represent an operation request so that they may be transmitted to the object server. When a Java primitive data type is marshalled, it must be converted into an IIOP-compatible format. The following table summarizes the mapping of Java primitive data types to IDL/IIOP types.
This section shows how the java2iiop compiler can be used to handle complex data types.
Java interfaces are represented in IDL as CORBA interfaces, and they must inherit from the org.omg.CORBA.
Object interface. When passing objects that implement these interfaces, they are passed by reference.