Project

General

Profile

Getting Started » History » Version 10

Henning Blohm, 01.03.2015 21:31

1 3 Henning Blohm
h1. Getting Started with org.z2env
2 1 Henning Blohm
3
See also [[FAQ]]
4
5
To understand how z2 works, you need to understand at most what are z2 modules and components and what are component repositories and how these concepts interplay. 
6
7
Check out [[wiki#Understanding-Z2|understanding-z2]] for that.
8
9
It is simplest to start by running a simple Java main program in z2 or a simple Web App. 
10
11
Follow this trail:
12
13
* [[Getting Started#Building-z2env-core|Building the core]]
14
* [[Getting Started#Running-a-Hello-World-main-program|Running a Hello World main program]]
15
* [[Getting Started#Running-a-Hello-World-Web-App|Running a Hello World Web App]]
16
* [[Getting Started#Developing-with-Eclipse-or-IntelliJ|Developing with Eclipse or IntelliJ]]
17
* [[Getting Started#Going-Multi-Module|Going Multi Module]]
18
19 9 Henning Blohm
---
20 1 Henning Blohm
21
h2. Building z2env-core
22
23
(For now, we need to build the core).
24
25 4 Henning Blohm
{{collapse
26 1 Henning Blohm
h3. Pre-requisites
27
28
* You need Git installed
29
* You need a JDK, at least version 7
30
* You need the ANT build tool
31
32
First clone http://git.z2-environment.net/z2env.core
33
34
<pre>
35
git clone http://git.z2-environment.net/z2env.core
36
</pre>
37
38
Change into *org.z2env.core.main* and run 
39
40
<pre>
41
ant -Doutput=<z2home> -Dsetup=<setup> 
42
</pre>
43
44
where <z2home> is where you want to install z2 (the *z2 home* that is) and <setup> is a choice of pre-configured content, actually component repositories.
45
46
If you omit *output* it will default to *gen/dist*. If you omit *setup*, no content will be pre-configured will be modified. 
47
48
Check the folder *setups* for available setups of the core build. These can be local (all repos will be cloned locally) or remote (repos will be remoted).
49
50
In general this build always updates only boot, z.jar, roots. It will not remove anything.
51
52
53
Example to install/update a core only into ../../z2env:
54
55
<pre>
56
ant -Doutput=../../z2env 
57
</pre>
58
59
To install/update a web-basic setup (with tomcat and eclipsoid support) with updates from remote repos:
60
61
<pre>
62
ant -Doutput=../../z2env -Dsetup=web-basic-remote
63
</pre>
64
65
Check out [[wiki#Understanding-the-ltHOMEgt|Understanding the <HOME>]] to learn more about the generated structure.
66
67 2 Henning Blohm
h4. Summary
68 1 Henning Blohm
69 2 Henning Blohm
* At any time you can update a z2 core installation by running the core build and using the *output* property to point to your installation
70
* Using the *setup* property you can choose between completely local setups (no remote access required - no automatic synchronization from remote either) or mostly remote setups (all except the core will be synchronized from remote repositories). 
71
72 4 Henning Blohm
}}
73
74 9 Henning Blohm
75
---
76
77 1 Henning Blohm
h2. Running a Hello World main program
78
79 5 Henning Blohm
In this section we will let z2 do what it is actually made for: Run some Java program in a modular environment without build and deploy.
80
81 4 Henning Blohm
{{collapse
82 1 Henning Blohm
For now, we will assume you have a z2 core installed in <HOME>. In its purest form, all the core can actually execute is simple Java main programs. 
83
84
Being in a modular environment, even if we only want to say „Hello World“, we need a module. Let's call it the greeter module. In order to have a main program run by z2, we need to also declare a  component for it, as that is what we tell z2 to run (not a class – mind you – but rather a component in a module). Assuming we use the local component name hello, than the absolut component name is 
85
86
<pre>
87
greeter/hello
88
</pre>
89
90
Finally, as this component actually has implementation code, we need to declare a Java component. By convention this is 
91
92
<pre>
93
greeter/java
94
</pre>
95
96
Now, after installing in <HOME> the place to simply drop a module is under <HOME>/modules. You might need to create that folder.
97
98
All in all, here is the complete structure to create:
99
100
| <HOME>/modules/greeter/hello.properties | 
101
<pre><code class="ruby">org.z2env.component.type=org.z2env.main
102
component.className=greetings.Main
103
</code></pre> |
104
| <HOME>/modules/greeter/java/z.properties | 
105
<pre><code class="ruby">org.z2env.component.type=org.z2env.java
106
</code></pre> |
107
| <HOME>/modules/greeter/java/src.impl/greetings/Main.java |
108
<pre><code class="java">
109
package greetings;
110
111
public class Main {
112
  public static void main(String[] args) {
113
    System.out.println("Hello!");
114
  }
115
}
116
</code></pre> |
117
118
That gives us the two components of module greeter. To run this on the command line, run
119
120
<pre>
121
java -DcomponentName=greeter/hello -jar z.jar
122
</pre>
123
124
Now, obviously this sample is not worth a modular execution environment. But even from here, you could check your module in with some Git repository that is referenced from the roots and all other users of the same repo would be able to run your component without installing anything.
125
126 2 Henning Blohm
h4. Summary
127
128
* Running a simple program in a modular environment requires no more than declaring the modules and add some code
129
* Apart from more technical component types, at the heart of the z2 core is to run simple Java main programs
130
131 4 Henning Blohm
}}
132 2 Henning Blohm
133 9 Henning Blohm
134
---
135
136 1 Henning Blohm
h2. Running a Hello World Web App
137
138 6 Henning Blohm
Rather than just running a Main program, using the Tomcat add-on we might as well run full-featured Web applications - of course: From anywhere, without build and deploy.
139
140 4 Henning Blohm
{{collapse
141
142 1 Henning Blohm
This introduction explains how to connect a z2 core to a given Tomcat installation and how to develop a simple Web Application.
143
144
Furthermore it describes how to use the Dev Repository and the Eclipsoid plugin for the Eclipse or the IntelliJ development environment.
145
146
h3. Pre-Requisites
147
148
* We assume a development workspace in *workspace*.
149
* Have a local Tomcat (7 or higher) installation.*
150
151
h3. Steps we are going to take
152
153
# Create a module with a simple Web app
154
# Make it visible to Z2
155
# Run the Web App in a Tomcat Web Container
156
157
At first get yourself a z2env core with the *web-basic-local* or *web-basic-remote* setup. Make sure it is in your *workspace*. If you follow [[wiki#Building-z2env-core|Building the core]] this means running 
158
159
<pre>
160
ant -Doutput=workspace/z2env -Dsetup=web-basic-remote
161
</pre>
162
163
(*Note:* If in doubt, use an absolute path for *workspace*)
164
165
Using your IDE create a new project *hello* in *workspace* with the following structure:
166
167
| java/z.properties | 
168
<pre><code class="ruby">
169
org.z2env.component.type=org.z2env.java
170
java.privateReferences=\
171
	javax.servlet
172
</code></pre> |
173
| web/z.properties |
174
<pre><code class="ruby">
175
org.z2env.component.type=org.z2env.tomcat.webapp
176
webapp.path=/hello
177
</code></pre> |
178
| web/WebContent/index.jsp |
179
<pre><code class="html"><html><body>Hello! Did you know that 7*7=<%=7*7%>?</body></html></code></pre> |
180
| LOCAL | <empty file> |
181
182
Your *workspace* folder now contains two subfolders *z2env* and *hello*.
183
184
So far, that's it.  We will touch on the LOCAL file later. 
185
186
When we run Z2 knowing this Web Application, it will attempt to start a Tomcat Web Container that will serve the application's content. To do that, it needs to find one. 
187
188
In order to tell Z2 where to look, you can either set an environment variable *CATALINA_HOME* (you might have already – it's the Tomcat standard) or specify an environment variable *catalina.home*. 
189
190
To be on the safe side and assuming the location is */home/me/tomcat*, we open a terminal, change into *workspace/z2env* and run
191
192
<pre>
193
java -Dcatalina.home=/home/me/tomcat -jar z.jar hello/web
194
</pre>
195
196
Note, unlike for the main program, the command line will not return. Instead you can enter „q“ to quit or „s“ to synchronize. But first let's open a browser and check out 
197
198
<pre>
199
http://localhost:8080/hello
200
</pre>
201
202
*Note:* What you just created is a prototypical z2 module structure containing a Java component *java* (holding implementation) and a Web component *web*. 
203
204
Instead of creating the structure yourself, you could use the Eclipsoid plugin (introduced below) for that:
205
* In Eclipse: New / Others / new z2...., 
206
* In IntelliJ: New / Module / z2....
207
208
... but beware of the pre-generated configuration. Where it says *com.zfabrik* change to *org.z2env*.
209
210
211
*Note:* Now on to that LOCAL file. Unlike for the Hello World main program, this time it was to so-called Dev Repo that made our module available to z2. 
212
213
The dev repo is a key component to the development approach with z2. It checks for all modules that have a LOCAL file and that are stored some levels deep, relative to the parent folder of the z2 home (by default), which not so coincidentally is our workspace.
214
215
We call modules with a LOCAL file _armed_.
216
217
*Note:* By default the dev repo looks for modules beneath the parent folder of the <home> location. Use the system property *org.z2env.dev.local.workspace* to specify other locations (separated by comma) to check for modules.
218
219
220
Try this: 
221
222
# Remove LOCAL
223
# Enter „s“ for synchronization. 
224
# Check the URL above (should say „not found“)
225
# Create a LOCAL file again
226
# Synchronize
227
# Check again.
228
229
Similarly, from now on, changes made to the hello module will be picked up, whenever you synchronize.
230
231 2 Henning Blohm
h4. Summary
232
233
* Addons extend z2 with capabilities, such as a Tomcat hosted Web application (albeit running in z2's module environment)
234
* The _dev repository_ allows to flexibly define local modules. Modules can put into or out visibility by a simple LOCAL marker file.
235
236 4 Henning Blohm
}}
237
238 9 Henning Blohm
239
---
240
241 1 Henning Blohm
h2. Developing with Eclipse or IntelliJ
242
243
In this section we will add some code to the hello Web app and see how to develop using an integrated development environment like the Eclipse IDE or Jetbrains' IntelliJ IDEA.
244
245 4 Henning Blohm
{{collapse
246
247 1 Henning Blohm
h3. Pre-Requisite
248
249
* Have an Eclipse or IntelliJ installation
250
* Install the Eclipsoid plugin from http://z2-environment.net/eclipsoid/update/site.xml or by searching for "z2" in the IntelliJ Plugin Repository respectively
251
252
h3. Steps we are going to take
253
254
# Complete the development workspace setup
255
# Add a simple Controller
256
257
h4. In Eclipse
258
259
Use the workspace *workspace*. Create a Java project *hello* where we created the *hello* module. That is, we use the existing module as project content. You should now have an Eclipse development workspace that has one Java project named "hello". Right-click on the project and choose "Transform into z2 Project". A small "Z" icon should not decorate the project icon. 
260
261
Add a source folder *java/src.impl* to the project.
262
263
Try "Arm Z2 Projects" and "Disarm Z2 Projects" from the context menu. You should see a LOCAL file showing up and disappearing as well as the "Z" decoration showing a green halo and going back to normal. 
264
265
Go into Window/Preferences, pick "z2-Environment". Change the port to 8081, set the user to "z*" and the password to "z". Done.
266
267
h4. In IntelliJ
268
269
Add a source folder *java/src.impl* to the module.
270
271
Start a new Project with root folder *workspace*. Press the "Manage z2-Modules" button in the toolbar. Import the *hello* module into your IntelliJ project. Open the Settings dialog, pick "z2-Environment". Change the port to 8081, set the user to "z*" and the password to "z". Done.
272
273
h4. Independently of whether you use IntelliJ or Eclipse
274
275
Start z2 as in the previous section but make sure the development support is enabled. Use this command line:
276
277
<pre>
278
java -Dcatalina.home=/home/me/tomcat -jar z.jar org.z2env.dev.shared/ready hello/web
279
</pre>
280
281
(possibly you want to turn this into a shell script)
282
283
*Note:* The _system state_ *org.z2env.dev.shared/ready* will pull up all necessary development support components. Make sure this is part of your to-be-run list.
284
285
286
Regardless whether you are using Eclipse or IntelliJ, press the "Resolve Classpath from Z2" button in the toolbar. This will make sure that all required dependencies for Z2 modules, as far as Java code is concerned, will be resolved for your workspace. 
287
288
Now add a class *SimpleController* and change the following files:
289
290
| java/src.impl/hello/SimpleController.java | 
291
<pre><code class="java">
292
package hello;
293
294
import javax.servlet.*;
295
import javax.servlet.http.*;
296
import java.io.IOException;
297
298
public class SimpleController extends HttpServlet {
299
300
    @Override
301
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
302
        String input = req.getParameter("input");
303
        if (input!=null && input.trim().length()>0) {
304
            req.setAttribute("output","You said: "+input);
305
        }
306
        req.getRequestDispatcher("/").forward(req,resp);
307
    }
308
}
309
</code></pre> |
310
| java/z.properties | 
311
<pre><code class="ruby">
312
org.z2env.component.type = org.z2env.java
313
314
java.privateReferences=\
315
  javax.servlet,\
316
  javax.servlet.jsp.jstl
317
</code></pre> |
318
| web/WebContent/WEB-INF/web.xml | 
319
<pre><code class="xml">
320
<?xml version="1.0" encoding="UTF-8"?>
321
<web-app id="hello" version="2.5"
322
		xmlns="http://java.sun.com/xml/ns/javaee"
323
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
324
		xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
325
326
    <servlet>
327
        <servlet-name>controller</servlet-name>
328
        <servlet-class>hello.SimpleController</servlet-class>
329
    </servlet>
330
    
331
    <servlet-mapping>
332
        <servlet-name>controller</servlet-name>
333
        <url-pattern>/do</url-pattern>
334
    </servlet-mapping>    
335
</web-app>
336
</code></pre> |
337
| web/WebContent/index.jsp |
338
<pre><code class="html">
339
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core_1_1" %>
340
<html>
341
<body>
342
  <c:if test="${not empty output}">
343
    <p><c:out value="${output}"/></p>
344
  </c:if>
345
  <form method="POST" action="<c:url value='/do'/>">
346
    Input: <input type="text" name="input"><input type="submit" value="go!">
347
  </form>
348
</body>
349
</html>
350
</code></pre>|
351
352
Make sure the *hello* module is armed (right-click) by having a LOCAL file.
353
354
Now synchronize your running z2 by either:
355
356
* Pressing the "Sync with z2-Environment" button in the toolbar
357
* Pressing ALT+y in your IDE
358
* Entering "s" on the command line running z2.
359
360
Go to http://localhost:8080/hello and check it out.
361
362 2 Henning Blohm
h4. Summary
363 1 Henning Blohm
364 2 Henning Blohm
* Using IDE plugins for Eclipse or IntelliJ you can conveniently develop for Z2.
365
* Regardless of the component types in use, all class path considerations will be resolved from Z2 and you will never need to change IDE configuration.
366
* Using the interplay of IDE plugin and the dev repository (see also [[FAQ#Development]]) synchronization from the IDE and overlay of modules with local development versions is simple and fast. 
367
368 4 Henning Blohm
}}
369
370 9 Henning Blohm
371
---
372
373 1 Henning Blohm
h2. Going Multi-Module
374
375
In this section we will extend the previous work by a simple service module. 
376
377 4 Henning Blohm
{{collapse
378 1 Henning Blohm
h3. Pre-Requisites
379
380
# Have all the results from the previous section ready.
381
# Start IDE and z2 as above.
382
383
384
h3. Steps we are going to take
385
386
# add a new module with a service API
387
# reference the module API from the *hello* module and invoke the service.
388
389
390
In your workspace, use Eclipsoid to create a new z2 Java module *goodbye*. Open *java/z.properties* and change all *com.zfabrik.* prefixes to *org.z2env*. Essentially the file only needs the line
391
392
<pre><code class="ruby">
393
org.z2env.component.type=org.z2env.java
394
</code></pre>
395
396
In our API we will only expose an interface and rather leave the implementation hidden in the implementation parts of the module. We do that, as we prefer a strong separation of API and implementation. This is not at all required but a conscious design choice. 
397
398
399
| java/src.api/goodbye/GoodbyeService.java | 
400
<pre><code class="java">
401
package goodbye;
402
403
public interface GoodbyeService {
404
405
	String sayGoodbye(String in);
406
	
407
}
408
409
</code></pre> |
410
| java/src.impl/goodbye/GoodbyeServiceImpl.java | 
411
<pre><code class="java">
412
package goodbye;
413
414
public class GoodbyeServiceImpl implements GoodbyeService {
415
416
	@Override
417
	public String sayGoodbye(String in) {
418
		return "Goodbye "+in+"!";
419
	}
420
421
}
422
</code></pre> |
423 10 Henning Blohm
| service.properties | 
424 1 Henning Blohm
<pre><code class="ruby">
425
org.z2env.component.type=org.z2env.any
426
component.className=goodbye.GoodbyeServiceImpl
427
</code></pre> |
428
| java/z.properties | 
429
<pre><code class="ruby">
430
org.z2env.component.type=org.z2env.java
431
</code></pre> |
432
433
In effect we created the following:
434
435
* A module *goodbye* that has 
436
* A Java component with API and Implementation source code
437
* An _any_ component *goodbye/service* that manages the service implementation (as we will see below)
438
439
Back in the *hello* module, we want to use the _goodbye service_. We apply the following changes:
440
441
| java/z.properties | 
442
<pre><code class="ruby">
443
org.z2env.component.type=org.z2env.java
444
445
java.privateReferences=\
446
    javax.servlet,\
447
    javax.servlet.jsp.jstl,\
448
    goodbye
449
</code></pre> |
450
| java/src.impl/hello/SimpleController.java | 
451
<pre><code class="java">
452
package hello;
453
454
import goodbye.GoodbyeService;
455
456
import java.io.IOException;
457
458
import javax.servlet.ServletException;
459
import javax.servlet.http.HttpServlet;
460
import javax.servlet.http.HttpServletRequest;
461
import javax.servlet.http.HttpServletResponse;
462
463
import org.z2env.components.IComponentsLookup;
464
465
public class SimpleController extends HttpServlet {
466
467
    @Override
468
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
469
    	GoodbyeService gb = IComponentsLookup.CL.lookup("goodbye/service", GoodbyeService.class);
470
        String input = req.getParameter("input");
471
        if (input!=null && input.trim().length()>0) {
472
            req.setAttribute(
473
        		"output",
474
        		gb.sayGoodbye(input)
475
        	);
476
        }
477
        req.getRequestDispatcher("/").forward(req,resp);
478
    }
479
}
480
</code></pre> |
481
482
After you have changed the Java references in *java/z.properties* you might want to press Alt-R or the "Resolve Classpath from Z2" button in the toolbar to have the IDE resolve the dependency for the *goodbye* module and so that
483
your IDE will not complain about using the *GoodbyeService* interface.
484
485
Now synchronize your running z2 by either:
486
487
* Pressing the "Sync with z2-Environment" button in the toolbar
488
* Pressing ALT+y in your IDE
489
* Entering "s" on the command line running z2.
490
491
Go to http://localhost:8080/hello and check it out.
492
493
h3. Discussion
494
495
What you just implemented is a programmatic component lookup. The first time <code>IComponentsLookup.CL.lookup("goodbye/service", GoodbyeService.class)</code> was invoked, z2 searched for a factory for *org.z2env.any* components. This specific factory simply created a singleton instance of the Goodbye Service and checked whether the requested interface is implemented. As that held, it returned the actual instance.
496
497
In later sections (for now check out [[z2-environment:How_to_Spring]]) we will explain how to that extends to the Spring Framework and Dependency Injection in general.
498 2 Henning Blohm
499
h4. Summary
500
501
* Being a modular runtime environment, Z2 offers an effective yet simple Java modularization approach
502
* The module concept of Z2 goes beyond code considerations and includes arbitrary component types such as Web applications
503 1 Henning Blohm
504
Feel free to apply changes to the Goodbye Service implementation class and have them made effective by synchronizing Z2.
505 4 Henning Blohm
506
}}
507 8 Henning Blohm
508 1 Henning Blohm
509 9 Henning Blohm
---
510
511 1 Henning Blohm
h2. Going System-Centric
512 2 Henning Blohm
513
In this section we show how to turn your z2 installation into a mere execution node of a system (which is what it really should be). That is, in team development situations for systems of non-trivial size of distribution requirements, it is crucial to be integrated with a common source code level. 
514 1 Henning Blohm
515 4 Henning Blohm
{{collapse
516
517 2 Henning Blohm
Using remote repositories in combination with the dev repository, z2 offers just that: Integration for all but those pieces you do actually need isolation from changes.
518
519
Using z2's synchronization approach rolling out changes to remote installation and scale-outs become a non-issue.
520 8 Henning Blohm
521
h3. Pre-Requisites
522
523
# Have the multi-module setup from the previous section at hand
524
# Start IDE and z2 as above.
525
526 2 Henning Blohm
527
h3. Steps we are going to take
528
529
# check our modules in with some new Git repository
530
# add a Git-based component repository component 
531
# develop with partial overlays
532
533
534 1 Henning Blohm
535 4 Henning Blohm
}}
536 1 Henning Blohm
537 9 Henning Blohm
538
539
---
540 1 Henning Blohm
541
h2. Understanding the <HOME>
542
543 4 Henning Blohm
We call an installation of a z2env core a *<home>*. The file structure of the *<home>* consists of few but important locations.
544 1 Henning Blohm
545 4 Henning Blohm
{{collapse
546 1 Henning Blohm
h3. Layout
547
548
| z.jar | The actual core implementation. This is precompiled.|
549
| boot/ | A component repository adding to the core and provides the most basic capabilities such as compiling Java code and running a main program. |
550
| roots/ | A file system component repository that is always registered by the core. This is typically filled with other repository components linking to remote or local component repositories. |
551
| modules/ | A file system repository declared under roots/ that is useful to locally augment a core installation.|
552
553
We use the modules repository for example for command line experiments and simple hacks. It is not as useful for regular development operations as is the dev repo.
554
555 4 Henning Blohm
556
557
558 1 Henning Blohm
h3. Folders and Properties
559
560
When running z2 from the command line, some logic is applied to derive where stuff is and some defaults apply:
561
562
|_. What |_. System property |_. Defaults |
563
| Z2 home - the installation location | org.z2env.home | If no system property is set, the environment variable Z2_HOME will be checked. If that is not set, the z2 home location will be derived from the location of the z.jar file |
564
| Dev Repo workspaces - where the Dev Repo checks for local modules | org.z2env.dev.local.workspaces | Defaults to ${z2.home}/.. assuming modules will be next to the home or one level deeper |
565
566 4 Henning Blohm
See also [[Core Layout]]
567 1 Henning Blohm
568 4 Henning Blohm
}}
569
570 1 Henning Blohm
h2. Understanding Z2
571
572
Most of the concepts that make up z2 can be derived from the desire to efficiently develop standard Java Web Applications that are defined in a central system definition. Add to that the wish to avoid all that build complexity and the desire for a practically usable modularization approach.
573
574 4 Henning Blohm
{{collapse
575 1 Henning Blohm
Once you loose the ability to tweak some build script or configuration to describe how to package a Web app or some libraries, you need some structural hint and simple declarations providing sufficient information.
576
577
Secondy, assuming you want to apply changes at runtime, you need some way of determining what to unload at runtime, given some changed file. Again: Structural information needs to present that maps to runtime state. 
578
579
Finally, as we want some support for modular application development anyway, why not make modules our essential structure. As we have not only code but also Web Applications, Data Sources,  Background Jobs and much more to consider, we add components with type into the mix. Voila.
580
581
*Component Repositories* provides modules and components to z2. A component is prefixed by the module name:
582
583
<pre>
584
<global component name> = <module name>/<local component name>
585
</pre>
586
587
In fact, the typical component repository has a file system style structure that is made up exactly like that. 
588
589
Structure from repo root:
590
591
| /<module>/<cmp>.properties | A component <cmp> in module <module> that has no resources on its own.|
592
| /<module>/<cmp>/z.properties | A component <cmp> in module <module> that may have additional resources on its own.|
593
594
Note that some components, like Web applications and typically Java components have file resources, such as HTML files or Java source code files, while other components, such as main program declarations or data source declarations, so not.
595
596
There are some conventions around this naming scheme. In particular, by convention, whenever a component requires Java implementation, z2 will first look for a component named *java* of the same module. As for example in the Hello World example.
597
598
To give you an idea what this model translates to at runtime consider this: At runtime, the static component is turned into a Resource instance by a component type implementation (that, in fact, is provided by another, built-in component type). 
599
600
!uml1.png!
601
602
Dependencies, for example those between Java components, translate into dependencies between resources that are observed during invalidation of resources. This introduces invalidation and synchronization.
603
604
h3. A crucial concept of z2 is that of a synchronization. 
605
606
For fast development roundtrips and in some cases for general configuration updates, it is desirable to not require a complete restart of a Java Virtual Machine process but rather just to change runtime state accordingly. 
607
608
In z2 a synchronization describes the following process:
609
610
# Check for changes in component repositories
611
# Based on changes found, identify components affected and invalidate associated runtime resources incl. dependent resources.
612
# Try to attain target states
613
614
That is, whenever you do a change and trigger a synchronization from your IDE, this is exactly what happens: Identify what needs to be thrown away, make sure to remove dependent stuff as well,  bring up what needs to be running.
615
616
h3. A second crucial concept of z2 is that of *System Centric Development*
617
618
When working on a software system with many access points and high re-use on a service level, as is typical for business systems, staying quick integration with a team's changes is key. Component repositories can be fed from remotely accessible version control systems such as Subversion and Git. When connecting to a central, team-shared repository, every synchronization will make sure that you are up-to-date with the real source of truth. 
619
620
Using the dev repo, you can still isolate yourself from changes on part of the system that you are actively working on. After your modifications are completed, rebased, and locally tested, getting a clean and consistent state is just one synchronization away.
621
622
h3. The third and final concept is that of a compile-free environment
623
624
It is within the nature of the synchronization concept, that anything required to happen to have your software available for execution must have happened after synchronization completed. Most preparation steps are executed at first use. This includes the compilation of Java code. Z2 uses the Eclipse Java Compiler for that purpose.
625
626
h2. The Component Model
627
628
See [[z2-environment:Z2_Modules_intro]]
629
630
h2. Java Components
631
632
See [[z2-environment:Z2_Java_components_intro]]
633 4 Henning Blohm
634
}}