protected void exceptionIfDependenciesNotActive() { for (LifeCycle dependency : dependencies) { if (dependency.getStatus().compareTo(Status.ACTIVE) != 0) { throw new IllegalStateException(String.format("Illegal state: %s for component: %s", dependency.getStatus(), dependency)); } } }
protected void exceptionIfNotActive() { if (!status.equals(Status.ACTIVE)) throw new IllegalStateException(String.format("not active: %s", this)); }
@PostConstruct public void start() { logger.info("Starting %s", this); synchronized (this.statusLock) { if (this.status.compareTo(Status.SHUTDOWN_REQUEST) >= 0) { doShutdown(); this.status = Status.SHUT_DOWN; this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.ACTIVE) == 0) { this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.INACTIVE) != 0) { throw new IllegalStateException("Illegal state: " + this.status); } exceptionIfDependenciesNotActive(); this.status = Status.ACTIVE; } userExecutor.execute(this); }
@PostConstruct public void start() { logger.info("Starting %s", this); synchronized (this.statusLock) { if (this.status.compareTo(Status.SHUTDOWN_REQUEST) >= 0) { doShutdown(); this.status = Status.SHUT_DOWN; this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.ACTIVE) == 0) { this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.INACTIVE) != 0) { throw new IllegalStateException("Illegal state: " + this.status); } exceptionIfDependenciesNotActive(); this.status = Status.ACTIVE; } userExecutor.execute(this); }
@PostConstruct public void start() { logger.info("Starting %s", this); synchronized (this.statusLock) { if (this.status.compareTo(Status.SHUTDOWN_REQUEST) >= 0) { doShutdown(); this.status = Status.SHUT_DOWN; this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.ACTIVE) == 0) { this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.INACTIVE) != 0) { throw new IllegalStateException("Illegal state: " + this.status); } exceptionIfDependenciesNotActive(); this.status = Status.ACTIVE; } userExecutor.execute(this); }
@PostConstruct public void start() { logger.info("Starting %s", this); synchronized (this.statusLock) { if (this.status.compareTo(Status.SHUTDOWN_REQUEST) >= 0) { doShutdown(); this.status = Status.SHUT_DOWN; this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.ACTIVE) == 0) { this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.INACTIVE) != 0) { throw new IllegalStateException("Illegal state: " + this.status); } exceptionIfDependenciesNotActive(); this.status = Status.ACTIVE; } userExecutor.execute(this); }
@PostConstruct public void start() { logger.info("Starting %s", this); synchronized (this.statusLock) { if (this.status.compareTo(Status.SHUTDOWN_REQUEST) >= 0) { doShutdown(); this.status = Status.SHUT_DOWN; this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.ACTIVE) == 0) { this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.INACTIVE) != 0) { throw new IllegalStateException("Illegal state: " + this.status); } exceptionIfDependenciesNotActive(); this.status = Status.ACTIVE; } userExecutor.execute(this); }
@PostConstruct public void start() { logger.info("Starting %s", this); synchronized (this.statusLock) { if (this.status.compareTo(Status.SHUTDOWN_REQUEST) >= 0) { doShutdown(); this.status = Status.SHUT_DOWN; this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.ACTIVE) == 0) { this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.INACTIVE) != 0) { throw new IllegalStateException("Illegal state: " + this.status); } exceptionIfDependenciesNotActive(); this.status = Status.ACTIVE; } userExecutor.execute(this); }
public void shutdown(long waitMs) { synchronized (this.statusLock) { if (this.status.compareTo(Status.ACTIVE) > 0) { return; } this.status = Status.SHUTDOWN_REQUEST; try { awaitShutdown(waitMs); } catch (InterruptedException ignore) { } } }
protected void exceptionIfDependenciesNotActive() { for (LifeCycle dependency : dependencies) { if (dependency.getStatus().compareTo(Status.ACTIVE) != 0) { throw new IllegalStateException(String.format("Illegal state: %s for component: %s", dependency.getStatus(), dependency)); } } }
/** * @return false if any dependencies are inactive, or we are inactive, or we have a global * exception. */ protected boolean shouldDoWork() { try { exceptionIfDependenciesNotActive(); } catch (IllegalStateException e) { return false; } return status.equals(Status.ACTIVE) && exception.get() == null; }
public void shutdown(long waitMs) { synchronized (this.statusLock) { if (this.status.compareTo(Status.ACTIVE) > 0) { return; } this.status = Status.SHUTDOWN_REQUEST; try { awaitShutdown(waitMs); } catch (InterruptedException ignore) { } } }
protected void exceptionIfDependenciesNotActive() { for (LifeCycle dependency : dependencies) { if (dependency.getStatus().compareTo(Status.ACTIVE) != 0) { throw new IllegalStateException(String.format("Illegal state: %s for component: %s", dependency.getStatus(), dependency)); } } }
/** * @return false if any dependencies are inactive, or we are inactive, or we have a global * exception. */ protected boolean shouldDoWork() { try { exceptionIfDependenciesNotActive(); } catch (IllegalStateException e) { return false; } return status.equals(Status.ACTIVE) && exception.get() == null; }
protected void exceptionIfNotActive() { if (!status.equals(Status.ACTIVE)) throw new IllegalStateException(String.format("not active: %s", this)); }
/** * @return false if any dependencies are inactive, or we are inactive, or we have a global * exception. */ protected boolean shouldDoWork() { try { exceptionIfDependenciesNotActive(); } catch (IllegalStateException e) { return false; } return status.equals(Status.ACTIVE) && exception.get() == null; }
protected void exceptionIfNotActive() { if (!status.equals(Status.ACTIVE)) throw new IllegalStateException(String.format("not active: %s", this)); }
protected void exceptionIfNotActive() { if (!status.equals(Status.ACTIVE)) throw new IllegalStateException(String.format("not active: %s", this)); }
public void shutdown(long waitMs) { synchronized (this.statusLock) { if (this.status.compareTo(Status.ACTIVE) > 0) { return; } this.status = Status.SHUTDOWN_REQUEST; try { awaitShutdown(waitMs); } catch (InterruptedException ignore) { } } }
protected void exceptionIfDependenciesNotActive() { for (LifeCycle dependency : dependencies) { if (dependency.getStatus().compareTo(Status.ACTIVE) != 0) { throw new IllegalStateException(String.format("Illegal state: %s for component: %s", dependency.getStatus(), dependency)); } } }