Loading IDL
All the CORBA support provided by OiL is based on interface and typing information. OiL stores all this information in a internal type repository, which implements the interface of the CORBA Interface Repository. Once an IDL interface definition is stored in this repository, OiL is able to create servants and proxies with that interface. OiL provides three ways to load an interface or type, as described below.
IDL Specifications
The most common way to load interface definitions is to load an IDL specification using method orb:loadidl
e orb:loadidlfile
of CORBA brokers.
In this case, the IDL specification is parsed to produce descriptions that are stored in the internal type repository, as illustrated in the example below.
require "oil" oil.main(function() local orb = oil.init() orb:loadidl[[ interface Hello { void say(); }; ]] orb:writeto("hello.ior", orb:newservant(hello, nil, "Hello")) orb:run() end)
Remote Interface Repository
An alternative to the use of IDL specifications is to acquire the interface definition from a remote CORBA Interface Repository (IR) that already contains them.
This can be done by method orb:setIR
.
Whenever OiL finds the name of a interface or type that it does not known, it then checks this remote IR and reads the definition.
However, this is only done for the first time.
Once OiL learns about an interface, it does not read its definition again, even if the original definition changes in the remote IR.
The code below shows how to setup the remote IR.
require "oil" oil.main(function() local orb = oil.init() -- create proxy for a CORBA IR -- and set it as the remote IR orb:setIR( orb:newproxy( oil.readfrom("ir.ior"))) orb:writeto("hello.ior", orb:newservant(hello, nil, "Hello")) orb:run() end)
OiL's internal type repository also implements the CORBA IR interface, therefore, all interface and type definitions can be accessed remotely by CORBA IR clients.
In particular, another CORBA broker can be configured to retrieve definition from the internal type repository of another CORBA broker.
To get the internal IR, use method orb:getLIR
.
Lua Constructors
Finally, another way to provide interface and type descriptions is to create them using the constructors provided by module oil.corba.idl
and register them in the internal IR.
For a description of these constructors, check section Value Mapping.
The code below shows how to create and register descriptions of the Hello
interface in the internal type repository.
require "oil" oil.main(function() local idl = require "oil.corba.idl" local orb = oil.init() orb:getLIR():put( idl.interface{ defintions = { say = idl.operation(), } } ) orb:writeto("hello.ior", orb:newservant(hello, nil, "Hello")) orb:run() end)