Skip to content

Instantly share code, notes, and snippets.

View martinandersson's full-sized avatar

Martin Andersson martinandersson

View GitHub Profile
@martinandersson
martinandersson / ThreadEndpoint.java
Created October 9, 2019 14:59
Micronaut Endpoint/Controller that reveals the calling thread.
package com.hello.controllerthread;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import io.reactivex.Single;
import java.util.Map;
@Controller("/thread")
public class ThreadEndpoint
@martinandersson
martinandersson / Launcher.java
Last active September 5, 2018 10:19
RxJava and what gets disposed
package com.hello;
import io.reactivex.Observable;
import io.reactivex.disposables.Disposable;
import io.reactivex.observables.ConnectableObservable;
/**
* Lesson learned: It is not the Observable that is disposed, it is the Observer
* that may get disposed. Rx's API and documentation continuously describe
* the Observable as the one being disposed, but this is wrong.
@martinandersson
martinandersson / DefaultFacade.java
Last active December 1, 2016 15:36
Configurator, passed to service by CDI.
class DefaultFacade implements Facade
{
@Inject
OrderService service;
@Override
public void buttonClicked() {
Instant dispatch = Instant.now().plus(2, ChronoUnit.HOURS);
Order order = service.createOrder(dispatch);
// ..
apply plugin: 'java'
apply plugin: 'java-library-distribution'
repositories {
mavenCentral()
}
dependencies {
compile 'org.apache.commons:commons-lang3:3.3.2'
}