|
@@ -10,6 +10,7 @@ import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
|
|
|
|
|
import static java.util.concurrent.TimeUnit.SECONDS; |
|
|
import static java.util.concurrent.TimeUnit.SECONDS; |
|
|
import static org.cobbzilla.util.daemon.ZillaRuntime.die; |
|
|
import static org.cobbzilla.util.daemon.ZillaRuntime.die; |
|
@@ -24,7 +25,13 @@ public class AccountInitializer implements Runnable { |
|
|
private Account account; |
|
|
private Account account; |
|
|
private AccountDAO accountDAO; |
|
|
private AccountDAO accountDAO; |
|
|
private AccountMessageDAO messageDAO; |
|
|
private AccountMessageDAO messageDAO; |
|
|
|
|
|
|
|
|
private AtomicBoolean ready = new AtomicBoolean(false); |
|
|
private AtomicBoolean ready = new AtomicBoolean(false); |
|
|
|
|
|
public boolean ready() { return ready.get(); } |
|
|
|
|
|
|
|
|
|
|
|
private AtomicReference<Exception> error = new AtomicReference<>(); |
|
|
|
|
|
public Exception getError() { return error.get(); } |
|
|
|
|
|
public boolean hasError () { return getError() != null; } |
|
|
|
|
|
|
|
|
public AccountInitializer(Account account, AccountDAO accountDAO, AccountMessageDAO messageDAO) { |
|
|
public AccountInitializer(Account account, AccountDAO accountDAO, AccountMessageDAO messageDAO) { |
|
|
this.account = account; |
|
|
this.account = account; |
|
@@ -32,8 +39,6 @@ public class AccountInitializer implements Runnable { |
|
|
this.messageDAO = messageDAO; |
|
|
this.messageDAO = messageDAO; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public boolean ready() { return ready.get(); } |
|
|
|
|
|
|
|
|
|
|
|
@Override public void run() { |
|
|
@Override public void run() { |
|
|
try { |
|
|
try { |
|
|
boolean success = false; |
|
|
boolean success = false; |
|
@@ -62,6 +67,7 @@ public class AccountInitializer implements Runnable { |
|
|
.setAction(AccountAction.welcome) |
|
|
.setAction(AccountAction.welcome) |
|
|
.setTarget(ActionTarget.account)); |
|
|
.setTarget(ActionTarget.account)); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
|
|
|
error.set(e); |
|
|
// todo: send to errbit |
|
|
// todo: send to errbit |
|
|
die("error: "+e, e); |
|
|
die("error: "+e, e); |
|
|
} |
|
|
} |
|
|