Search in sources :

Example 6 with Named

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

the class CoreRestGuiceModule method getServerAttributeSyntax.

@Provides
@Singleton
@Named("ServerAttributeSyntax")
public Properties getServerAttributeSyntax() throws IOException {
    Properties syntaxProperties = new Properties();
    syntaxProperties.load(getClass().getClassLoader().getResourceAsStream("validserverconfig.properties"));
    return syntaxProperties;
}
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 7 with Named

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

the class CoreRestGuiceModule method getAuthenticateHandler.

@Provides
@Named("AuthenticateHandler")
@Inject
Handler getAuthenticateHandler(@Named("InvalidRealmNames") Set<String> invalidRealms, HttpAccessAuditFilterFactory httpAuditFactory) {
    invalidRealms.add(firstPathSegment("authenticate"));
    org.forgerock.http.routing.Router authenticateVersionRouter = new org.forgerock.http.routing.Router();
    Handler authenticateHandlerV1 = Endpoints.from(AuthenticationServiceV1.class);
    Handler authenticateHandlerV2 = Endpoints.from(AuthenticationServiceV2.class);
    authenticateVersionRouter.addRoute(RouteMatchers.requestResourceApiVersionMatcher(version(1, 1)), authenticateHandlerV1);
    authenticateVersionRouter.addRoute(RouteMatchers.requestResourceApiVersionMatcher(version(2)), authenticateHandlerV2);
    return chainOf(authenticateVersionRouter, httpAuditFactory.createFilter(AUTHENTICATION));
}
Also used : ConsoleConfigHandler(org.forgerock.openam.sm.config.ConsoleConfigHandler) SmsRequestHandler(org.forgerock.openam.core.rest.sms.SmsRequestHandler) Handler(org.forgerock.http.Handler) Inject(javax.inject.Inject) Named(javax.inject.Named) Provides(com.google.inject.Provides)

Example 8 with Named

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

the class ConfigurationExtension method processInjectionTarget.

void processInjectionTarget(@Observes @SuppressWarnings("rawtypes") ProcessInjectionPoint pip) {
    InjectionPoint injectionPoint = pip.getInjectionPoint();
    Annotated annotated = injectionPoint.getAnnotated();
    Configuration configuration = annotated.getAnnotation(Configuration.class);
    if (configuration == null) {
        return;
    }
    Class<?> beanClass = injectionPoint.getBean().getBeanClass();
    String name = beanClass.getName();
    Named named = annotated.getAnnotation(Named.class);
    if (named != null) {
        name = named.value();
    }
    ConfigurationDependency configurationDependency = new ConfigurationDependency(_bundleContext, configuration.value(), configuration.required(), name, injectionPoint);
    _configurations.add(configurationDependency);
    if (_log.isDebugEnabled()) {
        _log.debug("CDIe - Found OSGi configuration dependency {}", configurationDependency);
    }
}
Also used : Annotated(javax.enterprise.inject.spi.Annotated) Named(javax.inject.Named) Configuration(org.osgi.service.cdi.annotations.Configuration) ProcessInjectionPoint(javax.enterprise.inject.spi.ProcessInjectionPoint) InjectionPoint(javax.enterprise.inject.spi.InjectionPoint)

Example 9 with Named

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

the class AnnotationInstanceProviderTest method assertMemberAccessIsCorrect.

@Test
public void assertMemberAccessIsCorrect() {
    Map<String, String> memberValues = new HashMap<String, String>();
    memberValues.put("value", "test");
    Named a1 = AnnotationInstanceProvider.of(Named.class, memberValues);
    assertThat(a1.value(), is("test"));
}
Also used : Named(javax.inject.Named) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 10 with Named

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

the class BeanBuilder method readFromType.

/**
     * <p>
     * Read the {@link AnnotatedType}, creating a bean from the class and it's
     * annotations.
     * </p>
     * <p/>
     * <p>
     * By default the bean lifecycle will wrap the result of calling
     * {@link BeanManager#createInjectionTarget(AnnotatedType)}.
     * </p>
     * <p/>
     * <p>
     * {@link BeanBuilder} does <em>not</em> support reading members of the class
     * to create producers or observer methods.
     * </p>
     *
     * @param type the type to read
     */
public BeanBuilder<T> readFromType(AnnotatedType<T> type) {
    this.beanClass = type.getJavaClass();
    if (beanLifecycle == null) {
        setDefaultBeanLifecycle(type);
    }
    this.qualifiers = new HashSet<Annotation>();
    this.stereotypes = new HashSet<Class<? extends Annotation>>();
    this.types = new HashSet<Type>();
    for (Annotation annotation : type.getAnnotations()) {
        if (beanManager.isQualifier(annotation.annotationType())) {
            this.qualifiers.add(annotation);
        } else if (beanManager.isScope(annotation.annotationType())) {
            this.scope = annotation.annotationType();
        } else if (beanManager.isStereotype(annotation.annotationType())) {
            this.stereotypes.add(annotation.annotationType());
        }
        if (annotation instanceof Named) {
            this.name = ((Named) annotation).value();
            if (name == null || name.length() == 0) {
                name = createDefaultBeanName(type);
            }
        }
        if (annotation instanceof Alternative) {
            this.alternative = true;
        }
    }
    if (type.isAnnotationPresent(Typed.class)) {
        Typed typed = type.getAnnotation(Typed.class);
        this.types.addAll(Arrays.asList(typed.value()));
    } else {
        for (Class<?> c = type.getJavaClass(); c != Object.class && c != null; c = c.getSuperclass()) {
            this.types.add(c);
        }
        Collections.addAll(this.types, type.getJavaClass().getInterfaces());
        this.types.add(Object.class);
    }
    if (qualifiers.isEmpty()) {
        qualifiers.add(new DefaultLiteral());
    }
    qualifiers.add(new AnyLiteral());
    this.id = ImmutableBeanWrapper.class.getName() + ":" + Annotateds.createTypeId(type);
    return this;
}
Also used : Named(javax.inject.Named) Alternative(javax.enterprise.inject.Alternative) Annotation(java.lang.annotation.Annotation) AnnotatedType(javax.enterprise.inject.spi.AnnotatedType) Type(java.lang.reflect.Type) Typed(javax.enterprise.inject.Typed) DefaultLiteral(org.apache.deltaspike.core.api.literal.DefaultLiteral) AnyLiteral(org.apache.deltaspike.core.api.literal.AnyLiteral)

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