Search in sources :

Example 66 with Named

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;
}
Also used : Named(javax.inject.Named) Annotation(java.lang.annotation.Annotation) ComponentAdapter(org.exoplatform.container.spi.ComponentAdapter) AbstractComponentAdapter(org.exoplatform.container.AbstractComponentAdapter)

Example 67 with Named

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;
}
Also used : MetadataHealthCheck(uk.gov.ida.saml.metadata.MetadataHealthCheck) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 68 with Named

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);
}
Also used : JsonClient(uk.gov.ida.jerseyclient.JsonClient) DefaultClientProvider(uk.gov.ida.jerseyclient.DefaultClientProvider) ClientProvider(uk.gov.ida.restclient.ClientProvider) Client(javax.ws.rs.client.Client) JsonClient(uk.gov.ida.jerseyclient.JsonClient) ErrorHandlingClient(uk.gov.ida.jerseyclient.ErrorHandlingClient) ErrorHandlingClient(uk.gov.ida.jerseyclient.ErrorHandlingClient) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 69 with Named

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;
    });
}
Also used : MetadataHealthCheck(uk.gov.ida.saml.metadata.MetadataHealthCheck) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 70 with Named

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;
}
Also used : MetadataHealthCheck(uk.gov.ida.saml.metadata.MetadataHealthCheck) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Named (javax.inject.Named)73 Produces (javax.enterprise.inject.Produces)32 ApplicationScoped (javax.enterprise.context.ApplicationScoped)20 Provides (com.google.inject.Provides)17 Singleton (javax.inject.Singleton)14 Properties (java.util.Properties)12 PropertiesComponent (org.apache.camel.component.properties.PropertiesComponent)12 Annotation (java.lang.annotation.Annotation)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 Inject (javax.inject.Inject)5 Provides (dagger.Provides)4 Test (org.junit.Test)4 Type (java.lang.reflect.Type)3 NamedLiteral (org.apache.deltaspike.core.api.literal.NamedLiteral)3 MetadataHealthCheck (uk.gov.ida.saml.metadata.MetadataHealthCheck)3 Bundle (android.os.Bundle)2 MovieFragment (com.dev.base.mvp.view.fragment.MovieFragment)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Gson (com.google.gson.Gson)2