Distributed application (below) using dynamic call mode (below)

zhaozj2021-02-08  487

Distributed application (below) using dynamic call mode (below)

(This article is reproduced from Software Engineering Expert Network www.21cmm.com)

Su Yang

The last lecture introduces the creation of the client dynamic call interface (DII) and service object dynamic skeleton interface (DSI) using dynamic call mode, using a specific example to explain the entire process.

1. Summary function description and system brief design

This example still simulates a telecommunications tariff management business process, and register a telephone user on the service object. The user queries the user's call for this month at the remote client. According to the instructions of the object function, use UML to describe the functions that the service object needs to be implemented:

Getfee (): float

OpenAccout: Agent

2. Service object interface definition

According to the system analysis results, use IDL to write the service object method description program Telecomm.IDL:

Module Telecomm

{

Interface Agent

{

Float getfee ();

}

Interface AgentManager

{

Account OpenAccount (in string name);

}

}

3. Implementation of the interface

(1) Realization of Agent interface

Public Class AgentImpl Extends DynamicImplementation

{

// Construct an AgentImpl class

// GET method In the invoke dynamic call method, press name matching call

Public synchronized org.omg.corba.object get (String name) {

// Apply for an account amount, generate an account object

}

Public void invoke (org.omg.corba.serverRequest request) {

// Apply a portable object adapter

// Fill in the calling parameters, put forward the application account request

}

}

(2) AgentManager interface implementation

Public class agentmanagerImpl Extends DynamicImPlementation {

// Construct an AgentManager class

Public void invoke (org.omg.corba.serverRequest request) {

// Fill in the calling parameter table, propose a business request to the Agent object, get an Agent object

// ......

}

}

(3) Server-side programming

Public class server {

Public static void main (String [] args) {

// Initialize ORB, apply for POA and POA Manager

// Apply for a default service object, activate the POA manager

// Waiting for the call request

// ......

}

(4) Client programming

Public class client {

Public static void main (String [] args) {

// Initialize ORB, locate the AgentManager object

/ / Send a call request

Org.omg.corba.Request Request = Manager ._Request ("getfee");

Request.invoke ();

// Query return result, get the return value

Request.get_Response ();

// abnormal processing

// ......

}

4. Program design and operational environment

The above-described dynamic call interface and the dynamic skeleton interface is based on the Visibroker 4.5.1 middleware environment. The implementation of the program in other environments may be different. In the Visibroker environment, run the program as follows:

(1) First launch the Visibroker Smart Agent transaction agent;

(2) Start the service object program: VBJ Server; (3) Start the customer object program: VBJ Client.

Where VBJ is the Java code interpretation executor in Visibroker For Java. The reader can also replace the Java interpretation tool Java, but you need to specify Vbjorb in Visibroker.

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

New Post(0)