Package org.jboss.weld.manager

Examples of org.jboss.weld.manager.BeanManagerImpl


        private SlimAnnotatedType<?> tryToLoadUnknownBackedAnnotatedType() {
            if (identifier.getSuffix() != null || identifier.isModified()) {
                return null; // this is not a backed annotated type
            }
            // first, obtain the BeanManager for a given BDA
            final BeanManagerImpl manager = Container.instance(identifier).activityManager(identifier.getBdaId());
            if (manager == null) {
                return null;
            }
            // second, try to load the class
            final ResourceLoader resourceLoader = manager.getServices().get(ResourceLoader.class);
            Class<?> clazz = null;
            try {
                clazz = resourceLoader.classForName(identifier.getClassName());
            } catch (ResourceLoadingException e) {
                MetadataLogger.LOG.catchingDebug(e);
                return null;
            }
            // finally, try to load the annotated type
            try {
                return manager.getServices().get(ClassTransformer.class).getBackedAnnotatedType(clazz, identifier.getBdaId());
            } catch (ResourceLoadingException e) {
                MetadataLogger.LOG.catchingDebug(e);
                return null;
            }
        }
View Full Code Here


    }

    public void validateBeans() {
        BootstrapLogger.LOG.validatingBeans();
        for (BeanDeployment beanDeployment : getBeanDeployments()) {
            BeanManagerImpl beanManager = beanDeployment.getBeanManager();
            beanManager.getBeanResolver().clear();
            deployment.getServices().get(Validator.class).validateDeployment(beanManager, beanDeployment);
            beanManager.getServices().get(InjectionTargetService.class).validate();
        }
        getContainer().setState(ContainerState.VALIDATED);
        AfterDeploymentValidationImpl.fire(deploymentManager);
    }
View Full Code Here

        // is not kept around using up memory
        flushCaches();
        deploymentManager.getServices().cleanupAfterBoot();
        deploymentManager.cleanupAfterBoot();
        for (BeanDeployment beanDeployment : getBeanDeployments()) {
            BeanManagerImpl beanManager = beanDeployment.getBeanManager();
            beanManager.getInterceptorMetadataReader().cleanAfterBoot();
            beanManager.getServices().cleanupAfterBoot();
            beanManager.cleanupAfterBoot();
            // clean up beans
            for (Bean<?> bean : beanManager.getBeans()) {
                if (bean instanceof RIBean<?>) {
                    RIBean<?> riBean = (RIBean<?>) bean;
                    riBean.cleanupAfterBoot();
                }
            }
            // clean up decorators
            for (Decorator<?> decorator : beanManager.getDecorators()) {
                if (decorator instanceof DecoratorImpl<?>) {
                    Reflections.<DecoratorImpl<?>>cast(decorator).cleanupAfterBoot();
                }
            }
            // clean up interceptors
            for (Interceptor<?> interceptor : beanManager.getInterceptors()) {
                if (interceptor instanceof InterceptorImpl<?>) {
                    Reflections.<InterceptorImpl<?>>cast(interceptor).cleanupAfterBoot();
                }
            }
        }
View Full Code Here

        deploymentManager.getGlobalLenientObserverNotifier().clear();
        deploymentManager.getDecoratorResolver().clear();
        deploymentManager.getInterceptorResolver().clear();
        deploymentManager.getNameBasedResolver().clear();
        for (BeanDeployment beanDeployment : getBeanDeployments()) {
            BeanManagerImpl beanManager = beanDeployment.getBeanManager();
            beanManager.getBeanResolver().clear();
            beanManager.getAccessibleLenientObserverNotifier().clear();
            beanManager.getDecoratorResolver().clear();
            beanManager.getInterceptorResolver().clear();
            beanManager.getNameBasedResolver().clear();
        }
    }
View Full Code Here

        this.deploymentManager = deploymentManager;
        this.bdaToBeanManagerMap = bdaToBeanManagerMap;
    }

    public BeanManagerImpl getManager(BeanDeploymentArchive beanDeploymentArchive) {
        BeanManagerImpl beanManager = bdaToBeanManagerMap.get(beanDeploymentArchive);
        return beanManager == null ? null : beanManager.getCurrent();
    }
View Full Code Here

                soleCreatedTypeConstructor, injectionTarget,
                constructorInjection));
    }

    private SimpleInjectionTarget<T> createInjectionTargetWithoutValidation() {
        BeanManagerImpl bmi = (BeanManagerImpl) beanManager;
        return new SimpleInjectionTarget<T>(bmi.getServices().get(ClassTransformer.class).loadClass(createdType), bmi);
    }
View Full Code Here

            return context.proceed();
        }
    }

    protected InterceptorBindings getInterceptorBindings(String ejbName) {
        BeanManagerImpl beanManager = (BeanManagerImpl) this.beanManager;
        EjbServices ejbServices = beanManager.getServices().get(EjbServices.class);
        if (ejbServices instanceof ForwardingEjbServices) {
            ejbServices = ((ForwardingEjbServices) ejbServices).delegate();
        }
        InterceptorBindings interceptorBindings = null;
        if (ejbServices instanceof WeldEjbServices) {
View Full Code Here

    @Override
    public WeldInjectionHandle inject(Object instance) {
        final ClassLoader oldTCCL = SecurityActions.getContextClassLoader();
        try {
            SecurityActions.setContextClassLoader(classLoader);
            final BeanManagerImpl bm = beanManager.getValue();
            WeldInjectionHandle weldHandle = new WeldInjectionHandle();
            for (Injection injectionPoint :injectionPoints) {
                weldHandle.addAll(injectionPoint.inject(instance,bm));
            }
            return weldHandle;
View Full Code Here

    @Override
    public void start(StartContext context) throws StartException {
        final ClassLoader oldTCCL = SecurityActions.getContextClassLoader();
        try {
            SecurityActions.setContextClassLoader(classLoader);
            final BeanManagerImpl bm = beanManager.getValue();
            final ClassTransformer transformer = bm.getServices().get(ClassTransformer.class);
            final List<Injection> injectionPoints = new ArrayList<Injection>();
            //we do it this way to get changes introduced by extensions
            WeldClass<?> weldClass = transformer.loadClass(componentClass);
            for (AnnotatedField<?> field : weldClass.getFields()) {
                if (field.isAnnotationPresent(Inject.class)) {
                    final Set<Annotation> qualifiers = new HashSet<Annotation>();
                    for (Annotation annotation : field.getAnnotations()) {
                        if (bm.isQualifier(annotation.annotationType())) {
                            qualifiers.add(annotation);
                        }
                    }
                    FieldInjectionPoint ip = new FieldInjectionPoint(field, qualifiers);
                    Set<Bean<?>> beans = bm.getBeans(ip);
                    if (beans.size() > 1) {
                        throw new StartException("Error resolving CDI injection point " + field + " on " + componentClass + ". Injection points is ambiguous " + beans);
                    } else if (beans.isEmpty()) {
                        throw new StartException("Error resolving CDI injection point " + field + " on " + componentClass + ". No bean satisfies the injection point.");
                    }
                    Bean<?> bean = bm.resolve(beans);
                    injectionPoints.add(new CDIFieldInjection(field.getJavaMember(), bean, ip));
                }
            }
            //now look for @Inject methods
            for (AnnotatedMethod<?> method : weldClass.getMethods()) {
                if (method.isAnnotationPresent(Inject.class)) {
                    final List<Bean<?>> parameterBeans = new ArrayList<Bean<?>>();
                    final List<InjectionPoint> ips = new ArrayList<InjectionPoint>();
                    for (AnnotatedParameter<?> param : method.getParameters()) {
                        final Set<Annotation> qualifiers = new HashSet<Annotation>();
                        for (Annotation annotation : param.getAnnotations()) {
                            if (bm.isQualifier(annotation.annotationType())) {
                                qualifiers.add(annotation);
                            }
                        }
                        ParameterInjectionPoint ip = new ParameterInjectionPoint(param, qualifiers);
                        Set<Bean<?>> beans = bm.getBeans(ip);
                        if (beans.size() > 1) {
                            throw new StartException("Error resolving CDI injection point " + param + " on " + componentClass + ". Injection points is ambiguous " + beans);
                        } else if (beans.isEmpty()) {
                            throw new StartException("Error resolving CDI injection point " + param + " on " + componentClass + ". No bean satisfies the injection point.");
                        }
                        Bean<?> bean = bm.resolve(beans);
                        parameterBeans.add(bean);
                        ips.add(ip);
                    }
                    injectionPoints.add(new CDIMethodInjection(method.getJavaMember(), parameterBeans, ips));
                }
View Full Code Here

            return context.proceed();
        }
    }

    protected InterceptorBindings getInterceptorBindings(String ejbName) {
        BeanManagerImpl beanManager = (BeanManagerImpl) this.beanManager;
        EjbServices ejbServices = beanManager.getServices().get(EjbServices.class);
        if (ejbServices instanceof ForwardingEjbServices) {
            ejbServices = ((ForwardingEjbServices) ejbServices).delegate();
        }
        InterceptorBindings interceptorBindings = null;
        if (ejbServices instanceof WeldEjbServices) {
View Full Code Here

TOP

Related Classes of org.jboss.weld.manager.BeanManagerImpl

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.