1
votes

I need to integrate Java system with legacy C++ system. Those two system communicate through CORBA. Since Java system runs on JBoss we use JacORB.

To generate java stubs from .idl files we use maven-idl-compiler plugin (using JacORB)

org.codehaus.mojo idlj-maven-plugin org.jacorb jacorb-idl-compiler 2.2.3 provided

Everything works fine but I would like to modify the way stubs are being generates (changes names of methods,classes etc). Is there any way to do it?

3
Why would you want to change the generated code? If everything works fine already, what problem are you trying to fix?Brian Kelly

3 Answers

1
votes

Everything works fine but I would like to modify the way stubs are being generates (changes names of methods,classes etc). Is there any way to do it?

This is not possible.

The Server Skeleton and the Client Stub are generated by Corba in the implementation you have chosen. They basically contains Marshaller and Unmarshaller to handle ORB object parameters when you interfere with distributed objects.

All this code is highly coupled with the IDL language used by CORBA, since the generation is dependent on the IDL you provided.

Thus, you cannot modify the stub nor the skeleton directly, that wouldn't make sense since the IDL language is there to ensure a common interface between all distributed objects, no matter the implementation language.

However, you can always modify the IDL itself to adapt it to your needs.

1
votes

Typically what people do in this situation is to use the Façade Pattern.

https://en.wikipedia.org/wiki/Facade_pattern

Create the IDL as normal then create another class that effectively wraps the IDL class but just passes the calls down to the IDL interface. Using this method you can create new names for the method which you can use in your program. You also have the opportunity to simplify methods if you for example always pass the same parameters in certain situations.

Another advantage is that if the IDL authors decided to rename one of their methods or alter the parameters you have a certain amount of protection because you are not using their interface directly in your program.

0
votes

You could modify the code under $JACORB_HOME/src/org/jacorb/idl to generate whatever you want. Take a look at the printStreamBody method in OpDecl.java for an example of generation code that looks easy to understand and modify.