Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2014, Red Hat, Inc. and/or its affiliates, 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.environment.deployment.discovery;
 
 import java.util.List;
 import java.util.Set;
 

Author(s):
Matej Briškár
Martin Kouba
Jozef Hartinger
 
 public abstract class AbstractDiscoveryStrategy implements DiscoveryStrategy {
 
     private static final Logger log = Logger.getLogger(AbstractDiscoveryStrategy.class);
 
     protected final ResourceLoader resourceLoader;
 
     protected final Bootstrap bootstrap;
 
     protected final Set<Class<? extends Annotation>> initialBeanDefiningAnnotations;
 
     protected BeanArchiveScanner scanner;
 
     private final List<BeanArchiveHandlerhandlers;

    

Parameters:
resourceLoader
bootstrap
initialBeanDefiningAnnotations
 
     public AbstractDiscoveryStrategy(ResourceLoader resourceLoaderBootstrap bootstrapSet<Class<? extends Annotation>> initialBeanDefiningAnnotations) {
         this. = resourceLoader;
         this. = bootstrap;
         this. = new LinkedList<BeanArchiveHandler>();
         this. = initialBeanDefiningAnnotations;
     }
 
     @Override
     public void setScanner(BeanArchiveScanner scanner) {
         this. = scanner;
     }
 
     @Override
 
         if ( == null) {
              = new DefaultBeanArchiveScanner();
         }
 
         final Collection<BeanArchiveBuilderbeanArchiveBuilders = new ArrayList<BeanArchiveBuilder>();
         for (ScanResult scanResult : .scan().values()) {
             final String ref = scanResult.getBeanArchiveRef();
             BeanArchiveBuilder builder = null;
             for (BeanArchiveHandler handler : ) {
                 builder = handler.handle(ref);
                 if (builder != null) {
                     builder.setId(ref);
                     builder.setBeansXml(scanResult.getBeansXml());
                     beanArchiveBuilders.add(builder);
                     break;
                 }
             }
             if (builder == null) {
                 .warnv("The bean archive reference {0} cannot be handled by any BeanArchiveHandler: {1}"ref);
             }
         }
 
        beforeDiscovery(beanArchiveBuilders);
        Set<WeldBeanDeploymentArchivearchives = new HashSet<WeldBeanDeploymentArchive>();
        for (BeanArchiveBuilder builder : beanArchiveBuilders) {
            BeansXml beansXml = builder.getBeansXml();
            switch (beansXml.getBeanDiscoveryMode()) {
                case :
                    addToArchives(archivesprocessAllDiscovery(builder));
                    break;
                case :
                    addToArchives(archivesprocessAnnotatedDiscovery(builder));
                    break;
                case :
                    addToArchives(archivesprocessNoneDiscovery(builder));
                    break;
                default:
                    ..undefinedBeanDiscoveryValue(beansXml.getBeanDiscoveryMode());
            }
        }
        afterDiscovery(archives);
        return archives;
    }
    @Override
        // By default no bytecode scanning facility available
        return null;
    }
    protected void assignVisibility(Set<WeldBeanDeploymentArchivedeploymentArchives) {
        // By default bean archives see each other
        for (WeldBeanDeploymentArchive archive : deploymentArchives) {
            archive.setAccessibleBeanDeploymentArchives(deploymentArchives);
        }
    }
    protected void addToArchives(Set<WeldBeanDeploymentArchivedeploymentArchivesWeldBeanDeploymentArchive bda) {
        if (bda != null) {
            deploymentArchives.add(bda);
        }
    }

    
Initialize the strategy before accessing found BeanArchiveBuilder builders. Best used for saving some information before the process method for each builder is called.
    protected void beforeDiscovery(Collection<BeanArchiveBuilderbuilders) {
        // No-op
    }
    protected void afterDiscovery(Set<WeldBeanDeploymentArchivearchives) {
        assignVisibility(archives);
    }

    
Process the bean archive with bean-discovery-mode of none. The archive is ignored by default.
        return null;
    }

    
Process the bean archive with bean-discovery-mode of annotated.
        throw new UnsupportedOperationException();
    }

    
Process the bean archive with bean-discovery-mode of all.
        return builder.build();
    }
    public ResourceLoader getResourceLoader() {
        return ;
    }
    @Override
    public void registerHandler(BeanArchiveHandler handler) {
        .add(handler);
    }
New to GrepCode? Check out our FAQ X