aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ic/examples/pre_post_condition/ReadMe.txt
blob: 2fb3f0a04f2eb125cac2108af5ca0ee4ce68bc9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
 ``Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 
 The Initial Developer of the Original Code is Ericsson Utvecklings AB.
 Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
 AB. All Rights Reserved.''
  
      $Id$


This example shows how pre and post condition can be used for a Corba server object.


The example consists of three files;

ex.idl        - the interface specification
m_i_impl.erl  - the server implementation
tracer.erl    - a module which contains a pre and a post condition


The IDL file can for example be compiled with the following options:

ic:gen(ex, [{precond, {tracer, pre}},{{postcond, "m::i::f"}, {tracer, post}}]).

The result is that the function m::i::f gets both a pre and post condition call while 
the function m::i::g just get a pre condition call.


A pre/post condition function should always return the atom ok and if something is wrong
it should raise an exception ( ex: corba:raise(#userexception{}) ).




Compile all erlang files and test the application.

First start an erlang node, then type the following commands in the erlang shell.

1> mnesia:create_schema([]).
2> orber:install([]).
3> orber:start().
3>
3> X = m_i:oe_create().
4> catch m_i:f(X, 17).
Precond called in process <0.139.0>: m_i:f() [[],17]
f working ....
Postcond called in process <0.139.0>: m_i:f() [[],17] {reply,{17,17},[]}
17
5> 
5> catch m_i:f(X, q).
6> {'EXCEPTION',{m_NotAnInteger,"IDL:m/NotAnInteger:1.0"}}
7>
7>m_i:g(X, 17).
Precond called in process <0.139.0>: m_i:g() [[],17]
ok
g working ....
8> 
8>corba_boa:dispose(X).
9> orber:stop().
10>