• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Google LLC
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  *      https://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 
17 package com.google.cloud.dialogflow.cx.v3.stub;
18 
19 import static com.google.cloud.dialogflow.cx.v3.AgentsClient.ListAgentsPagedResponse;
20 import static com.google.cloud.dialogflow.cx.v3.AgentsClient.ListLocationsPagedResponse;
21 
22 import com.google.api.gax.core.BackgroundResource;
23 import com.google.api.gax.core.BackgroundResourceAggregation;
24 import com.google.api.gax.grpc.GrpcCallSettings;
25 import com.google.api.gax.grpc.GrpcStubCallableFactory;
26 import com.google.api.gax.rpc.ClientContext;
27 import com.google.api.gax.rpc.OperationCallable;
28 import com.google.api.gax.rpc.UnaryCallable;
29 import com.google.cloud.dialogflow.cx.v3.Agent;
30 import com.google.cloud.dialogflow.cx.v3.AgentValidationResult;
31 import com.google.cloud.dialogflow.cx.v3.CreateAgentRequest;
32 import com.google.cloud.dialogflow.cx.v3.DeleteAgentRequest;
33 import com.google.cloud.dialogflow.cx.v3.ExportAgentRequest;
34 import com.google.cloud.dialogflow.cx.v3.ExportAgentResponse;
35 import com.google.cloud.dialogflow.cx.v3.GetAgentRequest;
36 import com.google.cloud.dialogflow.cx.v3.GetAgentValidationResultRequest;
37 import com.google.cloud.dialogflow.cx.v3.ListAgentsRequest;
38 import com.google.cloud.dialogflow.cx.v3.ListAgentsResponse;
39 import com.google.cloud.dialogflow.cx.v3.RestoreAgentRequest;
40 import com.google.cloud.dialogflow.cx.v3.UpdateAgentRequest;
41 import com.google.cloud.dialogflow.cx.v3.ValidateAgentRequest;
42 import com.google.cloud.location.GetLocationRequest;
43 import com.google.cloud.location.ListLocationsRequest;
44 import com.google.cloud.location.ListLocationsResponse;
45 import com.google.cloud.location.Location;
46 import com.google.common.collect.ImmutableMap;
47 import com.google.longrunning.Operation;
48 import com.google.longrunning.stub.GrpcOperationsStub;
49 import com.google.protobuf.Empty;
50 import com.google.protobuf.Struct;
51 import io.grpc.MethodDescriptor;
52 import io.grpc.protobuf.ProtoUtils;
53 import java.io.IOException;
54 import java.util.concurrent.TimeUnit;
55 import javax.annotation.Generated;
56 
57 // AUTO-GENERATED DOCUMENTATION AND CLASS.
58 /**
59  * gRPC stub implementation for the Agents service API.
60  *
61  * <p>This class is for advanced usage and reflects the underlying API directly.
62  */
63 @Generated("by gapic-generator-java")
64 public class GrpcAgentsStub extends AgentsStub {
65   private static final MethodDescriptor<ListAgentsRequest, ListAgentsResponse>
66       listAgentsMethodDescriptor =
67           MethodDescriptor.<ListAgentsRequest, ListAgentsResponse>newBuilder()
68               .setType(MethodDescriptor.MethodType.UNARY)
69               .setFullMethodName("google.cloud.dialogflow.cx.v3.Agents/ListAgents")
70               .setRequestMarshaller(ProtoUtils.marshaller(ListAgentsRequest.getDefaultInstance()))
71               .setResponseMarshaller(ProtoUtils.marshaller(ListAgentsResponse.getDefaultInstance()))
72               .build();
73 
74   private static final MethodDescriptor<GetAgentRequest, Agent> getAgentMethodDescriptor =
75       MethodDescriptor.<GetAgentRequest, Agent>newBuilder()
76           .setType(MethodDescriptor.MethodType.UNARY)
77           .setFullMethodName("google.cloud.dialogflow.cx.v3.Agents/GetAgent")
78           .setRequestMarshaller(ProtoUtils.marshaller(GetAgentRequest.getDefaultInstance()))
79           .setResponseMarshaller(ProtoUtils.marshaller(Agent.getDefaultInstance()))
80           .build();
81 
82   private static final MethodDescriptor<CreateAgentRequest, Agent> createAgentMethodDescriptor =
83       MethodDescriptor.<CreateAgentRequest, Agent>newBuilder()
84           .setType(MethodDescriptor.MethodType.UNARY)
85           .setFullMethodName("google.cloud.dialogflow.cx.v3.Agents/CreateAgent")
86           .setRequestMarshaller(ProtoUtils.marshaller(CreateAgentRequest.getDefaultInstance()))
87           .setResponseMarshaller(ProtoUtils.marshaller(Agent.getDefaultInstance()))
88           .build();
89 
90   private static final MethodDescriptor<UpdateAgentRequest, Agent> updateAgentMethodDescriptor =
91       MethodDescriptor.<UpdateAgentRequest, Agent>newBuilder()
92           .setType(MethodDescriptor.MethodType.UNARY)
93           .setFullMethodName("google.cloud.dialogflow.cx.v3.Agents/UpdateAgent")
94           .setRequestMarshaller(ProtoUtils.marshaller(UpdateAgentRequest.getDefaultInstance()))
95           .setResponseMarshaller(ProtoUtils.marshaller(Agent.getDefaultInstance()))
96           .build();
97 
98   private static final MethodDescriptor<DeleteAgentRequest, Empty> deleteAgentMethodDescriptor =
99       MethodDescriptor.<DeleteAgentRequest, Empty>newBuilder()
100           .setType(MethodDescriptor.MethodType.UNARY)
101           .setFullMethodName("google.cloud.dialogflow.cx.v3.Agents/DeleteAgent")
102           .setRequestMarshaller(ProtoUtils.marshaller(DeleteAgentRequest.getDefaultInstance()))
103           .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance()))
104           .build();
105 
106   private static final MethodDescriptor<ExportAgentRequest, Operation> exportAgentMethodDescriptor =
107       MethodDescriptor.<ExportAgentRequest, Operation>newBuilder()
108           .setType(MethodDescriptor.MethodType.UNARY)
109           .setFullMethodName("google.cloud.dialogflow.cx.v3.Agents/ExportAgent")
110           .setRequestMarshaller(ProtoUtils.marshaller(ExportAgentRequest.getDefaultInstance()))
111           .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
112           .build();
113 
114   private static final MethodDescriptor<RestoreAgentRequest, Operation>
115       restoreAgentMethodDescriptor =
116           MethodDescriptor.<RestoreAgentRequest, Operation>newBuilder()
117               .setType(MethodDescriptor.MethodType.UNARY)
118               .setFullMethodName("google.cloud.dialogflow.cx.v3.Agents/RestoreAgent")
119               .setRequestMarshaller(ProtoUtils.marshaller(RestoreAgentRequest.getDefaultInstance()))
120               .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance()))
121               .build();
122 
123   private static final MethodDescriptor<ValidateAgentRequest, AgentValidationResult>
124       validateAgentMethodDescriptor =
125           MethodDescriptor.<ValidateAgentRequest, AgentValidationResult>newBuilder()
126               .setType(MethodDescriptor.MethodType.UNARY)
127               .setFullMethodName("google.cloud.dialogflow.cx.v3.Agents/ValidateAgent")
128               .setRequestMarshaller(
129                   ProtoUtils.marshaller(ValidateAgentRequest.getDefaultInstance()))
130               .setResponseMarshaller(
131                   ProtoUtils.marshaller(AgentValidationResult.getDefaultInstance()))
132               .build();
133 
134   private static final MethodDescriptor<GetAgentValidationResultRequest, AgentValidationResult>
135       getAgentValidationResultMethodDescriptor =
136           MethodDescriptor.<GetAgentValidationResultRequest, AgentValidationResult>newBuilder()
137               .setType(MethodDescriptor.MethodType.UNARY)
138               .setFullMethodName("google.cloud.dialogflow.cx.v3.Agents/GetAgentValidationResult")
139               .setRequestMarshaller(
140                   ProtoUtils.marshaller(GetAgentValidationResultRequest.getDefaultInstance()))
141               .setResponseMarshaller(
142                   ProtoUtils.marshaller(AgentValidationResult.getDefaultInstance()))
143               .build();
144 
145   private static final MethodDescriptor<ListLocationsRequest, ListLocationsResponse>
146       listLocationsMethodDescriptor =
147           MethodDescriptor.<ListLocationsRequest, ListLocationsResponse>newBuilder()
148               .setType(MethodDescriptor.MethodType.UNARY)
149               .setFullMethodName("google.cloud.location.Locations/ListLocations")
150               .setRequestMarshaller(
151                   ProtoUtils.marshaller(ListLocationsRequest.getDefaultInstance()))
152               .setResponseMarshaller(
153                   ProtoUtils.marshaller(ListLocationsResponse.getDefaultInstance()))
154               .build();
155 
156   private static final MethodDescriptor<GetLocationRequest, Location> getLocationMethodDescriptor =
157       MethodDescriptor.<GetLocationRequest, Location>newBuilder()
158           .setType(MethodDescriptor.MethodType.UNARY)
159           .setFullMethodName("google.cloud.location.Locations/GetLocation")
160           .setRequestMarshaller(ProtoUtils.marshaller(GetLocationRequest.getDefaultInstance()))
161           .setResponseMarshaller(ProtoUtils.marshaller(Location.getDefaultInstance()))
162           .build();
163 
164   private final UnaryCallable<ListAgentsRequest, ListAgentsResponse> listAgentsCallable;
165   private final UnaryCallable<ListAgentsRequest, ListAgentsPagedResponse> listAgentsPagedCallable;
166   private final UnaryCallable<GetAgentRequest, Agent> getAgentCallable;
167   private final UnaryCallable<CreateAgentRequest, Agent> createAgentCallable;
168   private final UnaryCallable<UpdateAgentRequest, Agent> updateAgentCallable;
169   private final UnaryCallable<DeleteAgentRequest, Empty> deleteAgentCallable;
170   private final UnaryCallable<ExportAgentRequest, Operation> exportAgentCallable;
171   private final OperationCallable<ExportAgentRequest, ExportAgentResponse, Struct>
172       exportAgentOperationCallable;
173   private final UnaryCallable<RestoreAgentRequest, Operation> restoreAgentCallable;
174   private final OperationCallable<RestoreAgentRequest, Empty, Struct> restoreAgentOperationCallable;
175   private final UnaryCallable<ValidateAgentRequest, AgentValidationResult> validateAgentCallable;
176   private final UnaryCallable<GetAgentValidationResultRequest, AgentValidationResult>
177       getAgentValidationResultCallable;
178   private final UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable;
179   private final UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
180       listLocationsPagedCallable;
181   private final UnaryCallable<GetLocationRequest, Location> getLocationCallable;
182 
183   private final BackgroundResource backgroundResources;
184   private final GrpcOperationsStub operationsStub;
185   private final GrpcStubCallableFactory callableFactory;
186 
create(AgentsStubSettings settings)187   public static final GrpcAgentsStub create(AgentsStubSettings settings) throws IOException {
188     return new GrpcAgentsStub(settings, ClientContext.create(settings));
189   }
190 
create(ClientContext clientContext)191   public static final GrpcAgentsStub create(ClientContext clientContext) throws IOException {
192     return new GrpcAgentsStub(AgentsStubSettings.newBuilder().build(), clientContext);
193   }
194 
create( ClientContext clientContext, GrpcStubCallableFactory callableFactory)195   public static final GrpcAgentsStub create(
196       ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException {
197     return new GrpcAgentsStub(
198         AgentsStubSettings.newBuilder().build(), clientContext, callableFactory);
199   }
200 
201   /**
202    * Constructs an instance of GrpcAgentsStub, using the given settings. This is protected so that
203    * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
204    */
GrpcAgentsStub(AgentsStubSettings settings, ClientContext clientContext)205   protected GrpcAgentsStub(AgentsStubSettings settings, ClientContext clientContext)
206       throws IOException {
207     this(settings, clientContext, new GrpcAgentsCallableFactory());
208   }
209 
210   /**
211    * Constructs an instance of GrpcAgentsStub, using the given settings. This is protected so that
212    * it is easy to make a subclass, but otherwise, the static factory methods should be preferred.
213    */
GrpcAgentsStub( AgentsStubSettings settings, ClientContext clientContext, GrpcStubCallableFactory callableFactory)214   protected GrpcAgentsStub(
215       AgentsStubSettings settings,
216       ClientContext clientContext,
217       GrpcStubCallableFactory callableFactory)
218       throws IOException {
219     this.callableFactory = callableFactory;
220     this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory);
221 
222     GrpcCallSettings<ListAgentsRequest, ListAgentsResponse> listAgentsTransportSettings =
223         GrpcCallSettings.<ListAgentsRequest, ListAgentsResponse>newBuilder()
224             .setMethodDescriptor(listAgentsMethodDescriptor)
225             .setParamsExtractor(
226                 request -> {
227                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
228                   params.put("parent", String.valueOf(request.getParent()));
229                   return params.build();
230                 })
231             .build();
232     GrpcCallSettings<GetAgentRequest, Agent> getAgentTransportSettings =
233         GrpcCallSettings.<GetAgentRequest, Agent>newBuilder()
234             .setMethodDescriptor(getAgentMethodDescriptor)
235             .setParamsExtractor(
236                 request -> {
237                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
238                   params.put("name", String.valueOf(request.getName()));
239                   return params.build();
240                 })
241             .build();
242     GrpcCallSettings<CreateAgentRequest, Agent> createAgentTransportSettings =
243         GrpcCallSettings.<CreateAgentRequest, Agent>newBuilder()
244             .setMethodDescriptor(createAgentMethodDescriptor)
245             .setParamsExtractor(
246                 request -> {
247                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
248                   params.put("parent", String.valueOf(request.getParent()));
249                   return params.build();
250                 })
251             .build();
252     GrpcCallSettings<UpdateAgentRequest, Agent> updateAgentTransportSettings =
253         GrpcCallSettings.<UpdateAgentRequest, Agent>newBuilder()
254             .setMethodDescriptor(updateAgentMethodDescriptor)
255             .setParamsExtractor(
256                 request -> {
257                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
258                   params.put("agent.name", String.valueOf(request.getAgent().getName()));
259                   return params.build();
260                 })
261             .build();
262     GrpcCallSettings<DeleteAgentRequest, Empty> deleteAgentTransportSettings =
263         GrpcCallSettings.<DeleteAgentRequest, Empty>newBuilder()
264             .setMethodDescriptor(deleteAgentMethodDescriptor)
265             .setParamsExtractor(
266                 request -> {
267                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
268                   params.put("name", String.valueOf(request.getName()));
269                   return params.build();
270                 })
271             .build();
272     GrpcCallSettings<ExportAgentRequest, Operation> exportAgentTransportSettings =
273         GrpcCallSettings.<ExportAgentRequest, Operation>newBuilder()
274             .setMethodDescriptor(exportAgentMethodDescriptor)
275             .setParamsExtractor(
276                 request -> {
277                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
278                   params.put("name", String.valueOf(request.getName()));
279                   return params.build();
280                 })
281             .build();
282     GrpcCallSettings<RestoreAgentRequest, Operation> restoreAgentTransportSettings =
283         GrpcCallSettings.<RestoreAgentRequest, Operation>newBuilder()
284             .setMethodDescriptor(restoreAgentMethodDescriptor)
285             .setParamsExtractor(
286                 request -> {
287                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
288                   params.put("name", String.valueOf(request.getName()));
289                   return params.build();
290                 })
291             .build();
292     GrpcCallSettings<ValidateAgentRequest, AgentValidationResult> validateAgentTransportSettings =
293         GrpcCallSettings.<ValidateAgentRequest, AgentValidationResult>newBuilder()
294             .setMethodDescriptor(validateAgentMethodDescriptor)
295             .setParamsExtractor(
296                 request -> {
297                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
298                   params.put("name", String.valueOf(request.getName()));
299                   return params.build();
300                 })
301             .build();
302     GrpcCallSettings<GetAgentValidationResultRequest, AgentValidationResult>
303         getAgentValidationResultTransportSettings =
304             GrpcCallSettings.<GetAgentValidationResultRequest, AgentValidationResult>newBuilder()
305                 .setMethodDescriptor(getAgentValidationResultMethodDescriptor)
306                 .setParamsExtractor(
307                     request -> {
308                       ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
309                       params.put("name", String.valueOf(request.getName()));
310                       return params.build();
311                     })
312                 .build();
313     GrpcCallSettings<ListLocationsRequest, ListLocationsResponse> listLocationsTransportSettings =
314         GrpcCallSettings.<ListLocationsRequest, ListLocationsResponse>newBuilder()
315             .setMethodDescriptor(listLocationsMethodDescriptor)
316             .setParamsExtractor(
317                 request -> {
318                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
319                   params.put("name", String.valueOf(request.getName()));
320                   return params.build();
321                 })
322             .build();
323     GrpcCallSettings<GetLocationRequest, Location> getLocationTransportSettings =
324         GrpcCallSettings.<GetLocationRequest, Location>newBuilder()
325             .setMethodDescriptor(getLocationMethodDescriptor)
326             .setParamsExtractor(
327                 request -> {
328                   ImmutableMap.Builder<String, String> params = ImmutableMap.builder();
329                   params.put("name", String.valueOf(request.getName()));
330                   return params.build();
331                 })
332             .build();
333 
334     this.listAgentsCallable =
335         callableFactory.createUnaryCallable(
336             listAgentsTransportSettings, settings.listAgentsSettings(), clientContext);
337     this.listAgentsPagedCallable =
338         callableFactory.createPagedCallable(
339             listAgentsTransportSettings, settings.listAgentsSettings(), clientContext);
340     this.getAgentCallable =
341         callableFactory.createUnaryCallable(
342             getAgentTransportSettings, settings.getAgentSettings(), clientContext);
343     this.createAgentCallable =
344         callableFactory.createUnaryCallable(
345             createAgentTransportSettings, settings.createAgentSettings(), clientContext);
346     this.updateAgentCallable =
347         callableFactory.createUnaryCallable(
348             updateAgentTransportSettings, settings.updateAgentSettings(), clientContext);
349     this.deleteAgentCallable =
350         callableFactory.createUnaryCallable(
351             deleteAgentTransportSettings, settings.deleteAgentSettings(), clientContext);
352     this.exportAgentCallable =
353         callableFactory.createUnaryCallable(
354             exportAgentTransportSettings, settings.exportAgentSettings(), clientContext);
355     this.exportAgentOperationCallable =
356         callableFactory.createOperationCallable(
357             exportAgentTransportSettings,
358             settings.exportAgentOperationSettings(),
359             clientContext,
360             operationsStub);
361     this.restoreAgentCallable =
362         callableFactory.createUnaryCallable(
363             restoreAgentTransportSettings, settings.restoreAgentSettings(), clientContext);
364     this.restoreAgentOperationCallable =
365         callableFactory.createOperationCallable(
366             restoreAgentTransportSettings,
367             settings.restoreAgentOperationSettings(),
368             clientContext,
369             operationsStub);
370     this.validateAgentCallable =
371         callableFactory.createUnaryCallable(
372             validateAgentTransportSettings, settings.validateAgentSettings(), clientContext);
373     this.getAgentValidationResultCallable =
374         callableFactory.createUnaryCallable(
375             getAgentValidationResultTransportSettings,
376             settings.getAgentValidationResultSettings(),
377             clientContext);
378     this.listLocationsCallable =
379         callableFactory.createUnaryCallable(
380             listLocationsTransportSettings, settings.listLocationsSettings(), clientContext);
381     this.listLocationsPagedCallable =
382         callableFactory.createPagedCallable(
383             listLocationsTransportSettings, settings.listLocationsSettings(), clientContext);
384     this.getLocationCallable =
385         callableFactory.createUnaryCallable(
386             getLocationTransportSettings, settings.getLocationSettings(), clientContext);
387 
388     this.backgroundResources =
389         new BackgroundResourceAggregation(clientContext.getBackgroundResources());
390   }
391 
getOperationsStub()392   public GrpcOperationsStub getOperationsStub() {
393     return operationsStub;
394   }
395 
396   @Override
listAgentsCallable()397   public UnaryCallable<ListAgentsRequest, ListAgentsResponse> listAgentsCallable() {
398     return listAgentsCallable;
399   }
400 
401   @Override
listAgentsPagedCallable()402   public UnaryCallable<ListAgentsRequest, ListAgentsPagedResponse> listAgentsPagedCallable() {
403     return listAgentsPagedCallable;
404   }
405 
406   @Override
getAgentCallable()407   public UnaryCallable<GetAgentRequest, Agent> getAgentCallable() {
408     return getAgentCallable;
409   }
410 
411   @Override
createAgentCallable()412   public UnaryCallable<CreateAgentRequest, Agent> createAgentCallable() {
413     return createAgentCallable;
414   }
415 
416   @Override
updateAgentCallable()417   public UnaryCallable<UpdateAgentRequest, Agent> updateAgentCallable() {
418     return updateAgentCallable;
419   }
420 
421   @Override
deleteAgentCallable()422   public UnaryCallable<DeleteAgentRequest, Empty> deleteAgentCallable() {
423     return deleteAgentCallable;
424   }
425 
426   @Override
exportAgentCallable()427   public UnaryCallable<ExportAgentRequest, Operation> exportAgentCallable() {
428     return exportAgentCallable;
429   }
430 
431   @Override
432   public OperationCallable<ExportAgentRequest, ExportAgentResponse, Struct>
exportAgentOperationCallable()433       exportAgentOperationCallable() {
434     return exportAgentOperationCallable;
435   }
436 
437   @Override
restoreAgentCallable()438   public UnaryCallable<RestoreAgentRequest, Operation> restoreAgentCallable() {
439     return restoreAgentCallable;
440   }
441 
442   @Override
restoreAgentOperationCallable()443   public OperationCallable<RestoreAgentRequest, Empty, Struct> restoreAgentOperationCallable() {
444     return restoreAgentOperationCallable;
445   }
446 
447   @Override
validateAgentCallable()448   public UnaryCallable<ValidateAgentRequest, AgentValidationResult> validateAgentCallable() {
449     return validateAgentCallable;
450   }
451 
452   @Override
453   public UnaryCallable<GetAgentValidationResultRequest, AgentValidationResult>
getAgentValidationResultCallable()454       getAgentValidationResultCallable() {
455     return getAgentValidationResultCallable;
456   }
457 
458   @Override
listLocationsCallable()459   public UnaryCallable<ListLocationsRequest, ListLocationsResponse> listLocationsCallable() {
460     return listLocationsCallable;
461   }
462 
463   @Override
464   public UnaryCallable<ListLocationsRequest, ListLocationsPagedResponse>
listLocationsPagedCallable()465       listLocationsPagedCallable() {
466     return listLocationsPagedCallable;
467   }
468 
469   @Override
getLocationCallable()470   public UnaryCallable<GetLocationRequest, Location> getLocationCallable() {
471     return getLocationCallable;
472   }
473 
474   @Override
close()475   public final void close() {
476     try {
477       backgroundResources.close();
478     } catch (RuntimeException e) {
479       throw e;
480     } catch (Exception e) {
481       throw new IllegalStateException("Failed to close resource", e);
482     }
483   }
484 
485   @Override
shutdown()486   public void shutdown() {
487     backgroundResources.shutdown();
488   }
489 
490   @Override
isShutdown()491   public boolean isShutdown() {
492     return backgroundResources.isShutdown();
493   }
494 
495   @Override
isTerminated()496   public boolean isTerminated() {
497     return backgroundResources.isTerminated();
498   }
499 
500   @Override
shutdownNow()501   public void shutdownNow() {
502     backgroundResources.shutdownNow();
503   }
504 
505   @Override
awaitTermination(long duration, TimeUnit unit)506   public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
507     return backgroundResources.awaitTermination(duration, unit);
508   }
509 }
510