本文整理汇总了Java中javax.enterprise.inject.spi.ProcessInjectionPoint类的典型用法代码示例。如果您正苦于以下问题:Java ProcessInjectionPoint类的具体用法?Java ProcessInjectionPoint怎么用?Java ProcessInjectionPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProcessInjectionPoint类属于javax.enterprise.inject.spi包,在下文中一共展示了ProcessInjectionPoint类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processClaimValueInjections
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
void processClaimValueInjections(@Observes ProcessInjectionPoint pip) {
log.debugf("pipRaw: %s", pip.getInjectionPoint());
InjectionPoint ip = pip.getInjectionPoint();
if (ip.getAnnotated().isAnnotationPresent(Claim.class) && ip.getType() instanceof Class) {
Class rawClass = (Class) ip.getType();
if (Modifier.isFinal(rawClass.getModifiers())) {
Claim claim = ip.getAnnotated().getAnnotation(Claim.class);
rawTypes.add(ip.getType());
rawTypeQualifiers.add(claim);
log.debugf("+++ Added Claim raw type: %s", ip.getType());
Class declaringClass = ip.getMember().getDeclaringClass();
Annotation[] appScoped = declaringClass.getAnnotationsByType(ApplicationScoped.class);
Annotation[] sessionScoped = declaringClass.getAnnotationsByType(SessionScoped.class);
if ((appScoped != null && appScoped.length > 0) || (sessionScoped != null && sessionScoped.length > 0)) {
String err = String.format("A raw type cannot be injected into application/session scope: IP=%s", ip);
pip.addDefinitionError(new DeploymentException(err));
}
}
}
}
示例2: injectionPoints
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
public <T, X> void injectionPoints(
final @Observes ProcessInjectionPoint<T, X> processInjectionPoint
) {
final Type type = processInjectionPoint.getInjectionPoint().getType();
final Object mock = mockStore.findFor(type);
if (mock == null) {
return;
}
LOG.debug("Mocking injection point: {}", processInjectionPoint.getInjectionPoint());
final InjectionPoint original = processInjectionPoint.getInjectionPoint();
processInjectionPoint.setInjectionPoint(new ForwardingInjectionPoint() {
@Override
public Set<Annotation> getQualifiers() {
final Set<Annotation> ret = new HashSet<>(super.getQualifiers()).stream()
.filter(it -> !(it instanceof Default))
.collect(toSet());
ret.add(MOCKED);
return ret;
}
@Override
protected InjectionPoint delegate() {
return original;
}
});
mockedInjectionPoints.add(original);
}
示例3: captureProducerTypes
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
@Test
public void captureProducerTypes() {
final ProcessInjectionPoint<?, ?> pip = mock(ProcessInjectionPoint.class);
final InjectionPoint ip = mock(InjectionPoint.class);
when(pip.getInjectionPoint()).thenReturn(ip);
final Annotated annotated = mock(Annotated.class);
when(ip.getAnnotated()).thenReturn(annotated);
when(annotated.isAnnotationPresent(Body.class)).thenReturn(true);
when(ip.getType()).thenReturn(COLLECTION.getClass());
@SuppressWarnings("unchecked")
final InjectionTarget<Object> injectionTarget = mock(InjectionTarget.class);
when(this.beanManager.createInjectionTarget(Mockito.any())).thenReturn(injectionTarget);
final Member member = mock(Member.class);
when(ip.getMember()).thenReturn(member);
final List<Bean<?>> found = ReflectionUtil.get(this.extension, "found");
assertTrue(found.isEmpty());
this.extension.captureProducerTypes(pip, this.beanManager);
assertEquals(1, found.size());
verify(pip, times(2)).getInjectionPoint();
verify(ip).getAnnotated();
verify(annotated).isAnnotationPresent(Body.class);
verify(ip).getType();
verify(ip).getMember();
verify(member).getName();
verify(ip).getQualifiers();
verify(injectionTarget).getInjectionPoints();
verify(this.beanManager).createInjectionTarget(Mockito.any());
verifyNoMoreInteractions(pip, ip, annotated, injectionTarget, member);
}
示例4: processClaimProviderInjections
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
/**
* Collect the types of all Provider injection points annotated with {@linkplain Claim}.
*
* @param pip - the injection point event information
*/
void processClaimProviderInjections(@Observes ProcessInjectionPoint<?, ? extends Provider> pip) {
log.debugf("pip: %s", pip.getInjectionPoint());
final InjectionPoint ip = pip.getInjectionPoint();
if (ip.getAnnotated().isAnnotationPresent(Claim.class)) {
Claim claim = ip.getAnnotated().getAnnotation(Claim.class);
if (claim.value().length() == 0 && claim.standard() == Claims.UNKNOWN) {
throw new DeploymentException("@Claim at: " + ip + " has no name or valid standard enum setting");
}
boolean usesEnum = claim.standard() != Claims.UNKNOWN;
final String claimName = usesEnum ? claim.standard().name() : claim.value();
log.debugf("Checking Provider Claim(%s), ip: %s", claimName, ip);
ClaimIP claimIP = claims.get(claimName);
Type matchType = ip.getType();
Type actualType = ((ParameterizedType) matchType).getActualTypeArguments()[0];
// Don't add Optional as this is handled specially
if (!optionalOrJsonValue(actualType)) {
rawTypes.add(actualType);
} else if (!actualType.getTypeName().startsWith("javax.json.Json")) {
// Validate that this is not an Optional<JsonValue>
Type innerType = ((ParameterizedType) actualType).getActualTypeArguments()[0];
if (!innerType.getTypeName().startsWith("javax.json.Json")) {
providerOptionalTypes.add(actualType);
providerQualifiers.add(claim);
}
}
rawTypeQualifiers.add(claim);
ClaimIPType key = new ClaimIPType(claimName, actualType);
if (claimIP == null) {
claimIP = new ClaimIP(actualType, actualType, false, claim);
claimIP.setProviderSite(true);
claims.put(key, claimIP);
}
claimIP.getInjectionPoints().add(ip);
log.debugf("+++ Added Provider Claim(%s) ip: %s", claimName, ip);
}
}
示例5: cdiEventEndpoints
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
private void cdiEventEndpoints(@Observes ProcessInjectionPoint<?, CdiEventEndpoint> pip, BeanManager manager) {
InjectionPoint ip = pip.getInjectionPoint();
Type type = ip.getType() instanceof ParameterizedType
? ((ParameterizedType) ip.getType()).getActualTypeArguments()[0]
: Object.class;
String uri = eventEndpointUri(type, ip.getQualifiers());
cdiEventEndpoints.put(uri, new CdiEventEndpoint<>(uri, type, ip.getQualifiers(), manager));
}
示例6: processInjectionPoint
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
<K, V> void processInjectionPoint(@Observes ProcessInjectionPoint<K, V> pip) {
logger.info("finished the scanning process");
processInjectionPoint++;
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:5,代码来源:ObserverExtension.java
示例7: collectConfigProducer
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
public void collectConfigProducer(@Observes ProcessInjectionPoint<?, ?> pip) {
ConfigProperty configProperty = pip.getInjectionPoint().getAnnotated().getAnnotation(ConfigProperty.class);
if (configProperty != null) {
injectionPoints.add(pip.getInjectionPoint());
}
}
示例8: locateInjections
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
public void locateInjections(@Observes ProcessInjectionPoint<?, ReactorEvent<?,?>> pip) {
eventTypes.add(pip.getInjectionPoint());
}
示例9: captureProducerTypes
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
/**
*
* @param pip
* @param beanManager
*/
public void captureProducerTypes(@Observes final ProcessInjectionPoint<?, ?> pip, BeanManager beanManager) {
if (pip.getInjectionPoint().getAnnotated().isAnnotationPresent(Body.class)) {
found.add(createBeanAdapter(pip.getInjectionPoint(), beanManager));
}
}
示例10: processAsyncReferenceInjectionPoints
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
void processAsyncReferenceInjectionPoints(@Observes ProcessInjectionPoint<?, ? extends AsyncReference> event) {
asyncReferenceQualifiers.addAll(event.getInjectionPoint().getQualifiers());
}
示例11: processEventSchedulerInjectionPoint
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
<T, X extends EventScheduler> void processEventSchedulerInjectionPoint(
@Observes final ProcessInjectionPoint<T, X> processInjectionPoint,
final BeanManager beanManager) {
InjectionPoint injectionPoint = processInjectionPoint.getInjectionPoint();
eventSchedulerInfos.add(EventSchedulerInfo.of(injectionPoint));
}
示例12: logLifecycleEvent
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
<T, X> void logLifecycleEvent(@Observes ProcessInjectionPoint<T, X> event) {
LOGGER.info("ProcessInjectionPoint: injectionPoint=" + event.getInjectionPoint());
}
示例13: alterSubscriptionPublishInjectionPoints
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
public void alterSubscriptionPublishInjectionPoints(@Observes ProcessInjectionPoint processInjectionPoint) {
final InjectionPoint injectionPoint = processInjectionPoint.getInjectionPoint();
logger.info("Looking at injection point: " + injectionPoint);
if (injectionPoint.getType() instanceof Class
&& SubscriptionPublisher.class.isAssignableFrom((Class) injectionPoint.getType())) {
logger.info("Re-writing injection point type from {} to {} on bean {}",
injectionPoint.getType(),
SubscriptionPublisher.class,
injectionPoint.getBean());
final Bean<?> bean = injectionPoint.getBean();
InjectionPoint newInjectionPoint = new InjectionPoint() {
@Override
public Type getType() {
return SubscriptionPublisher.class;
}
@Override
public Set<Annotation> getQualifiers() {
return injectionPoint.getQualifiers();
}
@Override
public Bean<?> getBean() {
return bean;
}
@Override
public Member getMember() {
return injectionPoint.getMember();
}
@Override
public Annotated getAnnotated() {
return injectionPoint.getAnnotated();
}
@Override
public boolean isDelegate() {
return injectionPoint.isDelegate();
}
@Override
public boolean isTransient() {
return injectionPoint.isTransient();
}
};
processInjectionPoint.setInjectionPoint(newInjectionPoint);
}
}
示例14: processInjectionPoints
import javax.enterprise.inject.spi.ProcessInjectionPoint; //导入依赖的package包/类
/**
* Event generated by the container to process an injection point. Is called for every point defined in the
* container. During this phase, we check for any @ServiceReference qualifiers and create a bean for it.
* That bean is later added during another phase of the container construction.
*
* @param event The injection point event
* @param <T> The injection point type
* @param <X> The bean class declaring the point
*/
public <T, X> void processInjectionPoints(@Observes ProcessInjectionPoint<T, X> event) {
TrackerBean bean = processInjectionPoint(event.getInjectionPoint(), (e) -> event.addDefinitionError(e));
if (bean != null) {
beans.add(bean);
}
}