This example describes the API and behavior of Orber stubs and skeletons.
Orber servers can be started in several ways. The chosen start functions determines how the server can be accessed and its behavior.
Using
Using
Using
Using
To avoid flooding Orber with old object references start erlang using the flag -orber objectkeys_gc_time Time, which will remove all object references related to servers being dead for Time seconds. To avoid extra overhead, i.e., performing garbage collect if no persistent objects are started, the objectkeys_gc_time default value is infinity. For more information, see the orber and corba documentation.
Orber still allow
This section describes Orber pseudo objects.
The Orber stub can be used to start a
By adopting the rules for
To create a pseudo object do the following:
fingolfin 127> erl
Erlang (BEAM) emulator version 4.9
Eshell V4.9 (abort with ^G)
1> ic:gen(myDefinition, [{this, "MyModule::MyInterface"}]).
Erlang IDL compiler version 20
ok
2> make:all().
Recompile: oe_MyDefinition
Recompile: MyModule_MyInterface
Recompile: MyModule_MyInterface_impl
up_to_date
3> PseudoObj = MyModule_MyInterface:oe_create(Env, [{pseudo, true}]).
The call-back functions must be implemented as
This section provides an example of how a call-back module may be implemented.
Arguments and Replies are determined by the IDL-code and, hence, not further described here.
%%%-----------------------------------------------------------
%%% File : Module_Interface_impl.erl
%%% Author :
%%% Purpose :
%%% Created :
%%%-----------------------------------------------------------
-module('Module_Interface_impl').
%%--------------- INCLUDES -----------------------------------
-include_lib("orber/include/corba.hrl").
-include_lib(".. ..").
%%--------------- EXPORTS-------------------------------------
%% Arity depends on IC configuration parameters and the IDL
%% specification.
-export([own_function/X]).
%%--------------- gen_server specific ------------------------
-export([init/1, terminate/2, code_change/3, handle_info/2]).
%%------------------------------------------------------------
%% function : server specific
%%------------------------------------------------------------
init(InitialData) ->
%% 'trap_exit' optional (have no effect if pseudo object).
process_flag(trap_exit,true),
%%--- Possible replies ---
%% Reply and await next request
{ok, State}.
%% Reply and if no more requests within Time the special
%% timeout message should be handled in the
%% Module_Interface_impl:handle_info/2 call-back function (use the
%% IC option {{handle_info, "Module::Interface"}, true}).
{ok, State, Timeout}
%% Return ignore in order to inform the parent, especially if it is a
%% supervisor, that the server, as an example, did not start in
%% accordance with the configuration data.
ignore
%% If the initializing procedure fails, the reason
%% is supplied as StopReason.
{stop, StopReason}
terminate(Reason, State) ->
ok.
code_change(OldVsn, State, Extra) ->
{ok, NewState}.
%% If use IC option {{handle_info, "Module::Interface"}, true}.
%% (have no effect if pseudo object).
handle_info(Info, State) ->
%%--- Possible replies ---
%% Await the next invocation.
{noreply, State}.
%% Stop with Reason.
{stop, Reason, State}.
%%--- two-way ------------------------------------------------
%% If use IC option {this, "Module:Interface"}
%% (Required for pseudo objects)
own_function(This, State, .. Arguments ..) ->
%% IC options this and from
own_function(This, From, State, .. Arguments ..) ->
%% IC option from
own_function(From, State, .. Arguments ..) ->
%% Send explicit reply to client.
corba:reply(From, Reply),
%%--- Possible replies ---
{noreply, State}
{noreply, State, Timeout}
%% If not use IC option {this, "Module:Interface"}
own_function(State, .. Arguments ..) ->
%%--- Possible replies ---
%% Reply and await next request
{reply, Reply, State}
%% Reply and if no more requests within Time the special
%% timeout message should be handled in the
%% Module_Interface_impl:handle_info/2 call-back function (use the
%% IC option {{handle_info, "Module::Interface"}, true}).
{reply, Reply, State, Timeout}
%% Stop the server and send Reply to invoking object.
{stop, StopReason, Reply, State}
%% Stop the server and send no reply to invoking object.
{stop, StopReason, State}
%% Raise exception. Any changes to the internal State is lost.
corba:raise(Exception).
%%--- one-way ------------------------------------------------
%% If use IC option {this, "Module:Interface"}
%% (Required for pseudo objects)
own_function(This, State, .. Arguments ..) ->
%% If not use IC option {this, "Module:Interface"}
own_function(State, .. Arguments ..) ->
%%--- Possible results ---
{noreply, State}
%% Release and if no more requests within Time the special
%% timeout message should be handled in the
%% Module_Interface_impl:handle_info/2 call-back function (use the
%% IC option {{handle_info, "Module::Interface"}, true}).
{noreply, State, Timeout}
%% Stop the server with StopReason.
{stop, StopReason, State}
%%--------------- END OF MODULE ------------------------------