Refactor all Spring Session, Apache Geode Samples using Spring Boot to switch from Thymeleaf to FreeMarker.
Convert Thymelead templates to FreeMarker templates. Remove the use of WebJars. Refactor all Sample application code.
This commit is contained in:
@@ -6,7 +6,7 @@ dependencies {
|
||||
|
||||
implementation project(':spring-session-data-geode')
|
||||
|
||||
implementation("org.springframework.boot:spring-boot-starter-thymeleaf") {
|
||||
implementation("org.springframework.boot:spring-boot-starter-freemarker") {
|
||||
exclude group: "org.apache.logging.log4j", module: "log4j-to-slf4j"
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ dependencies {
|
||||
|
||||
implementation "jakarta.servlet:jakarta.servlet-api"
|
||||
implementation "org.springframework.data:spring-data-geode-test"
|
||||
implementation "org.webjars:bootstrap"
|
||||
implementation "org.webjars:webjars-locator"
|
||||
|
||||
runtimeOnly "org.springframework.shell:spring-shell"
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ public class Application {
|
||||
|
||||
// end::class[]
|
||||
|
||||
@SuppressWarnings("all")
|
||||
HttpSession updateRequestCount(HttpSession session) {
|
||||
|
||||
synchronized (session) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<!DOCTYPE html SYSTEM "https://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-3.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Session Attributes</title>
|
||||
<style type="text/css">
|
||||
@@ -19,7 +18,7 @@
|
||||
|
||||
<h1>Try it</h1>
|
||||
|
||||
<form class="form-inline" role="form" action="./session" method="post">
|
||||
<form role="form" action="./session" method="post">
|
||||
<label for="attributeName">Attribute Name</label>
|
||||
<input id="attributeName" type="text" name="attributeName"/>
|
||||
<label for="attributeValue">Attribute Value</label>
|
||||
@@ -29,7 +28,7 @@
|
||||
|
||||
<hr/>
|
||||
|
||||
<table class="table table-striped">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Attribute Name</th>
|
||||
@@ -37,10 +36,15 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="attribute: ${sessionAttributes}">
|
||||
<td th:text="${attribute.key}">name</td>
|
||||
<td th:text="${attribute.value}">value</td>
|
||||
<#attempt>
|
||||
<#list sessionAttributes as attributeName, attributeValue>
|
||||
<tr>
|
||||
<td>${attributeName}</td>
|
||||
<td>${attributeValue}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
<#recover>
|
||||
</#attempt>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -5,7 +5,7 @@ dependencies {
|
||||
|
||||
implementation project(':spring-session-data-geode')
|
||||
|
||||
implementation("org.springframework.boot:spring-boot-starter-thymeleaf") {
|
||||
implementation("org.springframework.boot:spring-boot-starter-freemarker") {
|
||||
exclude group: "org.apache.logging.log4j", module: "log4j-to-slf4j"
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@ dependencies {
|
||||
|
||||
implementation "jakarta.servlet:jakarta.servlet-api"
|
||||
implementation "org.springframework.data:spring-data-geode-test"
|
||||
implementation "org.webjars:bootstrap"
|
||||
implementation "org.webjars:webjars-locator"
|
||||
|
||||
runtimeOnly "org.springframework.shell:spring-shell"
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@ import org.springframework.session.data.gemfire.config.annotation.web.http.Enabl
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
@@ -67,7 +66,7 @@ public class Application {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@ClientCacheApplication(name = "SpringSessionDataGeodeBootSampleWithScopedProxiesClient", logLevel = "error",
|
||||
@ClientCacheApplication(name = "SpringSessionDataGeodeBootSampleWithScopedProxiesClient",
|
||||
readTimeout = 15000, retryAttempts = 1, subscriptionEnabled = true) // <3>
|
||||
@EnableGemFireHttpSession(poolName = "DEFAULT") // <4>
|
||||
static class ClientCacheConfiguration { }
|
||||
@@ -102,13 +101,13 @@ public class Application {
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "/ping")
|
||||
@GetMapping(path = "/ping")
|
||||
@ResponseBody
|
||||
public String ping() {
|
||||
return PING_RESPONSE;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "/counts")
|
||||
@GetMapping(path = "/counts")
|
||||
public String requestAndSessionInstanceCount(HttpServletRequest request, HttpSession session, Model model) { // <6>
|
||||
|
||||
model.addAttribute("sessionId", session.getId());
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<!DOCTYPE html SYSTEM "https://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-3.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Request and Session Counts</title>
|
||||
<style type="text/css">
|
||||
@@ -16,7 +15,7 @@
|
||||
in the context of Spring Session when GemFire is used to back the HTTP Session.
|
||||
</p>
|
||||
|
||||
<table class="table table-striped">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th> * </th>
|
||||
@@ -26,12 +25,15 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<#attempt>
|
||||
<tr>
|
||||
<td><b>count</b></td>
|
||||
<td th:text="${sessionId}">?</td>
|
||||
<td th:text="${sessionCount}">0</td>
|
||||
<td th:text="${requestCount}">0</td>
|
||||
<td>${sessionId}</td>
|
||||
<td>${sessionCount}</td>
|
||||
<td>${requestCount}/></td>
|
||||
</tr>
|
||||
<#recover>
|
||||
</#attempt>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -6,7 +6,7 @@ dependencies {
|
||||
|
||||
implementation project(':spring-session-data-geode')
|
||||
|
||||
implementation("org.springframework.boot:spring-boot-starter-thymeleaf") {
|
||||
implementation("org.springframework.boot:spring-boot-starter-freemarker") {
|
||||
exclude group: "org.apache.logging.log4j", module: "log4j-to-slf4j"
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ dependencies {
|
||||
|
||||
implementation "jakarta.servlet:jakarta.servlet-api"
|
||||
implementation "org.springframework.data:spring-data-geode-test"
|
||||
implementation "org.webjars:bootstrap"
|
||||
implementation "org.webjars:webjars-locator"
|
||||
|
||||
runtimeOnly "org.springframework.shell:spring-shell"
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample.pages;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -39,8 +39,8 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
@@ -74,7 +74,7 @@ public class Application {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@ClientCacheApplication(name = "SpringSessionDataGeodeBootSampleClient", logLevel = "error",
|
||||
@ClientCacheApplication(name = "SpringSessionDataGeodeBootSampleClient",
|
||||
readTimeout = 15000, retryAttempts = 1, subscriptionEnabled = true) // <3>
|
||||
@EnableGemFireHttpSession(poolName = "DEFAULT") // <4>
|
||||
static class ClientCacheConfiguration extends ClientServerIntegrationTestsSupport {
|
||||
@@ -111,18 +111,18 @@ public class Application {
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "/ping")
|
||||
@GetMapping(path = "/ping")
|
||||
@ResponseBody
|
||||
public String ping() {
|
||||
return PING_RESPONSE;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, path = "/session")
|
||||
public String session(HttpSession session, ModelMap modelMap,
|
||||
@PostMapping(path = "/session")
|
||||
public String session(HttpSession session, ModelMap model,
|
||||
@RequestParam(name = "attributeName", required = false) String name,
|
||||
@RequestParam(name = "attributeValue", required = false) String value) { // <7>
|
||||
|
||||
modelMap.addAttribute("sessionAttributes",
|
||||
model.addAttribute("sessionAttributes",
|
||||
attributes(setAttribute(updateRequestCount(session), name, value)));
|
||||
|
||||
return INDEX_TEMPLATE_VIEW_NAME;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<!DOCTYPE html SYSTEM "https://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-3.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="https://www.thymeleaf.org">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Session Attributes</title>
|
||||
<style type="text/css">
|
||||
@@ -19,7 +18,7 @@
|
||||
|
||||
<h1>Try it</h1>
|
||||
|
||||
<form class="form-inline" role="form" action="./session" method="post">
|
||||
<form role="form" action="./session" method="post">
|
||||
<label for="attributeName">Attribute Name</label>
|
||||
<input id="attributeName" type="text" name="attributeName"/>
|
||||
<label for="attributeValue">Attribute Value</label>
|
||||
@@ -29,7 +28,7 @@
|
||||
|
||||
<hr/>
|
||||
|
||||
<table class="table table-striped">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Attribute Name</th>
|
||||
@@ -37,10 +36,15 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="attribute: ${sessionAttributes}">
|
||||
<td th:text="${attribute.key}">name</td>
|
||||
<td th:text="${attribute.value}">value</td>
|
||||
<#attempt>
|
||||
<#list sessionAttributes as attributeName, attributeValue>
|
||||
<tr>
|
||||
<td>${attributeName}</td>
|
||||
<td>${attributeValue}</td>
|
||||
</tr>
|
||||
</#list>
|
||||
<#recover>
|
||||
</#attempt>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
Reference in New Issue
Block a user