1/* 2 * Copyright (C) 2011 The Guava Authors 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.google.common.util.concurrent; 18 19import java.util.concurrent.Callable; 20 21/** 22 * A listening executor service which forwards all its method calls to another 23 * listening executor service. Subclasses should override one or more methods to 24 * modify the behavior of the backing executor service as desired per the <a 25 * href="http://en.wikipedia.org/wiki/Decorator_pattern">decorator pattern</a>. 26 * 27 * @author Isaac Shum 28 * @since 10.0 29 */ 30public abstract class ForwardingListeningExecutorService 31 extends ForwardingExecutorService implements ListeningExecutorService { 32 /** Constructor for use by subclasses. */ 33 protected ForwardingListeningExecutorService() {} 34 35 @Override 36 protected abstract ListeningExecutorService delegate(); 37 38 @Override 39 public <T> ListenableFuture<T> submit(Callable<T> task) { 40 return delegate().submit(task); 41 } 42 43 @Override 44 public ListenableFuture<?> submit(Runnable task) { 45 return delegate().submit(task); 46 } 47 48 @Override 49 public <T> ListenableFuture<T> submit(Runnable task, T result) { 50 return delegate().submit(task, result); 51 } 52} 53