Jacorb installation and setting

xiaoxiao2021-03-06  79

1. Download the installation Jacorb2.1 Download Jacorb_2_1-Compact.zip (the version already compiled), unzip the disk, such as E: / JACORB. Then, in order to find the package and jacorb.properties configuration files, need Set ClassPath = .; E: /JACORB/iDL.jar; E: / JACORB/Jacorb.jar; E: / JACORB / CLASSES; additionally, add the ANT and command line tools, join in PATH E: / jacorb / bin

Modify Idl.bat in E: / JACORB / BIN (Under Linux) file, add execution parameters

@echo offjava -djava.endorsed.dirs = "E: / jAracorb / lib" -classpath "E: /JACORB/LIB/IDL.jar; E: /JACORB/LIB/Logkit-1.2.jar;% classpath%" ORG .jacorb.idl.parser% *

Next, copy the jACORB_PROPERTIES.TEMPLATE under the E: / JACORB / ETC directory to the E: / JACORB / CLASSES directory, and renamed Jacorb.properties in CORBA Name service is very important, edit the Jacorb.Properties file, set it ORBINITREF.NAMSERVICE = file: / e: / ns_ref (here is an example, can of course be any httpurl or other path), this ns_ref file is generated when the naming service is started. The rest of the configuation is reserved.

2. Test Naming Services (NS, Naming Service) Can I enter NS E: / ns_ref if the following output is now normal, if the following output description has been started [Configuration Loaded from ClassPath Resource File: / E: / SSS / Web- INF / CLASSES / JACORB.PROPERTIES] JACORB V 2.1, www.jacorb.org (c) Gerald BROSE, XTRADYNE TECHNOLOGIES / Fu Berlin, 16-Feb-2004 [Jacorb.naming] INFO: NS UP

If there is no output, it may be because 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 Refused: Connect

3. Idl Compilation DEMO Grid Example After the NS is observed correctly, the DOS window is transferred to the DEMO / Grid directory to perform Ant (if the ANT is not installed, it will not be compiled) E: / jacorb / demo / grid> Ant This will be IDL. Compile the server.idl file, generate the source file required for CORBA at E: / JACORB / DEMO / GRID / Generated, and Ant will compile all Java source files, E: / JACORB / CLASSES to generate .class files

4 Run the Grid example, this example implements a simple service. 4.1 First Refer to the second step to verify that the NS has been started normally. 4.2 Start Grid Server executes in the DOS window (in E: / JACORB / Directory) Jaco Demo.grid .Server or Jaco Demo.grid.tieserver Output: [Configuration Loaded from Classpath Resource File: / E: /SS/web-inf/classes/jacorb.properties] Jacorb V 2.1, www.jacorb.org (c) Gerald Brose, Xtradyne Technologies / Fu Berlin, 16-Feb-2004 [Jacorb.poa] info: Oid: 00 11 48 40 02 10 1f 00 01 1e 04 ..h @ ....... Object is activated at this time The NS output window can be seen: [JACORB.NAMING] INFO: Bound name: Grid.example In addition, you can establish a project to run Demo.grid.Server through JBuilder, etc., you must specify VM parameters -Djava.endorsed.dirs = "E: / JACORB / LIB" (set in Runtime Configuration in JBuilder), the result is consistent. 4. Start the Grid Client End Jaco Demo.grid.Client output: 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 :-)

Seeing this result indication has successfully run a Grid example.

5. Control source code, below 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. Implement the interface generated in step 2 4. Write the server start class, and register to ORB 5. Write customers End to get the service object reference

5.1 First Write Server.IDL files 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 whyl;}; short opwitHexception () Raises (myException) };};}; 5.2 Using tool bin / idl.bat to compile server.idl idl -d ../ .. Server.IDL 5.3 Implementation Interface Public Class GridImpl ExtensS MyServerPoA Fill in Construction Functions, and Interfaces, such 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 GridImpl classes, 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. Poa.The_PoAmanager (). Activate (); 4) Transforms a Java object into a CORBA object via POA. Org.omg.corba.object o = poa.servant_to_reference (new gridIMPL ()); 5) Make NC binding the reference to this object (this process is done by named server), pay attention to make the name of the object as bind () Parameters NamingContextExt NC = NamingContextextHelper.Narrow ("NAMESERVICE"); nc.bind (nc.to_name ("grid.example"), O);

5.5 Write a Client Call Service 1) Create an ORB object org.corba.orb orb = org.omg.corba.orb.init (args, null); 2) Grid service is obtained by named the server. reference nc = NamingContextExtHelper.narrow (orb.resolve_initial_references ( "NameService")) NamingContextExt; grid = MyServerHelper.narrow (nc.resolve (nc.to_name ( "grid.example"))); our calculations 3) using the grid object .

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

New Post(0)