Вы находитесь на странице: 1из 12

Building a CORBA Server

Basic Steps for Building a


CORBA Server
1. Define the server's interfaces using IDL.
2. Choose an implementation approach for the
server's interfaces.
3. Use the IDL compiler to generate client stubs
and server skeletons for the server interfaces.
4. Implement the server interfaces.
5. Compile the server application.
6. Run the server application.

1. Defining the Server


Interfaces

// StockMarket.idl
module StockMarket
{
typedef string StockSymbol;
typedef sequence<StockSymbol> StockSymbolList;

interface StockServer
{
float getStockValue(in StockSymbol symbol);
StockSymbolList getStockSymbols();
};

};

2. Choosing an Implementation
Approach

Implementation by inheritance

consists of a base class that defines the interfaces


of a particular object and a separate class,
inheriting from this base class, which provides the
actual implementations of these interfaces

Implementation by delegation

consists of a class that defines the interfaces for


an object and then delegates their
implementations to another class or classes.

3. Using the IDL Compiler

Sun's Java IDL product is this:


idltojava -fno-cpp -fclient -fserver StockMarket.idl

IDL Compiler generate number of files

Helper classes
Client Stub classes
Server Stub classes

The names of the files generated by the IDL compiler


are dependent on the language mapping used and
sometimes on command-line arguments passed to the
IDL compiler.

Using the IDL Compiler


(Cont)

For each IDL interface compiler generate

a source file and header file for the client


stub
a source file and header file for the server
skeleton

IDL Compiler can create separate


directories for IDL module.

4. Implementing the
Server Interfaces

To keep the example as simple Java


is used as implementation language.

i) Using Server Skeletons

The server skeleton, as you have


learned, provides a framework upon
which to build the server
implementation.

In Java, a server skeleton combines a


set of helper classes with an interface,
for providing the implementation.

After Compilation within StockMarket


directory are a number of files
containing client stub and server
skeleton definitions:
StockSymbolHelper.java
StockSymbolListHolder.java
StockSymbolListHelper.java
StockServer.java
StockServerHolder.java
StockServerHelper.java
_StockServerStub.java
_StockServerImplBase.java

StockServer.java

package StockMarket;
public interface StockServer extends
org.omg.CORBA.Object
{
float getStockValue(String symbol);
String[] getStockSymbols();
}

Вам также может понравиться