001    /*
002     * Copyright (C) 2009 Google Inc.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package com.google.common.util.concurrent;
018    
019    import com.google.common.annotations.Beta;
020    import com.google.common.base.Service;
021    import com.google.common.collect.ForwardingObject;
022    
023    import java.util.concurrent.Future;
024    
025    /**
026     * A {@link Service} that forwards all method calls to another service.
027     *
028     * @author Chris Nokleberg
029     * @since 1
030     */
031    @Beta
032    public abstract class ForwardingService extends ForwardingObject
033        implements Service {
034    
035      /** Constructor for use by subclasses. */
036      protected ForwardingService() {}
037    
038      @Override protected abstract Service delegate();
039    
040      @Override public Future<State> start() {
041        return delegate().start();
042      }
043    
044      @Override public State state() {
045        return delegate().state();
046      }
047    
048      @Override public Future<State> stop() {
049        return delegate().stop();
050      }
051    
052      @Override public State startAndWait() {
053        return delegate().startAndWait();
054      }
055    
056      @Override public State stopAndWait() {
057        return delegate().stopAndWait();
058      }
059    
060      @Override public boolean isRunning() {
061        return delegate().isRunning();
062      }
063    }