/** * Get the default value of the parameter. The default value is that which * would be injected according to the CDI type safe resolution rules. * * @param creationalContext the creationalContext to use to obtain the * injectable reference. * @return the default value */ public Object getDefaultValue(CreationalContext<?> creationalContext) { return beanManager.getInjectableReference(injectionPoint, creationalContext); }
/** * Get the default value of the parameter. The default value is that which * would be injected according to the CDI type safe resolution rules. * * @param creationalContext the creationalContext to use to obtain the * injectable reference. * @return the default value */ public Object getDefaultValue(CreationalContext<?> creationalContext) { return beanManager.getInjectableReference(injectionPoint, creationalContext); }
/** * Get the default value of the parameter. The default value is that which * would be injected according to the CDI type safe resolution rules. * * @param creationalContext the creationalContext to use to obtain the * injectable reference. * @return the default value */ public Object getDefaultValue(CreationalContext<?> creationalContext) { return beanManager.getInjectableReference(injectionPoint, creationalContext); }
/** * Get the default value of the parameter. The default value is that which * would be injected according to the CDI type safe resolution rules. * * @param creationalContext the creationalContext to use to obtain the * injectable reference. * @return the default value */ public Object getDefaultValue(CreationalContext<?> creationalContext) { return beanManager.getInjectableReference(injectionPoint, creationalContext); }
@Override public T create(CreationalContext<T> creationalContext) { return create.apply(creationalContext, beanManager.getInjectableReference(decoratorInjectionPoint, creationalContext)); }
/** * Returns the current injection point. */ public static InjectionPoint getCurrentInjectionPoint(BeanManager beanManager, CreationalContext<?> creationalContext) { Bean<? extends Object> bean = beanManager.resolve(beanManager.getBeans(InjectionPoint.class)); InjectionPoint injectionPoint = (InjectionPoint) beanManager.getReference(bean, InjectionPoint.class, creationalContext); if (injectionPoint == null) { // It's broken in some Weld versions. Below is a work around. bean = beanManager.resolve(beanManager.getBeans(InjectionPointGenerator.class)); injectionPoint = (InjectionPoint) beanManager.getInjectableReference(bean.getInjectionPoints().iterator().next(), creationalContext); } return injectionPoint; }
/** * Returns the current injection point. */ public static InjectionPoint getCurrentInjectionPoint(BeanManager beanManager, CreationalContext<?> creationalContext) { Bean<? extends Object> bean = beanManager.resolve(beanManager.getBeans(InjectionPoint.class)); InjectionPoint injectionPoint = (InjectionPoint) beanManager.getReference(bean, InjectionPoint.class, creationalContext); if (injectionPoint == null) { // It's broken in some Weld versions. Below is a work around. bean = beanManager.resolve(beanManager.getBeans(InjectionPointGenerator.class)); injectionPoint = (InjectionPoint) beanManager.getInjectableReference(bean.getInjectionPoints().iterator().next(), creationalContext); } return injectionPoint; }
/** * Returns the current injection point. */ public static InjectionPoint getCurrentInjectionPoint(BeanManager beanManager, CreationalContext<?> creationalContext) { Bean<? extends Object> bean = beanManager.resolve(beanManager.getBeans(InjectionPoint.class)); InjectionPoint injectionPoint = (InjectionPoint) beanManager.getReference(bean, InjectionPoint.class, creationalContext); if (injectionPoint == null) { // It's broken in some Weld versions. Below is a work around. bean = beanManager.resolve(beanManager.getBeans(InjectionPointGenerator.class)); injectionPoint = (InjectionPoint) beanManager.getInjectableReference(bean.getInjectionPoints().iterator().next(), creationalContext); } return injectionPoint; }
@Override public Object getInjectableReference(InjectionPoint ij, CreationalContext<?> ctx) { return delegate().getInjectableReference(ij, ctx); }
/** * @see Beans#getAnnotation(Annotated, Class) */ public static InjectionPoint getCurrentInjectionPoint(BeanManager beanManager, CreationalContext<?> creationalContext) { Bean<InjectionPointGenerator> bean = resolve(beanManager, InjectionPointGenerator.class); return (bean != null) ? (InjectionPoint) beanManager.getInjectableReference(bean.getInjectionPoints().iterator().next(), creationalContext) : null; }
public VehicleDecorator create(CreationalContext<VehicleDecorator> ctx) { VehicleDecorator decorator = new VehicleDecorator(); decorator.delegate = (Vehicle) beanManager.getInjectableReference(getInjectionPoints().iterator().next(), ctx); return decorator; }
public VehicleDecorator create(CreationalContext<VehicleDecorator> ctx) { VehicleDecorator decorator = new VehicleDecorator(); decorator.delegate = (Vehicle) beanManager.getInjectableReference(getInjectionPoints().iterator().next(), ctx); return decorator; }
/** * @see Beans#getAnnotation(Annotated, Class) */ public static InjectionPoint getCurrentInjectionPoint(BeanManager beanManager, CreationalContext<?> creationalContext) { Bean<InjectionPointGenerator> bean = resolve(beanManager, InjectionPointGenerator.class); return (bean != null) ? (InjectionPoint) beanManager.getInjectableReference(bean.getInjectionPoints().iterator().next(), creationalContext) : null; }
@Override public Object call() throws Exception { Bean<R> bean = (Bean<R>) manager.resolve(manager.getBeans(actualType, Annotations.getQualifiersFrom(actualType))); context = manager.createCreationalContext(bean); Object delegate = manager.getInjectableReference(injectionPoint, context); return Proxies.enhance(loader, delegate, new ClassLoaderInterceptor(loader, delegate)); } };
private void testAvailableMethodsInADV(BeanManager beanManager) { beanManager.getReference(new FooBean(), Foo.class, beanManager.createCreationalContext(null)); beanManager.getInjectableReference( beanManager.createInjectionPoint(beanManager.createAnnotatedType(Foo.class).getFields().iterator().next()), beanManager.createCreationalContext(null)); }
void execute() { beanManager.getInjectableReference( beanManager.createInjectionPoint(beanManager.createAnnotatedType(Foo.class).getFields().iterator().next()), creationalContext); } }.run();
@Override public Object create(final CreationalContext creationalContext) { InjectionPoint injectionPoint = (InjectionPoint) beanManager.getInjectableReference(new MetadataInjectionPoint(this), creationalContext); return MicroserviceProxyFactory.createProxy(this, injectionPoint); }
@Override public void evaluate() throws Throwable { BeanManager manager = context.getBeanManager(); Type[] types = method.getMethod().getGenericParameterTypes(); Object[] parameters = new Object[types.length]; for (int i = 0; i < types.length; i++) { // TODO: use a proper CreationalContext... parameters[i] = manager.getInjectableReference(new FrameworkMethodInjectionPoint(method.getMethod(), i, manager), manager.createCreationalContext(null)); } method.invokeExplosively(test, parameters); } }
@SuppressWarnings("unchecked") @Test(expectedExceptions = UnsatisfiedResolutionException.class) @SpecAssertions({ @SpecAssertion(section = BM_OBTAIN_INJECTABLE_REFERENCE, id = "bb") }) public void testUnsatisfiedReference() { Bean<SimpleBean> bean = this.getBeans(SimpleBean.class).iterator().next(); UnsatisfiedInjectionPoint injectionPoint = new UnsatisfiedInjectionPoint(bean); CreationalContext<SimpleBean> creationalContext = getCurrentManager().createCreationalContext( (Bean<SimpleBean>) injectionPoint.getBean()); getCurrentManager().getInjectableReference(injectionPoint, creationalContext); } }
@SuppressWarnings("unchecked") @Test(expectedExceptions = AmbiguousResolutionException.class) @SpecAssertions({ @SpecAssertion(section = BM_OBTAIN_INJECTABLE_REFERENCE, id = "bc") }) public void testUnsatisfiedReference() { Bean<SimpleBean> bean = this.getBeans(SimpleBean.class).iterator().next(); AmbiguousInjectionPoint injectionPoint = new AmbiguousInjectionPoint(bean); CreationalContext<SimpleBean> creationalContext = getCurrentManager().createCreationalContext( (Bean<SimpleBean>) injectionPoint.getBean()); getCurrentManager().getInjectableReference(injectionPoint, creationalContext); } }