[erlang-questions] separating application from gen server

Ulf Wiger (TN/EAB) <>
Wed Nov 28 09:44:49 CET 2007


Tom Whitcomb skrev:
> Hi,
> 
> I want to use application:get_env in my gen_server but it feels wrong
> to create a dependency between my gen_server and a specific application.
> 
> Is there a recommended way for a gen_server to receive and reference
> the application that contains it?

application:get_application() -> {ok, AppName} | undefined

   will return the name of the application which contains
   the current process.

application:get_env(Par) -> {ok, Val} | undefined

   will get the environment variable Par from the current
   application. get_env(AppName, Par) will get it from the
   specified application.


BR,
Ulf W



More information about the erlang-questions mailing list