com.amazonaws.client.builder.AwsAsyncClientBuilder Java Examples

The following examples show how to use com.amazonaws.client.builder.AwsAsyncClientBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AwsClientTracing.java    From zipkin-aws with Apache License 2.0 6 votes vote down vote up
public <Builder extends AwsClientBuilder, Client> Client build(
    AwsClientBuilder<Builder, Client> builder
) {
  if (builder == null) throw new NullPointerException("builder == null");
  if (builder instanceof AwsAsyncClientBuilder) {
    ExecutorFactory executorFactory = ((AwsAsyncClientBuilder) builder).getExecutorFactory();
    if (executorFactory == null) {
      ClientConfiguration clientConfiguration = builder.getClientConfiguration();
      if (clientConfiguration == null) {
        clientConfiguration = defaultClientConfigurationFactory.getConfig();
      }
      ((AwsAsyncClientBuilder) builder).setExecutorFactory(
          new TracingExecutorFactory(currentTraceContext, clientConfiguration)
      );
    } else {
      ((AwsAsyncClientBuilder) builder).setExecutorFactory(
          new TracingExecutorFactoryWrapper(currentTraceContext, executorFactory)
      );
    }
  }
  builder.withRequestHandlers(new TracingRequestHandler(httpTracing));
  return builder.build();
}
 
Example #2
Source File: AmazonWebserviceClientFactoryBean.java    From spring-cloud-aws with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
protected T createInstance() throws Exception {

	String builderName = this.clientClass.getName() + "Builder";
	Class<?> className = ClassUtils.resolveClassName(builderName,
			ClassUtils.getDefaultClassLoader());

	Method method = ClassUtils.getStaticMethod(className, "standard");
	Assert.notNull(method, "Could not find standard() method in class:'"
			+ className.getName() + "'");

	AwsClientBuilder<?, T> builder = (AwsClientBuilder<?, T>) ReflectionUtils
			.invokeMethod(method, null);

	if (this.executor != null) {
		AwsAsyncClientBuilder<?, T> asyncBuilder = (AwsAsyncClientBuilder<?, T>) builder;
		asyncBuilder.withExecutorFactory((ExecutorFactory) () -> this.executor);
	}

	if (this.credentialsProvider != null) {
		builder.withCredentials(this.credentialsProvider);
	}

	if (this.customRegion != null) {
		builder.withRegion(this.customRegion.getName());
	}
	else if (this.regionProvider != null) {
		builder.withRegion(this.regionProvider.getRegion().getName());
	}
	else {
		builder.withRegion(Regions.DEFAULT_REGION);
	}
	return builder.build();
}
 
Example #3
Source File: ExtendedDockerTestUtils.java    From spring-cloud-stream-binder-aws-kinesis with Apache License 2.0 4 votes vote down vote up
private static <T, C extends AwsAsyncClientBuilder<C, T>> T applyConfigurationAndBuild(C builder) {
	return builder.withCredentials(TestUtils.getCredentialsProvider())
			.withClientConfiguration(new ClientConfiguration().withMaxErrorRetry(0).withConnectionTimeout(1000))
			.build();
}