Sample-groovy-in-Z2 » History » Revision 13
« Previous |
Revision 13/29
(diff)
| Next »
Henning Blohm, 28.04.2013 17:06
Sample Groovy in Z2¶
This sample shows how to use the Groovy support, as implemented by the Groovy Add-on.
Prerequisites¶
All you need is a JDK 6 or JDK 7 distribution as described in Step_2_-_Install_and_run_in_5_minutes.
Setting up the sample¶
There is no further pre-requisite to running this sample, and you may proceed as described in How to run a sample. Here's the really fast version:
mkdir install
cd install
git clone -b master http://git.z2-environment.net/z2-base.core
git clone -b master http://git.z2-environment.net/z2-samples.groovy
# on Linux / Mac OS:
cd z2-base.core/run/bin
./gui.sh
# on Windows:
cd z2-base.core\run\bin
gui.bat
The first time you launch the sample will take a while. Watch the log output and keep an eye out for the following lines:
...pp.WebAppResource [800]: Starting WebApp: com.zfabrik.samples.groovy.web/web ...er.GroovyCompiler [800]: GROOVYC: Version 2.1.2 ...er.GroovyCompiler [800]: GROOVYC: Compiling 'com.zfabrik.samples.groovy.web/java' using plain Groovy Compiler... ...er.GroovyCompiler [800]: GROOVYC: 'com.zfabrik.samples.groovy.web/java' successfully compiled. ...er.GroovyCompiler [800]: GROOVYC: Total 613ms ...pp.WebAppResource [800]: Done starting Web App (/plain-groovy-sample): com.zfabrik.samples.groovy.web/web ...pp.WebAppResource [800]: Starting WebApp: com.zfabrik.admin/web ...pp.WebAppResource [800]: Done starting Web App (/adm): com.zfabrik.admin/web ...pp.WebAppResource [800]: Starting WebApp: com.zfabrik.samples.groovy_and_java.web/web ...er.GroovyCompiler [800]: GROOVYC: Version 2.1.2 ...er.GroovyCompiler [800]: GROOVYC: Compiling 'com.zfabrik.samples.groovy_and_java.web/java' using Joint-Compiler... ...er.GroovyCompiler [800]: GROOVYC: 'com.zfabrik.samples.groovy_and_java.web/java' successfully compiled. ...er.GroovyCompiler [800]: GROOVYC: Total 608ms ...pp.WebAppResource [800]: Done starting Web App (/groovy-java-sample): com.zfabrik.samples.groovy_and_java.web/web
If you want to inspect the code using Eclipse, please create a workspace in install (i.e. install/workspace
) and import the Git repositories and the following projects into your workspace: core from z2-base.core, environemnt and com.zfabrik.samples.groovy.web from z2-samples.groovy (see also First steps).
The sample apps just print the HTTP request header - the first is using plain Groovy (see project com.zfabrik.samples.groovy.web
) and the second is using a mixture of Groovy and Java sources (see project com.zfabrik.samples.groovy_and_java.web
). Note that while the former project is compiled using the plain Groovy compiler the latter is compiled using the Joint Groovy/Java Compiler.
Please refer to Groovy Add-on for more details and how-to use it for your own projects.
Updated by Henning Blohm over 11 years ago · 13 revisions