A generic binding annotation that can be associated with the up status
of an application.
bind(Boolean.class).annotatedWith(UpStatus.class).toInstance(new AtomicBoolean(true));
bind(new TypeLiteral() {}>).annotatedWith(UpStatus.class).toInstance(new SomeSupplierThatTellsYouTheUpStatus());
public class Foo() {
@Inject
public Foo(@UpStatus Supplier isUp) {
System.out.println("Application isUp: " + isUp);
}
}
If you're using RxJava you can set up an Observable of up status
bind(new TypeLiteral>() {}>).annotatedWith(UpStatus.class).toInstance(new SomethingThatEmitsChangesInUpStatus());
public class Foo() {
@Inject
public Foo(@UpStatus Observable upStatus) {
upStatus.subscribe(new Action1() {
public void call(Boolean status) {
System.out.println("Status is now up");
}
});
}
}