1%%-------------------------------------------------------------------- 2%% 3%% %CopyrightBegin% 4%% 5%% Copyright Ericsson AB 1999-2016. All Rights Reserved. 6%% 7%% Licensed under the Apache License, Version 2.0 (the "License"); 8%% you may not use this file except in compliance with the License. 9%% You may obtain a copy of the License at 10%% 11%% http://www.apache.org/licenses/LICENSE-2.0 12%% 13%% Unless required by applicable law or agreed to in writing, software 14%% distributed under the License is distributed on an "AS IS" BASIS, 15%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16%% See the License for the specific language governing permissions and 17%% limitations under the License. 18%% 19%% %CopyrightEnd% 20%% 21%% 22%%---------------------------------------------------------------------- 23%% File : cosTransactions.erl 24%% Purpose : Initialize the 'cosTransactions' application 25%%---------------------------------------------------------------------- 26 27-module(cosTransactions). 28 29%%--------------- INCLUDES ----------------------------------- 30%% Local 31-include_lib("ETraP_Common.hrl"). 32-include_lib("CosTransactions.hrl"). 33%%--------------- EXPORTS------------------------------------- 34%% cosTransactions API external 35-export([start/0, stop/0, start_factory/1, start_factory/0, stop_factory/1]). 36 37%% Application callbacks 38-export([start/2, init/1, stop/1]). 39 40%%------------------------------------------------------------ 41%% function : start/stop 42%% Arguments: 43%% Returns : 44%% Effect : Starts or stops the cosTRansaction application. 45%%------------------------------------------------------------ 46 47start() -> 48 application:start(cosTransactions). 49stop() -> 50 application:stop(cosTransactions). 51 52%%------------------------------------------------------------ 53%% function : start_factory 54%% Arguments: none or an argumentlist which by default is defined 55%% in ETraP_Common.hrl, i.e., '?tr_FAC_DEF' 56%% Returns : ObjectRef | {'EXCEPTION', _} | {'EXIT', Reason} 57%% Effect : Starts a CosTransactions_TransactionFactory 58%%------------------------------------------------------------ 59 60start_factory() -> 61 ?tr_start_child(?SUP_FAC(?tr_FAC_DEF)). 62 63start_factory(Args) when is_list(Args) -> 64 ?tr_start_child(?SUP_FAC(Args)); 65start_factory(Args) -> 66 ?tr_error_msg("applications:start( ~p ) failed. Bad parameters~n", [Args]), 67 exit("applications:start failed. Bad parameters"). 68 69%%------------------------------------------------------------ 70%% function : stop_factory 71%% Arguments: Factory Object Reference 72%% Returns : ok | {'EXCEPTION', _} 73%% Effect : 74%%------------------------------------------------------------ 75 76stop_factory(Fac)-> 77 corba:dispose(Fac). 78 79%%------------------------------------------------------------ 80%% function : start 81%% Arguments: Type - see module application 82%% Arg - see module application 83%% Returns : 84%% Effect : Module callback for application 85%%------------------------------------------------------------ 86 87start(_, _) -> 88 supervisor:start_link({local, ?SUPERVISOR_NAME}, cosTransactions, app_init). 89 90 91%%------------------------------------------------------------ 92%% function : stop 93%% Arguments: Arg - see module application 94%% Returns : 95%% Effect : Module callback for application 96%%------------------------------------------------------------ 97 98stop(_) -> 99 ok. 100 101%%------------------------------------------------------------ 102%% function : init 103%% Arguments: 104%% Returns : 105%% Effect : 106%%------------------------------------------------------------ 107 108%% Starting using create_factory/X 109init(own_init) -> 110 {ok,{?SUP_FLAG, [?SUP_CHILD]}}; 111%% When starting as an application. 112init(app_init) -> 113 {ok,{?SUP_FLAG, [?SUP_CHILD]}}. 114 115 116%%--------------- END OF MODULE ------------------------------ 117