CORBA Platform Jacorb2.1 Learning Notes - Getting Started

zhaozj2021-02-12  174

CORBA Platform Jacorb2.1 Learning Notes - Getting Started

JACORB2.1 Learning Notes - Getting Started Jacorb is a free Java Object Request Agent System (CORBA) with all source code, including most of the CORBA object service, and a large number of code instances. Here's how to run the Demo it takes to understand the basic JACORB knowledge. (Suppose your system is Win2K / XP / NT, and installed JDK1.4.x and Ant Tools) 1 Download Install Jacorb2.1 from http: //www.jacorb.org/download.html Download Jacorb_2_1-Compact.zip (Repaired Version), unzipped to disk, such as C: / Jacorb_2_1. Then, in order to find the relevant package and jacorb.properties when debugging Profile, you need to set classpath = .; c: /jacorb_2_1/idl.jar; c: /jacorb_2_1/jacorb.jar; C: / Jacorb_2_1 / classes; Add C: / JACORB_2_1 / BIN in PATH, then copy the jACORB_PROPERTIES.TEMPLATE in the C: / JACORB_2_1 / ETC directory to the C: / JACORB_2_1 / CLASSES directory and renamed Jacorb.properties Naming service in CORBA is very important. Edit the Jacorb.Properties file, set the ORBINITREF.NAMESERVICE = file: / c: / ns_ref (here is an example, of course, this ns_ref file is generated when the naming service is started. This configuration The remainder of the file reserves the default value. 2 Test Naming Service (NS, Naming Service) Do you enter NS C: / ns_ref nuster ns c: / ns_ref if the following output is started normally [Configuration Loaded from ClassPath Resource File] /C:/jacorb_2_1/classes/jacorb.properties] Jacorb V 2.1, www.jacorb.org (c) Gerald Brose, Xtradyne Technologies / FU Berlin, 16-Feb-2004 [Jacorb.orb.intercept] Info: InterceptorManager Starte D with 0 SIS, 0 CIS AND 1 IORIS [Jacorb.naming] Info: NS Up [Jacorb.orb] Info: ORB RUN If there is no output, it may be due to your Jacorb.Properties file is not placed in the directory where ClassPath is located .

If NS is not properly started, the following exception occurs when running below [Jacorb.orb.intercept] info: InterceptorManager Started with 0 Sis, 0 Cis and 1 Ioris .... [Jacorb.giop] Info: ClientConnectionManager: Created New conn to target 192.168.4.161:4089 [JACORB] error: java.net.connectException: Connection Refuse: Connect 3 IDL Compile DEMO Grid example Observer After the NS is started, the DOS window is transferred to the DEMO / GRID directory to perform Ant ( If the ANT is not installed, it will not be compiled.) C: / jacorb_2_1 / demo / grid> Ant This will make IDL compile server.idl file, generate the source file required by CORBA at C: / Jacorb_2_1 / demo / grid / generated, Ant will compile all Java source files, C: / JACORB_2_1 / Classes Brachest. Class file 4 runs the Grid example, this example implements a simple service. 4.1 Refer to the second step to verify whether the NS has started normally. 4.2 Start Grid Server executes Jaco Demo.grid.server or Jaco Demo.grid.Server or Jaco Demo.grid.Treserver, Output: [Configuration Loaded from ClassPath Resource File: / C: /Jacorb_2_1/Classes/jacorb.properties] Jacorb V 2.1, www.jacorb org (c) Gerald Brose, Xtradyne Technologies / Fu Berlin, 16-Feb-2004 [Jacorb.orb.intercept] Info: InterceptorManager STA RTED with 0 sis, 0 Cis and 1 Ioris [jacorb.poa] info: OID: 00 11 39 3D 4A 03 47 32 01 07 B ..9 = j.g2 ... Object is activated [jacorb.giop] info: ClientConnectionManager: Created New Conn To target 192.168.4.161:4261 [jacorb.iip.conn] info: connection to 192.168.4.161:4261 from local port 4282 [jacorb.orb] info: orb run, you can see in the NS output window : [JACORB.NAMING] INFO: BOUND Name: Grid.example In addition, a project can be established to run demo.grid.server through the IDE tools such as JBuilder, and must specify VM parameters -Djava.endorsed.dirs = "c: / jacorb_2_1 / Lib ", the result is consistent. 4.3 Start the Grid Client End Jaco Demo.grid.client Output Result: Height =

31 width = 14 Old Value At (30, 13): 0.21 Setting (30, 13) To 470.11 New Value At (30, 13): 470.11 MyException, Reason: this is only a test exception, no harm done :-) To this results, the Grid example has been successfully run .5 Control Source, the following we will simply analyze the Grid example: JACORB application development is generally divided into the following five steps: 1. Write IDL interface definition 2. Compile IDL interface definition Generate Java class 3 Implementing the interface generated in step 2 4. Write the server start class, and register to ORB 5. Write the client to get the service object reference 5.1 Write a Server.idl file About writing IDL reference doc / programmingGuide.pdf document // Grid. idl // IDL defintion of a 2-D grid: module demo {module grid {interface MyServer {typedef fixed <5,2> fixedT; readonly attribute short height; // height of the grid readonly attribute short width; // width of The Grid Void Set (In Short N, In Short M, In Fixedt Value); Fixedt Get (in Short N, in Short M); Exception MyException {String Why;}; Short OpwitHexception () Raises (myException);} ;}; 5.2 Using tool bin / idl.bat to compile SERVE R.IDL IDL -D ../ .. Server.IDL 5.3 Implementing Interface Public Class GridImpl Extends MyServerPoA Fill in Construction Functions, as: Public GridImpl () Public Java.math.BigDecimal Get (Short N, Short M PUBLIC VOID SET (SHORT N, SHORT M, JAVA.MATH.BIGDECIMAL VALUE) 5.4 Writing Server This step is to write a class to call the GridImpl class and register it to POA so that the remote object can access it through the MyServer interface. 1) Initialize the ORB object. Org.omg.corba.orb orb = org.omg.corba.orb.init (args, null); 2) Use PoaHelper to instantiate the reference to POA. Org.omg.portablesRver.poa poa = org.omg.portableserver.poahelper.narrow ("rootpoa")); 3) Activate the object, otherwise it is still in a "keep state," unable to process any request.

转载请注明原文地址:https://www.9cbs.com/read-7028.html

New Post(0)