@Override public T newInstance(CreationalContext<T> ctx, BeanManagerImpl manager) { InjectionPoint originalInjectionPoint = manager.getServices().get(CurrentInjectionPoint.class).peek(); return applyDecorators(delegate().newInstance(ctx, manager), ctx, originalInjectionPoint, manager); }
private T getBeanInstance(Bean<?> bean) { final ThreadLocalStackReference<InjectionPoint> stack = currentInjectionPoint.push(ip); try { return Reflections.<T> cast(getBeanManager().getReference(bean, getType(), getCreationalContext(), false)); } finally { stack.pop(); } }
InjectionPoint injectionPoint = beanManager.getServices().get(CurrentInjectionPoint.class).peek(); if (injectionPoint != null) { Class<?> injectionPointRawType = Reflections.getRawType(injectionPoint.getType()); if (injectionPointRawType.isPrimitive()) { return cast(Defaults.getJlsDefaultValue(injectionPointRawType)); if (beanManager.isPassivatingScope(getScope())) { throw BeanLogger.LOG.nonSerializableProductError(getProducer(), Formats.formatAsStackTraceElement(getAnnotated().getJavaMember())); InjectionPoint injectionPoint = beanManager.getServices().get(CurrentInjectionPoint.class).peek(); if (injectionPoint != null && injectionPoint.getBean() != null && Beans.isPassivatingScope(injectionPoint.getBean(), beanManager)) { if (!(injectionPoint.getMember() instanceof Field) || !injectionPoint.isTransient()) {
Preconditions.checkArgumentNotNull(creationalContext, CREATIONAL_CONTEXT); boolean registerInjectionPoint = isRegisterableInjectionPoint(injectionPoint); boolean delegateInjectionPoint = injectionPoint != null && injectionPoint.isDelegate(); final ThreadLocalStackReference<InjectionPoint> stack = currentInjectionPoint.pushConditionally(injectionPoint, registerInjectionPoint); try { Type requestedType = null; if (injectionPoint != null) { requestedType = injectionPoint.getType(); if (clientProxyOptimization && injectionPoint != null && injectionPoint.getBean() != null) { if (weldCreationalContext != null && Dependent.class.equals(bean.getScope()) && isNormalScope(resolvedBean.getScope())) { bean = findNormalScopedDependant(weldCreationalContext); if (context != null) { @SuppressWarnings({ "unchecked", "rawtypes" }) final Object existinInstance = context.get(Reflections.<Contextual> cast(resolvedBean)); if (existinInstance != null) { return existinInstance; stack.pop();
@Override public T create(CreationalContext<T> creationalContext) { InjectionPoint ip = getInjectionPoint(cip); List<Decorator<?>> decorators = getDecorators(ip); T instance = newInstance(ip, creationalContext); if (decorators == null) { decorators = beanManager.resolveDecorators(Collections.singleton(ip.getType()), getQualifiers()); } if (decorators.isEmpty()) { return instance; } return Decorators.getOuterDelegate(this, instance, creationalContext, getProxyClass(), cip.peek(), getBeanManager(), decorators); }
private void addImplementationServices(ServiceRegistry services) { final WeldConfiguration configuration = services.get(WeldConfiguration.class); services.add(SlimAnnotatedTypeStore.class, new SlimAnnotatedTypeStoreImpl()); if (services.get(ClassTransformer.class) == null) { throw new IllegalStateException(ClassTransformer.class.getSimpleName() + " not installed."); services.add(ContextualStore.class, new ContextualStoreImpl(contextId, beanIdentifierIndex)); services.add(CurrentInjectionPoint.class, new CurrentInjectionPoint()); services.add(CurrentInvocationInjectionPoint.class, new CurrentInvocationInjectionPoint()); services.add(CurrentEventMetadata.class, new CurrentEventMetadata());
InjectionPointPropagatingEnterpriseTargetBeanInstance(Class<?> baseType, MethodHandler methodHandler, BeanManagerImpl manager) { super(baseType, methodHandler); this.contextId = manager.getContextId(); this.currentInvocationInjectionPoint = manager.getServices().get(CurrentInvocationInjectionPoint.class); InjectionPoint ip = manager.getServices().get(CurrentInjectionPoint.class).peek(); if (ip != null) { this.injectionPointHolder = new InjectionPointHolder(manager.getContextId(), ip); } else { this.injectionPointHolder = null; } }
private T getBeanInstance(Bean<?> bean) { final ThreadLocalStackReference<InjectionPoint> stack = currentInjectionPoint.pushConditionally(ip, isRegisterableInjectionPoint()); try { return Reflections.<T> cast(getBeanManager().getReference(bean, getType(), getCreationalContext(), false)); } finally { stack.pop(); } }
@Override public Object getReference(Bean<?> bean, Type requestedType, CreationalContext<?> creationalContext) { Preconditions.checkArgumentNotNull(bean, "bean"); Preconditions.checkArgumentNotNull(requestedType, "requestedType"); Preconditions.checkArgumentNotNull(creationalContext, CREATIONAL_CONTEXT); if (!BeanTypeAssignabilityRules.instance().matches(requestedType, bean.getTypes())) { throw BeanManagerLogger.LOG.specifiedTypeNotBeanType(requestedType, bean); } // Ensure that there is no injection point associated final ThreadLocalStackReference<InjectionPoint> stack = currentInjectionPoint.push(EmptyInjectionPoint.INSTANCE); try { return getReference(bean, requestedType, creationalContext, false); } finally { stack.pop(); } }
public Set<Bean<?>> getBeans(InjectionPoint injectionPoint) { boolean registerInjectionPoint = isRegisterableInjectionPoint(injectionPoint); final ThreadLocalStackReference<InjectionPoint> stack = currentInjectionPoint.pushConditionally(injectionPoint, registerInjectionPoint); try { // We always cache, we assume that people don't use inline annotation literal declarations, a little risky but FAQd return beanResolver.resolve(new ResolvableBuilder(injectionPoint, this).create(), true); } finally { stack.pop(); } }
protected InjectionPoint getInjectionPoint(CurrentInjectionPoint cip) { InjectionPoint ip = cip.peek(); return EmptyInjectionPoint.INSTANCE.equals(ip) ? null : ip; }
@Override public void inject(T instance, CreationalContext<T> ctx, BeanManagerImpl manager, SlimAnnotatedType<T> type, InjectionTarget<T> injectionTarget) { ThreadLocalStackReference<InjectionPoint> stack = null; if (pushDynamicInjectionPoints) { stack = currentInjectionPoint.push(new DynamicInjectionPoint(manager)); } try { super.inject(instance, ctx, manager, type, injectionTarget); } finally { if (pushDynamicInjectionPoints) { stack.pop(); } } }
InjectionPoint injectionPoint = beanManager.getServices().get(CurrentInjectionPoint.class).peek(); if (injectionPoint != null) { Class<?> injectionPointRawType = Reflections.getRawType(injectionPoint.getType()); if (injectionPointRawType.isPrimitive()) { return cast(Defaults.getJlsDefaultValue(injectionPointRawType)); if (beanManager.isPassivatingScope(getScope())) { throw BeanLogger.LOG.nonSerializableProductError(getProducer(), Formats.formatAsStackTraceElement(getAnnotated().getJavaMember())); InjectionPoint injectionPoint = beanManager.getServices().get(CurrentInjectionPoint.class).peek(); if (injectionPoint != null && injectionPoint.getBean() != null && Beans.isPassivatingScope(injectionPoint.getBean(), beanManager)) { if (!(injectionPoint.getMember() instanceof Field) || !injectionPoint.isTransient()) {
Preconditions.checkArgumentNotNull(creationalContext, CREATIONAL_CONTEXT); boolean registerInjectionPoint = isRegisterableInjectionPoint(injectionPoint); boolean delegateInjectionPoint = injectionPoint != null && injectionPoint.isDelegate(); final ThreadLocalStackReference<InjectionPoint> stack = currentInjectionPoint.pushConditionally(injectionPoint, registerInjectionPoint); try { Type requestedType = null; if (injectionPoint != null) { requestedType = injectionPoint.getType(); if (clientProxyOptimization && injectionPoint != null && injectionPoint.getBean() != null) { if (weldCreationalContext != null && Dependent.class.equals(bean.getScope()) && isNormalScope(resolvedBean.getScope())) { bean = findNormalScopedDependant(weldCreationalContext); if (context != null) { @SuppressWarnings({ "unchecked", "rawtypes" }) final Object existinInstance = context.get(Reflections.<Contextual> cast(resolvedBean)); if (existinInstance != null) { return existinInstance; stack.pop();
@Override public T create(CreationalContext<T> creationalContext) { InjectionPoint ip = getInjectionPoint(cip); List<Decorator<?>> decorators = getDecorators(ip); T instance = newInstance(ip, creationalContext); if (decorators == null) { decorators = beanManager.resolveDecorators(Collections.singleton(ip.getType()), getQualifiers()); } if (decorators.isEmpty()) { return instance; } return Decorators.getOuterDelegate(this, instance, creationalContext, getProxyClass(), cip.peek(), getBeanManager(), decorators); }
private void addImplementationServices(ServiceRegistry services) { final WeldModules modules = new WeldModules(); services.add(WeldModules.class, modules); final WeldConfiguration configuration = services.get(WeldConfiguration.class); services.add(SlimAnnotatedTypeStore.class, new SlimAnnotatedTypeStoreImpl()); if (services.get(ClassTransformer.class) == null) { throw new IllegalStateException(ClassTransformer.class.getSimpleName() + " not installed."); services.add(ContextualStore.class, new ContextualStoreImpl(contextId, beanIdentifierIndex)); services.add(CurrentInjectionPoint.class, new CurrentInjectionPoint()); services.add(CurrentEventMetadata.class, new CurrentEventMetadata()); services.add(SpecializationAndEnablementRegistry.class, new SpecializationAndEnablementRegistry());
public InjectionPointPropagatingEnterpriseTargetBeanInstance(Class<?> baseType, MethodHandler methodHandler, BeanManagerImpl manager) { super(baseType, methodHandler); this.contextId = manager.getContextId(); this.currentInvocationInjectionPoint = manager.getServices().get(CurrentInvocationInjectionPoint.class); InjectionPoint ip = manager.getServices().get(CurrentInjectionPoint.class).peek(); if (ip != null) { this.injectionPointHolder = new InjectionPointHolder(manager.getContextId(), ip); } else { this.injectionPointHolder = null; } }
private T getBeanInstance(Bean<?> bean) { final ThreadLocalStackReference<InjectionPoint> stack = currentInjectionPoint.pushConditionally(ip, isRegisterableInjectionPoint()); try { return Reflections.<T> cast(getBeanManager().getReference(bean, getType(), getCreationalContext(), false)); } finally { stack.pop(); } }
@Override public Object getReference(Bean<?> bean, Type requestedType, CreationalContext<?> creationalContext) { Preconditions.checkArgumentNotNull(bean, "bean"); Preconditions.checkArgumentNotNull(requestedType, "requestedType"); Preconditions.checkArgumentNotNull(creationalContext, CREATIONAL_CONTEXT); if (!BeanTypeAssignabilityRules.instance().matches(requestedType, bean.getTypes())) { throw BeanManagerLogger.LOG.specifiedTypeNotBeanType(requestedType, bean); } // Ensure that there is no injection point associated final ThreadLocalStackReference<InjectionPoint> stack = currentInjectionPoint.push(EmptyInjectionPoint.INSTANCE); try { return getReference(bean, requestedType, creationalContext, false); } finally { stack.pop(); } }
public Set<Bean<?>> getBeans(InjectionPoint injectionPoint) { boolean registerInjectionPoint = isRegisterableInjectionPoint(injectionPoint); final ThreadLocalStackReference<InjectionPoint> stack = currentInjectionPoint.pushConditionally(injectionPoint, registerInjectionPoint); try { // We always cache, we assume that people don't use inline annotation literal declarations, a little risky but FAQd return beanResolver.resolve(new ResolvableBuilder(injectionPoint, this).create(), true); } finally { stack.pop(); } }