How to run a sample » History » Version 18
Henning Blohm, 11.09.2012 16:03
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 | 18 | Henning Blohm | Most likely you will want to look at code or configuration files of a sample. 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|From the Command Line]]. |
10 | 14 | Henning Blohm | |
11 | 17 | Henning Blohm | Open Eclipse with a new workspace in a new folder, say *sample*. Note: We will clone repositories as siblings to your workspace. So let's assume your workspace is *sample/workspace*. |
12 | 1 | Henning Blohm | |
13 | 17 | Henning Blohm | h2. 1. Prepare a z2-base Installation |
14 | 1 | Henning Blohm | |
15 | 17 | Henning Blohm | As the location where repositories are cloned to matters, it is simplest you open the Git tab in the Eclipse preferences and enter "${workspace_loc}/.." as default repository location. |
16 | 1 | Henning Blohm | |
17 | 18 | Henning Blohm | Open the Git Perspective and clone the "z2-base.core":http://redmine.z2-environment.net/projects/z2-base/repository/core repository from this URL *http://git.z2-environment.net/z2-base.core*. For convenience choose to import all projects into the workspace or do so after cloning has completed. You should end up having a project *core* in your workspace. That project is the z2 core that will fetch dependency resources as needed later on. |
18 | 1 | Henning Blohm | |
19 | 17 | Henning Blohm | h2. 2. Clone the Sample Repository |
20 | |||
21 | Now repeat the same with the repository for the specific sample. It is important that the repository is cloned as a sibling to the core, So that the core can pick up modules defined in the sample. |
||
22 | |||
23 | h2. 3. Start |
||
24 | |||
25 | You can launch Z2 from Eclipse by the _launcher_ file in the root of the *core* project (or by navigating to *Run* / *External Tools* / *External Tools Configurations...* and pick the launcher). A GUI wrapping the console should open up and you are ready to go. |
||
26 | |||
27 | h1. From the Command Line |
||
28 | |||
29 | All you need is Java Runtime Environment (JRE) of at least version 6. Other pre-requisites, for example some database setup may be required based on the specific example, i.e. stuff that cannot be covered here. |
||
30 | 1 | Henning Blohm | |
31 | 2 | Henning Blohm | h2. 1. Prepare a z2-base Installation |
32 | |||
33 | Create a folder to hold the installation. We will assume that folder is called *sample* |
||
34 | |||
35 | In *sample* execute |
||
36 | 11 | Henning Blohm | |
37 | 5 | Henning Blohm | <pre> |
38 | 11 | Henning Blohm | git clone -b master http://git.z2-environment.net/z2-base.core |
39 | 2 | Henning Blohm | </pre> |
40 | |||
41 | Go into *sample/z2-base.core/run/bin* and run |
||
42 | |||
43 | <pre> |
||
44 | ./gui.sh |
||
45 | </pre> |
||
46 | |||
47 | or |
||
48 | |||
49 | <pre> |
||
50 | gui.bat |
||
51 | 1 | Henning Blohm | </pre> |
52 | 3 | Henning Blohm | |
53 | 2 | Henning Blohm | depending on your operating system. A simple graphical console should open up that displays the console log output of the z2 <home> and worker processes - as explained in http://www.z2-environment.eu/check_it_out. |
54 | |||
55 | 18 | Henning Blohm | 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 much quicker. 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. You do actually not need to start before completing step 3. But checking things are working doesn't hurt either. |
56 | 6 | Henning Blohm | |
57 | 1 | 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. |
58 | 3 | Henning Blohm | |
59 | 1 | Henning Blohm | h2. 2. Clone the specific sample repository |
60 | 3 | Henning Blohm | |
61 | 1 | Henning Blohm | Given the sample repository is called *z2-samples.sampleX*, go into *sample* once more and run |
62 | 3 | Henning Blohm | |
63 | 1 | Henning Blohm | <pre> |
64 | git clone -b master http://git.z2-environment.net/z2-samples.sampleX |
||
65 | 5 | Henning Blohm | </pre> |
66 | 3 | Henning Blohm | |
67 | 18 | Henning Blohm | h2. 3. Start |
68 | |||
69 | Now start the environment again as described above. The environment will now run with the sample configuration and all required dependencies. |
||
70 | 4 | Henning Blohm | |
71 | In other words: That's it. |
||
72 | 3 | Henning Blohm | |
73 | h2. Why does that actually work |
||
74 | |||
75 | If you care, here is how everything falls into place: |
||
76 | 13 | Henning Blohm | |
77 | 3 | 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. |
78 | |||
79 | 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*. |
||
80 | |||
81 | In addition the sample repository contains all the modules holding code and other resources that implement the actual sample. |
||
82 | |||
83 | 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. |
||
84 | |||
85 | h2. References |
||
86 | |||
87 | 1 | Henning Blohm | * Dev Repository: http://www.z2-environment.eu/v20doc#Workspace%20Development%20Using%20the%20Dev%20Repository |