Skip to content

Instantly share code, notes, and snippets.

View odrotbohm's full-sized avatar
👨‍💻
@ home

Oliver Drotbohm odrotbohm

👨‍💻
@ home
View GitHub Profile
<!DOCTYPE html>
<html html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
th:replace="~{layout :: layout(~{:: #content})}">
<body cds-theme="dark">
<div class="content-area" id="content">
</div>
</body>

tl;dr

We would like to simplify the event-based module integration and make sure the default transactional setup is correct by introducing a custom @ModuleIntegrationListener annotation.

Context

Classic Spring applications use bean references and invocations to orchestrate functionality, even if the functionality triggered resides in different application modules. In those cases, the default approach to consistency is a transaction that spans the original business method and all transitive functionality:

@Service
@RequiredArgsConstructor

Suggestions for HAL FORMS

{
  "_links" : { … },
  "name" : "…",
  "other-values" : [
    { … }, …
  ],
 "_templates" : {
@odrotbohm
odrotbohm / Sample.java
Created June 29, 2020 21:08
Jackson deserialization into a complex constructor
@SpringBootTest
@RequiredArgsConstructor
class Sample {
private final ObjectMapper jackson;
@Test
void deserializesThroughConstructor() throws Exception {
var result = jackson.readValue("{\"firstname\" : \"Dave\", \"lastname\" : \"Matthews\" }", SomeSample.class);
/*
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
/*
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software

Hibernate Enhancer problem on Java 11

Spring RESTBucks uses Hibernate’s bytecode enhancement to avoid runtime overhead in favor of a build time step. This works fine on JDK 8. However, if the project is built on JDK 11, starting it fails with:

Caused by: java.lang.IllegalAccessError: Update to non-static final field org.springsource.restbucks.payment.Payment.order attempted from a different method ($$_hibernate_write_order) than the initializer method <init>
	at org.springsource.restbucks.payment.Payment.$$_hibernate_write_order(Payment.java) ~[classes/:na]
@odrotbohm
odrotbohm / readme.adoc
Created July 1, 2019 09:57
Proposal – Leveraging hypermedia in Android clients

Hypermedia in Android clients

Context

When it comes to JVM based clients of REST / HTTP APIs, Android is the most dominant platform. There are a variety of HTTP client libraries available for Android, but none of them have dedicated support to work with hypermedia elements (like links and forms) or late binding of data. Using those elements is crucial to avoid strong coupling between client and server. See this presentation (slides, recording for details.

Idea

Wanted but not invoked:
entityLinks.linkForItemResource(
class org.springframework.data.rest.core.domain.Profile,
isNull()
);
-> at org.springframework.data.rest.core.support.DefaultSelfLinkProviderUnitTests.looksUpSelfLinksForProxies(DefaultSelfLinkProviderUnitTests.java:144)
However, there was exactly 1 interaction with this mock:
entityLinks.linkToItemResource(
class org.springframework.data.rest.core.domain.Profile,
class Sample {
public this someMethod() {
// …
return this;
}
}
class Subtype extends Sample {};