-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.txt
214 lines (135 loc) · 7.24 KB
/
README.txt
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
This is Glu.
Specifically, this is the pure Python version of Glu.
Files
=====
You can see the following files and directories:
src/ Contains the source code
src/python Contains the Python code (this includes some test utilities).
The glu/ directory there contains most of the code. starter.py
and glujson.py are the exception.
src/python/starter.py The start script for the Glu server. It is outside of the
glu/ directory, because this is going to change depending on
whether Glu runs in a container or standalone.
src/python/glujson.py It's very annoying that this file is even necessary. The reason
is that we would like to use JSON, but the available JSON
library is different depending on the runtime: jython, python
or Google AppEngine. It imports the 'right' JSON for each
case. This file will eventually go away once we have it
ported to pure Java, I assume.
src/python/glu_make_sample_resources.py This is a small utility that creates some
resources on a running server. It's not fancy
and was just created for testing.
src/java Contains the Java code
static_files/ The directory from where the Glu erver can serve static files.
app.yaml This file is used for Google AppEngine. It contains the
configuration for the application on GAE. OUTDATED!
index.yaml This file is used for Google AppEngine. It's automatically
updated by the GAE tools. OUTDATED!
Getting started
===============
Pure Python
-----------
0. Tell Glu that you are running in pure Python:
Edit glu/platform_specifics.py and make sure that
the PLATFORM variable is assigned like this:
PLATFORM = PLATFORM_PYTHON
1. Set your PYTHONPATH to point to this directory:
% export PYTHONPATH=`pwd`
2. Install 'paste' if you have not done so already:
% easy_install paste
3. Make sure that 'simplejson' is available in your
Python installation. If not do:
% easy_install simplejson
4. In your /tmp directory, create a /rdb/ directory.
That is where the server stores resource definitions.
5. Start the Glu server:
% python src/python/starter.py
Jython
------
0. Tell Glu that you are running in Jython:
Edit glu/platform_specifics.py and make sure that
the PLATFORM variable is assigned like this:
PLATFORM = PLATFORM_JYTHON
1. Set your PYTHONPATH to point to this directory:
% export PYTHONPATH=`pwd`
2. Install 'simplejson' if you have not done so already:
% wget http://peak.telecommunity.com/dist/ez_setup.py
% jython ez_setyp.py
% ln -s $JYTHON_HOME/bin/easy_install /usr/local/bin/jython_easy_install
% jython_easy_install simplejson
3. In your /tmp directory, create a /rdb/ directory.
That is where the server stores resource definitions.
4. Start the Glu server:
% jython src/python/starter.py
Google AppEngine (OUTDATED!)
----------------
0. Tell Glu that you are running on AppEngine:
Edit glu/platform_specifics.py and make sure that
the PLATFORM variable is assigned like this:
PLATFORM = PLATFORM_GAE
1. Move this directory into your local Google AppEngine
install directory.
2. To run in the local development server, use this command
from within your local AppEngine install:
% python dev_appserver.py glu/
3. To upload to AppEngine, use this command from within your
local AppEngine install:
% python appcfg.py update glu/
Development of mixed Jython/Java project in Eclipse
===================================================
This describes the necessary steps to be taken in Eclipse in order to
develop Glu as a mixed Jython/Java project.
0. The following pre-requisites are assumed:
- You have checked out the Glu project somewhere. Hereafter, we will
refer to the directory which was created during the checkout as "$GLU".
- You have installed PyDev and Jython as described here:
http://corp.wiki.mulesource.com/display/MULEDEV/Working+with+Python
1. Start a PyDev project and call it 'Glu_Python' (switch to the PyDev perspective for this).
2. Set the 'src' folder for this project to be $GLU/src/python. There is
probably a neat way to do this in Eclipse (creating folder resources and
referencing this somehow?), but it seems that PyDev is a bit more limited
than a normal Java project. So, instead I just created a symbolic link to that
external source directory in the $GLU folder:
a. Go to the $WORKSPACE/Glu_Python directory.
b. % rmdir src
c. % ln -s $GLU/src/python src
d. Refresh the project in Eclipse.
3. Start a Java project and call it 'Glu_Java' (switch to the Java perspective for this).
4. Set the 'src' folder for this project to be $GLU/src/java. For Java Eclipse
offers other ways to include external folders. However, to keep things uniform
I have simply used the symbolic link approach that I used for Python:
a. Go to the $WORKSPACE/Glu_Java directory.
b. % rmdir src
c. % ln -s $GLU/src/java src
d. Refresh the project in Eclipse.
You should see the 'org.mulesource.glu' package and the sample FooBar.java file.
5. Right click on the 'Glu_Java' project, find the 'PyDev' menu item and select
'Set as PyDev Project'.
6. Right click on the 'Glu_Python' project and select 'New->SourceFolder'.
Chose to add the 'bin' folder from the 'Test_Java' project by specifying 'Test_Java'
as the project name and 'bin' as the folder name.
7. Set 'Glu_Java' as a project reference for 'Glu_Python'.
8. Tell the system where to find your resources folder. For this, edit the file
$GLU/src/python/glu/platform_specifics.py
Locate the definition of STORAGE_OBJECT. Specifically the line:
STORAGE_OBJECT = FileStorage("resourceDB")
Edit the 'resourceDB' to be the absolute path for your resource directory.
When you check out Glu you find a 'resourceDB' directory created within $GLU.
You could therefore edit this to read "$GLU/resourceDB" (unless you set $GLU
as a variable for the project, you'd have to expand that part of the path
name manually).
Alternatively, we can just use a link again. Since we start the server
by running '$GLU/src/python/starter.py' we can create a symbolic link in
$GLU/src/python to point to the actual location of the 'resourceDB' directory:
% ln -s $GLU/resourceDB $GLU/src/python/resourceDB
The advantage of this approach is that you don't have to edit the source
file at all.
9. Use the same approach to tell Glu where to find the static_file folder.
Either edit the $GLU/settings.py file and modify the STATIC_LOCATION variable,
or create another symbolic link without editing any source:
% ln -s $GLU/static_files $GLU/src/python/static_files
10. Test that your project works by right-clicking on 'starter.py' in your
'Glu_Python' project (in the src/glu folder) and selecting 'Run As -> Jython Run'.
After a short while you should see the server's startup message appear, informing
you that it listens on port 8001. You should then be able to take your web browser
to http://localhost:8001 and connect to the Glu server.