Search in sources :

Example 6 with ProcessInjectionPoint

use of jakarta.enterprise.inject.spi.ProcessInjectionPoint in project helidon by oracle.

the class JedisExtension method processJedisPoolProviderInjectionPoint.

@SuppressWarnings("checkstyle:linelength")
private <T extends Provider<JedisPool>> void processJedisPoolProviderInjectionPoint(@Observes final ProcessInjectionPoint<?, T> e) {
    if (e != null) {
        final InjectionPoint injectionPoint = e.getInjectionPoint();
        if (injectionPoint != null) {
            final Type type = injectionPoint.getType();
            assert type instanceof Class;
            assert Provider.class.isAssignableFrom((Class<?>) type);
            final Set<Annotation> qualifiers = injectionPoint.getQualifiers();
            for (final Annotation qualifier : qualifiers) {
                final String instanceName;
                if (qualifier instanceof Default) {
                    instanceName = "default";
                } else if (qualifier instanceof Named) {
                    instanceName = ((Named) qualifier).value();
                } else {
                    instanceName = null;
                }
                if (instanceName != null && !instanceName.isEmpty()) {
                    this.instanceNames.add(instanceName);
                }
            }
        }
    }
}
Also used : Named(jakarta.inject.Named) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ProcessInjectionPoint(jakarta.enterprise.inject.spi.ProcessInjectionPoint) InjectionPoint(jakarta.enterprise.inject.spi.InjectionPoint) Default(jakarta.enterprise.inject.Default) Annotation(java.lang.annotation.Annotation)

Example 7 with ProcessInjectionPoint

use of jakarta.enterprise.inject.spi.ProcessInjectionPoint in project helidon by oracle.

the class JedisExtension method processJedisPoolInjectionPoint.

private <T extends JedisPool> void processJedisPoolInjectionPoint(@Observes final ProcessInjectionPoint<?, T> e) {
    if (e != null) {
        final InjectionPoint injectionPoint = e.getInjectionPoint();
        if (injectionPoint != null) {
            final Type type = injectionPoint.getType();
            assert type instanceof Class;
            assert JedisPool.class.isAssignableFrom((Class<?>) type);
            final Set<Annotation> qualifiers = injectionPoint.getQualifiers();
            for (final Annotation qualifier : qualifiers) {
                final String instanceName;
                if (qualifier instanceof Default) {
                    instanceName = "default";
                } else if (qualifier instanceof Named) {
                    instanceName = ((Named) qualifier).value();
                } else {
                    instanceName = null;
                }
                if (instanceName != null && !instanceName.isEmpty()) {
                    this.instanceNames.add(instanceName);
                }
            }
        }
    }
}
Also used : Named(jakarta.inject.Named) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ProcessInjectionPoint(jakarta.enterprise.inject.spi.ProcessInjectionPoint) InjectionPoint(jakarta.enterprise.inject.spi.InjectionPoint) Default(jakarta.enterprise.inject.Default) Annotation(java.lang.annotation.Annotation)

Example 8 with ProcessInjectionPoint

use of jakarta.enterprise.inject.spi.ProcessInjectionPoint in project helidon by oracle.

the class JedisExtension method processJedisPoolConfigProviderInjectionPoint.

@SuppressWarnings("checkstyle:linelength")
private <T extends Provider<JedisPoolConfig>> void processJedisPoolConfigProviderInjectionPoint(@Observes final ProcessInjectionPoint<?, T> e) {
    if (e != null) {
        final InjectionPoint injectionPoint = e.getInjectionPoint();
        if (injectionPoint != null) {
            final Type type = injectionPoint.getType();
            assert type instanceof Class;
            assert Provider.class.isAssignableFrom((Class<?>) type);
            final Set<Annotation> qualifiers = injectionPoint.getQualifiers();
            for (final Annotation qualifier : qualifiers) {
                final String instanceName;
                if (qualifier instanceof Default) {
                    instanceName = "default";
                } else if (qualifier instanceof Named) {
                    instanceName = ((Named) qualifier).value();
                } else {
                    instanceName = null;
                }
                if (instanceName != null && !instanceName.isEmpty()) {
                    this.instanceNames.add(instanceName);
                }
            }
        }
    }
}
Also used : Named(jakarta.inject.Named) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ProcessInjectionPoint(jakarta.enterprise.inject.spi.ProcessInjectionPoint) InjectionPoint(jakarta.enterprise.inject.spi.InjectionPoint) Default(jakarta.enterprise.inject.Default) Annotation(java.lang.annotation.Annotation)

Example 9 with ProcessInjectionPoint

use of jakarta.enterprise.inject.spi.ProcessInjectionPoint in project core by weld.

the class ModifyingExtension method overrideDelegateInjectionPoint.

public void overrideDelegateInjectionPoint(@Observes ProcessInjectionPoint<AnimalDecorator, Object> event) {
    final InjectionPoint delegate = event.getInjectionPoint();
    event.setInjectionPoint(new ForwardingInjectionPoint() {

        @Override
        protected InjectionPoint delegate() {
            return delegate;
        }

        @Override
        public boolean isDelegate() {
            return true;
        }

        @Override
        public Type getType() {
            return Animal.class;
        }
    });
}
Also used : Type(java.lang.reflect.Type) ForwardingInjectionPoint(org.jboss.weld.injection.ForwardingInjectionPoint) InjectionPoint(jakarta.enterprise.inject.spi.InjectionPoint) ProcessInjectionPoint(jakarta.enterprise.inject.spi.ProcessInjectionPoint) ForwardingInjectionPoint(org.jboss.weld.injection.ForwardingInjectionPoint)

Example 10 with ProcessInjectionPoint

use of jakarta.enterprise.inject.spi.ProcessInjectionPoint in project helidon by oracle.

the class VaultCdiExtension method updateInjectionPoints.

/**
 * Add internal qualifier.
 *
 * @param event CDI event
 */
void updateInjectionPoints(@Observes ProcessInjectionPoint<?, ?> event) {
    InjectionPoint injectionPoint = event.getInjectionPoint();
    Annotated annotated = injectionPoint.getAnnotated();
    Type type = injectionPoint.getType();
    if (supportedTypes.contains(type)) {
        VaultName vault = annotated.getAnnotation(VaultName.class);
        VaultPath vaultPath = annotated.getAnnotation(VaultPath.class);
        VaultInternal internal = VaultInternal.Literal.create((vault == null ? "" : vault.value()), (vaultPath == null ? "" : vaultPath.value()));
        event.configureInjectionPoint().addQualifier(internal);
    }
}
Also used : Annotated(jakarta.enterprise.inject.spi.Annotated) Type(java.lang.reflect.Type) ProcessInjectionPoint(jakarta.enterprise.inject.spi.ProcessInjectionPoint) InjectionPoint(jakarta.enterprise.inject.spi.InjectionPoint)

Aggregations

ProcessInjectionPoint (jakarta.enterprise.inject.spi.ProcessInjectionPoint)14 InjectionPoint (jakarta.enterprise.inject.spi.InjectionPoint)13 Type (java.lang.reflect.Type)11 Named (jakarta.inject.Named)7 Annotation (java.lang.annotation.Annotation)7 ParameterizedType (java.lang.reflect.ParameterizedType)7 Default (jakarta.enterprise.inject.Default)6 Annotated (jakarta.enterprise.inject.spi.Annotated)2 RequestScoped (jakarta.enterprise.context.RequestScoped)1 InjectionException (jakarta.enterprise.inject.InjectionException)1 AfterBeanDiscovery (jakarta.enterprise.inject.spi.AfterBeanDiscovery)1 AfterDeploymentValidation (jakarta.enterprise.inject.spi.AfterDeploymentValidation)1 AfterTypeDiscovery (jakarta.enterprise.inject.spi.AfterTypeDiscovery)1 BeforeBeanDiscovery (jakarta.enterprise.inject.spi.BeforeBeanDiscovery)1 BeforeShutdown (jakarta.enterprise.inject.spi.BeforeShutdown)1 DeploymentException (jakarta.enterprise.inject.spi.DeploymentException)1 Extension (jakarta.enterprise.inject.spi.Extension)1 ProcessAnnotatedType (jakarta.enterprise.inject.spi.ProcessAnnotatedType)1 ProcessBean (jakarta.enterprise.inject.spi.ProcessBean)1 ProcessBeanAttributes (jakarta.enterprise.inject.spi.ProcessBeanAttributes)1