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 static org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue;
 
 import java.util.List;
 import java.util.Set;
 
 
 
BeanDeployer that processes some of the deployment tasks in parallel. A threadsafe instance of org.jboss.weld.bootstrap.BeanDeployerEnvironment is used.

Author(s):
Jozef Hartinger
 
 public class ConcurrentBeanDeployer extends BeanDeployer {
 
     private final ExecutorServices executor;
 
     public ConcurrentBeanDeployer(BeanManagerImpl managerEjbDescriptors ejbDescriptorsServiceRegistry services) {
         super(managerejbDescriptorsservices, BeanDeployerEnvironmentFactory.newConcurrentEnvironment(ejbDescriptorsmanager));
         this. = services.get(ExecutorServices.class);
     }
 
     @Override
     public BeanDeployer addClasses(Iterable<Stringc) {
         final AnnotatedTypeLoader loader = createAnnotatedTypeLoader();
             @Override
             protected void doWork(String className) {
                 addClass(classNameloader);
             }
         });
         return this;
     }
 
     @Override
     public void createClassBeans() {
         final LoadingCache<Class<?>, Set<SlimAnnotatedType<?>>> otherWeldClasses = Multimaps.newConcurrentSetMultimap();
 
             @Override
             protected void doWork(SlimAnnotatedTypeContext<?> ctx) {
                 createClassBean(ctx.getAnnotatedType(), otherWeldClasses);
             }
         });
 
             @Override
             protected void doWork(InternalEjbDescriptor<?> descriptor) {
                 if (!getEnvironment().isVetoed(descriptor.getBeanClass()) && !Beans.isVetoed(descriptor.getBeanClass())) {
                     if (descriptor.isSingleton() || descriptor.isStateful() || descriptor.isStateless()) {
                         if (otherWeldClasses.getIfPresent(descriptor.getBeanClass()) != null) {
                             for (SlimAnnotatedType<?> annotatedType : getCacheValue(otherWeldClassesdescriptor.getBeanClass())) {
                                 EnhancedAnnotatedType<?> weldClass = .getEnhancedAnnotatedType(annotatedType);
                                 createSessionBean(descriptor, Reflections.<EnhancedAnnotatedTypecast(weldClass));
                             }
                         } else {
                             createSessionBean(descriptor);
                         }
                     }
                 }
             }
         });
     }
    @Override
    public void createProducersAndObservers() {
            @Override
            protected void doWork(AbstractClassBean<?> bean) {
                createObserversProducersDisposers(bean);
            }
        });
    }
    @Override
    public void doAfterBeanDiscovery(List<? extends Bean<?>> beanList) {
    }
    @Override
            @Override
            protected void doWork(RIBean<?> bean) {
                bean.initialize(getEnvironment());
            }
        });
        return this;
    }
    private static class AfterBeanDiscoveryInitializerFactory extends IterativeWorkerTaskFactory<Bean<?>> {
        public AfterBeanDiscoveryInitializerFactory(Iterable<? extends Bean<?>> iterable) {
            super(iterable);
        }
        @Override
        protected void doWork(Bean<?> bean) {
            if (bean instanceof RIBean<?>) {
                ((RIBean<?>) bean).initializeAfterBeanDiscovery();
            }
        }
    }
New to GrepCode? Check out our FAQ X