AbstractExecutionThreadService.java 7.55 KB
package com.google.common.util.concurrent;

import com.google.common.annotations.Beta;
import com.google.common.base.Supplier;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.logging.Logger;

@Beta
public abstract class AbstractExecutionThreadService
  implements Service
{
  private static final Logger a = Logger.getLogger(AbstractExecutionThreadService.class.getName());
  private final Service b = new AbstractService()
  {
    protected final void doStart()
    {
      MoreExecutors.a(AbstractExecutionThreadService.this.executor(), new Supplier() {}).execute(new Runnable()
      {
        /* Error */
        public final void run()
        {
          // Byte code:
          //   0: aload_0
          //   1: getfield 17	com/google/common/util/concurrent/AbstractExecutionThreadService$1$2:a	Lcom/google/common/util/concurrent/AbstractExecutionThreadService$1;
          //   4: getfield 28	com/google/common/util/concurrent/AbstractExecutionThreadService$1:a	Lcom/google/common/util/concurrent/AbstractExecutionThreadService;
          //   7: invokevirtual 33	com/google/common/util/concurrent/AbstractExecutionThreadService:startUp	()V
          //   10: aload_0
          //   11: getfield 17	com/google/common/util/concurrent/AbstractExecutionThreadService$1$2:a	Lcom/google/common/util/concurrent/AbstractExecutionThreadService$1;
          //   14: invokevirtual 36	com/google/common/util/concurrent/AbstractExecutionThreadService$1:notifyStarted	()V
          //   17: aload_0
          //   18: getfield 17	com/google/common/util/concurrent/AbstractExecutionThreadService$1$2:a	Lcom/google/common/util/concurrent/AbstractExecutionThreadService$1;
          //   21: invokevirtual 40	com/google/common/util/concurrent/AbstractExecutionThreadService$1:isRunning	()Z
          //   24: istore_1
          //   25: iload_1
          //   26: ifeq +13 -> 39
          //   29: aload_0
          //   30: getfield 17	com/google/common/util/concurrent/AbstractExecutionThreadService$1$2:a	Lcom/google/common/util/concurrent/AbstractExecutionThreadService$1;
          //   33: getfield 28	com/google/common/util/concurrent/AbstractExecutionThreadService$1:a	Lcom/google/common/util/concurrent/AbstractExecutionThreadService;
          //   36: invokevirtual 42	com/google/common/util/concurrent/AbstractExecutionThreadService:run	()V
          //   39: aload_0
          //   40: getfield 17	com/google/common/util/concurrent/AbstractExecutionThreadService$1$2:a	Lcom/google/common/util/concurrent/AbstractExecutionThreadService$1;
          //   43: getfield 28	com/google/common/util/concurrent/AbstractExecutionThreadService$1:a	Lcom/google/common/util/concurrent/AbstractExecutionThreadService;
          //   46: invokevirtual 45	com/google/common/util/concurrent/AbstractExecutionThreadService:shutDown	()V
          //   49: aload_0
          //   50: getfield 17	com/google/common/util/concurrent/AbstractExecutionThreadService$1$2:a	Lcom/google/common/util/concurrent/AbstractExecutionThreadService$1;
          //   53: invokevirtual 48	com/google/common/util/concurrent/AbstractExecutionThreadService$1:notifyStopped	()V
          //   56: return
          //   57: astore_2
          //   58: aload_0
          //   59: getfield 17	com/google/common/util/concurrent/AbstractExecutionThreadService$1$2:a	Lcom/google/common/util/concurrent/AbstractExecutionThreadService$1;
          //   62: getfield 28	com/google/common/util/concurrent/AbstractExecutionThreadService$1:a	Lcom/google/common/util/concurrent/AbstractExecutionThreadService;
          //   65: invokevirtual 45	com/google/common/util/concurrent/AbstractExecutionThreadService:shutDown	()V
          //   68: aload_2
          //   69: athrow
          //   70: astore_2
          //   71: aload_0
          //   72: getfield 17	com/google/common/util/concurrent/AbstractExecutionThreadService$1$2:a	Lcom/google/common/util/concurrent/AbstractExecutionThreadService$1;
          //   75: aload_2
          //   76: invokevirtual 52	com/google/common/util/concurrent/AbstractExecutionThreadService$1:notifyFailed	(Ljava/lang/Throwable;)V
          //   79: aload_2
          //   80: invokestatic 58	com/google/common/base/Throwables:propagate	(Ljava/lang/Throwable;)Ljava/lang/RuntimeException;
          //   83: athrow
          //   84: astore_3
          //   85: invokestatic 61	com/google/common/util/concurrent/AbstractExecutionThreadService:a	()Ljava/util/logging/Logger;
          //   88: getstatic 67	java/util/logging/Level:WARNING	Ljava/util/logging/Level;
          //   91: ldc 69
          //   93: aload_3
          //   94: invokevirtual 75	java/util/logging/Logger:log	(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
          //   97: goto -29 -> 68
          // Local variable table:
          //   start	length	slot	name	signature
          //   0	100	0	this	2
          //   24	2	1	bool	boolean
          //   57	12	2	localThrowable1	Throwable
          //   70	10	2	localThrowable2	Throwable
          //   84	10	3	localException	Exception
          // Exception table:
          //   from	to	target	type
          //   29	39	57	java/lang/Throwable
          //   0	25	70	java/lang/Throwable
          //   39	56	70	java/lang/Throwable
          //   58	68	70	java/lang/Throwable
          //   68	70	70	java/lang/Throwable
          //   85	97	70	java/lang/Throwable
          //   58	68	84	java/lang/Exception
        }
      });
    }
    
    protected final void doStop()
    {
      AbstractExecutionThreadService.this.triggerShutdown();
    }
  };
  
  public final void addListener(Service.Listener paramListener, Executor paramExecutor)
  {
    this.b.addListener(paramListener, paramExecutor);
  }
  
  public final void awaitRunning()
  {
    this.b.awaitRunning();
  }
  
  public final void awaitRunning(long paramLong, TimeUnit paramTimeUnit)
    throws TimeoutException
  {
    this.b.awaitRunning(paramLong, paramTimeUnit);
  }
  
  public final void awaitTerminated()
  {
    this.b.awaitTerminated();
  }
  
  public final void awaitTerminated(long paramLong, TimeUnit paramTimeUnit)
    throws TimeoutException
  {
    this.b.awaitTerminated(paramLong, paramTimeUnit);
  }
  
  protected Executor executor()
  {
    new Executor()
    {
      public final void execute(Runnable paramAnonymousRunnable)
      {
        MoreExecutors.a(AbstractExecutionThreadService.this.serviceName(), paramAnonymousRunnable).start();
      }
    };
  }
  
  public final Throwable failureCause()
  {
    return this.b.failureCause();
  }
  
  public final boolean isRunning()
  {
    return this.b.isRunning();
  }
  
  protected abstract void run()
    throws Exception;
  
  protected String serviceName()
  {
    return getClass().getSimpleName();
  }
  
  protected void shutDown()
    throws Exception
  {}
  
  public final Service startAsync()
  {
    this.b.startAsync();
    return this;
  }
  
  protected void startUp()
    throws Exception
  {}
  
  public final Service.State state()
  {
    return this.b.state();
  }
  
  public final Service stopAsync()
  {
    this.b.stopAsync();
    return this;
  }
  
  public String toString()
  {
    String str1 = String.valueOf(String.valueOf(serviceName()));
    String str2 = String.valueOf(String.valueOf(state()));
    return str1.length() + 3 + str2.length() + str1 + " [" + str2 + "]";
  }
  
  protected void triggerShutdown() {}
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/util/concurrent/AbstractExecutionThreadService.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */