Exemple #1
0
  private static Worker getCallerWorker() {
    Class<? extends Worker> caller = Reflection.getCallerClass(Worker.class);
    if (caller == null)
      throw new IllegalAccessError("Queries must be submitted from a Worker class");

    return getWorker(caller);
  }
Exemple #2
0
  private static Worker getCallerWorkerFromRunnable() {
    Class<? extends WorkerRunnable> caller = Reflection.getCallerClass(WorkerRunnable.class);
    if (caller == null)
      throw new IllegalAccessError("Main thread queries must be submitted from a WorkerRunnable");

    Worker worker = runnables.get(caller);
    if (worker == null)
      throw new IllegalStateException("Caller runnable does not belong to any worker");

    return worker;
  }