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.
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:
..........
};
}
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:
getORB() - returns ORB and increments counter of references to ORB
in compliance with standard technique of working with CORBA API.
Typycal usage :
CORBA::ORB_var orb=corbaService->getORB();
throwCORBAInvokedException - raises CASL exception with code
1001 and with message about CORBA system exception.
printCORBASystemException - prints information about CORBA system
exception to output. Actually it is same as operator
std::ostream& operator<<(std::ostream&, const CORBA::SystemException&)We duplicate it in CASL service to support compatibility with depricated ORB.
stringCORBASystemException - returns string with information about
ORB system error.
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");
}
}
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>
false1