Merge pull request #8125 from eugenp/revert-8119-BAEL-3275-2

Revert "BAEL-3275: Using blocking queue for pub-sub"
This commit is contained in:
Eric Martin
2019-10-31 20:43:47 -05:00
committed by GitHub
parent db85c8f275
commit 3225470df5
20543 changed files with 1642750 additions and 0 deletions
@@ -0,0 +1,12 @@
package com.baeldung.cachecontrol;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class AppRunner {
public static void main(String[] args) {
SpringApplication.run(AppRunner.class, args);
}
}
@@ -0,0 +1,48 @@
package com.baeldung.cachecontrol;
import com.baeldung.cachecontrol.model.TimestampDto;
import com.baeldung.cachecontrol.model.UserDto;
import org.springframework.http.CacheControl;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.concurrent.TimeUnit;
@Controller
public class ResourceEndpoint {
@GetMapping(value = "/default/users/{name}")
public ResponseEntity<UserDto> getUserWithDefaultCaching(@PathVariable String name) {
return ResponseEntity.ok(new UserDto(name));
}
@GetMapping("/users/{name}")
public ResponseEntity<UserDto> getUser(@PathVariable String name) {
return ResponseEntity
.ok()
.cacheControl(CacheControl.maxAge(60, TimeUnit.SECONDS))
.body(new UserDto(name));
}
@GetMapping("/timestamp")
public ResponseEntity<TimestampDto> getServerTimestamp() {
return ResponseEntity
.ok()
.cacheControl(CacheControl.noStore())
.body(new TimestampDto(LocalDateTime
.now()
.toInstant(ZoneOffset.UTC)
.toEpochMilli()));
}
@GetMapping("/private/users/{name}")
public ResponseEntity<UserDto> getUserNotCached(@PathVariable String name) {
return ResponseEntity
.ok()
.body(new UserDto(name));
}
}
@@ -0,0 +1,17 @@
package com.baeldung.cachecontrol.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {}
}
@@ -0,0 +1,10 @@
package com.baeldung.cachecontrol.model;
public class TimestampDto {
public final Long timestamp;
public TimestampDto(Long timestamp) {
this.timestamp = timestamp;
}
}
@@ -0,0 +1,11 @@
package com.baeldung.cachecontrol.model;
public class UserDto {
public final String name;
public UserDto(String name) {
this.name = name;
}
}