Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2008, 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.reflection.Reflections.cast;
 
 import java.util.Set;
 
 

Author(s):
pmuir
 
 public class ExtensionBeanDeployer {
 
     private final BeanManagerImpl beanManager;
     private final Set<Metadata<Extension>> extensions;
     private final Deployment deployment;
     private final BeanDeploymentArchiveMapping bdaMapping;
     private final Collection<ContextHolder<? extends Context>> contexts;
 
     public ExtensionBeanDeployer(BeanManagerImpl managerDeployment deploymentBeanDeploymentArchiveMapping bdaMapping,
             Collection<ContextHolder<? extends Context>> contexts) {
         this. = manager;
         this. = new HashSet<Metadata<Extension>>();
         this. = deployment;
         this. = bdaMapping;
         this. = contexts;
     }
 
     public ExtensionBeanDeployer deployBeans() {
         ClassTransformer classTransformer = .getServices().get(ClassTransformer.class);
         for (Metadata<Extensionextension : ) {
             // Locate the BeanDeployment for this extension
             BeanDeployment beanDeployment = DeploymentStructures.getOrCreateBeanDeployment(extension.getValue()
                     .getClass());
 
             EnhancedAnnotatedType<ExtensionenchancedAnnotatedType = getEnhancedAnnotatedType(classTransformerextensionbeanDeployment);
 
             if (enchancedAnnotatedType != null) {
                 ExtensionBean bean = new ExtensionBean(beanDeployment.getBeanManager(), enchancedAnnotatedTypeextension);
                 Set<ObserverInitializationContext<?, ?>> observerMethodInitializers = new HashSet<ObserverInitializationContext<?, ?>>();
                 createObserverMethods(beanbeanDeployment.getBeanManager(), enchancedAnnotatedTypeobserverMethodInitializers);
                 beanDeployment.getBeanManager().addBean(bean);
                 beanDeployment.getBeanDeployer().addExtension(bean);
                 for (ObserverInitializationContext<?, ?> observerMethodInitializer : observerMethodInitializers) {
                     observerMethodInitializer.initialize();
                     beanDeployment.getBeanManager().addObserver(observerMethodInitializer.getObserver());
                     .processObserverMethod(observerMethodInitializer.getObserver());
                 }
             }
         }
         return this;
     }
 
             BeanDeployment beanDeployment) {
         Class<? extends Extensionclazz = extension.getValue().getClass();
         try {
             return cast(classTransformer.getEnhancedAnnotatedType(clazzbeanDeployment.getBeanDeploymentArchive().getId()));
         } catch (ResourceLoadingException e) {
            String missingDependency = Formats.getNameOfMissingClassLoaderDependency(e);
            ..ignoringExtensionClassDueToLoadingError(clazz.getName(), missingDependency);
            ..catchingDebug(e);
            .registerClassWithMissingDependency(clazz.getName(), missingDependency);
            return null;
        }
    }
    public void addExtensions(Iterable<Metadata<Extension>> extensions) {
        for (Metadata<Extensionextension : extensions) {
            addExtension(extension);
        }
    }
    public void addExtension(Metadata<Extensionextension) {
        this..add(extension);
    }
    protected <X> void createObserverMethods(RIBean<X> declaringBeanBeanManagerImpl beanManagerEnhancedAnnotatedType<? super X> annotatedClass,
            Set<ObserverInitializationContext<?, ?>> observerMethodInitializers) {
        for (EnhancedAnnotatedMethod<?, ? super X> method : BeanMethods.getObserverMethods(annotatedClass)) {
            createObserverMethod(declaringBeanbeanManagermethodobserverMethodInitializers);
        }
    }
    protected <T, X> void createObserverMethod(RIBean<X> declaringBeanBeanManagerImpl beanManagerEnhancedAnnotatedMethod<T, ? super X> method,
            Set<ObserverInitializationContext<?, ?>> observerMethodInitializers) {
        ObserverMethodImpl<T, X> observer = ObserverFactory.create(methoddeclaringBeanbeanManager);
        ObserverInitializationContext<T, X> observerMethodInitializer = ObserverInitializationContext.of(observermethod);
        observerMethodInitializers.add(observerMethodInitializer);
    }
New to GrepCode? Check out our FAQ X