%%------------------------------------------------------------
%%
%% Implementation stub file
%% 
%% Target: CosTransactions_Resource
%% Source: /ldisk/daily_build/otp_prebuild_r12b.2008-09-02_20/otp_src_R12B-4/lib/cosTransactions/src/CosTransactions.idl
%% IC vsn: 4.2.18
%% 
%% This file is automatically generated. DO NOT EDIT IT.
%%
%%------------------------------------------------------------

-module('CosTransactions_Resource').
-ic_compiled("4_2_18").


%% Interface functions
-export([prepare/1, prepare/2, rollback/1]).
-export([rollback/2, commit/1, commit/2]).
-export([commit_one_phase/1, commit_one_phase/2, forget/1]).
-export([forget/2]).

%% Type identification function
-export([typeID/0]).

%% Used to start server
-export([oe_create/0, oe_create_link/0, oe_create/1]).
-export([oe_create_link/1, oe_create/2, oe_create_link/2]).

%% TypeCode Functions and inheritance
-export([oe_tc/1, oe_is_a/1, oe_get_interface/0]).

%% gen server export stuff
-behaviour(gen_server).
-export([init/1, terminate/2, handle_call/3]).
-export([handle_cast/2, handle_info/2, code_change/3]).

-include_lib("orber/include/corba.hrl").


%%------------------------------------------------------------
%%
%% Object interface functions.
%%
%%------------------------------------------------------------



%%%% Operation: prepare
%% 
%%   Returns: RetVal
%%   Raises:  CosTransactions::HeuristicMixed, CosTransactions::HeuristicHazard
%%
prepare(OE_THIS) ->
    corba:call(OE_THIS, prepare, [], ?MODULE).

prepare(OE_THIS, OE_Options) ->
    corba:call(OE_THIS, prepare, [], ?MODULE, OE_Options).

%%%% Operation: rollback
%% 
%%   Returns: RetVal
%%   Raises:  CosTransactions::HeuristicCommit, CosTransactions::HeuristicMixed, CosTransactions::HeuristicHazard
%%
rollback(OE_THIS) ->
    corba:call(OE_THIS, rollback, [], ?MODULE).

rollback(OE_THIS, OE_Options) ->
    corba:call(OE_THIS, rollback, [], ?MODULE, OE_Options).

%%%% Operation: commit
%% 
%%   Returns: RetVal
%%   Raises:  CosTransactions::NotPrepared, CosTransactions::HeuristicRollback, CosTransactions::HeuristicMixed, CosTransactions::HeuristicHazard
%%
commit(OE_THIS) ->
    corba:call(OE_THIS, commit, [], ?MODULE).

commit(OE_THIS, OE_Options) ->
    corba:call(OE_THIS, commit, [], ?MODULE, OE_Options).

%%%% Operation: commit_one_phase
%% 
%%   Returns: RetVal
%%   Raises:  CosTransactions::HeuristicHazard, CosTransactions::HeuristicRollback, CosTransactions::HeuristicMixed
%%
commit_one_phase(OE_THIS) ->
    corba:call(OE_THIS, commit_one_phase, [], ?MODULE).

commit_one_phase(OE_THIS, OE_Options) ->
    corba:call(OE_THIS, commit_one_phase, [], ?MODULE, OE_Options).

%%%% Operation: forget
%% 
%%   Returns: RetVal
%%
forget(OE_THIS) ->
    corba:call(OE_THIS, forget, [], ?MODULE).

forget(OE_THIS, OE_Options) ->
    corba:call(OE_THIS, forget, [], ?MODULE, OE_Options).

%%------------------------------------------------------------
%%
%% Inherited Interfaces
%%
%%------------------------------------------------------------
oe_is_a("IDL:omg.org/CosTransactions/Resource:1.0") -> true;
oe_is_a(_) -> false.

%%------------------------------------------------------------
%%
%% Interface TypeCode
%%
%%------------------------------------------------------------
oe_tc(prepare) -> 
	{{tk_enum,"IDL:omg.org/CosTransactions/Vote:1.0","Vote",
                  ["VoteCommit","VoteRollback","VoteReadOnly"]},
         [],[]};
oe_tc(rollback) -> 
	{tk_void,[],[]};
oe_tc(commit) -> 
	{tk_void,[],[]};
oe_tc(commit_one_phase) -> 
	{tk_void,[],[]};
oe_tc(forget) -> 
	{tk_void,[],[]};
oe_tc(_) -> undefined.

oe_get_interface() -> 
	[{"forget", oe_tc(forget)},
	{"commit_one_phase", oe_tc(commit_one_phase)},
	{"commit", oe_tc(commit)},
	{"rollback", oe_tc(rollback)},
	{"prepare", oe_tc(prepare)}].




%%------------------------------------------------------------
%%
%% Object server implementation.
%%
%%------------------------------------------------------------


%%------------------------------------------------------------
%%
%% Function for fetching the interface type ID.
%%
%%------------------------------------------------------------

typeID() ->
    "IDL:omg.org/CosTransactions/Resource:1.0".


%%------------------------------------------------------------
%%
%% Object creation functions.
%%
%%------------------------------------------------------------

oe_create() ->
    corba:create(?MODULE, "IDL:omg.org/CosTransactions/Resource:1.0").

oe_create_link() ->
    corba:create_link(?MODULE, "IDL:omg.org/CosTransactions/Resource:1.0").

oe_create(Env) ->
    corba:create(?MODULE, "IDL:omg.org/CosTransactions/Resource:1.0", Env).

oe_create_link(Env) ->
    corba:create_link(?MODULE, "IDL:omg.org/CosTransactions/Resource:1.0", Env).

oe_create(Env, RegName) ->
    corba:create(?MODULE, "IDL:omg.org/CosTransactions/Resource:1.0", Env, RegName).

oe_create_link(Env, RegName) ->
    corba:create_link(?MODULE, "IDL:omg.org/CosTransactions/Resource:1.0", Env, RegName).

%%------------------------------------------------------------
%%
%% Init & terminate functions.
%%
%%------------------------------------------------------------

init(Env) ->
%% Call to implementation init
    corba:handle_init('ETraP_Server_impl', Env).

terminate(Reason, State) ->
    corba:handle_terminate('ETraP_Server_impl', Reason, State).


%%%% Operation: prepare
%% 
%%   Returns: RetVal
%%   Raises:  CosTransactions::HeuristicMixed, CosTransactions::HeuristicHazard
%%
handle_call({OE_THIS, OE_Context, prepare, []}, _, OE_State) ->
  corba:handle_call('ETraP_Server_impl', prepare, [], OE_State, OE_Context, OE_THIS, false);

%%%% Operation: rollback
%% 
%%   Returns: RetVal
%%   Raises:  CosTransactions::HeuristicCommit, CosTransactions::HeuristicMixed, CosTransactions::HeuristicHazard
%%
handle_call({OE_THIS, OE_Context, rollback, []}, _, OE_State) ->
  corba:handle_call('ETraP_Server_impl', rollback, [], OE_State, OE_Context, OE_THIS, false);

%%%% Operation: commit
%% 
%%   Returns: RetVal
%%   Raises:  CosTransactions::NotPrepared, CosTransactions::HeuristicRollback, CosTransactions::HeuristicMixed, CosTransactions::HeuristicHazard
%%
handle_call({OE_THIS, OE_Context, commit, []}, _, OE_State) ->
  corba:handle_call('ETraP_Server_impl', commit, [], OE_State, OE_Context, OE_THIS, false);

%%%% Operation: commit_one_phase
%% 
%%   Returns: RetVal
%%   Raises:  CosTransactions::HeuristicHazard, CosTransactions::HeuristicRollback, CosTransactions::HeuristicMixed
%%
handle_call({OE_THIS, OE_Context, commit_one_phase, []}, _, OE_State) ->
  corba:handle_call('ETraP_Server_impl', commit_one_phase, [], OE_State, OE_Context, OE_THIS, false);

%%%% Operation: forget
%% 
%%   Returns: RetVal
%%
handle_call({OE_THIS, OE_Context, forget, []}, _, OE_State) ->
  corba:handle_call('ETraP_Server_impl', forget, [], OE_State, OE_Context, OE_THIS, false);



%%%% Standard gen_server call handle
%%
handle_call(stop, _, State) ->
    {stop, normal, ok, State};

handle_call(_, _, State) ->
    {reply, catch corba:raise(#'BAD_OPERATION'{minor=1163001857, completion_status='COMPLETED_NO'}), State}.


%%%% Standard gen_server cast handle
%%
handle_cast(stop, State) ->
    {stop, normal, State};

handle_cast(_, State) ->
    {noreply, State}.


%%%% Standard gen_server handles
%%
handle_info(_, State) ->
    {noreply, State}.


code_change(OldVsn, State, Extra) ->
    corba:handle_code_change('ETraP_Server_impl', OldVsn, State, Extra).

