use of javax.enterprise.inject.spi.InjectionPoint in project deltaspike by apache.
the class BeanBuilderTest method assertNonNullInjectionPointsFromBeanBuilder.
@Test
public void assertNonNullInjectionPointsFromBeanBuilder() {
final BeanBuilder beanBuilder = new BeanBuilder(beanManager);
final AnnotatedType<?> at = beanManager.createAnnotatedType(WithInjectionPoint.class);
final Bean<?> newInjectionBean = beanBuilder.readFromType(at).create();
for (final InjectionPoint ip : newInjectionBean.getInjectionPoints()) {
Assert.assertNotNull(ip);
}
}
use of javax.enterprise.inject.spi.InjectionPoint in project wildfly by wildfly.
the class ResourceInjectionUtilities method getResourceName.
public static String getResourceName(InjectionPoint injectionPoint) {
Resource resource = getResourceAnnotated(injectionPoint).getAnnotation(Resource.class);
String mappedName = resource.mappedName();
if (!mappedName.equals("")) {
return mappedName;
}
String name = resource.name();
if (!name.equals("")) {
//see if this is a prefixed name
//and if so just return it
int firstSlash = name.indexOf("/");
int colon = name.indexOf(":");
if (colon != -1) {
if (firstSlash == -1 || colon < firstSlash) {
return name;
}
}
return RESOURCE_LOOKUP_PREFIX + "/" + name;
}
String propertyName;
if (injectionPoint.getMember() instanceof Field) {
propertyName = injectionPoint.getMember().getName();
} else if (injectionPoint.getMember() instanceof Method) {
propertyName = getPropertyName((Method) injectionPoint.getMember());
if (propertyName == null) {
throw WeldLogger.ROOT_LOGGER.injectionPointNotAJavabean((Method) injectionPoint.getMember());
}
} else {
throw WeldLogger.ROOT_LOGGER.cannotInject(injectionPoint);
}
String className = injectionPoint.getMember().getDeclaringClass().getName();
return RESOURCE_LOOKUP_PREFIX + "/" + className + "/" + propertyName;
}
use of javax.enterprise.inject.spi.InjectionPoint in project aries by apache.
the class ConfigurationBean method create0.
protected <T> T create0(CreationalContext<T> creationalContext) {
Map<String, Object> map = new AbstractMap<String, Object>() {
@Override
public Set<java.util.Map.Entry<String, Object>> entrySet() {
return _configurationDependency.getConfiguration().entrySet();
}
};
T instance = cast(Conversions.c().convert(map).to(_configurationDependency.getBeanClass()));
InjectionPoint ip = getInjectionPoint(_currentInjectionPoint);
if (ip == null) {
return instance;
}
List<Decorator<?>> decorators = getDecorators(ip);
if (decorators.isEmpty()) {
return instance;
}
return Decorators.getOuterDelegate(cast(this), instance, creationalContext, cast(getBeanClass()), ip, _beanManagerImpl, decorators);
}
use of javax.enterprise.inject.spi.InjectionPoint in project aries by apache.
the class ReferenceBean method create0.
protected <T> T create0(CreationalContext<T> creationalContext) {
T instance = cast(getServiceImpl());
InjectionPoint ip = getInjectionPoint(_currentInjectionPoint);
if (ip == null) {
return instance;
}
List<Decorator<?>> decorators = getDecorators(ip);
if (decorators.isEmpty()) {
return instance;
}
return Decorators.getOuterDelegate(cast(this), instance, creationalContext, cast(getBeanClass()), ip, _beanManagerImpl, decorators);
}
use of javax.enterprise.inject.spi.InjectionPoint 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