Your own behaviours
Vance Shipley
vances@REDACTED
Thu Sep 27 14:51:22 CEST 2001
Chandru,
This is an issue I have visited before. The first time we packaged
an "application" I found it odd that the top module, having behaviour
application, did pretty much nothing but start top level supervisor
which was implemented in another module. I wondered why the supervisor
couldn't also be the application master. Looking at the callbacks
which the two behaviours have I saw no conflict. Then I looked at
OTP for examples and that is just what I found. Some notable modules
which behave as both supervisor and application master are kernel
and sasl.
Here is the example from kernel.erl:
-module(kernel).
-behaviour(application).
-behaviour(supervisor).
I wrote a shell script to find all examples (included below) and
here is the list from R7B-3:
./lib/sasl/src/sasl.erl
./lib/kernel/src/kernel.erl
./lib/mnesia/src/mnesia_event.erl
./lib/mnesia/src/mnesia_sup.erl
./lib/mnemosyne/src/mnemosyne_sup.erl
./lib/mnesia_session/src/mnesia_session_top_sup.erl
-Vance
Vance Shipley
Motivity Telecom Inc.
+1 519 579 5816
find_multiple_behaviours.sh:
#! /bin/sh
for i in `find . -name "*.erl"`
do
if [ `fgrep -c "behaviour(" $i` -gt 1 ]
then
echo $i
fi
done
More information about the erlang-questions
mailing list