Project

General

Profile

How to create your own system » History » Version 7

Henning Blohm, 20.07.2013 15:43

1 2 Henning Blohm
h1. How to create your own system
2 1 Henning Blohm
3 5 Henning Blohm
This Wiki is on the task of creating a complete system of yours. I.e. to set up a development of your own solution based on the z2-base system.
4 1 Henning Blohm
5 5 Henning Blohm
*Note:* This is not needed to run the samples or to check things out. This is only useful, if you wish to start 
6
7
Fortunately, the actual things to do a are few and simple.
8 1 Henning Blohm
9 7 Henning Blohm
From a Z2 Core perspective it all starts with the local repository that is part of the core (to be found in @Z2_HOME/run/local@). In there, we define at least the _Base Repository_. The Base Repository typically points to some remote Git or Subversion based repository. Once Z2 has registered that repository, other repository may have appeared that will be registered as well which may lead to the appearance of more repositories and so on. Hence, in effect, we have a chain or tree of repositories with the local repository on its root as far as repositories contain declarations of repositories. 
10 4 Henning Blohm
11 3 Henning Blohm
On the other hand, repositories have a priority (more on that below) that determines what repository has the right to say what a module contains. 
12 4 Henning Blohm
13 3 Henning Blohm
Based on that mechanism you can construct a system definitions that consist of as few as one repository (if we do not count the core) or many repositories of which some are even shared between systems.
14 4 Henning Blohm
15 3 Henning Blohm
Before moving forward on that, let's have a look at the add-ons. 
16 1 Henning Blohm
17 3 Henning Blohm
h2. Add-ons
18 1 Henning Blohm
19 3 Henning Blohm
Add-ons (see [[Add-ons]]) add more functionality to Z2. Generally speaking, an add-on is a regular Git or Subversion  repository that holds one or more modules and is incorporated into a z2-Environment defined system via a component repository declaration (see Components and Component Repositories).
20 1 Henning Blohm
21 3 Henning Blohm
In other words, technically there is nothing particular about add-ons. It is the way they are used that is noteworthy. The idea is that you can pick the add-ons you need and add them on top of z2-base. Previously Z2 was available in distributions. Now you take z2-base and add what you need on top. 
22 1 Henning Blohm
23 3 Henning Blohm
Add-ons provided on z2-environment.net are versioned just like z2-base, so that there is no complicated version vector.  Also add-ons have some documentation in the z2-Environment Wiki and come with some samples.
24 1 Henning Blohm
25 6 Henning Blohm
h2. Assembling a system on z2-base and add-ons
26 3 Henning Blohm
27 7 Henning Blohm
Starting from a z2 core installation, a z2 home, there are two recommended repository configurations that hook a home up with remote content:
28 1 Henning Blohm
29 7 Henning Blohm
# com.zfabrik.boot.config/baseRepository (located in @<Z2_HOME>/run/local/com.zfabrik.boot.config/baseRepository.properties) and 
30
# com.zfabrik.boot.config/scenarioRepository (located in @<Z2_HOME>/run/local/com.zfabrik.boot.config/baseRepository.properties)
31 1 Henning Blohm
32 7 Henning Blohm
The first one points to the *z2-base.base* repository by default. The base repository completes the system to the extent that all commonly used features (such as the web container) are available. The second repository, the scenario repository, points to the top of the repository food chain that makes the solution (see the diagram below). This setup is of course a matter of choice and simply what we find practical. 
33
34
The scenario repository has a higher priority than the base repository, meaning that its module may overwrite definitions of the base repository.
35
36
Within the scenario repository (and, following the previous paragraph, as a fallback within the base repository), it is a best practice to encapsulate all system-specifc configuration in a module called *environment*. Also the repository "z2-base.base":http://redmine.z2-environment.net/projects/z2-base/repository/base contains an environment module (exactly "here":http://redmine.z2-environment.net/projects/z2-base/repository/base/show/environment?rev=master). 
37
38
The environment module is one of the preferred places to add additional repository definitions.
39 3 Henning Blohm
40
We recommend a setup where the z2-base repositories hosted z2-environment.net can be incorporated as-is, modulo copying or cloning, that has zero or more add-ons from z2-environment.net or from you and that has one scenario repository that assembles everything.
41
42
Such a setup consists of a *z2-base.core* (or a clone or a copy – in all cases from here on) and a *z2-base.base* plus zero or more add-ons, and one of possibly many scenario repositories.
43
44
The Local Repository, in the core, has the Base Repository pointing to *z2-base.base* and an Scenario Repository, next to the Base Repository (*z2-base.core* contains a template for that) that points to the Scenario Repository. 
45
46
The Scenario Repository has an *environment* module that has definitions for all other add-ons used in the scenario. 
47
48
And finally, the scenario component repository has a higher priority that the base component repository. 
49
50
Here is a schematic overview:
51
52
!extensions.png!
53 4 Henning Blohm
54
Sounds complicated. But in reality, it's really just filling the scenario component repository definition. The samples in z2-environment.net work almost exactly the same way. The difference is that we do not use the extension component repository but rather the Development Repository.
55
56
The effects of this setup are:
57
58
*The z2-base.core always stays connected with z2-base.base*
59
60
This is somewhat crucial. There is no meaningful way of using Z2 without a base repository like z2-base.base.
61
62
*You can run many scenarios with shared add-ons*
63
64
By only changing the scenario repository definition you can control a complete application system definition that is implemented on a Z2 Home - while still sharing all Add-on and base repositories. 
65
66
The *environment* module in the scenario repository defines what is part of the scenario.
67
68
*You can leave repositories from z2-environment.net untouched*
69
70
As you only re-use, typically you will not need to modify repository content unless you apply bug fixes and the like. That separates cleanly what is yours, what is from others.