分类: Java
2008-11-20 21:34:49
Installation of ORB Studio 7 | |
First
of all, extract the ORB Studio 7 package file and put ORBStudio773.zip
file into the |
Starting up Eclipse | |
Start up Eclipse 3.X after installation of the plugin.
|
|
Choosing CORBA Implementation | |
Open ORB Studio 7 preference dialog by choosing [Windows] -> [Preference] Find [ORB Studio] node in left pain and expand it. Choose IDL Compiler node. Since we make use of Java IDL in this document, choose [JavaIDL(JDK)] implementation. This screen allow you to setup your IDL compiler information. Enter IDL compiler command location into IDL Command: field. Note that absolute path is required. In my environment idlj.exe command is located in C:\Tools\Java\bin though. Here, leave it Command Options: field. You can setup IDLÂ compiler options by modifying Command Options: field. Please chagnge them corresponding to your IDL compiler if you need it. Finally, Click [OK] button to complete your configuration. |
|
Creating a new Java project. | |
Create your sample Java Project by choosing [File] -> [New] ->[Project].
Say here we give the project a name,"MyFirstCORBA". Enter "MyFirstCORBA" in Project Name: filed. Here, click [Finish] button and make sure that new project ,"MyFirstCORBA" has generated. Since we decided to choose JavaIDL that is bundled in Java SDK you don't need specify extra class libraries to enable CORBA stack. Note: when you make use of other CORBA implementation, you need to add extra class libraries for ORB into your project. |
|
Generate a new IDL file | |
Create
a new IDL file into your project by the ORB Studio IDL Wizard. To open
CORBA IDL Wizard, choose "MyFirstCORBA" in Package explorer, then open
sub-menu by click right button. Choose [New] -> [Other].
Then choose Simple IDL wizard in CORBA Wizard. Specify the location of the File container in which you want to generate new IDL file. Here enter "/MyFirstCORBA", default package. And give the IDL File a name, "simple.idl". Then click [Finish] button. ORB Studio 7 IDL Wizard automatically generates a simple IDL file and open it with IDL editor. The IDL editor provides syntax highlight of CORBA IDL and allow you to detect OMG-IDL syntax error during editing work.
|
|
Compilation the IDL file | |
ORB
Studio 7 provides IDL compiler integration on the top of Eclipse IDE.
All stub/skelton files generated by IDL comilers are managed into
Eclipse project.
In Package Explorer, choose the IDL file, "simple.idl", open sub-menu by click right button. Compile the IDL file by select [ORB Menu] -> [Compile]. Compilation must be successful in this point. And you now can look over MyServer package that generated by the IDL compiler. Package name is the same as that specified in "module" in the IDL file.
|
|
Generate CORBA Server object | |
CORBA
Server Wizard. That is a main feature of ORB Studio 7 and most useful,
powerful tool. CORBA Server Wizard supports all type of object adaptors
mentioned in OMG CORBA specification. And it can generate *complete*
codes, it means you can just go run them without any modification for
those.
Here we are developping most popular server objets based on Active Object Map. In Package Explorer, choose "MyFirstCORBA" project and open CORBA Server Wizard as below. Choose [Active object map] leaf in CORBA Wizard node to open CORBA Server Wizard. This screen of Server Wizard (Wizard page 1/2) allow you to setup information in server code generation. Choose a name of IDL file that put in already exist project "MyFirstCORBA", from drop down list. Next choose Interface as well. Here choose "MyServer.MyService" as interface. Next enter name into both Package and Server(Servant) classname fields. Here enter "MyServiceServerImpl" as Server classname.
Click [Next] button. In Server Implementation Wizard 2/2 page, you can configure two options, whether or not create Server class in addition to Servant class and use TIE approach. Here just give a check in Create server class field then Clieck [Next] button. Now two files are generated in your project and a servant class file is opened as below.
And also Eclipse reports a error against generated servant class, "MyServiceServerImpl.java". Don't mind about this. Eclipse complain that the servant class does not include any corresponding operation methods defined in the IDL files. Ok, let Eclipse implement them automatically. We can take advantage of Code Assistant capability of Eclipse. Place mouse pointer in red X mark appeared in right side in Java Editor and click the point to open an Assist menu. The code assistant menu appears as below and choose "Add unimplemented methods". Eclipse will assist you and make the declaration of "operation1(String msg)" into servant class as below. Just implement your business logic. Here our business logic is that display a message got from client on the console.
|
|
Generate CORBA Client implementation | |
What we have to do next is to generate an corresponding client code for the server we had had in previous. In Package Explorer, choose "MyFirstCORBA" project and open CORBA Client Wizard as below . CORBA Client Wizard can generate *complete* codes that you can just go run without any modification. Choose [Simple implementation] leaf in CORBA Wizard node to open CORBA Client Wizard.The screen of Client Wizard allow you to setup information in client code generation. Fill information for the client code that you want to make the wizard generated automatically. Give a client class a name, "MyServiceClientImpl". Then click [Finish] button. New file will be generated in your project and be opened as below. The generated client code is not only a proxy object but also standalone application including main() operation for test purpose. Implement client code for invocation of server operation. Find out the following line in main() method and un-comment it. test.getORBInterface().operation1("A message in the bottle."); |
|
Run CORBA Server and Client | |
Finally, let's make both CORBAÂ server and client executed from Eclipse environment.
To execute CORBA Server, choose Server_AOM.java in Package Explorer and open sub-menu by click right button. Then choose [Run] ->[Java Application]. When the server is succeeded in booting up, you must see the following message in the console view as below. CORBA Server ready ... Next, do execute Client as well. Choose Client.java in Package Explorer and open sub-menu then choose [Run] -> [Java Application]. You can see the process of server access by client as below. Of course you can make them run in debug mode also. Ok, That's it. |