Package org.jboss.weld.injection

Examples of org.jboss.weld.injection.CurrentInjectionPoint


    private T getBeanInstance(Bean<?> bean) {
        // Generate a correct injection point for the bean, we do this by taking the original injection point and adjusting the
        // qualifiers and type
        InjectionPoint ip = new DynamicLookupInjectionPoint(getInjectionPoint(), getType(), getQualifiers());
        CurrentInjectionPoint currentInjectionPoint = getBeanManager().getServices().get(CurrentInjectionPoint.class);
        try {
            currentInjectionPoint.push(ip);
            return Reflections.<T> cast(getBeanManager().getReference(bean, getType(), getCreationalContext()));
        } finally {
            currentInjectionPoint.pop();
        }
    }
View Full Code Here


        return beanResolver.resolve(new ResolvableBuilder(beanType, this).addQualifiers(qualifiers).create(), isCacheable(qualifiers));
    }

    public Set<Bean<?>> getBeans(InjectionPoint injectionPoint) {
        boolean registerInjectionPoint = isRegisterableInjectionPoint(injectionPoint);
        CurrentInjectionPoint currentInjectionPoint = null;
        if (registerInjectionPoint) {
            currentInjectionPoint = services.get(CurrentInjectionPoint.class);
            currentInjectionPoint.push(injectionPoint);
        }
        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 {
            if (registerInjectionPoint) {
                currentInjectionPoint.pop();
            }
        }
    }
View Full Code Here

        Preconditions.checkArgumentNotNull(creationalContext, CREATIONAL_CONTEXT);

        boolean registerInjectionPoint = isRegisterableInjectionPoint(injectionPoint);
        boolean delegateInjectionPoint = injectionPoint != null && injectionPoint.isDelegate();

        CurrentInjectionPoint currentInjectionPoint = null;
        if (registerInjectionPoint) {
            currentInjectionPoint = services.get(CurrentInjectionPoint.class);
            currentInjectionPoint.push(injectionPoint);
        }
        try {
            Type requestedType = null;
            if (injectionPoint != null) {
                requestedType = injectionPoint.getType();
            }

            if (injectionPoint != null && injectionPoint.getBean() != null) {
                // For certain combinations of scopes, the container is permitted to optimize an injectable reference lookup
                // This should also partially solve circular @PostConstruct invocation
                CreationalContextImpl<?> weldCreationalContext = null;
                Bean<?> bean = injectionPoint.getBean();

                // Do not optimize for self injection
                if(!bean.equals(resolvedBean)) {

                    if (creationalContext instanceof CreationalContextImpl) {
                        weldCreationalContext = (CreationalContextImpl<?>) creationalContext;
                    }

                    if (weldCreationalContext != null && Dependent.class.equals(bean.getScope()) && isNormalScope(resolvedBean.getScope())) {
                        bean = findNormalScopedDependant(weldCreationalContext);
                    }

                    if (InjectionPoints.isInjectableReferenceLookupOptimizationAllowed(bean, resolvedBean)) {
                        if (weldCreationalContext != null) {
                            final Object incompleteInstance = weldCreationalContext.getIncompleteInstance(resolvedBean);
                            if (incompleteInstance != null) {
                                return incompleteInstance;
                            }
                        }
                        Context context = internalGetContext(resolvedBean.getScope());
                        if(context != null) {
                            @java.lang.SuppressWarnings({ "unchecked", "rawtypes" })
                            final Object existinInstance = context.get(Reflections.<Contextual>cast(resolvedBean));
                            if(existinInstance != null) {
                                return existinInstance;
                            }
                        }
                    }
                }
            }
            return getReference(resolvedBean, requestedType, creationalContext, delegateInjectionPoint);

        } finally {
            if (registerInjectionPoint) {
                currentInjectionPoint.pop();
            }
        }
    }
View Full Code Here

        if (previousCreationalContext == null) {
            creationalContext = new CreationalContextImpl<T>(bean);
        } else {
            creationalContext = previousCreationalContext.getCreationalContext(bean);
        }
        final CurrentInjectionPoint currentInjectionPoint = container.services().get(CurrentInjectionPoint.class);
        currentCreationalContext.set(creationalContext);
        try {
            // Ensure that there is no injection point associated
            currentInjectionPoint.push(EmptyInjectionPoint.INSTANCE);
            return context.get(bean, creationalContext);
        } finally {
            currentInjectionPoint.pop();
            if (previousCreationalContext == null) {
                currentCreationalContext.remove();
            } else {
                currentCreationalContext.set(previousCreationalContext);
            }
View Full Code Here

        services.add(MemberTransformer.class, new MemberTransformer(services.get(ClassTransformer.class)));
        services.add(MetaAnnotationStore.class, new MetaAnnotationStore(services.get(ClassTransformer.class)));
        BeanIdentifierIndex beanIdentifierIndex = new BeanIdentifierIndex();
        services.add(BeanIdentifierIndex.class, beanIdentifierIndex);
        services.add(ContextualStore.class, new ContextualStoreImpl(contextId, beanIdentifierIndex));
        services.add(CurrentInjectionPoint.class, new CurrentInjectionPoint());
        services.add(SLSBInvocationInjectionPoint.class, new SLSBInvocationInjectionPoint());
        services.add(CurrentEventMetadata.class, new CurrentEventMetadata());
        services.add(SpecializationAndEnablementRegistry.class, new SpecializationAndEnablementRegistry());
        services.add(MissingDependenciesRegistry.class, new MissingDependenciesRegistry());
View Full Code Here

    @Override
    public Object invoke(Object o, Method method, Object[] parameters) throws Throwable {
        T instance;

        if (createdTypeData.isConstructorInjection()) {
            CurrentInjectionPoint currentInjectionPoint = Container.instance().services().get(CurrentInjectionPoint.class);
            currentInjectionPoint.push(ConstructorInjectionPoint.of(bean, (WeldConstructor<T>) createdTypeData.getCreatedTypeConstructor()));
            instance = newInstance(parameters);
            currentInjectionPoint.pop();
        } else {
            instance = newInstance(parameters);
            createdTypeData.getCreatedTypeInjectionTarget().inject(instance, creationalContext);
            createdTypeData.getCreatedTypeInjectionTarget().postConstruct(instance);
        }
View Full Code Here

        this.qualifiers = qualifiers;
    }

    @Override
    public Object getValue(BeanManager bm, Object[] factoryParameters) {
        CurrentInjectionPoint currentInjectionPointStack = Container.instance().services().get(CurrentInjectionPoint.class);
        ConstructorInjectionPoint currentInjectionPoint = (ConstructorInjectionPoint) currentInjectionPointStack.peek();
        currentInjectionPointStack.push(findParameterInjectionPoint(currentInjectionPoint));

        Object result = BeanInject.lookup(bm, beanType, qualifiers);

        currentInjectionPointStack.pop();

        return result;
    }
View Full Code Here

TOP

Related Classes of org.jboss.weld.injection.CurrentInjectionPoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.