use of javax.inject.Named in project kernel by exoplatform.
the class ConcurrentContainer method resolveType.
/**
* Resolves the given type and generic type
*/
private Object resolveType(Class<?> type, Type genericType, Annotation[] annotations, String logMessagePrefix) {
if (type.isPrimitive()) {
if (LOG.isDebugEnabled()) {
LOG.debug(logMessagePrefix + ": Primitive types are not supported");
}
return 1;
}
Named named = null;
Class<?> qualifier = null;
for (int i = 0, length = annotations.length; i < length; i++) {
Annotation a = annotations[i];
if (a instanceof Named) {
named = (Named) a;
break;
} else if (a.annotationType().isAnnotationPresent(Qualifier.class)) {
qualifier = a.annotationType();
break;
}
}
if (type.isInterface() && type.equals(Provider.class)) {
if (!(genericType instanceof ParameterizedType)) {
if (LOG.isDebugEnabled()) {
LOG.debug(logMessagePrefix + ": The generic type is not of type ParameterizedType");
}
return 2;
}
ParameterizedType aType = (ParameterizedType) genericType;
Type[] typeVars = aType.getActualTypeArguments();
Class<?> expectedType = (Class<?>) typeVars[0];
final ComponentAdapter<?> adapter;
if (named != null) {
adapter = holder.getComponentAdapter(named.value(), expectedType);
} else if (qualifier != null) {
adapter = holder.getComponentAdapter(qualifier, expectedType);
} else {
adapter = holder.getComponentAdapterOfType(expectedType);
}
if (adapter == null) {
if (LOG.isDebugEnabled()) {
LOG.debug(logMessagePrefix + ": We have no value to set so we skip it");
}
return 3;
}
return new Provider<Object>() {
public Object get() {
return adapter.getComponentInstance();
}
};
} else {
if (named != null) {
return holder.getComponentInstance(named.value(), type);
} else if (qualifier != null) {
return holder.getComponentInstance(qualifier, type);
} else {
return holder.getComponentInstanceOfType(type);
}
}
}
use of javax.inject.Named in project kernel by exoplatform.
the class ConcurrentContainerMT method resolveType.
/**
* Resolves the given type and generic type
*/
private Object resolveType(final Class<?> type, Type genericType, Annotation[] annotations, String logMessagePrefix, List<Dependency> dependencies) {
if (type.isPrimitive()) {
if (LOG.isDebugEnabled()) {
LOG.debug(logMessagePrefix + ": Primitive types are not supported");
}
return 1;
}
Named named = null;
Class<?> qualifier = null;
for (int i = 0, length = annotations.length; i < length; i++) {
Annotation a = annotations[i];
if (a instanceof Named) {
named = (Named) a;
break;
} else if (a.annotationType().isAnnotationPresent(Qualifier.class)) {
qualifier = a.annotationType();
break;
}
}
if (type.isInterface() && type.equals(Provider.class)) {
if (!(genericType instanceof ParameterizedType)) {
if (LOG.isDebugEnabled()) {
LOG.debug(logMessagePrefix + ": The generic type is not of type ParameterizedType");
}
return 2;
}
ParameterizedType aType = (ParameterizedType) genericType;
Type[] typeVars = aType.getActualTypeArguments();
Class<?> expectedType = (Class<?>) typeVars[0];
final ComponentAdapter<?> adapter;
final Object key;
if (named != null) {
adapter = holder.getComponentAdapter(key = named.value(), expectedType);
} else if (qualifier != null) {
adapter = holder.getComponentAdapter(key = qualifier, expectedType);
} else {
key = expectedType;
adapter = holder.getComponentAdapterOfType(expectedType);
}
if (adapter == null) {
if (LOG.isDebugEnabled()) {
LOG.debug(logMessagePrefix + ": We have no value to set so we skip it");
}
return 3;
}
final Provider<Object> result = new Provider<Object>() {
public Object get() {
return adapter.getComponentInstance();
}
};
dependencies.add(new DependencyByProvider(key, expectedType, result, adapter));
return result;
} else {
if (named != null) {
final String name = named.value();
dependencies.add(new DependencyByName(name, type));
return holder.getComponentAdapter(name, type);
} else if (qualifier != null) {
dependencies.add(new DependencyByQualifier(qualifier, type));
return holder.getComponentAdapter(qualifier, type);
} else {
dependencies.add(new DependencyByType(type));
return holder.getComponentAdapterOfType(type);
}
}
}
use of javax.inject.Named in project verify-hub by alphagov.
the class SamlProxyModule method getVerifyMetadataResolver.
@Provides
@Singleton
@Named("VerifyMetadataResolver")
public MetadataResolver getVerifyMetadataResolver(Environment environment, SamlProxyConfiguration configuration) {
final MetadataResolver metadataResolver = new DropwizardMetadataResolverFactory().createMetadataResolver(environment, configuration.getMetadataConfiguration());
registerMetadataRefreshTask(environment, metadataResolver, configuration.getMetadataConfiguration(), "metadata");
return metadataResolver;
}
use of javax.inject.Named in project verify-hub by alphagov.
the class SamlEngineModule method getVerifyMetadataResolver.
@Provides
@Singleton
@Named("VerifyMetadataResolver")
private MetadataResolver getVerifyMetadataResolver(Environment environment, SamlEngineConfiguration configuration) {
final MetadataResolver metadataResolver = new DropwizardMetadataResolverFactory().createMetadataResolver(environment, configuration.getMetadataConfiguration());
registerMetadataRefreshTask(environment, metadataResolver, configuration.getMetadataConfiguration(), "metadata");
return metadataResolver;
}
use of javax.inject.Named in project verify-hub by alphagov.
the class SamlEngineModule method getAES256WithGCMAssertionDecrypter.
@Provides
@Named("AES256DecrypterWithGCM")
private AssertionDecrypter getAES256WithGCMAssertionDecrypter(IdaKeyStore keyStore) {
IdaKeyStoreCredentialRetriever idaKeyStoreCredentialRetriever = new IdaKeyStoreCredentialRetriever(keyStore);
Decrypter decrypter = new DecrypterFactory().createDecrypter(idaKeyStoreCredentialRetriever.getDecryptingCredentials());
return new AssertionDecrypter(new EncryptionAlgorithmValidator(ImmutableSet.of(EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256, EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256_GCM)), decrypter);
}
Aggregations