All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.photos.library.v1.upload.PhotosLibraryUploadStubImpl Maven / Gradle / Ivy

There is a newer version: 1.7.3
Show newest version
/*
 * Copyright 2018 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.photos.library.v1.upload;

import com.google.api.gax.core.BackgroundResource;
import com.google.api.gax.core.BackgroundResourceAggregation;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.photos.library.v1.PhotosLibrarySettings;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

/** Implementation for {@link PhotosLibraryUploadStub}. */
public final class PhotosLibraryUploadStubImpl extends PhotosLibraryUploadStub {

  private final ClientContext clientContext;
  private final BackgroundResource backgroundResources;
  private final PhotosLibraryUploadUnaryCallable photosLibraryUploadUnaryCallable;

  private PhotosLibraryUploadStubImpl(PhotosLibrarySettings settings) throws IOException {
    this.clientContext = ClientContext.create(settings);
    this.backgroundResources =
        new BackgroundResourceAggregation(clientContext.getBackgroundResources());
    this.photosLibraryUploadUnaryCallable =
        new PhotosLibraryUploadUnaryCallable(clientContext, settings);
  }

  public static PhotosLibraryUploadStub createStub(PhotosLibrarySettings settings)
      throws IOException {
    return new PhotosLibraryUploadStubImpl(settings);
  }

  @Override
  public UnaryCallable uploadMediaItemCallable() {
    return photosLibraryUploadUnaryCallable;
  }

  @Override
  public void shutdown() {
    backgroundResources.shutdown();
  }

  @Override
  public boolean isShutdown() {
    return backgroundResources.isShutdown();
  }

  @Override
  public boolean isTerminated() {
    return backgroundResources.isTerminated();
  }

  @Override
  public void shutdownNow() {
    backgroundResources.shutdownNow();
  }

  @Override
  public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
    return backgroundResources.awaitTermination(duration, unit);
  }

  @Override
  public void close() throws Exception {
    backgroundResources.close();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy