~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/orber/doc/src/ch_example.xml

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="latin1" ?>
2
 
<!DOCTYPE chapter SYSTEM "chapter.dtd">
3
 
 
4
 
<chapter>
5
 
  <header>
6
 
    <copyright>
7
 
      <year>1997</year><year>2009</year>
8
 
      <holder>Ericsson AB. All Rights Reserved.</holder>
9
 
    </copyright>
10
 
    <legalnotice>
11
 
      The contents of this file are subject to the Erlang Public License,
12
 
      Version 1.1, (the "License"); you may not use this file except in
13
 
      compliance with the License. You should have received a copy of the
14
 
      Erlang Public License along with this software. If not, it can be
15
 
      retrieved online at http://www.erlang.org/.
16
 
    
17
 
      Software distributed under the License is distributed on an "AS IS"
18
 
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
19
 
      the License for the specific language governing rights and limitations
20
 
      under the License.
21
 
    
22
 
    </legalnotice>
23
 
 
24
 
    <title>Orber Examples</title>
25
 
    <prepared></prepared>
26
 
    <docno></docno>
27
 
    <date>1997-05-20</date>
28
 
    <rev>A</rev>
29
 
    <file>ch_example.xml</file>
30
 
  </header>
31
 
 
32
 
  <section>
33
 
    <title>A Tutorial on How to Create a Simple Service</title>
34
 
 
35
 
    <section>
36
 
      <title>Interface Design</title>
37
 
      <p>This example uses a very simple stack server. The specification
38
 
        contains two interfaces: the first is the Stack itself and the 
39
 
        other is the StackFactory which is used to create new stacks. 
40
 
        The specification is in the file <c>stack.idl</c>.</p>
41
 
      <codeinclude file="../../examples/Stack/stack.idl" tag="" type="c"></codeinclude>
42
 
    </section>
43
 
 
44
 
    <section>
45
 
      <title>Generating Erlang Code</title>
46
 
      <p>Run the IDL compiler on this file by calling the <c>ic:gen/1</c> function      </p>
47
 
      <code type="erl">
48
 
\0111> ic:gen("stack").
49
 
      </code>
50
 
      <p>This will produce the client stub and server skeleton. Among other files a stack API module named <c>StackModule_Stack.erl</c>
51
 
        will be produced.
52
 
        This will produce among other files a stack API module called 
53
 
        <c>StackModule_Stack.erl</c> which contains the client stub and
54
 
        the server skeleton. </p>
55
 
    </section>
56
 
 
57
 
    <section>
58
 
      <title>Implementation of Interface</title>
59
 
      <p>After generating the API stubs and the server skeletons it is time to 
60
 
        implement the servers and if no special options are sent 
61
 
        to the IDL compiler the file name should be
62
 
        <c><![CDATA[<global interface name>_impl.erl]]></c>, in our case
63
 
        <c>StackModule_Stack_impl.erl</c>.</p>
64
 
      <codeinclude file="../../examples/Stack/StackModule_Stack_impl.erl" tag="" type="erl"></codeinclude>
65
 
      <p>We also have the factory interface which is used to create new stacks
66
 
        and that implementation is in the file 
67
 
        <c>StackModule_StackFactory_impl.erl</c>.</p>
68
 
      <codeinclude file="../../examples/Stack/StackModule_StackFactory_impl.erl" tag="" type="erl"></codeinclude>
69
 
      <p>To start the factory server one executes the function 
70
 
        <c>StackModule_StackFactory:oe_create/0</c> which in this 
71
 
        example is done in the module <c>stack_factory.erl</c> where 
72
 
        the started service is also registered in the name service.</p>
73
 
      <codeinclude file="../../examples/Stack/stack_factory.erl" tag="" type="erl"></codeinclude>
74
 
    </section>
75
 
 
76
 
    <section>
77
 
      <title>Writing a Client in Erlang</title>
78
 
      <p>At last we will write a client to access our service.</p>
79
 
      <codeinclude file="../../examples/Stack/stack_client.erl" tag="" type="erl"></codeinclude>
80
 
    </section>
81
 
 
82
 
    <section>
83
 
      <title>Writing a Client in Java</title>
84
 
      <p>To write a Java client for Orber you must have another
85
 
        ORB that uses IIOP for client-server communication and supports a
86
 
        Java language mapping. It must also have support for
87
 
        <c>IDL:CosNaming/NamingContext</c> or <c>IDL:CosNaming/NamingContextExt</c>.
88
 
        If the client ORB support Interoperable Naming Service the Java Client
89
 
        can look like:</p>
90
 
      <codeinclude file="../../examples/Stack/StackClient.java" tag="" type="c"></codeinclude>
91
 
      <note>
92
 
        <p>If an ORB does not support CosNaming at all the <c>cos_naming.idl</c> 
93
 
          file must be compiled and imported.</p>
94
 
      </note>
95
 
    </section>
96
 
 
97
 
    <section>
98
 
      <title>Building the Example</title>
99
 
      <p>To build the example for access from a Java client you need a Java 
100
 
        enabled ORB (e.g. JavaIDL). The example below is based on JDK-1.4.</p>
101
 
      <code type="none">
102
 
fingolfin 127> erl            
103
 
Erlang (BEAM) emulator version 5.5.4.3 [async-threads:0] [hipe] [kernel-poll:false]
104
 
 
105
 
Eshell V5.5.4.3  (abort with ^G)
106
 
1> ic:gen(stack).
107
 
Erlang IDL compiler version 4.2.12
108
 
ok
109
 
2> make:all().
110
 
Recompile: StackModule_EmptyStack
111
 
Recompile: StackModule_Stack
112
 
Recompile: StackModule_StackFactory
113
 
Recompile: StackModule_StackFactory_impl
114
 
Recompile: StackModule_Stack_impl
115
 
Recompile: oe_stack
116
 
Recompile: stack_client
117
 
Recompile: stack_factory
118
 
up_to_date
119
 
3> 
120
 
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
121
 
       (v)ersion (k)ill (D)b-tables (d)istribution
122
 
a
123
 
fingolfin 128> idlj stack.idl
124
 
fingolfin 129> javac StackModule/*.java
125
 
fingolfin 130> javac *.java
126
 
fingolfin 131> cp StackClient.class StackModule/
127
 
      </code>
128
 
    </section>
129
 
 
130
 
    <section>
131
 
      <title>How to Run Everything</title>
132
 
      <p>Below is a short transcript on how to run Orber.</p>
133
 
      <code type="none">
134
 
 
135
 
fingolfin 143> erl 
136
 
Erlang (BEAM) emulator version 5.5.4.3 [async-threads:0] [hipe] [kernel-poll:false]
137
 
 
138
 
Eshell V5.5.4.3  (abort with ^G)
139
 
1> orber:jump_start([{interceptors, {native, [orber_iiop_tracer_silent]}}]).
140
 
ok
141
 
2> oe_stack:oe_register().     
142
 
ok
143
 
3> stack_factory:start().
144
 
ok
145
 
4> stack_client:run().
146
 
1
147
 
1
148
 
7
149
 
4
150
 
ok
151
 
5> 
152
 
      </code>
153
 
      <p>Before testing the Java part of this example generate and compile Java classes for 
154
 
        <c>orber/examples/stack.idl</c> as seen in the build example. 
155
 
        To run the Java client use the following command:</p>
156
 
      <code type="none">
157
 
 
158
 
fingolfin 38> java StackModule.StackClient "corbaname::localhost:4001#StackFactory"
159
 
1
160
 
1
161
 
7
162
 
4
163
 
Empty stack
164
 
fingolfin 39> 
165
 
      </code>
166
 
    </section>
167
 
  </section>
168
 
 
169
 
</chapter>
170