next_inactive up previous


CASL: CORBA API: Programing Guide
DocumentId:GradSof-CASL-CORBA-r-PG-12.02.2002-1.0.0

Introduction

CORBA API service is one of the CASL services. What is it? - It is simply CASL shell around ORB supplied together with CASL. It gives uniform interface to ORB functionality and set of utility functions.

C++ interface

CORBA services definitions is located in file:

 <CASL-ROOT>/include/GradSoft/CASL/CORBAService.h

Public methods of CASL service are listed below:

namespace CASL {


class CORBAService: public CASL::Service
{ 
public:

  /**
   * return string "CORBAService"
   **/
  virtual const char* name() const;

  /**
   * init
   **/
  virtual void init(ServerContext* );

  /**
   * return 
   *    false, if we work in client-only mode.
   *    true, otherwice
   **/
  virtual bool requireThread();

  /**
   * run CORBA Service.
   **/
  virtual void run();

  /**
   * close
   **/
  virtual void close();

  //
  // CORBA specific stuff.
  //

  /**
   * return ORB
   **/
  virtual CORBA::ORB_ptr  getORB();

  /**
   * throw CASL::Exception with code 1001 and message about 
   * CORBA::SystemException
   **/
  virtual void  throwCORBAInvokedException(const CORBA::SystemException& ex);

  /**
   * print information about CORBA::SystemException to stream out.
   **/
  virtual void  printCORBASystemException(const CORBA::SystemException& ex, 
                                  ostream& out);

  /**
   * pring information about CORBA::SystemException to string
   **/
  virtual std::string  stringCORBASystemException(
                                      const CORBA::SystemException& ex);

private:

 ..........

};

}

Methods description

Standart service methods are : name, init, run and requireThread.

Individual explanation is required only for methods run() and requireThread : CORBA service is able to work as client and as server. Boolean ClientOnly parameter adjusts it.

If ClientOnly is true, CORBAService::init executes ORB initialization, run does nothing - i.e. in this case CASL CORBA service works as API service. In case ClientOnly is false 1 run contains call of orb::run(), and is called in separate thread, accordingly requireThread returns true. Then CASL application becomes server and retrieves CORBA requests by network. Notice, for proper work of CORBA application within CASL it is necessary to set thread policy to multithreaded.

All service parameters are:

CORBA service specific methods

Accessing CORBA service from other CASL components

CORBA service CASL is available from other CASL-components by CORBAService name.

Here is typical code fragment to retrieve this service:

void MyService::initCORBA() throw(CASL::Exception)
{
   CASL::Service* srv = getServerContext().getService("CORBAService");
   corbaService_p_ = dynamic_cast<CASL::CORBAService*>(srv);
   if (corbaService_p_==NULL) {
     throw CASL::Exception("Can't load CORBA Service: bad service type");
   }
}

Libraries and startup configuration

CORBA service is in the shared library with name like libCASL_CORBA_<ORB-name>.so, which depend on ORB supplied together with CASL : for instance - libCASL_CORBA_TAO.so.

Accordingly, if you are using CORBA service CASL, then it is necessary to load CORBA service before yours. The configuration file will look like following

<Service Name="CORBAService" Library="libCASL_CORBA_TAO">
 <parameter>
  <name> ClientOnly </name>
  <value> false </value>
 </parameter> 
 <parameter>
  <name> ORBArgs  </name>
  <value> 
    -ORBInitRef NameService=corbaloc::my.host.com:2809/NameService 
  </value>
</Service>
<Service Name="MyService" Library="libCASL_My">
  my parameters.
</Service>

Error messages list

1001
- CORBA system exception occurs.

Changes list

  1. 12.02.2002 - created.



Footnotes

... false1
by default

next_inactive up previous
GradSoft