Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2010, Red Hat, Inc., and individual contributors
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.jboss.weld.bootstrap;
 
 import java.util.List;
 import java.util.Set;
 
 
 
Processes validation of beans, decorators and interceptors in parallel.

Author(s):
Jozef Hartinger
 
 public class ConcurrentValidator extends Validator {
 
     private final ExecutorServices executor;
 
     public ConcurrentValidator(ExecutorServices executor) {
         this. = executor;
     }
 
     @Override
     public void validateBeans(Collection<? extends Bean<?>> beansfinal BeanManagerImpl manager) {
         final List<RuntimeExceptionproblems = new CopyOnWriteArrayList<RuntimeException>();
         final Set<CommonBean<?>> specializedBeans = Sets.newSetFromMap(new ConcurrentHashMap<CommonBean<?>, Boolean>());
 
             protected void doWork(Bean<?> bean) {
                 validateBean(beanspecializedBeansmanagerproblems);
             }
         });
 
         if (!problems.isEmpty()) {
             if (problems.size() == 1) {
                 throw problems.get(0);
             } else {
                 throw new DeploymentException(problems);
             }
         }
     }
 
     @Override
     public void validateInterceptors(Collection<? extends Interceptor<?>> interceptorsfinal BeanManagerImpl manager) {
             protected void doWork(Interceptor<?> interceptor) {
                 validateInterceptor(interceptormanager);
             }
         });
     }
 
     @Override
     public void validateDecorators(Collection<? extends Decorator<?>> decoratorsfinal BeanManagerImpl manager) {
         final Set<CommonBean<?>> specializedBeans = Sets.newSetFromMap(new ConcurrentHashMap<CommonBean<?>, Boolean>());
 
             protected void doWork(Decorator<?> decorator) {
                 validateDecorator(decoratorspecializedBeansmanager);
             }
         });
     }
    @Override
    protected void validateObserverMethods(Iterable<ObserverInitializationContext<?, ?>> observersfinal BeanManagerImpl beanManager) {
            protected void doWork(ObserverInitializationContext<?, ?> observerMethod) {
                for (InjectionPoint ip : observerMethod.getObserver().getInjectionPoints()) {
                    validateInjectionPointForDefinitionErrors(ipip.getBean(), beanManager);
                    validateMetadataInjectionPoint(ipnull.);
                    validateInjectionPointForDeploymentProblems(ipip.getBean(), beanManager);
                }
            }
        });
    }
    @Override
    public void validateBeanNames(final BeanManagerImpl beanManager) {
        final SetMultimap<StringBean<?>> namedAccessibleBeans = Multimaps.newSetMultimap(new HashMap<StringCollection<Bean<?>>>(), HashSetSupplier.<Bean<?>> instance());
        for (Bean<?> bean : beanManager.getAccessibleBeans()) {
            if (bean.getName() != null) {
                namedAccessibleBeans.put(bean.getName(), bean);
            }
        }
        final List<StringaccessibleNamespaces = new ArrayList<String>();
        for (String namespace : beanManager.getAccessibleNamespaces()) {
            accessibleNamespaces.add(namespace);
        }
        final SpecializationAndEnablementRegistry registry = beanManager.getServices().get(SpecializationAndEnablementRegistry.class);
        .invokeAllAndCheckForExceptions(new IterativeWorkerTaskFactory<String>(namedAccessibleBeans.keySet()) {
            protected void doWork(String name) {
                Set<Bean<?>> resolvedBeans = beanManager.getBeanResolver().<Object>resolve(Beans.removeDisabledBeans(namedAccessibleBeans.get(name), beanManagerregistry));
                if (resolvedBeans.size() > 1) {
                    throw ..ambiguousElName(name, WeldCollections.toMultiRowString(resolvedBeans));
                }
                if (accessibleNamespaces.contains(name)) {
                    throw ..beanNameIsPrefix(name);
                }
            }
        });
    }
    @Override
    public void validateProducers(Collection<Producer<?>> producersfinal BeanManagerImpl beanManager) {
            protected void doWork(Producer<?> producer) {
                validateProducer(producerbeanManager);
            }
        });
    }
New to GrepCode? Check out our FAQ X