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

com.amazonaws.services.translate.AmazonTranslateAsyncClient Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon Translate module holds the client classes that are used for communicating with Amazon Translate Service

There is a newer version: 1.12.778
Show newest version
/*
 * Copyright 2019-2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file 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.amazonaws.services.translate;

import javax.annotation.Generated;

import com.amazonaws.services.translate.model.*;
import com.amazonaws.client.AwsAsyncClientParams;
import com.amazonaws.annotation.ThreadSafe;

import java.util.concurrent.ExecutorService;

/**
 * Client for accessing Amazon Translate asynchronously. Each asynchronous method will return a Java Future object
 * representing the asynchronous operation; overloads which accept an {@code AsyncHandler} can be used to receive
 * notification when an asynchronous operation completes.
 * 

*

* Provides translation of the input content from the source language to the target language. *

*/ @ThreadSafe @Generated("com.amazonaws:aws-java-sdk-code-generator") public class AmazonTranslateAsyncClient extends AmazonTranslateClient implements AmazonTranslateAsync { private static final int DEFAULT_THREAD_POOL_SIZE = 50; private final java.util.concurrent.ExecutorService executorService; public static AmazonTranslateAsyncClientBuilder asyncBuilder() { return AmazonTranslateAsyncClientBuilder.standard(); } /** * Constructs a new asynchronous client to invoke service methods on Amazon Translate using the specified * parameters. * * @param asyncClientParams * Object providing client parameters. */ AmazonTranslateAsyncClient(AwsAsyncClientParams asyncClientParams) { this(asyncClientParams, false); } /** * Constructs a new asynchronous client to invoke service methods on Amazon Translate using the specified * parameters. * * @param asyncClientParams * Object providing client parameters. * @param endpointDiscoveryEnabled * true will enable endpoint discovery if the service supports it. */ AmazonTranslateAsyncClient(AwsAsyncClientParams asyncClientParams, boolean endpointDiscoveryEnabled) { super(asyncClientParams, endpointDiscoveryEnabled); this.executorService = asyncClientParams.getExecutor(); } /** * Returns the executor service used by this client to execute async requests. * * @return The executor service used by this client to execute async requests. */ public ExecutorService getExecutorService() { return executorService; } @Override public java.util.concurrent.Future createParallelDataAsync(CreateParallelDataRequest request) { return createParallelDataAsync(request, null); } @Override public java.util.concurrent.Future createParallelDataAsync(final CreateParallelDataRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final CreateParallelDataRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public CreateParallelDataResult call() throws Exception { CreateParallelDataResult result = null; try { result = executeCreateParallelData(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future deleteParallelDataAsync(DeleteParallelDataRequest request) { return deleteParallelDataAsync(request, null); } @Override public java.util.concurrent.Future deleteParallelDataAsync(final DeleteParallelDataRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final DeleteParallelDataRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public DeleteParallelDataResult call() throws Exception { DeleteParallelDataResult result = null; try { result = executeDeleteParallelData(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future deleteTerminologyAsync(DeleteTerminologyRequest request) { return deleteTerminologyAsync(request, null); } @Override public java.util.concurrent.Future deleteTerminologyAsync(final DeleteTerminologyRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final DeleteTerminologyRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public DeleteTerminologyResult call() throws Exception { DeleteTerminologyResult result = null; try { result = executeDeleteTerminology(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future describeTextTranslationJobAsync(DescribeTextTranslationJobRequest request) { return describeTextTranslationJobAsync(request, null); } @Override public java.util.concurrent.Future describeTextTranslationJobAsync(final DescribeTextTranslationJobRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final DescribeTextTranslationJobRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public DescribeTextTranslationJobResult call() throws Exception { DescribeTextTranslationJobResult result = null; try { result = executeDescribeTextTranslationJob(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future getParallelDataAsync(GetParallelDataRequest request) { return getParallelDataAsync(request, null); } @Override public java.util.concurrent.Future getParallelDataAsync(final GetParallelDataRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final GetParallelDataRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public GetParallelDataResult call() throws Exception { GetParallelDataResult result = null; try { result = executeGetParallelData(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future getTerminologyAsync(GetTerminologyRequest request) { return getTerminologyAsync(request, null); } @Override public java.util.concurrent.Future getTerminologyAsync(final GetTerminologyRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final GetTerminologyRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public GetTerminologyResult call() throws Exception { GetTerminologyResult result = null; try { result = executeGetTerminology(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future importTerminologyAsync(ImportTerminologyRequest request) { return importTerminologyAsync(request, null); } @Override public java.util.concurrent.Future importTerminologyAsync(final ImportTerminologyRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final ImportTerminologyRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public ImportTerminologyResult call() throws Exception { ImportTerminologyResult result = null; try { result = executeImportTerminology(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future listLanguagesAsync(ListLanguagesRequest request) { return listLanguagesAsync(request, null); } @Override public java.util.concurrent.Future listLanguagesAsync(final ListLanguagesRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final ListLanguagesRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public ListLanguagesResult call() throws Exception { ListLanguagesResult result = null; try { result = executeListLanguages(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future listParallelDataAsync(ListParallelDataRequest request) { return listParallelDataAsync(request, null); } @Override public java.util.concurrent.Future listParallelDataAsync(final ListParallelDataRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final ListParallelDataRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public ListParallelDataResult call() throws Exception { ListParallelDataResult result = null; try { result = executeListParallelData(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future listTagsForResourceAsync(ListTagsForResourceRequest request) { return listTagsForResourceAsync(request, null); } @Override public java.util.concurrent.Future listTagsForResourceAsync(final ListTagsForResourceRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final ListTagsForResourceRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public ListTagsForResourceResult call() throws Exception { ListTagsForResourceResult result = null; try { result = executeListTagsForResource(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future listTerminologiesAsync(ListTerminologiesRequest request) { return listTerminologiesAsync(request, null); } @Override public java.util.concurrent.Future listTerminologiesAsync(final ListTerminologiesRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final ListTerminologiesRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public ListTerminologiesResult call() throws Exception { ListTerminologiesResult result = null; try { result = executeListTerminologies(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future listTextTranslationJobsAsync(ListTextTranslationJobsRequest request) { return listTextTranslationJobsAsync(request, null); } @Override public java.util.concurrent.Future listTextTranslationJobsAsync(final ListTextTranslationJobsRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final ListTextTranslationJobsRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public ListTextTranslationJobsResult call() throws Exception { ListTextTranslationJobsResult result = null; try { result = executeListTextTranslationJobs(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future startTextTranslationJobAsync(StartTextTranslationJobRequest request) { return startTextTranslationJobAsync(request, null); } @Override public java.util.concurrent.Future startTextTranslationJobAsync(final StartTextTranslationJobRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final StartTextTranslationJobRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public StartTextTranslationJobResult call() throws Exception { StartTextTranslationJobResult result = null; try { result = executeStartTextTranslationJob(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future stopTextTranslationJobAsync(StopTextTranslationJobRequest request) { return stopTextTranslationJobAsync(request, null); } @Override public java.util.concurrent.Future stopTextTranslationJobAsync(final StopTextTranslationJobRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final StopTextTranslationJobRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public StopTextTranslationJobResult call() throws Exception { StopTextTranslationJobResult result = null; try { result = executeStopTextTranslationJob(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future tagResourceAsync(TagResourceRequest request) { return tagResourceAsync(request, null); } @Override public java.util.concurrent.Future tagResourceAsync(final TagResourceRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final TagResourceRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public TagResourceResult call() throws Exception { TagResourceResult result = null; try { result = executeTagResource(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future translateDocumentAsync(TranslateDocumentRequest request) { return translateDocumentAsync(request, null); } @Override public java.util.concurrent.Future translateDocumentAsync(final TranslateDocumentRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final TranslateDocumentRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public TranslateDocumentResult call() throws Exception { TranslateDocumentResult result = null; try { result = executeTranslateDocument(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future translateTextAsync(TranslateTextRequest request) { return translateTextAsync(request, null); } @Override public java.util.concurrent.Future translateTextAsync(final TranslateTextRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final TranslateTextRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public TranslateTextResult call() throws Exception { TranslateTextResult result = null; try { result = executeTranslateText(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future untagResourceAsync(UntagResourceRequest request) { return untagResourceAsync(request, null); } @Override public java.util.concurrent.Future untagResourceAsync(final UntagResourceRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final UntagResourceRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public UntagResourceResult call() throws Exception { UntagResourceResult result = null; try { result = executeUntagResource(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } @Override public java.util.concurrent.Future updateParallelDataAsync(UpdateParallelDataRequest request) { return updateParallelDataAsync(request, null); } @Override public java.util.concurrent.Future updateParallelDataAsync(final UpdateParallelDataRequest request, final com.amazonaws.handlers.AsyncHandler asyncHandler) { final UpdateParallelDataRequest finalRequest = beforeClientExecution(request); return executorService.submit(new java.util.concurrent.Callable() { @Override public UpdateParallelDataResult call() throws Exception { UpdateParallelDataResult result = null; try { result = executeUpdateParallelData(finalRequest); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(finalRequest, result); } return result; } }); } /** * Shuts down the client, releasing all managed resources. This includes forcibly terminating all pending * asynchronous service calls. Clients who wish to give pending asynchronous service calls time to complete should * call {@code getExecutorService().shutdown()} followed by {@code getExecutorService().awaitTermination()} prior to * calling this method. */ @Override public void shutdown() { super.shutdown(); executorService.shutdownNow(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy