use of jakarta.enterprise.inject.spi.ProcessInjectionPoint in project helidon by oracle.
the class JedisExtension method processJedisPoolConfigInjectionPoint.
private <T extends JedisPoolConfig> void processJedisPoolConfigInjectionPoint(@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 JedisPoolConfig.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);
}
}
}
}
}
use of jakarta.enterprise.inject.spi.ProcessInjectionPoint in project helidon by oracle.
the class JpaExtension method saveEntityManagerQualifiers.
/**
* Stores {@link Set}s of qualifiers that annotate {@link
* EntityManager}-typed injection points.
*
* <p>{@link EntityManager}-typed beans will be added for each
* such {@link Set}.</p>
*
* @param event a {@link ProcessInjectionPoint} container
* lifecycle event; must not be {@code null}
*
* @exception NullPointerException if {@code event} is {@code
* null}
*/
private <T extends EntityManager> void saveEntityManagerQualifiers(@Observes final ProcessInjectionPoint<?, T> event) {
final String cn = JpaExtension.class.getName();
final String mn = "saveEntityManagerQualifiers";
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.entering(cn, mn, event);
}
Objects.requireNonNull(event);
final InjectionPoint injectionPoint = event.getInjectionPoint();
assert injectionPoint != null;
final Set<Annotation> qualifiers = injectionPoint.getQualifiers();
assert qualifiers != null;
boolean error = false;
if (qualifiers.contains(JpaTransactionScoped.Literal.INSTANCE)) {
if (qualifiers.contains(CdiTransactionScoped.Literal.INSTANCE) || qualifiers.contains(Extended.Literal.INSTANCE) || qualifiers.contains(NonTransactional.Literal.INSTANCE)) {
error = true;
}
} else if (qualifiers.contains(Extended.Literal.INSTANCE)) {
if (qualifiers.contains(CdiTransactionScoped.Literal.INSTANCE) || qualifiers.contains(NonTransactional.Literal.INSTANCE)) {
error = true;
}
} else if (qualifiers.contains(NonTransactional.Literal.INSTANCE)) {
if (qualifiers.contains(CdiTransactionScoped.Literal.INSTANCE)) {
error = true;
}
} else if (qualifiers.contains(Synchronized.Literal.INSTANCE)) {
if (qualifiers.contains(Unsynchronized.Literal.INSTANCE)) {
error = true;
}
}
if (error) {
event.addDefinitionError(new InjectionException("Invalid injection point; some qualifiers are mutually exclusive: " + qualifiers));
} else {
this.persistenceContextQualifiers.add(qualifiers);
}
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.exiting(cn, mn);
}
}
use of jakarta.enterprise.inject.spi.ProcessInjectionPoint in project helidon by oracle.
the class JpaExtension method saveEntityManagerFactoryQualifiers.
/**
* Stores {@link Set}s of qualifiers that annotate {@link
* EntityManagerFactory}-typed injection points.
*
* <p>{@link EntityManagerFactory}-typed beans will be added for
* each such {@link Set}.</p>
*
* @param event a {@link ProcessInjectionPoint} container
* lifecycle event; must not be {@code null}
*
* @exception NullPointerException if {@code event} is {@code
* null}
*/
private <T extends EntityManagerFactory> void saveEntityManagerFactoryQualifiers(@Observes final ProcessInjectionPoint<?, T> event) {
final String cn = JpaExtension.class.getName();
final String mn = "saveEntityManagerFactoryQualifiers";
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.entering(cn, mn, event);
}
Objects.requireNonNull(event);
final InjectionPoint injectionPoint = event.getInjectionPoint();
assert injectionPoint != null;
this.persistenceUnitQualifiers.add(injectionPoint.getQualifiers());
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.exiting(cn, mn);
}
}
use of jakarta.enterprise.inject.spi.ProcessInjectionPoint in project helidon by oracle.
the class JwtAuthCdiExtension method collectClaimProducer.
/**
* Process each injection point for {@link Claim}.
*
* @param pip event from CDI container
*/
void collectClaimProducer(@Observes ProcessInjectionPoint<?, ?> pip) {
Claim claim = pip.getInjectionPoint().getAnnotated().getAnnotation(Claim.class);
if (claim != null) {
if ((claim.standard() != Claims.UNKNOWN) && !claim.value().isEmpty()) {
throw new DeploymentException("Claim annotation should not have both values at value and standard! " + "@Claim(value=" + claim.value() + ", standard=Claims." + claim.standard().name() + ")");
}
InjectionPoint ip = pip.getInjectionPoint();
Type type = ip.getType();
FieldTypes ft = FieldTypes.forType(type);
ClaimLiteral q = new ClaimLiteral((claim.standard() == Claims.UNKNOWN) ? claim.value() : claim.standard().name(), ip.getMember().getDeclaringClass().getName() + "." + getFieldName(ip), ft.isOptional(), ft.isClaimValue(), ft.getField0().getRawType(), ft.getField1().getRawType(), ft.getField2().getRawType(), ft.getField3().getRawType(), type.toString());
pip.configureInjectionPoint().addQualifier(q);
if (ft.getField0().getRawType().equals(ClaimValue.class)) {
claimValueQualifiers.add(new ClaimIP(q, type));
} else {
qualifiers.add(new ClaimIP(q, type));
}
}
}
Aggregations