Project

General

Profile

How to run a sample » History » Revision 17

Revision 16 (Henning Blohm, 11.09.2012 15:40) → Revision 17/39 (Henning Blohm, 11.09.2012 15:58)

h1. How to Run a Sample 

 Various z2-based sample system configurations have been prepared as Git repositories.  

 Assuming you know the repository URL these three steps (with or without Eclipse) are all there is to do:  

 h1. Eclipse users 

 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]]. 

 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*. 

 h2. 1. Prepare a z2-base Installation 

 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. 

 Open the Git Perspective and clone the "z2-base.core":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. 

 h2. 2. Clone the Sample Repository 

 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. 

 h2. 3. Start 

 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. 

 


 h1. From the Command Line 


 h2. 0. Pre-Requisites 

 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. 
 Other pre-requisites, for example some database setup may be required based on the specific example, i.e. stuff that cannot be covered here. 

 h2. 1. Prepare a z2-base Installation 

 Create a folder to hold the installation. We will assume that folder is called *sample* 

 In *sample* execute 

 <pre> 
 git clone -b master http://git.z2-environment.net/z2-base.core 
 </pre> 

 Go into *sample/z2-base.core/run/bin* and run  

 <pre> 
 ./gui.sh 
 </pre> 

 or  

 <pre> 
 gui.bat 
 </pre> 

 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. 

 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. 
 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. 

 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. 

 h2. 2. Clone the specific sample repository 

 Given the sample repository is called *z2-samples.sampleX*, go into *sample* once more and run  

 <pre> 
 git clone -b master http://git.z2-environment.net/z2-samples.sampleX 
 </pre> 

 Now start the environment as described above. The environment will now run with the sample configuration and all required dependencies. 

 In other words: That's it. 

 h2. Why does that actually work 

 If you care, here is how everything falls into place: 

 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. 

 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*. 

 In addition the sample repository contains all the modules holding code and other resources that implement the actual sample. 

 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. 

 h2. References 

 * Dev Repository: http://www.z2-environment.eu/v20doc#Workspace%20Development%20Using%20the%20Dev%20Repository