use of org.springframework.context.annotation.Bean in project zipkin by openzipkin.
the class ZipkinElasticsearchAwsStorageAutoConfiguration method credentials.
/** By default, get credentials from the {@link DefaultAWSCredentialsProviderChain} */
@Bean
@ConditionalOnMissingBean
AWSCredentials.Provider credentials() {
return new AWSCredentials.Provider() {
AWSCredentialsProvider delegate = new DefaultAWSCredentialsProviderChain();
@Override
public AWSCredentials get() {
com.amazonaws.auth.AWSCredentials result = delegate.getCredentials();
String sessionToken = result instanceof AWSSessionCredentials ? ((AWSSessionCredentials) result).getSessionToken() : null;
return new AWSCredentials(result.getAWSAccessKeyId(), result.getAWSSecretKey(), sessionToken);
}
};
}
use of org.springframework.context.annotation.Bean in project zipkin by openzipkin.
the class TraceZipkinElasticsearchHttpStorageAutoConfiguration method elasticsearchOkHttpClientBuilder.
@Bean
@Qualifier("zipkinElasticsearchHttp")
@ConditionalOnMissingBean
OkHttpClient.Builder elasticsearchOkHttpClientBuilder() {
// have to indirect to unwind a circular dependency
Interceptor tracingInterceptor = new Interceptor() {
Interceptor delegate = BraveTracingInterceptor.builder(brave).serverName("elasticsearch").build();
@Override
public Response intercept(Chain chain) throws IOException {
// Only join traces, don't start them. This prevents LocalCollector's thread from amplifying.
if (brave.serverSpanThreadBinder().getCurrentServerSpan() != null && brave.serverSpanThreadBinder().getCurrentServerSpan().getSpan() != null) {
return delegate.intercept(chain);
}
return chain.proceed(chain.request());
}
};
BraveExecutorService tracePropagatingExecutor = BraveExecutorService.wrap(new Dispatcher().executorService(), brave);
OkHttpClient.Builder builder = new OkHttpClient.Builder();
builder.addInterceptor(tracingInterceptor);
builder.addNetworkInterceptor(tracingInterceptor);
builder.dispatcher(new Dispatcher(tracePropagatingExecutor));
return builder;
}
use of org.springframework.context.annotation.Bean in project scoold by Erudika.
the class ScooldServer method csrfFilterRegistrationBean.
/**
* @return CSRF protection filter bean
*/
@Bean
public FilterRegistrationBean csrfFilterRegistrationBean() {
String path = "/*";
logger.debug("Initializing CSRF filter [{}]...", path);
FilterRegistrationBean frb = new FilterRegistrationBean(new CsrfFilter());
frb.setDispatcherTypes(EnumSet.of(DispatcherType.REQUEST));
frb.setName("csrfFilter");
frb.setAsyncSupported(true);
frb.addUrlPatterns(path);
frb.setMatchAfter(false);
frb.setEnabled(true);
frb.setOrder(2);
return frb;
}
use of org.springframework.context.annotation.Bean in project scoold by Erudika.
the class ScooldServer method jettyConfigBean.
/**
* @return Jetty config bean
*/
@Bean
public EmbeddedServletContainerFactory jettyConfigBean() {
JettyEmbeddedServletContainerFactory jef = new JettyEmbeddedServletContainerFactory();
jef.setPort(getServerPort());
logger.info("Listening on port {}...", jef.getPort());
return jef;
}
use of org.springframework.context.annotation.Bean in project opennms by OpenNMS.
the class CustomSpringConfiguration method createFetchStrategy.
@Bean(name = "measurementFetchStrategy")
public MeasurementFetchStrategy createFetchStrategy() {
return new AbstractRrdBasedFetchStrategy() {
@Override
protected FetchResults fetchMeasurements(long start, long end, long step, int maxrows, Map<Source, String> rrdsBySource, Map<String, Object> constants) throws RrdException {
final long[] timestamps = new long[] { start, end };
final Map columnMap = new HashMap<>();
if (!rrdsBySource.isEmpty()) {
for (Source eachKey : rrdsBySource.keySet()) {
columnMap.put(eachKey.getLabel(), new double[] { 13, 17 });
}
}
return new FetchResults(timestamps, columnMap, step, constants);
}
};
}
Aggregations