use of javax.inject.Named in project kernel by exoplatform.
the class SpringContainer method getComponentAdapter.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public <T> ComponentAdapter<T> getComponentAdapter(Object componentKey, Class<T> bindType, boolean autoRegistration) {
ComponentAdapter<?> result = super.getComponentAdapter(componentKey, bindType, autoRegistration);
if (ctx != null && result == null) {
if (componentKey instanceof Class<?> && !((Class<?>) componentKey).isAnnotation()) {
return getAdapterOfType(bindType);
} else if (!(componentKey instanceof String) && !(componentKey instanceof Class<?>)) {
return null;
}
String beanName = keyToBeanName(componentKey);
if (ctx.containsBean(beanName) && bindType.isAssignableFrom(ctx.getType(beanName))) {
return createComponentAdapter(bindType, beanName);
}
String[] names = ctx.getBeanNamesForType(bindType);
if (names != null && names.length > 0) {
for (int i = 0, length = names.length; i < length; i++) {
String name = names[i];
if (componentKey instanceof String) {
Named n = ctx.findAnnotationOnBean(name, Named.class);
if (n != null && componentKey.equals(n.value())) {
return createComponentAdapter(bindType, name);
}
} else {
Annotation a = ctx.findAnnotationOnBean(name, (Class<? extends Annotation>) componentKey);
if (a != null) {
return createComponentAdapter(bindType, name);
}
}
}
}
}
return (ComponentAdapter<T>) result;
}
use of javax.inject.Named in project verify-hub by alphagov.
the class SamlEngineModule method getVerifyMetadataHealthCheck.
@Provides
@Singleton
@Named(VERIFY_METADATA_HEALTH_CHECK)
private MetadataHealthCheck getVerifyMetadataHealthCheck(@Named("VerifyMetadataResolver") MetadataResolver metadataResolver, Environment environment, SamlEngineConfiguration configuration) {
MetadataHealthCheck metadataHealthCheck = new MetadataHealthCheck(metadataResolver, configuration.getMetadataConfiguration().getExpectedEntityId());
environment.healthChecks().register(VERIFY_METADATA_HEALTH_CHECK, metadataHealthCheck);
return metadataHealthCheck;
}
use of javax.inject.Named in project verify-hub by alphagov.
the class PolicyModule method forSamlSoapProxy.
@Provides
@Singleton
@Named("samlSoapProxyClient")
public JsonClient forSamlSoapProxy(JsonResponseProcessor responseProcessor, PolicyConfiguration configuration, Environment environment) {
Client client = new ClientProvider(environment, configuration.getSamlSoapProxyClient(), configuration.getEnableRetryTimeOutConnections(), "SamlSoapProxyClient").get();
ErrorHandlingClient errorHandlingClient = new ErrorHandlingClient(client);
return new JsonClient(errorHandlingClient, responseProcessor);
}
use of javax.inject.Named in project verify-hub by alphagov.
the class SamlProxyModule method getCountryMetadataHealthCheck.
@Provides
@Singleton
@Named(COUNTRY_METADATA_HEALTH_CHECK)
public Optional<MetadataHealthCheck> getCountryMetadataHealthCheck(@Named("CountryMetadataResolver") Optional<MetadataResolver> metadataResolver, Environment environment, SamlProxyConfiguration configuration) {
return metadataResolver.map(resolver -> {
MetadataHealthCheck metadataHealthCheck = new MetadataHealthCheck(metadataResolver.get(), configuration.getCountryConfiguration().get().getMetadataConfiguration().getExpectedEntityId());
environment.healthChecks().register(COUNTRY_METADATA_HEALTH_CHECK, metadataHealthCheck);
return metadataHealthCheck;
});
}
use of javax.inject.Named in project verify-hub by alphagov.
the class SamlProxyModule method getVerifyMetadataHealthCheck.
@Provides
@Singleton
@Named(VERIFY_METADATA_HEALTH_CHECK)
public MetadataHealthCheck getVerifyMetadataHealthCheck(@Named("VerifyMetadataResolver") MetadataResolver metadataResolver, Environment environment, SamlProxyConfiguration configuration) {
MetadataHealthCheck metadataHealthCheck = new MetadataHealthCheck(metadataResolver, configuration.getMetadataConfiguration().getExpectedEntityId());
environment.healthChecks().register(VERIFY_METADATA_HEALTH_CHECK, metadataHealthCheck);
return metadataHealthCheck;
}
Aggregations