use of org.apache.deltaspike.core.util.metadata.builder.ImmutableInjectionPoint in project deltaspike by apache.
the class BeanUtils method createInjectionPoints.
/**
* Given a method, and the bean on which the method is declared, create a
* collection of injection points representing the parameters of the method.
*
* @param <X> the type declaring the method
* @param method the method
* @param declaringBean the bean on which the method is declared
* @param beanManager the bean manager to use to create the injection points
* @return the injection points
*/
public static <X> List<InjectionPoint> createInjectionPoints(AnnotatedMethod<X> method, Bean<?> declaringBean, BeanManager beanManager) {
List<InjectionPoint> injectionPoints = new ArrayList<InjectionPoint>();
for (AnnotatedParameter<X> parameter : method.getParameters()) {
InjectionPoint injectionPoint = new ImmutableInjectionPoint(parameter, beanManager, declaringBean, false, false);
injectionPoints.add(injectionPoint);
}
return injectionPoints;
}
use of org.apache.deltaspike.core.util.metadata.builder.ImmutableInjectionPoint in project deltaspike by apache.
the class BeanBuilderTest method assertNonNullInjectionPointsWhenOverriding.
@Test
public void assertNonNullInjectionPointsWhenOverriding() {
final BeanBuilder beanBuilder = new BeanBuilder(beanManager);
final AnnotatedType<?> at = beanManager.createAnnotatedType(WithInjectionPoint.class);
beanBuilder.readFromType(at);
// It's not easy to actually create these in the state we need, so we have to get the InjectionPonits,
// create new ones with the correct info, null out the bean, set them as the new injection points
// then move on.
final Set<InjectionPoint> origInjectionPoints = beanBuilder.getInjectionPoints();
beanBuilder.injectionPoints(beanBuilder.getInjectionPoints());
final Set<InjectionPoint> newInjectionPoints = new HashSet<InjectionPoint>();
for (InjectionPoint ip : origInjectionPoints) {
newInjectionPoints.add(new ImmutableInjectionPoint((AnnotatedField) ip.getAnnotated(), ip.getQualifiers(), null, ip.isTransient(), ip.isDelegate()));
}
beanBuilder.injectionPoints(newInjectionPoints);
final Bean<?> newInjectionBean = beanBuilder.create();
for (final InjectionPoint ip : newInjectionBean.getInjectionPoints()) {
Assert.assertNotNull(ip);
}
}
Aggregations