Search in sources :

Example 16 with Named

use of javax.inject.Named in project camel by apache.

the class PropertyInjectTest method configuration.

@Produces
@ApplicationScoped
@Named("properties")
private static PropertiesComponent configuration() {
    Properties properties = new Properties();
    properties.put("property", "value");
    PropertiesComponent component = new PropertiesComponent();
    component.setInitialProperties(properties);
    return component;
}
Also used : Properties(java.util.Properties) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 17 with Named

use of javax.inject.Named in project camel by apache.

the class UndefinedPropertyTest method configuration.

@Produces
@ApplicationScoped
@Named("properties")
private static PropertiesComponent configuration() {
    Properties properties = new Properties();
    properties.put("from", "inbound");
    // Do not add the looked up property for test purpose
    //properties.put("to", "mock:outbound");
    PropertiesComponent component = new PropertiesComponent();
    component.setInitialProperties(properties);
    return component;
}
Also used : Properties(java.util.Properties) PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 18 with Named

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

the class AppInitializer method initOpenIdConfiguration.

@Produces
@ApplicationScoped
@Named("openIdConfiguration")
public OpenIdConfigurationResponse initOpenIdConfiguration() throws OxIntializationException {
    String oxAuthIssuer = this.configurationFactory.getAppConfiguration().getOxAuthIssuer();
    if (StringHelper.isEmpty(oxAuthIssuer)) {
        log.info("oxAuth issuer isn't specified");
        return null;
    }
    log.debug("Attempting to determine configuration endpoint URL");
    OpenIdConnectDiscoveryClient openIdConnectDiscoveryClient;
    try {
        openIdConnectDiscoveryClient = new OpenIdConnectDiscoveryClient(oxAuthIssuer);
    } catch (URISyntaxException ex) {
        throw new OxIntializationException("OpenId discovery response is invalid!", ex);
    }
    OpenIdConnectDiscoveryResponse openIdConnectDiscoveryResponse = openIdConnectDiscoveryClient.exec();
    if ((openIdConnectDiscoveryResponse.getStatus() != 200) || (openIdConnectDiscoveryResponse.getSubject() == null) || (openIdConnectDiscoveryResponse.getLinks().size() == 0)) {
        throw new OxIntializationException("OpenId discovery response is invalid!");
    }
    log.debug("Attempting to load OpenID configuration");
    String configurationEndpoint = openIdConnectDiscoveryResponse.getLinks().get(0).getHref() + "/.well-known/openid-configuration";
    OpenIdConfigurationClient client = new OpenIdConfigurationClient(configurationEndpoint);
    OpenIdConfigurationResponse openIdConfiguration = client.execOpenIdConfiguration();
    if (openIdConfiguration.getStatus() != 200) {
        throw new OxIntializationException("OpenId configuration response is invalid!");
    }
    return openIdConfiguration;
}
Also used : OpenIdConnectDiscoveryClient(org.xdi.oxauth.client.OpenIdConnectDiscoveryClient) OpenIdConfigurationClient(org.xdi.oxauth.client.OpenIdConfigurationClient) OpenIdConnectDiscoveryResponse(org.xdi.oxauth.client.OpenIdConnectDiscoveryResponse) OpenIdConfigurationResponse(org.xdi.oxauth.client.OpenIdConfigurationResponse) URISyntaxException(java.net.URISyntaxException) OxIntializationException(org.xdi.exception.OxIntializationException) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 19 with Named

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

the class AppInitializer method getLdapEntryManager.

@Produces
@ApplicationScoped
@Named(LDAP_ENTRY_MANAGER_NAME)
public LdapEntryManager getLdapEntryManager() {
    LdapEntryManager ldapEntryManager = new LdapEntryManager(new OperationsFacade(this.connectionProvider));
    log.info("Created {}: {}", new Object[] { LDAP_ENTRY_MANAGER_NAME, ldapEntryManager.getLdapOperationService() });
    return ldapEntryManager;
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) OperationsFacade(org.gluu.site.ldap.OperationsFacade) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 20 with Named

use of javax.inject.Named in project deltaspike by apache.

the class NamingConventionAwareMetadataFilter method ensureNamingConvention.

public void ensureNamingConvention(@Observes ProcessAnnotatedType processAnnotatedType) {
    Class<?> beanClass = processAnnotatedType.getAnnotatedType().getJavaClass();
    Named namedAnnotation = beanClass.getAnnotation(Named.class);
    if (namedAnnotation != null && namedAnnotation.value().length() > 0 && Character.isUpperCase(namedAnnotation.value().charAt(0))) {
        AnnotatedTypeBuilder builder = new AnnotatedTypeBuilder();
        builder.readFromType(beanClass);
        String beanName = namedAnnotation.value();
        String newBeanName = beanName.substring(0, 1).toLowerCase() + beanName.substring(1);
        builder.removeFromClass(Named.class).addToClass(new NamedLiteral(newBeanName));
        processAnnotatedType.setAnnotatedType(builder.create());
    }
}
Also used : Named(javax.inject.Named) AnnotatedTypeBuilder(org.apache.deltaspike.core.util.metadata.builder.AnnotatedTypeBuilder) NamedLiteral(org.apache.deltaspike.core.api.literal.NamedLiteral)

Aggregations

Named (javax.inject.Named)126 Produces (javax.enterprise.inject.Produces)36 Test (org.junit.Test)29 ApplicationScoped (javax.enterprise.context.ApplicationScoped)26 Provides (com.google.inject.Provides)22 Singleton (javax.inject.Singleton)17 Properties (java.util.Properties)16 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)15 Api (com.google.api.server.spi.config.Api)15 SimpleLevelOverridingApi (com.google.api.server.spi.testing.SimpleLevelOverridingApi)15 JsonNode (com.fasterxml.jackson.databind.JsonNode)14 PropertiesComponent (org.apache.camel.component.properties.PropertiesComponent)12 Annotation (java.lang.annotation.Annotation)11 Provides (dagger.Provides)9 ArrayList (java.util.ArrayList)8 List (java.util.List)7 Inject (javax.inject.Inject)7 HashMap (java.util.HashMap)6 ApiConfigAnnotationReader (com.google.api.server.spi.config.annotationreader.ApiConfigAnnotationReader)4 Type (java.lang.reflect.Type)4