├── .gitignore ├── LICENSE ├── README.adoc ├── annotationscan ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── giffing │ └── examples │ └── wicket │ └── spring │ └── boot │ └── annotationscan │ ├── WicketApplication.java │ └── pages │ ├── BasePage.html │ ├── BasePage.java │ ├── FirstPage.html │ ├── FirstPage.java │ ├── HomePage.html │ ├── HomePage.java │ ├── SecondPage.html │ └── SecondPage.java ├── bootstrap ├── .factorypath ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── giffing │ │ └── examples │ │ └── wicket │ │ └── spring │ │ └── boot │ │ └── bootstrap │ │ ├── HomePage.html │ │ ├── HomePage.java │ │ ├── WicketApplication.java │ │ ├── autoconfiguration │ │ ├── BootstrapConfig.java │ │ └── BootstrapProperties.java │ │ └── pages │ │ ├── BasePage.html │ │ └── BasePage.java │ └── resources │ └── application.yml ├── cluster ├── .gitignore ├── README.adoc ├── cluster-wicket │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── giffing │ │ │ └── examples │ │ │ └── wicket │ │ │ └── spring │ │ │ └── boot │ │ │ └── cluster │ │ │ └── wicket │ │ │ ├── HealthPage.html │ │ │ ├── HealthPage.java │ │ │ ├── HomePage.html │ │ │ ├── HomePage.java │ │ │ ├── LoginPage.html │ │ │ ├── LoginPage.java │ │ │ ├── WicketApplication.java │ │ │ ├── WicketConfig.java │ │ │ └── WicketWebSecurityApapterConfig.java │ │ └── resources │ │ └── application.yml ├── cluster-zuul │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── com │ │ │ └── giffing │ │ │ └── examples │ │ │ └── wicket │ │ │ └── spring │ │ │ └── boot │ │ │ └── cluster │ │ │ └── zuul │ │ │ ├── SpringBootPing.java │ │ │ ├── StickySessionRule.java │ │ │ └── ZuulApplication.java │ │ └── resources │ │ └── application.yml └── pom.xml ├── devtools ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── giffing │ └── examples │ └── wicket │ └── spring │ └── boot │ └── devtools │ ├── HomePage.html │ ├── HomePage.java │ └── WicketApplication.java ├── internal-tests ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── giffing │ │ └── examples │ │ └── wicket │ │ └── spring │ │ └── boot │ │ └── internaltest │ │ ├── WicketApplication.java │ │ └── pages │ │ ├── HomePage.html │ │ └── HomePage.java │ └── resources │ └── application.yml ├── pom.xml ├── shiro-security ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── giffing │ └── examples │ └── wicket │ └── spring │ └── boot │ └── shirosecurity │ ├── HomePage.html │ ├── HomePage.java │ ├── LoginPage.html │ ├── LoginPage.java │ ├── SecondPage.html │ ├── SecondPage.java │ ├── ShiroInitializer.java │ └── WicketApplication.java ├── simple-war-websocket ├── .gitignore ├── .springBeans ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── giffing │ │ └── examples │ │ └── wicket │ │ └── spring │ │ └── boot │ │ └── simple │ │ ├── DateEvent.java │ │ ├── HomePage.html │ │ ├── HomePage.java │ │ ├── SecondPage.html │ │ ├── SecondPage.java │ │ └── WicketApplication.java │ └── test │ └── java │ └── com │ └── giffing │ └── examples │ └── wicket │ └── spring │ └── boot │ └── simple │ └── HomePageTest.java ├── simple-war ├── .gitignore ├── .springBeans ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── giffing │ │ └── examples │ │ └── wicket │ │ └── spring │ │ └── boot │ │ └── simplewar │ │ ├── HomePage.html │ │ ├── HomePage.java │ │ ├── SecondPage.html │ │ ├── SecondPage.java │ │ └── WicketApplication.java │ └── test │ └── java │ └── com │ └── giffing │ └── examples │ └── wicket │ └── spring │ └── boot │ └── simple │ └── HomePageTest.java ├── simple ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── giffing │ │ └── examples │ │ └── wicket │ │ └── spring │ │ └── boot │ │ └── simple │ │ ├── HomePage.html │ │ ├── HomePage.java │ │ ├── SecondPage.html │ │ ├── SecondPage.java │ │ └── WicketApplication.java │ └── test │ └── java │ └── com │ └── giffing │ └── examples │ └── wicket │ └── spring │ └── boot │ └── simple │ └── HomePageTest.java ├── spring-actuator ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── giffing │ │ └── examples │ │ └── wicket │ │ └── spring │ │ └── boot │ │ └── springactuator │ │ ├── HomePage.html │ │ ├── HomePage.java │ │ └── WicketApplication.java │ └── resources │ └── application.properties ├── spring-security.zip ├── spring-security ├── .gitignore ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── giffing │ │ └── examples │ │ └── wicket │ │ └── spring │ │ └── boot │ │ └── springsecurity │ │ ├── HomePage.html │ │ ├── HomePage.java │ │ ├── LoginPage.html │ │ ├── LoginPage.java │ │ ├── WicketApplication.java │ │ └── WicketWebSecurityApapterConfig.java │ └── test │ └── java │ └── com │ └── giffing │ └── examples │ └── wicket │ └── spring │ └── boot │ └── springsecurity │ └── LoginPageTest.java └── websockets ├── .gitignore ├── pom.xml └── src └── main └── java └── com └── giffing └── examples └── wicket └── spring └── boot └── websockets ├── WicketApplication.java └── pages ├── ChatMessageEvent.java ├── HomePage.html └── HomePage.java /.gitignore: -------------------------------------------------------------------------------- 1 | # Maven 2 | /target/ 3 | 4 | # Eclipse 5 | /.settings/ 6 | .classpath 7 | .project 8 | 9 | # IntelliJ 10 | *.iml 11 | *.ipr 12 | *.iws 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.adoc: -------------------------------------------------------------------------------- 1 | # wicket-spring-boot-examples 2 | 3 | Provides some example projects to show what the Wicket Spring Boot Starter project can do. 4 | 5 | ## Project List: 6 | 7 | * Basic simple example - link:/simple[simple] 8 | ** Minimal project setup with only a single HomePage. 9 | * Spring Boot Devtools - link:/devtools[devtools] 10 | ** Added Sprinb Boot Devtools to auto reload the application on class changes. 11 | * Spring Boot Actuator - link:/spring-actuator[spring-actuator] 12 | ** Adds a Wicket specific Wicket endpoint (http://localhost:8080/wicket) with information of the auto configuration 13 | * Websocket - link:/websockets[websockets] 14 | ** Example project with native Websocket support. Open the Page in two browser tabs and fill the input. 15 | * Annotationscan - link:/annotationscan[annotationscan] 16 | ** Example of Wicketstuffs Annotationscann 17 | * Spring Security - link:/spring-security[spring-security] 18 | ** Autoconfiguration of Spring Security 19 | * Bootstrap - link:/bootstrap[bootstrap] 20 | ** Example of using https://github.com/l0rdn1kk0n/wicket-bootstrap 21 | * Internal Tests - link:/internal-tests[internal-tests] 22 | ** Only used for my internal tests 23 | * Cluster - link:/cluster[cluster] 24 | ** Using Zuul as a loadbalancer. Using hazelcast for session and page replication 25 | * Deploy to Servlet Container as war file 26 | ** link:/simple-war[war] 27 | ** link:/simple-war-webscocket[war-websockets] -------------------------------------------------------------------------------- /annotationscan/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /annotationscan/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 1.5.7.RELEASE 8 | 9 | 10 | annotationscan 11 | 12 | 13 | 7.9.0 14 | 15 | 16 | 17 | 18 | com.giffing.wicket.spring.boot.starter 19 | wicket-spring-boot-starter 20 | 1.0.10 21 | 22 | 23 | org.wicketstuff 24 | wicketstuff-annotation 25 | ${wicket.version} 26 | 27 | 28 | 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-maven-plugin 34 | 35 | 36 | 37 | 38 | src/main/resources 39 | 40 | 41 | src/main/java 42 | 43 | ** 44 | 45 | 46 | **/*.java 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /annotationscan/src/main/java/com/giffing/examples/wicket/spring/boot/annotationscan/WicketApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.annotationscan; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class WicketApplication { 8 | 9 | public static void main(String[] args) throws Exception { 10 | new SpringApplicationBuilder() 11 | .sources(WicketApplication.class) 12 | .run(args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /annotationscan/src/main/java/com/giffing/examples/wicket/spring/boot/annotationscan/pages/BasePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 | 7 | 8 |
9 | home 10 |
11 | first 12 |
13 | second 14 | 15 | -------------------------------------------------------------------------------- /annotationscan/src/main/java/com/giffing/examples/wicket/spring/boot/annotationscan/pages/BasePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.annotationscan.pages; 2 | 3 | import org.apache.wicket.markup.html.WebPage; 4 | import org.apache.wicket.markup.html.link.BookmarkablePageLink; 5 | 6 | public class BasePage extends WebPage { 7 | 8 | public BasePage() { 9 | add(new BookmarkablePageLink("home", HomePage.class)); 10 | add(new BookmarkablePageLink("first", FirstPage.class)); 11 | add(new BookmarkablePageLink("second", SecondPage.class)); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /annotationscan/src/main/java/com/giffing/examples/wicket/spring/boot/annotationscan/pages/FirstPage.html: -------------------------------------------------------------------------------- 1 | 2 | First 3 | -------------------------------------------------------------------------------- /annotationscan/src/main/java/com/giffing/examples/wicket/spring/boot/annotationscan/pages/FirstPage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.annotationscan.pages; 2 | 3 | import org.wicketstuff.annotation.mount.MountPath; 4 | 5 | @MountPath("first") 6 | public class FirstPage extends BasePage { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /annotationscan/src/main/java/com/giffing/examples/wicket/spring/boot/annotationscan/pages/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | Home 3 | -------------------------------------------------------------------------------- /annotationscan/src/main/java/com/giffing/examples/wicket/spring/boot/annotationscan/pages/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.annotationscan.pages; 2 | 3 | import org.wicketstuff.annotation.mount.MountPath; 4 | 5 | import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; 6 | 7 | @WicketHomePage 8 | @MountPath("home") 9 | public class HomePage extends BasePage { 10 | } 11 | -------------------------------------------------------------------------------- /annotationscan/src/main/java/com/giffing/examples/wicket/spring/boot/annotationscan/pages/SecondPage.html: -------------------------------------------------------------------------------- 1 | 2 | Second 3 | -------------------------------------------------------------------------------- /annotationscan/src/main/java/com/giffing/examples/wicket/spring/boot/annotationscan/pages/SecondPage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.annotationscan.pages; 2 | 3 | import org.wicketstuff.annotation.mount.MountPath; 4 | 5 | @MountPath("second") 6 | public class SecondPage extends BasePage { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /bootstrap/.factorypath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /bootstrap/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .factorypath 5 | .project 6 | /.apt_generated/ 7 | -------------------------------------------------------------------------------- /bootstrap/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 1.5.7.RELEASE 8 | 9 | 10 | bootstrap 11 | 12 | 13 | 0.10.16 14 | 15 | 16 | 17 | 18 | com.giffing.wicket.spring.boot.starter 19 | wicket-spring-boot-starter 20 | 1.0.10 21 | 22 | 23 | de.agilecoders.wicket 24 | wicket-bootstrap-core 25 | ${wicket-bootstrap.version} 26 | 27 | 28 | 29 | de.agilecoders.wicket 30 | wicket-bootstrap-extensions 31 | ${wicket-bootstrap.version} 32 | 33 | 34 | 35 | de.agilecoders.wicket 36 | wicket-bootstrap-less 37 | ${wicket-bootstrap.version} 38 | 39 | 40 | 41 | de.agilecoders.wicket 42 | wicket-bootstrap-themes 43 | ${wicket-bootstrap.version} 44 | 45 | 46 | 47 | org.apache.wicket 48 | wicket-extensions 49 | 7.9.0 50 | 51 | 52 | 53 | org.apache.wicket 54 | wicket-request 55 | 7.9.0 56 | 57 | 58 | 59 | org.apache.wicket 60 | wicket-util 61 | 7.9.0 62 | 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-configuration-processor 67 | true 68 | 69 | 70 | 71 | 72 | 73 | 74 | org.springframework.boot 75 | spring-boot-maven-plugin 76 | 77 | 78 | 79 | 80 | src/main/resources 81 | 82 | 83 | src/main/java 84 | 85 | ** 86 | 87 | 88 | **/*.java 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /bootstrap/src/main/java/com/giffing/examples/wicket/spring/boot/bootstrap/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | HomePage 6 | 7 | 8 | 9 |
10 | Content! 11 | 12 |
13 |
14 | 15 | -------------------------------------------------------------------------------- /bootstrap/src/main/java/com/giffing/examples/wicket/spring/boot/bootstrap/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.bootstrap; 2 | 3 | import org.apache.wicket.request.mapper.parameter.PageParameters; 4 | 5 | import com.giffing.examples.wicket.spring.boot.bootstrap.pages.BasePage; 6 | import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; 7 | 8 | @WicketHomePage 9 | public class HomePage extends BasePage { 10 | 11 | public HomePage(PageParameters parameters) { 12 | super(parameters); 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /bootstrap/src/main/java/com/giffing/examples/wicket/spring/boot/bootstrap/WicketApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.bootstrap; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class WicketApplication { 8 | 9 | public static void main(String[] args) throws Exception { 10 | new SpringApplicationBuilder() 11 | .sources(WicketApplication.class) 12 | .run(args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /bootstrap/src/main/java/com/giffing/examples/wicket/spring/boot/bootstrap/autoconfiguration/BootstrapConfig.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.bootstrap.autoconfiguration; 2 | 3 | import org.apache.wicket.protocol.http.WebApplication; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; 6 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 7 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 8 | 9 | import com.giffing.wicket.spring.boot.context.extensions.ApplicationInitExtension; 10 | import com.giffing.wicket.spring.boot.context.extensions.WicketApplicationInitConfiguration; 11 | 12 | import de.agilecoders.wicket.core.Bootstrap; 13 | import de.agilecoders.wicket.core.settings.ThemeProvider; 14 | import de.agilecoders.wicket.less.BootstrapLess; 15 | import de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchThemeProvider; 16 | 17 | @ApplicationInitExtension 18 | @ConditionalOnProperty(prefix = BootstrapProperties.PROPERTY_PREFIX, value = "enabled", matchIfMissing = true) 19 | @ConditionalOnClass(BootstrapConfig.class) 20 | @EnableConfigurationProperties({ BootstrapProperties.class }) 21 | public class BootstrapConfig implements WicketApplicationInitConfiguration { 22 | 23 | @Autowired 24 | private BootstrapProperties prop; 25 | 26 | @Override 27 | public void init(WebApplication webApplication) { 28 | final ThemeProvider themeProvider = new BootswatchThemeProvider(prop.getTheme()); 29 | prop.setThemeProvider(themeProvider); 30 | 31 | Bootstrap.install(webApplication, prop); 32 | 33 | 34 | BootstrapLess.install(webApplication); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /bootstrap/src/main/java/com/giffing/examples/wicket/spring/boot/bootstrap/autoconfiguration/BootstrapProperties.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.bootstrap.autoconfiguration; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | import de.agilecoders.wicket.core.settings.BootstrapSettings; 6 | import de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchTheme; 7 | 8 | @ConfigurationProperties(prefix = BootstrapProperties.PROPERTY_PREFIX) 9 | public class BootstrapProperties extends BootstrapSettings { 10 | 11 | public static final String PROPERTY_PREFIX = "wicket.external.agilcoders.bootstrap"; 12 | 13 | private boolean enabled = true; 14 | 15 | private BootswatchTheme theme = BootswatchTheme.Sandstone; 16 | 17 | public BootswatchTheme getTheme() { 18 | return theme; 19 | } 20 | 21 | public void setTheme(BootswatchTheme theme) { 22 | this.theme = theme; 23 | } 24 | 25 | public boolean isEnabled() { 26 | return enabled; 27 | } 28 | 29 | public void setEnabled(boolean enabled) { 30 | this.enabled = enabled; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /bootstrap/src/main/java/com/giffing/examples/wicket/spring/boot/bootstrap/pages/BasePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /bootstrap/src/main/java/com/giffing/examples/wicket/spring/boot/bootstrap/pages/BasePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.bootstrap.pages; 2 | 3 | import org.apache.wicket.markup.html.GenericWebPage; 4 | import org.apache.wicket.model.Model; 5 | import org.apache.wicket.request.mapper.parameter.PageParameters; 6 | 7 | import com.giffing.examples.wicket.spring.boot.bootstrap.HomePage; 8 | 9 | import de.agilecoders.wicket.core.markup.html.bootstrap.image.GlyphIconType; 10 | import de.agilecoders.wicket.core.markup.html.bootstrap.navbar.Navbar; 11 | import de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarButton; 12 | import de.agilecoders.wicket.core.markup.html.bootstrap.navbar.NavbarComponents; 13 | 14 | public class BasePage extends GenericWebPage { 15 | 16 | public BasePage(final PageParameters parameters) { 17 | super(parameters); 18 | 19 | add(newNavbar("navbar")); 20 | } 21 | 22 | protected Navbar newNavbar(String markupId) { 23 | Navbar navbar = new Navbar(markupId); 24 | 25 | navbar.setPosition(Navbar.Position.TOP); 26 | navbar.setInverted(true); 27 | 28 | navbar.setBrandName(Model.of("Wicket Boot - Bootstrap")); 29 | 30 | navbar.addComponents(NavbarComponents.transform(Navbar.ComponentPosition.LEFT, 31 | new NavbarButton(HomePage.class, Model.of("Home")) 32 | .setIconType(GlyphIconType.home))); 33 | 34 | 35 | return navbar; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /bootstrap/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | wicket: 2 | external: 3 | agilcoders: 4 | bootstrap: 5 | theme: paper -------------------------------------------------------------------------------- /cluster/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /cluster/README.adoc: -------------------------------------------------------------------------------- 1 | = Spring Boot & Apache Wicket in a Clustered Environment 2 | 3 | This project is using https://github.com/Netflix/zuul[Zuul] as a https://en.wikipedia.org/wiki/Reverse_proxy[reverse proxy] 4 | for a Wicket backend. Cause https://ci.apache.org/projects/wicket/guide/7.x/single.html#_lost_in_redirection_with_apache_wicket[Wicket doesn't work with a load balancer] when using the REDIRECT\_TO\_BUFFER strategy we have to use sticky sessions to redirect the user to the same instance. I've found a https://github.com/alejandro-du/vaadin-microservices-demo[vaadin demo] project which uses a https://github.com/alejandro-du/vaadin-microservices-demo[custom round robin rule] which is reused in this project. 5 | 6 | Zuul can be used with Eureka to automatically detects the running instances. This project uses hard coded URLs in the application.properties. To check if the instances are up and running the Netflix PingUrl class is used. PingUrl checks if a specific URL of each instance is available. If not the server is removed from the list of available servers and is not used for load balancing. 7 | 8 | For the session replication http://projects.spring.io/spring-session/[Spring Session] is used with hazelcast as a provider. So if you're logged in on one instance you're logged in on all instances. 9 | 10 | The last missing thing is the page store which also have to be clustered. In this project https://github.com/wicketstuff/core/wiki/DataStores#hazelcast[Wicketstuff Datastore Hazelelcast] is used so that each instance shares the same page stores. 11 | 12 | == Run the examples 13 | 14 | Zuul : *mvn spring-boot:run -f cluster-zuul/pom.xml -Dserver.port=8080* 15 | 16 | Wicket Instance 1 : *mvn spring-boot:run -f cluster-wicket/pom.xml -Dserver.port=8081* 17 | 18 | Wicket Instance 2 : *mvn spring-boot:run -f cluster-wicket/pom.xml -Dserver.port=8082* 19 | 20 | 21 | If you shutdown one instance all users which are sticked to that instance are 'load balanced' to another instance. -------------------------------------------------------------------------------- /cluster/cluster-wicket/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /cluster/cluster-wicket/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 1.5.7.RELEASE 8 | 9 | 10 | cluster-wicket 11 | 12 | 13 | 1.8 14 | 7.9.0 15 | 16 | 17 | 18 | 19 | com.giffing.wicket.spring.boot.starter 20 | wicket-spring-boot-starter 21 | 1.0.10 22 | 23 | 24 | org.apache.wicket 25 | wicket-core 26 | ${wicket.version} 27 | 28 | 29 | org.apache.wicket 30 | wicket-spring 31 | ${wicket.version} 32 | 33 | 34 | org.apache.wicket 35 | wicket-ioc 36 | ${wicket.version} 37 | 38 | 39 | org.apache.wicket 40 | wicket-auth-roles 41 | ${wicket.version} 42 | 43 | 44 | org.wicketstuff 45 | wicketstuff-annotation 46 | ${wicket.version} 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-security 51 | 52 | 53 | org.springframework.session 54 | spring-session 55 | 56 | 57 | org.springframework.session 58 | spring-session-hazelcast 59 | 60 | 61 | 62 | com.hazelcast 63 | hazelcast 64 | 3.8 65 | 66 | 67 | org.springframework 68 | spring-web 69 | 70 | 71 | 72 | org.springframework.boot 73 | spring-boot-starter-test 74 | test 75 | 76 | 77 | org.springframework.session 78 | spring-session 79 | 80 | 81 | org.wicketstuff 82 | wicketstuff-datastore-hazelcast 83 | ${wicket.version} 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /cluster/cluster-wicket/src/main/java/com/giffing/examples/wicket/spring/boot/cluster/wicket/HealthPage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /cluster/cluster-wicket/src/main/java/com/giffing/examples/wicket/spring/boot/cluster/wicket/HealthPage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.cluster.wicket; 2 | 3 | import org.apache.wicket.markup.html.WebPage; 4 | import org.wicketstuff.annotation.mount.MountPath; 5 | 6 | @MountPath("health") 7 | public class HealthPage extends WebPage { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /cluster/cluster-wicket/src/main/java/com/giffing/examples/wicket/spring/boot/cluster/wicket/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | So simple! 8 | 9 |

10 | 11 |

12 | increase 13 |

14 | 15 | 16 |
17 | 18 | -------------------------------------------------------------------------------- /cluster/cluster-wicket/src/main/java/com/giffing/examples/wicket/spring/boot/cluster/wicket/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.cluster.wicket; 2 | 3 | import java.util.concurrent.atomic.AtomicInteger; 4 | 5 | import org.apache.wicket.ajax.AjaxRequestTarget; 6 | import org.apache.wicket.ajax.markup.html.AjaxLink; 7 | import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation; 8 | import org.apache.wicket.markup.html.WebPage; 9 | import org.apache.wicket.markup.html.basic.Label; 10 | import org.apache.wicket.markup.html.link.Link; 11 | import org.apache.wicket.model.LoadableDetachableModel; 12 | import org.apache.wicket.model.Model; 13 | import org.wicketstuff.annotation.mount.MountPath; 14 | 15 | import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; 16 | 17 | @WicketHomePage 18 | @MountPath("home") 19 | @AuthorizeInstantiation("USER") 20 | public class HomePage extends WebPage { 21 | 22 | private AtomicInteger counter = new AtomicInteger( 1 ); 23 | 24 | public HomePage() { 25 | System.out.println( "call home page" ); 26 | Label counterLabel = new Label("counterLabel", new LoadableDetachableModel(counter) { 27 | 28 | @Override 29 | protected AtomicInteger load() { 30 | return counter; 31 | } 32 | }); 33 | counterLabel.setOutputMarkupId( true ); 34 | 35 | AjaxLink link = new AjaxLink("click") { 36 | 37 | @Override 38 | public void onClick(AjaxRequestTarget target) { 39 | System.out.println( counter.incrementAndGet()); 40 | target.add( counterLabel ); 41 | } 42 | }; 43 | 44 | add(counterLabel); 45 | add(link); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /cluster/cluster-wicket/src/main/java/com/giffing/examples/wicket/spring/boot/cluster/wicket/LoginPage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Login Page 6 | 7 | 8 | 9 |

Login

10 |
11 |
12 |

13 | 14 | 15 |

16 |

17 | 18 | 19 |

20 | 21 |
22 | 23 | -------------------------------------------------------------------------------- /cluster/cluster-wicket/src/main/java/com/giffing/examples/wicket/spring/boot/cluster/wicket/LoginPage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.cluster.wicket; 2 | 3 | import org.apache.wicket.authroles.authentication.AbstractAuthenticatedWebSession; 4 | import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; 5 | import org.apache.wicket.markup.html.WebPage; 6 | import org.apache.wicket.markup.html.form.Form; 7 | import org.apache.wicket.markup.html.form.PasswordTextField; 8 | import org.apache.wicket.markup.html.form.RequiredTextField; 9 | import org.apache.wicket.markup.html.panel.FeedbackPanel; 10 | import org.apache.wicket.model.CompoundPropertyModel; 11 | import org.apache.wicket.request.mapper.parameter.PageParameters; 12 | import org.wicketstuff.annotation.mount.MountPath; 13 | 14 | import com.giffing.wicket.spring.boot.context.scan.WicketSignInPage; 15 | 16 | @WicketSignInPage 17 | @MountPath("login") 18 | public class LoginPage extends WebPage { 19 | 20 | public LoginPage(PageParameters parameters) { 21 | super(parameters); 22 | System.out.println( "call login" ); 23 | if (((AbstractAuthenticatedWebSession) getSession()).isSignedIn()) { 24 | setResponsePage(new HomePage()); 25 | } 26 | add(new LoginForm("loginForm")); 27 | } 28 | 29 | private class LoginForm extends Form { 30 | 31 | private String username; 32 | 33 | private String password; 34 | 35 | public LoginForm(String id) { 36 | super(id); 37 | setModel(new CompoundPropertyModel<>(this)); 38 | add(new FeedbackPanel("feedback")); 39 | add(new RequiredTextField("username")); 40 | add(new PasswordTextField("password")); 41 | } 42 | 43 | @Override 44 | protected void onSubmit() { 45 | System.out.println( "login try" ); 46 | AuthenticatedWebSession session = AuthenticatedWebSession.get(); 47 | if (session.signIn(username, password)) { 48 | setResponsePage(new HomePage()); 49 | } else { 50 | error("Login failed"); 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /cluster/cluster-wicket/src/main/java/com/giffing/examples/wicket/spring/boot/cluster/wicket/WicketApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.cluster.wicket; 2 | 3 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.builder.SpringApplicationBuilder; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.session.hazelcast.HazelcastSessionRepository; 8 | import org.springframework.session.hazelcast.PrincipalNameExtractor; 9 | import org.springframework.session.hazelcast.config.annotation.web.http.EnableHazelcastHttpSession; 10 | 11 | import com.giffing.wicket.spring.boot.starter.WicketAutoConfiguration; 12 | import com.hazelcast.config.Config; 13 | import com.hazelcast.config.MapAttributeConfig; 14 | import com.hazelcast.config.MapIndexConfig; 15 | import com.hazelcast.core.Hazelcast; 16 | import com.hazelcast.core.HazelcastInstance; 17 | 18 | @SpringBootApplication 19 | @EnableHazelcastHttpSession 20 | public class WicketApplication { 21 | 22 | public static void main(String[] args) throws Exception { 23 | new SpringApplicationBuilder() 24 | .sources(WicketApplication.class) 25 | .run(args); 26 | } 27 | 28 | @Bean 29 | public HazelcastInstance hazelcastInstance() { 30 | MapAttributeConfig attributeConfig = new MapAttributeConfig() 31 | .setName(HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE) 32 | .setExtractor(PrincipalNameExtractor.class.getName()); 33 | 34 | Config config = new Config(); 35 | 36 | config.getMapConfig("spring:session:sessions") 37 | .addMapAttributeConfig(attributeConfig) 38 | .addMapIndexConfig(new MapIndexConfig( 39 | HazelcastSessionRepository.PRINCIPAL_NAME_ATTRIBUTE, false)); 40 | 41 | return Hazelcast.newHazelcastInstance(config); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /cluster/cluster-wicket/src/main/java/com/giffing/examples/wicket/spring/boot/cluster/wicket/WicketConfig.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.cluster.wicket; 2 | 3 | import org.apache.wicket.protocol.http.WebApplication; 4 | import org.springframework.stereotype.Component; 5 | 6 | import com.giffing.wicket.spring.boot.context.extensions.WicketApplicationInitConfiguration; 7 | 8 | 9 | @Component 10 | public class WicketConfig implements WicketApplicationInitConfiguration { 11 | 12 | @Override 13 | public void init(WebApplication webApplication) { 14 | // webApplication.getRequestLoggerSettings().setRequestLoggerEnabled( true ); 15 | 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /cluster/cluster-wicket/src/main/java/com/giffing/examples/wicket/spring/boot/cluster/wicket/WicketWebSecurityApapterConfig.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.cluster.wicket; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 6 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 7 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 8 | 9 | @Configuration 10 | public class WicketWebSecurityApapterConfig extends WebSecurityConfigurerAdapter { 11 | @Override 12 | protected void configure(HttpSecurity http) throws Exception { 13 | http 14 | .csrf().disable() 15 | .authorizeRequests().antMatchers("/**").permitAll() 16 | .and() 17 | .logout() 18 | .permitAll(); 19 | http.headers().frameOptions().disable(); 20 | } 21 | 22 | @Autowired 23 | public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { 24 | auth 25 | .inMemoryAuthentication() 26 | .withUser("admin").password("admin").authorities("USER", "ADMIN"); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /cluster/cluster-wicket/src/main/resources/application.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcGiffing/wicket-spring-boot-examples/5faec6efa9d803a7d452074720fb8bdcf80e0c38/cluster/cluster-wicket/src/main/resources/application.yml -------------------------------------------------------------------------------- /cluster/cluster-zuul/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /cluster/cluster-zuul/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 1.5.7.RELEASE 8 | 9 | 10 | cluster-zuul 11 | 12 | 13 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter 29 | 30 | 31 | org.springframework.cloud 32 | spring-cloud-starter-zuul 33 | 1.2.6.RELEASE 34 | 35 | 36 | org.springframework.boot 37 | spring-boot-starter-web 38 | 39 | 49 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | org.springframework.boot 67 | spring-boot-maven-plugin 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /cluster/cluster-zuul/src/main/java/com/giffing/examples/wicket/spring/boot/cluster/zuul/SpringBootPing.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.cluster.zuul; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import com.netflix.loadbalancer.PingUrl; 6 | 7 | @Component 8 | public class SpringBootPing extends PingUrl { 9 | @Override 10 | public String getPingAppendString() { 11 | return "/health"; 12 | } 13 | } -------------------------------------------------------------------------------- /cluster/cluster-zuul/src/main/java/com/giffing/examples/wicket/spring/boot/cluster/zuul/StickySessionRule.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.cluster.zuul; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | import java.util.Optional; 6 | 7 | import javax.servlet.http.Cookie; 8 | 9 | import org.springframework.stereotype.Component; 10 | 11 | import com.netflix.loadbalancer.ClientConfigEnabledRoundRobinRule; 12 | import com.netflix.loadbalancer.Server; 13 | import com.netflix.zuul.context.RequestContext; 14 | 15 | /** 16 | * @author Alejandro Duarte. 17 | */ 18 | @Component 19 | public class StickySessionRule extends ClientConfigEnabledRoundRobinRule { 20 | 21 | public static final String COOKIE_NAME = StickySessionRule.class.getSimpleName(); 22 | 23 | @Override 24 | public Server choose(Object key) { 25 | Optional cookie = getCookie(); 26 | 27 | if (cookie.isPresent()) { 28 | Cookie hash = cookie.get(); 29 | List servers = getLoadBalancer().getReachableServers(); 30 | Optional serverFound = servers.stream() 31 | .filter(s -> hash.getValue().equals("" + s.hashCode())) 32 | .findFirst(); 33 | 34 | if (serverFound.isPresent()) { 35 | return serverFound.get(); 36 | } 37 | } 38 | 39 | return addServer(key); 40 | } 41 | 42 | private Optional getCookie() { 43 | Cookie[] cookies = RequestContext.getCurrentContext().getRequest().getCookies(); 44 | if (cookies != null) { 45 | return Arrays.stream(cookies) 46 | .filter(c -> c.getName().equals(COOKIE_NAME)) 47 | .findFirst(); 48 | } 49 | 50 | return Optional.empty(); 51 | } 52 | 53 | private Server addServer(Object key) { 54 | Server server = super.choose(key); 55 | Cookie newCookie = new Cookie(COOKIE_NAME, "" + server.hashCode()); 56 | newCookie.setPath("/"); 57 | RequestContext.getCurrentContext().getResponse().addCookie(newCookie); 58 | return server; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /cluster/cluster-zuul/src/main/java/com/giffing/examples/wicket/spring/boot/cluster/zuul/ZuulApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.cluster.zuul; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 6 | 7 | @SpringBootApplication 8 | @EnableZuulProxy 9 | public class ZuulApplication { 10 | 11 | public static void main(String[] args) throws Exception { 12 | new SpringApplicationBuilder() 13 | .sources( ZuulApplication.class ) 14 | .run( args ); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cluster/cluster-zuul/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | session: 3 | store-type: hazelcast 4 | 5 | zuul: 6 | add-host-header: true 7 | sensitiveHeaders: 8 | add-proxy-headers: true 9 | 10 | routes: 11 | wicket: 12 | path: /** 13 | serviceId: wicketservice 14 | 15 | 16 | wicketservice: 17 | ribbon: 18 | sensitiveHeaders: 19 | NFLoadBalancerPingClassName: com.giffing.examples.wicket.spring.boot.cluster.zuul.SpringBootPing 20 | listOfServers: localhost:8081,localhost:8082 21 | -------------------------------------------------------------------------------- /cluster/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.giffing.examples.wicket.spring.boot 5 | wicket-spring-boot-parent 6 | 1.0.10 7 | 8 | cluster 9 | pom 10 | 11 | cluster-wicket 12 | cluster-zuul 13 | 14 | -------------------------------------------------------------------------------- /devtools/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /devtools/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 1.5.7.RELEASE 8 | 9 | 10 | devtools 11 | 12 | 13 | 14 | com.giffing.wicket.spring.boot.starter 15 | wicket-spring-boot-starter 16 | 1.0.10 17 | 18 | 19 | org.springframework.boot 20 | spring-boot-devtools 21 | provided 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-maven-plugin 30 | 31 | 32 | 33 | 34 | src/main/resources 35 | 36 | 37 | src/main/java 38 | 39 | ** 40 | 41 | 42 | **/*.java 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /devtools/src/main/java/com/giffing/examples/wicket/spring/boot/devtools/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | 8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /devtools/src/main/java/com/giffing/examples/wicket/spring/boot/devtools/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.devtools; 2 | 3 | import org.apache.wicket.markup.html.WebPage; 4 | import org.apache.wicket.markup.html.basic.Label; 5 | 6 | import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; 7 | 8 | @WicketHomePage 9 | public class HomePage extends WebPage { 10 | 11 | public HomePage() { 12 | queue(new Label("myLabel", 9 + 1)); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /devtools/src/main/java/com/giffing/examples/wicket/spring/boot/devtools/WicketApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.devtools; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class WicketApplication { 8 | 9 | public static void main(String[] args) throws Exception { 10 | new SpringApplicationBuilder() 11 | .sources(WicketApplication.class) 12 | .run(args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /internal-tests/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /internal-tests/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 1.5.7.RELEASE 8 | 9 | 10 | internal-tests 11 | Internal-Tests 12 | Only used for internal tests. 13 | 14 | 15 | 16 | 1.7 17 | 18 | 19 | 20 | 21 | com.giffing.wicket.spring.boot.starter 22 | wicket-spring-boot-starter 23 | 1.0.10 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-web 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-devtools 32 | provided 33 | 34 | 35 | 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-maven-plugin 41 | 42 | 43 | 44 | 45 | src/main/resources 46 | 47 | 48 | src/main/java 49 | 50 | ** 51 | 52 | 53 | **/*.java 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /internal-tests/src/main/java/com/giffing/examples/wicket/spring/boot/internaltest/WicketApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.internaltest; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class WicketApplication { 8 | 9 | public static void main(String[] args) throws Exception { 10 | new SpringApplicationBuilder() 11 | .sources(WicketApplication.class) 12 | .run(args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /internal-tests/src/main/java/com/giffing/examples/wicket/spring/boot/internaltest/pages/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | internal test asdf 8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /internal-tests/src/main/java/com/giffing/examples/wicket/spring/boot/internaltest/pages/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.internaltest.pages; 2 | 3 | 4 | import org.apache.wicket.markup.html.WebPage; 5 | 6 | import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; 7 | 8 | @WicketHomePage 9 | public class HomePage extends WebPage { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /internal-tests/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | wicket: 2 | core: 3 | settings: 4 | general: 5 | configuration-type: development -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.giffing.examples.wicket.spring.boot 5 | wicket-spring-boot-parent 6 | 1.0.10 7 | pom 8 | 9 | 10 | simple 11 | spring-security 12 | websockets 13 | bootstrap 14 | internal-tests 15 | annotationscan 16 | devtools 17 | spring-actuator 18 | shiro-security 19 | cluster 20 | simple-war 21 | simple-war-websocket 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /shiro-security/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | 3 | /.settings/ 4 | 5 | .classpath 6 | 7 | .project -------------------------------------------------------------------------------- /shiro-security/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.giffing.wicket.spring.boot.starter 6 | wicket-spring-boot-starter-parent 7 | 1.0.10 8 | 9 | shiro-security 10 | 11 | 12 | 1.8 13 | 14 | 15 | 16 | 17 | com.giffing.wicket.spring.boot.starter 18 | wicket-spring-boot-starter 19 | 20 | 21 | org.wicketstuff 22 | wicketstuff-annotation 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-test 27 | test 28 | 29 | 30 | org.wicketstuff 31 | wicketstuff-shiro 32 | 7.9.0 33 | 34 | 35 | org.apache.shiro 36 | shiro-spring-boot-web-starter 37 | 1.4.0-RC2 38 | 39 | 40 | org.apache.shiro 41 | shiro-core 42 | 1.4.0-RC2 43 | 44 | 45 | org.apache.shiro 46 | shiro-web 47 | 1.4.0-RC2 48 | 49 | 50 | org.apache.shiro 51 | shiro-event 52 | 1.4.0-RC2 53 | 54 | 55 | 56 | 57 | 58 | 59 | org.springframework.boot 60 | spring-boot-maven-plugin 61 | 62 | 63 | 64 | 65 | src/main/resources 66 | 67 | 68 | src/main/java 69 | 70 | ** 71 | 72 | 73 | **/*.java 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /shiro-security/src/main/java/com/giffing/examples/wicket/spring/boot/shirosecurity/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | So simple! 8 | 9 | link 10 | 11 |
12 | 13 |
14 | 15 |
16 | 17 | -------------------------------------------------------------------------------- /shiro-security/src/main/java/com/giffing/examples/wicket/spring/boot/shirosecurity/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.shirosecurity; 2 | 3 | import org.apache.wicket.markup.html.WebPage; 4 | import org.apache.wicket.markup.html.form.Form; 5 | import org.apache.wicket.markup.html.link.Link; 6 | import org.wicketstuff.annotation.mount.MountPath; 7 | import org.wicketstuff.shiro.ShiroConstraint; 8 | import org.wicketstuff.shiro.annotation.ShiroSecurityConstraint; 9 | 10 | import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; 11 | 12 | @WicketHomePage 13 | @MountPath("home") 14 | @ShiroSecurityConstraint(constraint = ShiroConstraint.HasRole, value = "admin", loginMessage = "You must be logged in to view this page", unauthorizedMessage = "You need to be an ADMIN") 15 | public class HomePage extends WebPage { 16 | 17 | public HomePage() { 18 | Form form = new Form("form"){ 19 | @Override 20 | protected void onSubmit() { 21 | setResponsePage(SecondPage.class); 22 | } 23 | }; 24 | queue(form); 25 | 26 | 27 | add(new Link("mylink") { 28 | 29 | @Override 30 | public void onClick() { 31 | setResponsePage(SecondPage.class); 32 | } 33 | 34 | }); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /shiro-security/src/main/java/com/giffing/examples/wicket/spring/boot/shirosecurity/LoginPage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Login Page 6 | 7 | 8 | 9 |

Login

10 |
11 |
12 |

13 | 14 | 15 |

16 |

17 | 18 | 19 |

20 | 21 |
22 | 23 | -------------------------------------------------------------------------------- /shiro-security/src/main/java/com/giffing/examples/wicket/spring/boot/shirosecurity/LoginPage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.shirosecurity; 2 | 3 | import org.apache.shiro.SecurityUtils; 4 | import org.apache.shiro.authc.AuthenticationException; 5 | import org.apache.shiro.authc.IncorrectCredentialsException; 6 | import org.apache.shiro.authc.UnknownAccountException; 7 | import org.apache.shiro.authc.UsernamePasswordToken; 8 | import org.apache.shiro.subject.Subject; 9 | import org.apache.wicket.authroles.authentication.AbstractAuthenticatedWebSession; 10 | import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; 11 | import org.apache.wicket.markup.html.WebPage; 12 | import org.apache.wicket.markup.html.form.Form; 13 | import org.apache.wicket.markup.html.form.PasswordTextField; 14 | import org.apache.wicket.markup.html.form.RequiredTextField; 15 | import org.apache.wicket.markup.html.panel.FeedbackPanel; 16 | import org.apache.wicket.model.CompoundPropertyModel; 17 | import org.apache.wicket.request.mapper.parameter.PageParameters; 18 | import org.wicketstuff.annotation.mount.MountPath; 19 | 20 | import com.giffing.wicket.spring.boot.context.scan.WicketSignInPage; 21 | 22 | @WicketSignInPage 23 | @MountPath("login") 24 | public class LoginPage extends WebPage { 25 | 26 | public LoginPage(PageParameters parameters) { 27 | super( parameters ); 28 | 29 | final Subject currentUser = SecurityUtils.getSubject(); 30 | if(currentUser.isAuthenticated()) { 31 | continueToOriginalDestination(); 32 | setResponsePage( SecondPage.class ); 33 | } 34 | 35 | add( new LoginForm( "loginForm" ) ); 36 | } 37 | 38 | private class LoginForm extends Form { 39 | 40 | private String username; 41 | 42 | private String password; 43 | 44 | public LoginForm(String id) { 45 | super( id ); 46 | setModel( new CompoundPropertyModel<>( this ) ); 47 | add( new FeedbackPanel( "feedback" ) ); 48 | add( new RequiredTextField( "username" ) ); 49 | add( new PasswordTextField( "password" ) ); 50 | } 51 | 52 | @Override 53 | protected void onSubmit() { 54 | if ( login( username, password, false ) ) { 55 | continueToOriginalDestination(); 56 | setResponsePage( SecondPage.class ); 57 | } 58 | else { 59 | error( "Login failed" ); 60 | } 61 | } 62 | } 63 | 64 | public boolean login(final String username, final String password, final boolean rememberMe) { 65 | final Subject currentUser = SecurityUtils.getSubject(); 66 | final UsernamePasswordToken token = new UsernamePasswordToken( username, password,rememberMe ); 67 | try { 68 | currentUser.login( token ); 69 | return true; 70 | } 71 | catch (final Exception ex) { 72 | error( "Login failed" ); 73 | } 74 | return false; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /shiro-security/src/main/java/com/giffing/examples/wicket/spring/boot/shirosecurity/SecondPage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | Second 8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /shiro-security/src/main/java/com/giffing/examples/wicket/spring/boot/shirosecurity/SecondPage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.shirosecurity; 2 | 3 | import org.apache.wicket.markup.html.WebPage; 4 | import org.wicketstuff.annotation.mount.MountPath; 5 | 6 | @MountPath("second") 7 | public class SecondPage extends WebPage { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /shiro-security/src/main/java/com/giffing/examples/wicket/spring/boot/shirosecurity/ShiroInitializer.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.shirosecurity; 2 | 3 | import org.apache.shiro.event.EventBus; 4 | import org.apache.shiro.event.EventBusAware; 5 | import org.apache.shiro.event.Subscribe; 6 | import org.apache.shiro.realm.Realm; 7 | import org.apache.shiro.realm.text.TextConfigurationRealm; 8 | import org.apache.shiro.spring.web.config.DefaultShiroFilterChainDefinition; 9 | import org.apache.shiro.spring.web.config.ShiroFilterChainDefinition; 10 | import org.apache.wicket.protocol.http.WebApplication; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | import org.springframework.stereotype.Component; 14 | import org.wicketstuff.shiro.annotation.AnnotationsShiroAuthorizationStrategy; 15 | import org.wicketstuff.shiro.authz.ShiroUnauthorizedComponentListener; 16 | 17 | import com.giffing.wicket.spring.boot.context.extensions.WicketApplicationInitConfiguration; 18 | 19 | @Component 20 | @Configuration 21 | public class ShiroInitializer implements WicketApplicationInitConfiguration { 22 | 23 | @Bean 24 | @SuppressWarnings("Duplicates") 25 | Realm getTextConfigurationRealm() { 26 | TextConfigurationRealm realm = new TextConfigurationRealm(); 27 | realm.setUserDefinitions( 28 | "user=user,user\n" + 29 | "admin=admin,admin"); 30 | realm.setRoleDefinitions( 31 | "admin=read,write\n" + 32 | "user=read"); 33 | realm.setCachingEnabled(true); 34 | return realm; 35 | } 36 | 37 | @Bean 38 | ShiroFilterChainDefinition shiroFilterChainDefinition() { 39 | return new DefaultShiroFilterChainDefinition(); 40 | } 41 | 42 | public void init(WebApplication app) { 43 | AnnotationsShiroAuthorizationStrategy authz = new AnnotationsShiroAuthorizationStrategy(); 44 | app.getSecuritySettings().setAuthorizationStrategy(authz); 45 | app.getSecuritySettings().setUnauthorizedComponentInstantiationListener(new ShiroUnauthorizedComponentListener(LoginPage.class, LoginPage.class, authz)); 46 | } 47 | } -------------------------------------------------------------------------------- /shiro-security/src/main/java/com/giffing/examples/wicket/spring/boot/shirosecurity/WicketApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.shirosecurity; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class WicketApplication { 8 | 9 | public static void main(String[] args) throws Exception { 10 | new SpringApplicationBuilder() 11 | .sources(WicketApplication.class) 12 | .run(args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /simple-war-websocket/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /simple-war-websocket/.springBeans: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1 4 | 5 | 6 | 7 | 8 | 9 | 10 | java:com.giffing.examples.wicket.spring.boot.simplewar.WicketApplication 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /simple-war-websocket/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.giffing.wicket.spring.boot.starter 6 | wicket-spring-boot-starter-parent 7 | 1.0.10 8 | 9 | simple-war-websocket 10 | 11 | 12 | 13 | 14 | 15 | 16 | com.giffing.wicket.spring.boot.starter 17 | wicket-spring-boot-starter 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-tomcat 22 | provided 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-test 27 | test 28 | 29 | 30 | org.apache.wicket 31 | wicket-native-websocket-javax 32 | 33 | 34 | 35 | 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-maven-plugin 40 | 41 | 42 | 43 | repackage 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | src/main/resources 52 | 53 | 54 | src/main/java 55 | 56 | ** 57 | 58 | 59 | **/*.java 60 | 61 | 62 | 63 | 64 | 65 | war 66 | -------------------------------------------------------------------------------- /simple-war-websocket/src/main/java/com/giffing/examples/wicket/spring/boot/simple/DateEvent.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simple; 2 | 3 | import java.util.Date; 4 | 5 | import org.apache.wicket.protocol.ws.api.message.IWebSocketPushMessage; 6 | 7 | public class DateEvent implements IWebSocketPushMessage { 8 | 9 | private Date currentDate; 10 | 11 | public DateEvent(Date currentDate) { 12 | this.currentDate = currentDate; 13 | } 14 | 15 | public Date getCurrentDate() { 16 | return currentDate; 17 | } 18 | 19 | public void setCurrentDate(Date currentDate) { 20 | this.currentDate = currentDate; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /simple-war-websocket/src/main/java/com/giffing/examples/wicket/spring/boot/simple/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | So simple! 8 | 9 | link 10 | 11 |
12 | 13 |
14 | 15 | send event 16 |
17 | 18 |
19 | 20 | -------------------------------------------------------------------------------- /simple-war-websocket/src/main/java/com/giffing/examples/wicket/spring/boot/simple/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simple; 2 | 3 | import java.util.Date; 4 | 5 | import org.apache.wicket.ajax.AjaxRequestTarget; 6 | import org.apache.wicket.ajax.markup.html.AjaxLink; 7 | import org.apache.wicket.markup.html.WebPage; 8 | import org.apache.wicket.markup.html.basic.Label; 9 | import org.apache.wicket.markup.html.form.Form; 10 | import org.apache.wicket.markup.html.link.Link; 11 | import org.apache.wicket.protocol.ws.api.WebSocketBehavior; 12 | import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler; 13 | import org.apache.wicket.protocol.ws.api.message.IWebSocketPushMessage; 14 | import org.apache.wicket.spring.injection.annot.SpringBean; 15 | 16 | import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; 17 | import com.giffing.wicket.spring.boot.starter.web.servlet.websocket.WebSocketMessageBroadcaster; 18 | 19 | @WicketHomePage 20 | public class HomePage extends WebPage { 21 | 22 | @SpringBean 23 | private WebSocketMessageBroadcaster broadcaster; 24 | 25 | Label currentTime; 26 | 27 | public HomePage() { 28 | currentTime = new Label( "currentTime", "no time" ); 29 | currentTime.setOutputMarkupId( true ); 30 | add(currentTime); 31 | 32 | Form form = new Form("form"){ 33 | @Override 34 | protected void onSubmit() { 35 | setResponsePage(SecondPage.class); 36 | } 37 | }; 38 | queue(form); 39 | 40 | 41 | add(new Link("mylink") { 42 | @Override 43 | public void onClick() { 44 | setResponsePage(SecondPage.class); 45 | } 46 | }); 47 | 48 | add(new AjaxLink("push") { 49 | 50 | @Override 51 | public void onClick(AjaxRequestTarget target) { 52 | broadcaster.send( new DateEvent( new Date() ) ); 53 | 54 | } 55 | 56 | }); 57 | 58 | add(new WebSocketBehavior() { 59 | 60 | @Override 61 | protected void onPush(WebSocketRequestHandler handler, IWebSocketPushMessage message) { 62 | if(message instanceof DateEvent) { 63 | DateEvent de = (DateEvent) message; 64 | currentTime.setDefaultModelObject( de.getCurrentDate().toString() ); 65 | handler.add( currentTime ); 66 | } 67 | } 68 | }); 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /simple-war-websocket/src/main/java/com/giffing/examples/wicket/spring/boot/simple/SecondPage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | Second 8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /simple-war-websocket/src/main/java/com/giffing/examples/wicket/spring/boot/simple/SecondPage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simple; 2 | 3 | import org.apache.wicket.markup.html.WebPage; 4 | 5 | public class SecondPage extends WebPage { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /simple-war-websocket/src/main/java/com/giffing/examples/wicket/spring/boot/simple/WicketApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simple; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | import org.springframework.boot.web.support.SpringBootServletInitializer; 6 | 7 | import com.giffing.wicket.spring.boot.starter.web.config.WicketWebInitializerAutoConfig.WebSocketWicketWebInitializerAutoConfiguration; 8 | 9 | @SpringBootApplication 10 | public class WicketApplication extends SpringBootServletInitializer { 11 | 12 | public static void main(String[] args) throws Exception { 13 | new SpringApplicationBuilder() 14 | .sources(WicketApplication.class) 15 | .run(args); 16 | } 17 | 18 | 19 | @Override 20 | protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { 21 | builder.properties( WebSocketWicketWebInitializerAutoConfiguration.REGISTER_SERVER_ENDPOINT_ENABLED + "=false" ); 22 | return super.configure( builder ); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /simple-war-websocket/src/test/java/com/giffing/examples/wicket/spring/boot/simple/HomePageTest.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simple; 2 | 3 | import org.apache.wicket.protocol.http.WebApplication; 4 | import org.apache.wicket.util.tester.FormTester; 5 | import org.apache.wicket.util.tester.WicketTester; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.context.ApplicationContext; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | import org.springframework.test.util.ReflectionTestUtils; 14 | 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest(classes = WicketApplication.class) 17 | public class HomePageTest { 18 | 19 | private WicketTester tester; 20 | 21 | @Autowired 22 | private WebApplication wicketApplication; 23 | 24 | @Autowired 25 | private ApplicationContext applicationContextMock; 26 | 27 | @Before 28 | public void setUp() { 29 | ReflectionTestUtils.setField(wicketApplication, "applicationContext", applicationContextMock); 30 | tester = new WicketTester(wicketApplication); 31 | } 32 | 33 | 34 | @Test 35 | public void testest() { 36 | tester.startPage(HomePage.class); 37 | FormTester newFormTester = tester.newFormTester("form"); 38 | newFormTester.submit(); 39 | tester.assertRenderedPage(SecondPage.class); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /simple-war/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /simple-war/.springBeans: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1 4 | 5 | 6 | 7 | 8 | 9 | 10 | java:com.giffing.examples.wicket.spring.boot.simplewar.WicketApplication 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /simple-war/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.giffing.wicket.spring.boot.starter 6 | wicket-spring-boot-starter-parent 7 | 1.0.10 8 | 9 | simple-war 10 | 11 | 12 | 13 | 14 | 15 | 16 | com.giffing.wicket.spring.boot.starter 17 | wicket-spring-boot-starter 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-tomcat 22 | provided 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-test 27 | test 28 | 29 | 30 | 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-maven-plugin 36 | 37 | 38 | 39 | repackage 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | src/main/resources 48 | 49 | 50 | src/main/java 51 | 52 | ** 53 | 54 | 55 | **/*.java 56 | 57 | 58 | 59 | 60 | 61 | war 62 | -------------------------------------------------------------------------------- /simple-war/src/main/java/com/giffing/examples/wicket/spring/boot/simplewar/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | So simple! 8 | 9 | link 10 | 11 |
12 | 13 |
14 | 15 |
16 | 17 | -------------------------------------------------------------------------------- /simple-war/src/main/java/com/giffing/examples/wicket/spring/boot/simplewar/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simplewar; 2 | 3 | import org.apache.wicket.markup.html.WebPage; 4 | import org.apache.wicket.markup.html.basic.Label; 5 | import org.apache.wicket.markup.html.form.Form; 6 | import org.apache.wicket.markup.html.link.Link; 7 | import org.apache.wicket.spring.injection.annot.SpringBean; 8 | 9 | import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; 10 | import com.giffing.wicket.spring.boot.starter.web.servlet.websocket.WebSocketMessageBroadcaster; 11 | 12 | @WicketHomePage 13 | public class HomePage extends WebPage { 14 | 15 | Label currentTime; 16 | 17 | public HomePage() { 18 | currentTime = new Label( "currentTime", "no time" ); 19 | currentTime.setOutputMarkupId( true ); 20 | add(currentTime); 21 | 22 | Form form = new Form("form"){ 23 | @Override 24 | protected void onSubmit() { 25 | setResponsePage(SecondPage.class); 26 | } 27 | }; 28 | queue(form); 29 | 30 | 31 | add(new Link("mylink") { 32 | @Override 33 | public void onClick() { 34 | setResponsePage(SecondPage.class); 35 | } 36 | }); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /simple-war/src/main/java/com/giffing/examples/wicket/spring/boot/simplewar/SecondPage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | Second 8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /simple-war/src/main/java/com/giffing/examples/wicket/spring/boot/simplewar/SecondPage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simplewar; 2 | 3 | import org.apache.wicket.markup.html.WebPage; 4 | 5 | public class SecondPage extends WebPage { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /simple-war/src/main/java/com/giffing/examples/wicket/spring/boot/simplewar/WicketApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simplewar; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | import org.springframework.boot.web.support.SpringBootServletInitializer; 6 | 7 | @SpringBootApplication 8 | public class WicketApplication extends SpringBootServletInitializer { 9 | 10 | public static void main(String[] args) throws Exception { 11 | new SpringApplicationBuilder() 12 | .sources(WicketApplication.class) 13 | .run(args); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /simple-war/src/test/java/com/giffing/examples/wicket/spring/boot/simple/HomePageTest.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simple; 2 | 3 | import org.apache.wicket.protocol.http.WebApplication; 4 | import org.apache.wicket.util.tester.FormTester; 5 | import org.apache.wicket.util.tester.WicketTester; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.context.ApplicationContext; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | import org.springframework.test.util.ReflectionTestUtils; 14 | 15 | import com.giffing.examples.wicket.spring.boot.simplewar.HomePage; 16 | import com.giffing.examples.wicket.spring.boot.simplewar.SecondPage; 17 | import com.giffing.examples.wicket.spring.boot.simplewar.WicketApplication; 18 | 19 | @RunWith(SpringRunner.class) 20 | @SpringBootTest(classes = WicketApplication.class) 21 | public class HomePageTest { 22 | 23 | private WicketTester tester; 24 | 25 | @Autowired 26 | private WebApplication wicketApplication; 27 | 28 | @Autowired 29 | private ApplicationContext applicationContextMock; 30 | 31 | @Before 32 | public void setUp() { 33 | ReflectionTestUtils.setField(wicketApplication, "applicationContext", applicationContextMock); 34 | tester = new WicketTester(wicketApplication); 35 | } 36 | 37 | 38 | @Test 39 | public void testest() { 40 | tester.startPage(HomePage.class); 41 | FormTester newFormTester = tester.newFormTester("form"); 42 | newFormTester.submit(); 43 | tester.assertRenderedPage(SecondPage.class); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /simple/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /simple/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.giffing.wicket.spring.boot.starter 6 | wicket-spring-boot-starter-parent 7 | 1.0.10 8 | 9 | simple 10 | 11 | 12 | 7.9.0 13 | 14 | 15 | 16 | 17 | com.giffing.wicket.spring.boot.starter 18 | wicket-spring-boot-starter 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-test 23 | test 24 | 25 | 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-maven-plugin 32 | 33 | 34 | 35 | 36 | src/main/resources 37 | 38 | 39 | src/main/java 40 | 41 | ** 42 | 43 | 44 | **/*.java 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /simple/src/main/java/com/giffing/examples/wicket/spring/boot/simple/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | So simple! 8 | 9 | link 10 | 11 |
12 | 13 |
14 | 15 |
16 | 17 | -------------------------------------------------------------------------------- /simple/src/main/java/com/giffing/examples/wicket/spring/boot/simple/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simple; 2 | 3 | import org.apache.wicket.markup.html.WebPage; 4 | import org.apache.wicket.markup.html.form.Form; 5 | import org.apache.wicket.markup.html.link.Link; 6 | 7 | import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; 8 | 9 | @WicketHomePage 10 | public class HomePage extends WebPage { 11 | 12 | public HomePage() { 13 | Form form = new Form("form"){ 14 | @Override 15 | protected void onSubmit() { 16 | setResponsePage(SecondPage.class); 17 | } 18 | }; 19 | queue(form); 20 | 21 | 22 | add(new Link("mylink") { 23 | 24 | @Override 25 | public void onClick() { 26 | setResponsePage(SecondPage.class); 27 | } 28 | 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /simple/src/main/java/com/giffing/examples/wicket/spring/boot/simple/SecondPage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | Second 8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /simple/src/main/java/com/giffing/examples/wicket/spring/boot/simple/SecondPage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simple; 2 | 3 | import org.apache.wicket.markup.html.WebPage; 4 | 5 | public class SecondPage extends WebPage { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /simple/src/main/java/com/giffing/examples/wicket/spring/boot/simple/WicketApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simple; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class WicketApplication { 8 | 9 | public static void main(String[] args) throws Exception { 10 | new SpringApplicationBuilder() 11 | .sources(WicketApplication.class) 12 | .run(args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /simple/src/test/java/com/giffing/examples/wicket/spring/boot/simple/HomePageTest.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.simple; 2 | 3 | import org.apache.wicket.protocol.http.WebApplication; 4 | import org.apache.wicket.util.tester.FormTester; 5 | import org.apache.wicket.util.tester.WicketTester; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.context.ApplicationContext; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | import org.springframework.test.util.ReflectionTestUtils; 14 | 15 | @RunWith(SpringRunner.class) 16 | @SpringBootTest(classes = WicketApplication.class) 17 | public class HomePageTest { 18 | 19 | private WicketTester tester; 20 | 21 | @Autowired 22 | private WebApplication wicketApplication; 23 | 24 | @Autowired 25 | private ApplicationContext applicationContextMock; 26 | 27 | @Before 28 | public void setUp() { 29 | ReflectionTestUtils.setField(wicketApplication, "applicationContext", applicationContextMock); 30 | tester = new WicketTester(wicketApplication); 31 | } 32 | 33 | 34 | @Test 35 | public void testest() { 36 | tester.startPage(HomePage.class); 37 | FormTester newFormTester = tester.newFormTester("form"); 38 | newFormTester.submit(); 39 | tester.assertRenderedPage(SecondPage.class); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /spring-actuator/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /spring-actuator/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 1.5.7.RELEASE 8 | 9 | 10 | 11 | spring-actuator 12 | 13 | 14 | 15 | com.giffing.wicket.spring.boot.starter 16 | wicket-spring-boot-starter 17 | 1.0.10 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-actuator 22 | 23 | 24 | 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-maven-plugin 30 | 31 | 32 | 33 | 34 | src/main/resources 35 | 36 | 37 | src/main/java 38 | 39 | ** 40 | 41 | 42 | **/*.java 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /spring-actuator/src/main/java/com/giffing/examples/wicket/spring/boot/springactuator/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | So simple! 8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /spring-actuator/src/main/java/com/giffing/examples/wicket/spring/boot/springactuator/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.springactuator; 2 | 3 | import org.apache.wicket.markup.html.WebPage; 4 | 5 | import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; 6 | 7 | @WicketHomePage 8 | public class HomePage extends WebPage { 9 | } 10 | -------------------------------------------------------------------------------- /spring-actuator/src/main/java/com/giffing/examples/wicket/spring/boot/springactuator/WicketApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.springactuator; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class WicketApplication { 8 | 9 | public static void main(String[] args) throws Exception { 10 | new SpringApplicationBuilder() 11 | .sources(WicketApplication.class) 12 | .run(args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-actuator/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | management.security.enabled=false -------------------------------------------------------------------------------- /spring-security.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarcGiffing/wicket-spring-boot-examples/5faec6efa9d803a7d452074720fb8bdcf80e0c38/spring-security.zip -------------------------------------------------------------------------------- /spring-security/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /spring-security/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 2.0.2.RELEASE 8 | 9 | 10 | spring-security 11 | 12 | 13 | 1.8 14 | 8.0.0 15 | 16 | 17 | 18 | 19 | com.giffing.wicket.spring.boot.starter 20 | wicket-spring-boot-starter 21 | 2.1.1 22 | 23 | 24 | org.apache.wicket 25 | wicket-core 26 | ${wicket.version} 27 | 28 | 29 | org.apache.wicket 30 | wicket-spring 31 | ${wicket.version} 32 | 33 | 34 | org.apache.wicket 35 | wicket-ioc 36 | ${wicket.version} 37 | 38 | 39 | org.apache.wicket 40 | wicket-auth-roles 41 | ${wicket.version} 42 | 43 | 44 | org.springframework.boot 45 | spring-boot-starter-security 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-starter-test 50 | test 51 | 52 | 53 | 54 | 55 | 56 | 57 | org.springframework.boot 58 | spring-boot-maven-plugin 59 | 60 | 61 | 62 | 63 | src/main/resources 64 | 65 | 66 | src/main/java 67 | 68 | ** 69 | 70 | 71 | **/*.java 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /spring-security/src/main/java/com/giffing/examples/wicket/spring/boot/springsecurity/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 | So simple! 8 | 9 |
10 | 11 | -------------------------------------------------------------------------------- /spring-security/src/main/java/com/giffing/examples/wicket/spring/boot/springsecurity/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.springsecurity; 2 | 3 | import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation; 4 | import org.apache.wicket.markup.html.WebPage; 5 | 6 | import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; 7 | 8 | @WicketHomePage 9 | @AuthorizeInstantiation("USER") 10 | public class HomePage extends WebPage { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /spring-security/src/main/java/com/giffing/examples/wicket/spring/boot/springsecurity/LoginPage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Login Page 6 | 7 | 8 | 9 |

Login

10 |
11 |
12 |

13 | 14 | 15 |

16 |

17 | 18 | 19 |

20 | 21 |
22 | 23 | -------------------------------------------------------------------------------- /spring-security/src/main/java/com/giffing/examples/wicket/spring/boot/springsecurity/LoginPage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.springsecurity; 2 | 3 | import org.apache.wicket.authroles.authentication.AbstractAuthenticatedWebSession; 4 | import org.apache.wicket.authroles.authentication.AuthenticatedWebSession; 5 | import org.apache.wicket.markup.html.WebPage; 6 | import org.apache.wicket.markup.html.form.Form; 7 | import org.apache.wicket.markup.html.form.PasswordTextField; 8 | import org.apache.wicket.markup.html.form.RequiredTextField; 9 | import org.apache.wicket.markup.html.panel.FeedbackPanel; 10 | import org.apache.wicket.model.CompoundPropertyModel; 11 | import org.apache.wicket.request.mapper.parameter.PageParameters; 12 | 13 | import com.giffing.wicket.spring.boot.context.scan.WicketSignInPage; 14 | 15 | @WicketSignInPage 16 | public class LoginPage extends WebPage { 17 | 18 | public LoginPage(PageParameters parameters) { 19 | super(parameters); 20 | 21 | if (((AbstractAuthenticatedWebSession) getSession()).isSignedIn()) { 22 | continueToOriginalDestination(); 23 | } 24 | add(new LoginForm("loginForm")); 25 | } 26 | 27 | private class LoginForm extends Form { 28 | 29 | private String username; 30 | 31 | private String password; 32 | 33 | public LoginForm(String id) { 34 | super(id); 35 | setModel(new CompoundPropertyModel<>(this)); 36 | add(new FeedbackPanel("feedback")); 37 | add(new RequiredTextField("username")); 38 | add(new PasswordTextField("password")); 39 | } 40 | 41 | @Override 42 | protected void onSubmit() { 43 | AuthenticatedWebSession session = AuthenticatedWebSession.get(); 44 | if (session.signIn(username, password)) { 45 | setResponsePage(HomePage.class); 46 | } else { 47 | error("Login failed"); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /spring-security/src/main/java/com/giffing/examples/wicket/spring/boot/springsecurity/WicketApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.springsecurity; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class WicketApplication { 8 | 9 | public static void main(String[] args) throws Exception { 10 | new SpringApplicationBuilder() 11 | .sources(WicketApplication.class) 12 | .run(args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /spring-security/src/main/java/com/giffing/examples/wicket/spring/boot/springsecurity/WicketWebSecurityApapterConfig.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.springsecurity; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.security.authentication.AuthenticationManager; 7 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 8 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 9 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 10 | 11 | @Configuration 12 | public class WicketWebSecurityApapterConfig extends WebSecurityConfigurerAdapter { 13 | 14 | @Override 15 | @Bean(name = "authenticationManager") 16 | public AuthenticationManager authenticationManagerBean() throws Exception { 17 | return super.authenticationManagerBean(); 18 | } 19 | 20 | @Override 21 | protected void configure(HttpSecurity http) throws Exception { 22 | http 23 | .csrf().disable() 24 | .authorizeRequests().antMatchers("/**").permitAll() 25 | .and() 26 | .logout() 27 | .permitAll(); 28 | http.headers().frameOptions().disable(); 29 | } 30 | 31 | @Autowired 32 | public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { 33 | auth 34 | .inMemoryAuthentication() 35 | .withUser("admin").password("{noop}admin").authorities("USER", "ADMIN"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /spring-security/src/test/java/com/giffing/examples/wicket/spring/boot/springsecurity/LoginPageTest.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.springsecurity; 2 | 3 | import org.apache.wicket.protocol.http.WebApplication; 4 | import org.apache.wicket.util.tester.FormTester; 5 | import org.apache.wicket.util.tester.WicketTester; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.boot.test.mock.mockito.SpyBean; 12 | import org.springframework.context.ApplicationContext; 13 | import org.springframework.security.authentication.AuthenticationManager; 14 | import org.springframework.security.authentication.TestingAuthenticationToken; 15 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 16 | import org.springframework.security.core.Authentication; 17 | import org.springframework.security.core.AuthenticationException; 18 | import org.springframework.test.context.junit4.SpringRunner; 19 | import org.springframework.test.util.ReflectionTestUtils; 20 | 21 | import com.giffing.wicket.spring.boot.starter.configuration.extensions.external.spring.security.SecureWebSession; 22 | 23 | @RunWith(SpringRunner.class) 24 | @SpringBootTest(classes = WicketApplication.class) 25 | @EnableWebSecurity 26 | public class LoginPageTest { 27 | 28 | private static final String USERNAME = "admin"; 29 | private static final String PASSWORD = "admin"; 30 | 31 | private WicketTester tester; 32 | 33 | @Autowired 34 | private WebApplication wicketApplication; 35 | 36 | @Autowired 37 | private ApplicationContext applicationContextMock; 38 | 39 | 40 | @Before 41 | public void setUp() { 42 | ReflectionTestUtils.setField(wicketApplication, "applicationContext", applicationContextMock); 43 | tester = new WicketTester(wicketApplication); 44 | login(USERNAME, PASSWORD); 45 | } 46 | 47 | @Test 48 | public void test_something() { 49 | System.out.println("test"); 50 | } 51 | 52 | private void login(String username, String password) { 53 | SecureWebSession session = (SecureWebSession) tester.getSession(); 54 | session.signOut(); 55 | tester.startPage(LoginPage.class); 56 | FormTester formTester = tester.newFormTester("loginForm"); 57 | formTester.setValue("username", username); 58 | formTester.setValue("password", password); 59 | formTester.submit(); 60 | tester.assertNoErrorMessage(); 61 | tester.assertNoInfoMessage(); 62 | tester.assertRenderedPage(HomePage.class); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /websockets/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | .classpath 4 | .project -------------------------------------------------------------------------------- /websockets/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 1.5.7.RELEASE 8 | 9 | 10 | websockets 11 | 12 | 13 | 7.9.0 14 | 15 | 16 | 17 | 18 | com.giffing.wicket.spring.boot.starter 19 | wicket-spring-boot-starter 20 | 1.0.10 21 | 22 | 23 | org.apache.wicket 24 | wicket-native-websocket-javax 25 | ${wicket.version} 26 | 27 | 28 | -------------------------------------------------------------------------------- /websockets/src/main/java/com/giffing/examples/wicket/spring/boot/websockets/WicketApplication.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.websockets; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | 6 | @SpringBootApplication 7 | public class WicketApplication { 8 | 9 | public static void main(String[] args) throws Exception { 10 | new SpringApplicationBuilder() 11 | .sources(WicketApplication.class) 12 | .run(args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /websockets/src/main/java/com/giffing/examples/wicket/spring/boot/websockets/pages/ChatMessageEvent.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.websockets.pages; 2 | 3 | import org.apache.wicket.protocol.ws.api.message.IWebSocketPushMessage; 4 | 5 | public class ChatMessageEvent implements IWebSocketPushMessage{ 6 | 7 | private String message; 8 | 9 | public ChatMessageEvent(String message){ 10 | this.setMessage(message); 11 | } 12 | 13 | public String getMessage() { 14 | return message; 15 | } 16 | 17 | public void setMessage(String message) { 18 | this.message = message; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /websockets/src/main/java/com/giffing/examples/wicket/spring/boot/websockets/pages/HomePage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Wicket! 4 | 5 | 6 |
7 |
8 | 9 | 10 |
11 | 12 |
13 |
    14 |
  • 15 |
16 |
17 | 18 | 19 |
20 | 21 | -------------------------------------------------------------------------------- /websockets/src/main/java/com/giffing/examples/wicket/spring/boot/websockets/pages/HomePage.java: -------------------------------------------------------------------------------- 1 | package com.giffing.examples.wicket.spring.boot.websockets.pages; 2 | 3 | import java.util.ArrayList; 4 | 5 | import org.apache.wicket.ajax.AjaxRequestTarget; 6 | import org.apache.wicket.ajax.markup.html.form.AjaxButton; 7 | import org.apache.wicket.markup.html.WebMarkupContainer; 8 | import org.apache.wicket.markup.html.WebPage; 9 | import org.apache.wicket.markup.html.basic.Label; 10 | import org.apache.wicket.markup.html.form.Form; 11 | import org.apache.wicket.markup.html.form.TextField; 12 | import org.apache.wicket.markup.html.list.ListItem; 13 | import org.apache.wicket.markup.html.list.ListView; 14 | import org.apache.wicket.model.IModel; 15 | import org.apache.wicket.model.Model; 16 | import org.apache.wicket.model.util.ListModel; 17 | import org.apache.wicket.protocol.ws.api.WebSocketBehavior; 18 | import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler; 19 | import org.apache.wicket.protocol.ws.api.message.IWebSocketPushMessage; 20 | import org.apache.wicket.spring.injection.annot.SpringBean; 21 | 22 | import com.giffing.wicket.spring.boot.context.scan.WicketHomePage; 23 | import com.giffing.wicket.spring.boot.starter.web.servlet.websocket.WebSocketMessageBroadcaster; 24 | 25 | @WicketHomePage 26 | public class HomePage extends WebPage { 27 | 28 | @SpringBean 29 | private WebSocketMessageBroadcaster broadcaster; 30 | 31 | private ListView chatList; 32 | 33 | private ListModel chatModel = new ListModel(new ArrayList()); 34 | 35 | private IModel latestChatMessage = Model.of(""); 36 | 37 | private TextField chatTextField; 38 | 39 | public HomePage() { 40 | 41 | queue(new Form("form")); 42 | chatTextField = new TextField("chatInput", latestChatMessage); 43 | chatTextField.setOutputMarkupId(true); 44 | queue(chatTextField); 45 | queue(new AjaxButton("send") { 46 | 47 | @Override 48 | protected void onSubmit(AjaxRequestTarget target, Form form) { 49 | broadcaster.send(new ChatMessageEvent(latestChatMessage.getObject())); 50 | } 51 | }); 52 | 53 | final WebMarkupContainer chatContainer = new WebMarkupContainer("chatContainer"); 54 | chatContainer.setOutputMarkupId(true); 55 | queue(chatContainer); 56 | 57 | chatList = new ListView("chat", chatModel) { 58 | 59 | @Override 60 | protected void populateItem(ListItem item) { 61 | item.add(new Label("message", item.getModelObject())); 62 | 63 | } 64 | }; 65 | chatList.setOutputMarkupId(true); 66 | queue(chatList); 67 | 68 | add(new WebSocketBehavior() { 69 | 70 | @Override 71 | protected void onPush(WebSocketRequestHandler handler, IWebSocketPushMessage message) { 72 | if(message instanceof ChatMessageEvent){ 73 | ChatMessageEvent event = (ChatMessageEvent)message; 74 | if(event != null){ 75 | chatModel.getObject().add(event.getMessage()); 76 | handler.add(chatContainer); 77 | chatTextField.setModelObject(""); 78 | handler.add(chatTextField); 79 | } 80 | } 81 | } 82 | }); 83 | 84 | 85 | 86 | } 87 | 88 | } 89 | --------------------------------------------------------------------------------