Search in sources :

Example 46 with Named

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

the class Jms method sjms.

@Produces
@Named("sjms")
@ApplicationScoped
SjmsComponent sjms() {
    SjmsComponent component = new SjmsComponent();
    component.setConnectionFactory(new ActiveMQConnectionFactory("vm://broker?broker.persistent=false&broker.useShutdownHook=false&broker.useJmx=false"));
    component.setConnectionCount(maxConnections);
    return component;
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) SjmsComponent(org.apache.camel.component.sjms.SjmsComponent) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 47 with Named

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

the class Application method properties.

@Produces
@ApplicationScoped
@Named("properties")
// "properties" component bean that Camel uses to lookup properties
PropertiesComponent properties(PropertiesParser parser) {
    PropertiesComponent component = new PropertiesComponent();
    // Use DeltaSpike as configuration source for Camel CDI
    component.setPropertiesParser(parser);
    return component;
}
Also used : PropertiesComponent(org.apache.camel.component.properties.PropertiesComponent) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 48 with Named

use of javax.inject.Named in project rest.li by linkedin.

the class Jsr330Adapter method scanInjectableConstructors.

private void scanInjectableConstructors(Class<?> beanClazz) {
    int annotatedConstructors = 0;
    for (Constructor<?> constructor : beanClazz.getConstructors()) {
        Inject injectAnnotation = constructor.getAnnotation(Inject.class);
        if (injectAnnotation != null) {
            ++annotatedConstructors;
            if (annotatedConstructors > 1) {
                throw new RestLiInternalException("Found multiple constructors annotated with @Inject in " + "class '" + beanClazz.getCanonicalName() + "'.  At most one constructor can be annotated " + "with @Inject.");
            }
            Class<?>[] parameters = constructor.getParameterTypes();
            Annotation[][] parameterAnnotations = constructor.getParameterAnnotations();
            List<DependencyDecl> parameterDecls = new ArrayList<DependencyDecl>(parameters.length);
            for (int i = 0; i < parameters.length; ++i) {
                Class<?> parameter = parameters[i];
                AnnotationSet annotations = new AnnotationSet(parameterAnnotations[i]);
                Named namedAnno = annotations.get(Named.class);
                parameterDecls.add(new DependencyDecl(parameter, namedAnno != null ? namedAnno.value() : null));
            }
            constructor.setAccessible(true);
            _constructorParameterDependencies.put(beanClazz, new InjectableConstructor(constructor, parameterDecls));
        }
    }
    if (annotatedConstructors == 0) {
        try {
            Constructor<?> defaultConstructor = beanClazz.getConstructor();
            defaultConstructor.setAccessible(true);
            _constructorParameterDependencies.put(beanClazz, new InjectableConstructor(defaultConstructor, Collections.<DependencyDecl>emptyList()));
        } catch (NoSuchMethodException e) {
            throw new RestLiInternalException(String.format("No injectable constructor defined for class %s.  Classes must define" + " either a default constructor or a constructor annotated " + "with @Inject.", beanClazz.getName()), e);
        }
    }
}
Also used : Inject(javax.inject.Inject) Named(javax.inject.Named) ArrayList(java.util.ArrayList) AnnotationSet(com.linkedin.restli.internal.server.model.AnnotationSet) RestLiInternalException(com.linkedin.restli.internal.server.RestLiInternalException)

Example 49 with Named

use of javax.inject.Named in project OpenAM by OpenRock.

the class CoreRestGuiceModule method getServerAttributeTitles.

@Provides
@Singleton
@Named("ServerAttributeTitles")
public Properties getServerAttributeTitles() throws IOException {
    Properties titleProperties = new Properties();
    titleProperties.load(getClass().getClassLoader().getResourceAsStream("amConsole.properties"));
    return titleProperties;
}
Also used : SystemProperties(com.iplanet.am.util.SystemProperties) Properties(java.util.Properties) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 50 with Named

use of javax.inject.Named in project OpenAM by OpenRock.

the class OAuth2GuiceModule method getOAuth2AuditContextProviders.

@Inject
@Provides
@Singleton
@Named(OAUTH2_AUDIT_CONTEXT_PROVIDERS)
Set<OAuth2AuditContextProvider> getOAuth2AuditContextProviders(TokenStore tokenStore, OAuth2RequestFactory<?, Request> requestFactory) {
    Set<OAuth2AuditContextProvider> set = new HashSet<>();
    set.add(new OAuth2AuditAccessTokenContextProvider(tokenStore, requestFactory));
    set.add(new OAuth2AuditRefreshTokenContextProvider(tokenStore, requestFactory));
    set.add(new OAuth2AuditSSOTokenContextProvider());
    return set;
}
Also used : OAuth2AuditRefreshTokenContextProvider(org.forgerock.openam.rest.audit.OAuth2AuditRefreshTokenContextProvider) OAuth2AuditContextProvider(org.forgerock.openam.rest.audit.OAuth2AuditContextProvider) OAuth2AuditAccessTokenContextProvider(org.forgerock.openam.rest.audit.OAuth2AuditAccessTokenContextProvider) OAuth2AuditSSOTokenContextProvider(org.forgerock.openam.rest.audit.OAuth2AuditSSOTokenContextProvider) HashSet(java.util.HashSet) Inject(javax.inject.Inject) 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