Since Spring 4.1, it is really easy to enable JSONP on an API controller:
@RestController
@RequestMapping(value = "/")
public class MyController {
@ControllerAdvice
static class JsonpAdvice extends AbstractJsonpResponseBodyAdvice {
public JsonpAdvice() {
super("callback"); // name of the query parameter to use
}
}
@RequestMapping(value = "/", method = RequestMethod.GET)
public MyAPIResult getStuff(...) {
...
}
}
There is no RFC …
Annotation processor to create immutable objects and builders. Feels like Guava's immutable collections but for regular value objects. JSON, Jackson, Gson, JAX-RS integrations included http://immutables.org
"Every class begins with a babe, in a cafe."
Ce court article détaille comment mettre en place simplement 3 analyseurs de code statique avec Maven.
Contexte
Au sein de mon équipe à Voyages-Sncf, le nombre de composants Java est en train d'augmenter.
Nous avons déjà toute une batterie de tests pour valider notre code, ainsi qu'un Sonar en place …
En mars dernier, j'ai participé à la Battledev de RegionJobs.
Et c'était super fun.
Pour ceux qui ne connaissent pas, c'est une compétition de programmation en ligne, où l'on doit résoudre 5 questions de difficulté croissante en 2 heures.
J'ai eu l'occasion d'y participer avec quelques collègues, et ça a …
Simply add the following class to your project. It will be automatically registered at start-up if you use the @EnableAutoConfiguration
annotation :
@ControllerAdvice // Makes this the default behaviour of all controllers
@ConditionalOnProperty(prefix = "app", name = "disable-default-exception-handling")
class GlobalControllerExceptionHandler {
@ExceptionHandler(Exception.class) // Catch any exception
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) // Returns an error code …
I’ve always found it strange that Java is the most popular programming language on the planet yet actually getting stats out is extremely frustrating.
Orbit is a framework to write distributed systems using virtual actors on the JVM. It allows developers to write highly distributed and scalable applications while greatly simplifying clustering, discovery, networking, state management, actor lifetime and more.
Java 8 Resources (lambdas, method references, defender methods, streams) - Java 8 Cheatsheet
Pourquoi, mais pourquoi faut-il 3 lignes en Java pour juste extraire un groupe d'une expression régulière qui "match" ???
Matcher matcher = Pattern.compile("o?k(b|i)s+").matcher("kiss");
matcher.matches();
assert matcher.group(1) == "i";
En Python:
assert re.match("o?k(b|i)s+", "kiss").group(1) == "i …
java-design-patterns - Design pattern samples implemented in Java
This post is a cheatsheet with enumeration of options, which should be always used to configure Java Virtual Machine for Web-oriented server applications (i.e. Web Front-End) in production or production-like environments.
error-prone - Catch common Java mistakes as compile-time errors
What does it means when some tool or framework has literally dozens of guides, pages long each? It probably means that it is popular, or complicated to use. Usually, both. That’s the story of Maven Central (a.k.a. Central Repository, a.k.a. repo1, a.k.a. ibiblio). Of course, there is a better alternative nowadays - Bintray is already…
finagle - A fault tolerant, protocol-agnostic RPC system