use of org.jboss.weld.injection.ForwardingInjectionPoint in project core by weld.
the class ModifyingExtension method overrideFieldInjectionPoint.
public void overrideFieldInjectionPoint(@Observes ProcessInjectionPoint<InjectingBean, Dog> event) {
final InjectionPoint delegate = event.getInjectionPoint();
event.setInjectionPoint(new ForwardingInjectionPoint() {
@Override
protected InjectionPoint delegate() {
return delegate;
}
@Override
public boolean isTransient() {
return true;
}
@Override
public Type getType() {
return Hound.class;
}
@Override
public Set<Annotation> getQualifiers() {
return Collections.<Annotation>singleton(Fast.Literal.INSTANCE);
}
});
}
use of org.jboss.weld.injection.ForwardingInjectionPoint in project core by weld.
the class ModifyingExtension method overrideFieldInjectionPointToTriggerNewBeanCreation.
public void overrideFieldInjectionPointToTriggerNewBeanCreation(@Observes ProcessInjectionPoint<InjectingBean, Cat> event) {
final InjectionPoint delegate = event.getInjectionPoint();
event.setInjectionPoint(new ForwardingInjectionPoint() {
@Override
protected InjectionPoint delegate() {
return delegate;
}
@Override
public Set<Annotation> getQualifiers() {
return Collections.<Annotation>singleton(New.Literal.INSTANCE);
}
});
}
use of org.jboss.weld.injection.ForwardingInjectionPoint in project core by weld.
the class GlueDecoratorExtension method registerDecorator.
void registerDecorator(@Observes AfterBeanDiscovery event, BeanManager manager) {
AnnotatedType<GlueDecorator> annotatedType = manager.createAnnotatedType(GlueDecorator.class);
final BeanAttributes<GlueDecorator> attributes = manager.createBeanAttributes(annotatedType);
final InjectionPoint delegateInjectionPoint = manager.createInjectionPoint(annotatedType.getConstructors().iterator().next().getParameters().get(0));
Decorator<GlueDecorator> decorator = new DecoratorImpl<GlueDecorator>() {
@Override
public Type getDelegateType() {
return Glue.class;
}
@Override
public Set<Annotation> getDelegateQualifiers() {
return Collections.<Annotation>singleton(Any.Literal.INSTANCE);
}
@Override
public Set<Type> getDecoratedTypes() {
return Collections.emptySet();
}
@Override
public Class<?> getBeanClass() {
return GlueDecorator.class;
}
@Override
public Set<InjectionPoint> getInjectionPoints() {
final Decorator<GlueDecorator> decorator = this;
InjectionPoint wrappedInjectionPoint = new ForwardingInjectionPoint() {
@Override
public Bean<?> getBean() {
return decorator;
}
@Override
protected InjectionPoint delegate() {
return delegateInjectionPoint;
}
};
return Collections.singleton(wrappedInjectionPoint);
}
@Override
public GlueDecorator create(CreationalContext<GlueDecorator> creationalContext) {
return new GlueDecorator(null);
}
@Override
public void destroy(GlueDecorator instance, CreationalContext<GlueDecorator> creationalContext) {
creationalContext.release();
}
@Override
protected BeanAttributes<GlueDecorator> attributes() {
return attributes;
}
};
event.addBean(decorator);
}
use of org.jboss.weld.injection.ForwardingInjectionPoint 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;
}
});
}
Aggregations