Skip to content

Instantly share code, notes, and snippets.

View mvitz's full-sized avatar

Michael Vitz mvitz

View GitHub Profile
@mvitz
mvitz / JugAugsburg.java
Last active October 27, 2021 06:32
Examples for JDK/Java features introduced between JDK 11 and 17
package com.innoq.java17;
import java.util.ArrayList;
import java.util.List;
public class JugAugsburg {
// Switch Expressions
static void switchExpressions() {
int i = 3;
@mvitz
mvitz / Config.java
Created May 28, 2018 15:13
Simplified example of how Spring Boot enhances @configuration classes with CGLib to intercept internal calls to other public methods
public class Config {
public static void main(String[] args) {
Map<String, Object> beans = new HashMap<>();
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(Config.class);
enhancer.setCallback((MethodInterceptor) (obj, method, arguments, proxy) -> {
String name = method.getName();
if (!beans.containsKey(name)) {
@mvitz
mvitz / Request with MediaType without EnableHypermediaSupport
Last active November 1, 2023 07:12
Spring-Boot HATEOAS server example
~/Development/new/spring-hateoas-server $ http -p Hhb :8080/users Accept:application/hal+json
GET /users HTTP/1.1
Accept: application/hal+json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: localhost:8080
User-Agent: HTTPie/0.9.8
HTTP/1.1 200
Content-Type: application/hal+json;charset=UTF-8
@mvitz
mvitz / MvcUriComponentsBuilderApplication.java
Created June 26, 2016 09:32
Empty query parameters should not be shown in build URI.
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder;
@SpringBootApplication
@Controller
public class MvcUriComponentsBuilderApplication {
spring:
resources:
chain:
enabled: true
strategy:
content:
enabled: true
cache-period: 3600
package com;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@mvitz
mvitz / MyBenchmark.java
Created October 21, 2015 08:27
Adam Bien JSON Parser Benchmark
package com.innoq;
import java.util.Map;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;

Keybase proof

I hereby claim:

  • I am mvitz on github.
  • I am mvitz (https://keybase.io/mvitz) on keybase.
  • I have a public key whose fingerprint is CF17 83E8 A3DE CC24 AE34 26CA 560B 340B 93E7 3B5D

To claim this, I am signing this object: