[Erlang Systems]

10 Orber Stubs/Skeletons

10.1 Orber stubs and skeletons description.

This example describes the API and behavior of Orber stubs and skeletons.

10.1.1 Server start

Orber servers can be started in several ways. The chosen start functions determines how the server can be accessed and its behavior.

Using Module_Interface:oe_create() or oe_create_link():

Using Module_Interface:oe_create(Env) or oe_create_link(Env):

Using Module_Interface:oe_create(Env, Options):

Using Module_Interface:oe_create_link(Env, Options):

Warning!

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.

Warning!

Orber still allow oe_create(Env, {Type,RegName}) and oe_create_link(Env, {Type,RegName}) to be used, but may not in future releases.

10.1.2 Call-back module

This section provides an example of how a call-back module may be implemented.

Note!

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
    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}
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"}
own_function(This, State, .. Arguments ..) ->

%% 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"}
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 ------------------------------

      

Copyright © 1991-1999 Ericsson Utvecklings AB