Search in sources :

Example 61 with Named

use of javax.inject.Named in project oxAuth by GluuFederation.

the class AppInitializer method createLdapAuthEntryManager.

@Produces
@ApplicationScoped
@Named(LDAP_AUTH_ENTRY_MANAGER_NAME)
public List<LdapEntryManager> createLdapAuthEntryManager() {
    List<LdapEntryManager> ldapAuthEntryManagers = new ArrayList<LdapEntryManager>();
    if (this.ldapAuthConfigs.size() == 0) {
        return ldapAuthEntryManagers;
    }
    for (int i = 0; i < this.ldapAuthConfigs.size(); i++) {
        LdapEntryManager ldapAuthEntryManager = new LdapEntryManager(new OperationsFacade(this.authConnectionProviders.get(i), this.authBindConnectionProviders.get(i)));
        log.debug("Created {}#{}: {}", new Object[] { LDAP_AUTH_ENTRY_MANAGER_NAME, i, ldapAuthEntryManager });
        ldapAuthEntryManagers.add(ldapAuthEntryManager);
    }
    return ldapAuthEntryManagers;
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) ArrayList(java.util.ArrayList) OperationsFacade(org.gluu.site.ldap.OperationsFacade) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 62 with Named

use of javax.inject.Named in project AngularBeans by bessemHmidi.

the class CommonUtils method getBeanName.

public static String getBeanName(Class targetClass) {
    if (targetClass.isAnnotationPresent(Named.class)) {
        Named named = (Named) targetClass.getAnnotation(Named.class);
        if (!named.value().isEmpty()) {
            return named.value();
        }
    }
    String name = Introspector.decapitalize(targetClass.getSimpleName());
    beanNamesHolder.put(name, targetClass);
    return name;
}
Also used : Named(javax.inject.Named)

Example 63 with Named

use of javax.inject.Named in project oxTrust by GluuFederation.

the class AppInitializer method createCentralLdapEntryManager.

@Produces
@ApplicationScoped
@Named(LDAP_CENTRAL_ENTRY_MANAGER_NAME)
@CentralLdap
public LdapEntryManager createCentralLdapEntryManager() {
    if (!((configurationFactory.getLdapCentralConfiguration() != null) && configurationFactory.getAppConfiguration().isUpdateApplianceStatus())) {
        return new LdapEntryManager();
    }
    FileConfiguration ldapCentralConfig = configurationFactory.getLdapCentralConfiguration();
    Properties centralConnectionProperties = (Properties) ldapCentralConfig.getProperties();
    EncryptionService securityService = encryptionServiceInstance.get();
    Properties decryptedCentralConnectionProperties = securityService.decryptProperties(centralConnectionProperties);
    LdapEntryManager centralLdapEntryManager = this.ldapEntryManagerFactory.createEntryManager(decryptedCentralConnectionProperties);
    log.info("Created {}: {}", new Object[] { LDAP_CENTRAL_ENTRY_MANAGER_NAME, centralLdapEntryManager.getOperationService() });
    return centralLdapEntryManager;
}
Also used : FileConfiguration(org.xdi.util.properties.FileConfiguration) LdapEntryManager(org.gluu.persist.ldap.impl.LdapEntryManager) Properties(java.util.Properties) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) CentralLdap(org.gluu.oxtrust.service.cdi.event.CentralLdap) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 64 with Named

use of javax.inject.Named in project oxTrust by GluuFederation.

the class AppInitializer method initUmaMetadataConfiguration.

@Produces
@ApplicationScoped
@Named("umaMetadataConfiguration")
public UmaMetadata initUmaMetadataConfiguration() throws OxIntializationException {
    String umaConfigurationEndpoint = getUmaConfigurationEndpoint();
    if (StringHelper.isEmpty(umaConfigurationEndpoint)) {
        return null;
    }
    UmaMetadataService metaDataConfigurationService = UmaClientFactory.instance().createMetadataService(umaConfigurationEndpoint);
    UmaMetadata metadataConfiguration = metaDataConfigurationService.getMetadata();
    if (metadataConfiguration == null) {
        throw new OxIntializationException("UMA meta data configuration is invalid!");
    }
    return metadataConfiguration;
}
Also used : UmaMetadata(org.xdi.oxauth.model.uma.UmaMetadata) OxIntializationException(org.xdi.exception.OxIntializationException) UmaMetadataService(org.xdi.oxauth.client.uma.UmaMetadataService) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 65 with Named

use of javax.inject.Named in project kernel by exoplatform.

the class SpringContainer method getComponentInstance.

/**
 * {@inheritDoc}
 */
@Override
public <T> T getComponentInstance(Object componentKey, Class<T> bindType, boolean autoRegistration) {
    T result = super.getComponentInstance(componentKey, bindType, autoRegistration);
    if (ctx != null && result == null) {
        if (componentKey instanceof Class<?> && !((Class<?>) componentKey).isAnnotation()) {
            return bindType.cast(getInstanceOfType((Class<?>) componentKey));
        } else if (!(componentKey instanceof String) && !(componentKey instanceof Class<?>)) {
            return null;
        }
        String beanName = keyToBeanName(componentKey);
        if (ctx.containsBean(beanName) && bindType.isAssignableFrom(ctx.getType(beanName))) {
            return bindType.cast(ctx.getBean(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 bindType.cast(ctx.getBean(name));
                    }
                } else {
                    @SuppressWarnings("unchecked") Annotation a = ctx.findAnnotationOnBean(name, (Class<? extends Annotation>) componentKey);
                    if (a != null) {
                        return bindType.cast(ctx.getBean(name));
                    }
                }
            }
        }
    }
    return result;
}
Also used : Named(javax.inject.Named) Annotation(java.lang.annotation.Annotation)

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