forked from ubf/ubf-jsonrpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
208 lines (142 loc) · 6.32 KB
/
README
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
This is ubf-jsonrpc, a framework for integrating UBF, JSF and
JSON-RPC. This repository depends on the ubf, gmt-util, and mochiweb
open source repositories.
To download
===========
1. Configure your e-mail and name for Git
$ git config --global user.email "[email protected]"
$ git config --global user.name "Your Name"
2. Install Repo
$ mkdir -p ~/bin
$ wget -O - http://android.git.kernel.org/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
3. Create working directory
$ mkdir working-directory-name
$ cd working-directory-name
$ repo init -u git://github.com/norton/manifests.git -m ubf-jsonrpc-default.xml
NOTE: Your "Git" identity is needed during the init step. Please
enter the name and email of your GitHub account if you have one.
Team members having read-write access are recommended to use "repo
init -u [email protected]:norton/manifests.git -m
ubf-jsonrpc-default-rw.xml".
TIP: If you want to checkout the latest development version of UBF
JSON-RPC, please append " -b dev" to the repo init command.
4. Download Git repositories
$ cd working-directory-name
$ repo sync
For futher information and help for related tools, please refer to the
following links:
- Erlang - http://www.erlang.org/
* *R14B01 has been tested most recently*
* *R13B01 or newer*
- Git - http://git-scm.com/
* *Git 1.5.4 or newer*
* _required for Repo and GitHub_
- GitHub - https://github.com
- Python - http://www.python.org
* *Python 2.4 or newer (CAUTION: Python 3.x might be too new)*
* _required for Repo_
- Rebar - https://github.com/basho/rebar/wiki
- Repo - http://source.android.com/source/git-repo.html
To build - basic recipe
=======================
1. Get and install an erlang system
http://www.erlang.org
2. Build UBF
$ cd working-directory-name/src
$ make compile
3. Run the unit tests
$ cd working-directory-name/src
$ make eunit
To build - optional features
============================
A. Dialyzer Testing _basic recipe_
A.1. Build Dialyzer's PLT _(required once)_
$ cd working-directory-name/src
$ make build-plt
TIP: Check Makefile and dialyzer's documentation for further
information.
A.2. Dialyze without specs
$ cd working-directory-name/src
$ make dialyze
CAUTION: If you manually run dialyzer with the "-r" option, execute
"make clean compile" first to avoid finding duplicate beam files
underneath rebar's .eunit directory. Check Makefile for further
information.
A.3. Dialyze with specs
$ cd working-directory-name/src
$ make dialyze-spec
Documentation -- Where should I start?
======================================
This README is a good first step. Check out and build using the "To
build" instructions above.
The UBF User's Guide is the best next step. Check out
http://norton.github.com/ubf/ubf-user-guide.en.html for further
detailed information.
Eunit tests can be found in the test/eunit directory. These
tests illustrate an inets-based httpd module that uses UBF's contract
manager for checking JSON-RPC requests and responses.
What is UBF?
============
UBF is the "Universal Binary Format", designed and implemented by Joe
Armstrong. UBF is a language for transporting and describing complex
data structures across a network. It has three components:
* UBF(A) is a "language neutral" data transport format, roughly
equivalent to well-formed XML.
* UBF(B) is a programming language for describing types in UBF(A)
and protocols between clients and servers. This layer is
typically called the "protocol contract". UBF(B) is roughly
equivalent to Verified XML, XML-schemas, SOAP and WDSL.
* UBF(C) is a meta-level protocol used between a UBF client and a
UBF server.
See http://norton.github.com/ubf for further details.
What is JSF?
============
JSF is an implementation of UBF(B) but does not use UBF(A) for
client<->server communication. Instead, JSON (RFC 4627) is used.
"JSF" is short for "JavaScript Format".
There is no agreed-upon convention for converting Erlang terms to JSON
objects. This library uses the convention set forth by MochiWeb's
JSON library (see URL above). In addition, there are a couple of
other conventions layered on top of MochiWeb's implementation.
The UBF(B) contract checker has been modified to make a distinction
between an Erlang record and an arbitrary Erlang tuple. An
experience Erlang developer would view such a distinction either
with skepticism or with approval.
For the skeptics, the contract author has the option of having the
UBF(B) contract compiler automatically generate Erlang -record()
definitions for appropriate tuples within the contract. Such
record definitions are very convenient for developers on the Erlang
side of the world, but they introduce more complication to the
JavaScript side of the world. For example, JavaScript does not
have a concept of an arbitrary atom, as Erlang does. Also, the
JavaScript side must make a distinction between {foo, 42} and {bar,
42} when #foo is a record on the Erlang side but #bar is not.
This extra convention creates something slightly messy-looking, if you
look at the raw JSON passed back-and-forth. The examples of the
Erlang record {foo, 42} and the general tuple {bar, 42} would look
like this:
record (defined in the contract as "foo() = #foo{attribute1 = term()};")
{"$R":"foo", "attribute1":42}
general tuple
{"$T":[{"$A":"bar"}, 42]}
However, it requires very little JavaScript code to convert objects
with the "$R", "$T", and "$A" notation (for records, tuples, and
atoms) into whatever object is most convenient.
TIP: Gemini Mobile Technologies, Inc. has implemented a module for
classifying the input character set to detect non-UTF8 JSON inputs.
This module has been released to the open-source world
(http://github.com/norton/gmt-util/blob/master/src/gmt_charset.erl).
What is JSON-RPC?
=================
JSON-RPC is a remote procedure call protocol encoded in JSON. See
http://json-rpc.org/ for full details.
Credits
=======
Many, many thanks to Joe Armstrong, UBF's designer and original
implementor.
Thanks to MochiWeb. UBF-JSONRPC relies on the MochiWeb
(i.e. mochijson2.erl) application for encoding and decoding JSON in
erlang.
Gemini Mobile Technologies, Inc. has approved the release of this
repository under an MIT license.