| /////////////////////////////////////////////////////////////// |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| /////////////////////////////////////////////////////////////// |
| |
| [[two-minutes-intro,Zest™ in 2 minutes]] |
| = Zest™ in 2 minutes = |
| |
| TIP: Theses tutorials are based on actual code found in the `tutorials/` directory of the |
| https://zest.apache.org/download.html[Zest™ SDK sources]. You should start your favorite editor and find the code related to |
| this tutorial, run it and play with it. |
| |
| To show that Zest™ is not necessarily complex, not hard to get going with and easy to deploy, we are first showing the |
| classic HelloWorld, as small as it can get and still be Composite Oriented Programming and not only standard OOP. |
| |
| If you want to reproduce what's explained in this tutorial, remember to depend on the Core Runtime artifact that depends |
| on Core API, Core SPI, Core Bootstrap and Core Functional & I/O APIs: |
| |
| include::../../../../../core/runtime/build/docs/buildinfo/artifact.txt[] |
| |
| See the <<howto-depend-on-zest>> tutorial for details. |
| |
| Ready, Set, Go! |
| |
| Let's say we want to do the common HelloWorld example, but with a more domain-oriented setting. |
| We have a Speaker interface that does the talking. |
| But we also need an implementation for Speaker, which we declare here via the `@Mixins( SpeakerMixin.class )`. |
| |
| |
| [snippet,java] |
| ----------- |
| source=tutorials/introduction/twominutes/src/main/java/org/qi4j/demo/twominute/Speaker.java |
| tag=documentation |
| ----------- |
| |
| And of course, the simple implementation of the Speaker interface. |
| In this case, return a String with the content "Hello, World!". |
| |
| [snippet,java] |
| ----------- |
| source=tutorials/introduction/twominutes/src/main/java/org/qi4j/demo/twominute/SpeakerMixin.java |
| tag=documentation |
| ----------- |
| |
| So far so good. We now need to make this into something that can run. This can be done like this; |
| |
| [snippet,java] |
| ----------- |
| source=tutorials/introduction/twominutes/src/main/java/org/qi4j/demo/twominute/Main.java |
| tag=documentation |
| ----------- |
| |
| . The SingletonAssembler is a convenience class that creates a Zest™ Runtime instance and an application with one layer |
| and one module in it. |
| |
| . We declare a TransientComposite of type `Speaker`. |
| |
| . We create the Composite instance from the Module. |
| |
| *Done!* |