Project

General

Profile

How to run a sample » History » Version 16

Henning Blohm, 11.09.2012 15:40

1 1 Henning Blohm
h1. How to Run a Sample
2
3
Various z2-based sample system configurations have been prepared as Git repositories. 
4
5 14 Henning Blohm
Assuming you know the repository URL these three steps (with or without Eclipse) are all there is to do: 
6
7
h1. Eclipse users
8
9 16 Henning Blohm
Most likely you also want to look at code or configuration files of an example. That is why we recommend to start from within the Eclipse IDE. If you prefer the command line or another IDE, please proceed to [[How to Run a Sample#From the Command Line]].
10 14 Henning Blohm
11
12 15 Henning Blohm
h1. From the Command Line
13 14 Henning Blohm
14 1 Henning Blohm
15 2 Henning Blohm
h2. 0. Pre-Requisites
16
17
All you need is Java Runtime Environment (JRE) of at least version 6. Preferrably, as that is easier to understand a sample, have the Eclipse IDE installed.
18 3 Henning Blohm
Other pre-requisites, for example some database setup may be required based on the specific example, i.e. stuff that cannot be covered here.
19 2 Henning Blohm
20 1 Henning Blohm
h2. 1. Prepare a z2-base Installation
21 2 Henning Blohm
22
Create a folder to hold the installation. We will assume that folder is called *sample*
23
24
In *sample* execute
25
26 11 Henning Blohm
<pre>
27 5 Henning Blohm
git clone -b master http://git.z2-environment.net/z2-base.core
28 11 Henning Blohm
</pre>
29 2 Henning Blohm
30
Go into *sample/z2-base.core/run/bin* and run 
31
32
<pre>
33
./gui.sh
34
</pre>
35
36
or 
37
38
<pre>
39
gui.bat
40
</pre>
41 1 Henning Blohm
42 3 Henning Blohm
depending on your operating system. A simple graphical console should open up that displays the console log output of the z2 &lt;home&gt; and worker processes - as explained in http://www.z2-environment.eu/check_it_out.
43 2 Henning Blohm
44
At the first start, the environment will download required resources, which may take a few minutes - depending on your network bandwidth. Subsequent starts will be faster.
45
Eventually the server should be up and you can go to the basic admin view at http://localhost:8080/adm (use z* with password z) to verify everything is cool.
46 1 Henning Blohm
47 6 Henning Blohm
Stop the environment again by either pressing Ctrl+C on the console where you started the GUI or by clicking the Exit button on the GUI.
48 1 Henning Blohm
49 3 Henning Blohm
h2. 2. Clone the specific sample repository
50 1 Henning Blohm
51 3 Henning Blohm
Given the sample repository is called *z2-samples.sampleX*, go into *sample* once more and run 
52 1 Henning Blohm
53 3 Henning Blohm
<pre>
54 5 Henning Blohm
git clone -b master http://git.z2-environment.net/z2-samples.sampleX
55 3 Henning Blohm
</pre>
56
57
Now start the environment as described above. The environment will now run with the sample configuration and all required dependencies.
58
59 4 Henning Blohm
In other words: That's it.
60
61 3 Henning Blohm
h2. Why does that actually work
62
63
If you care, here is how everything falls into place:
64
65 13 Henning Blohm
The z2-base.core repository contains a z2 core installation that is bound to a remote "system repository" at "http://git.z2-environment.net/z2-base.base":http://redmine.z2-environment.net/projects/z2-base/repository/base?rev=master. As it is by now best practice with z2, that repository contains an *environment* module that describes system specific settings such as other repositories.
66 3 Henning Blohm
67
By cloning the sample repository you put an override of *environment* module into view of the _dev repository_. That is, the local server will take your local definitions with preference over the remote definitions. These may include other remote component repositories such as *z2-addons.spring*.
68
69
In addition the sample repository contains all the modules holding code and other resources that implement the actual sample.
70
71
If you already understand how the _dev repository_ works, you will not be surprised to find files called LOCAL in the module folders of cloned repository's workspace.
72
73
h2. References
74
75
* Dev Repository: http://www.z2-environment.eu/v20doc#Workspace%20Development%20Using%20the%20Dev%20Repository