Scans bundle manifest for matches against configured manifest headers.

@param bundle bundle to be scanned

@return list of matching manifest entries

@see BundleScanner#scan(Bundle)
501861
public List<ManifestEntry> scan( final Bundle bundle )
    {
        NullArgumentException.validateNotNull( bundle, "Bundle" );

        final Dictionary bundleHeaders = bundle.getHeaders();
        if( bundleHeaders != null && !bundleHeaders.isEmpty() )
        {
            return asManifestEntryList( m_manifestFilter.match( dictionaryToMap( bundleHeaders ) ) );
        }
        else
        {
            return Collections.emptyList();
        }
    }
998199
private Map<String, String> getBundleMap() {

        Map<String, String> bundles = new HashMap<String, String>();

        if (m_bundleComponentKeyMap != null) {
            Set<TextField> fields = m_bundleComponentKeyMap.keySet();

            for (TextField field : fields) {
                bundles.put(m_bundleComponentKeyMap.get(field), field.getValue());
            }
        }
        return bundles;
    }
253937
static private String getRequiredBundles(File file) throws IOException {
        JarFile jar = new JarFile(file);
        Attributes attr = jar.getManifest().getMainAttributes();
        jar.close();
        return attr.getValue("Require-Bundle");
    }
1222418
protected void processBundle(Bundle bundle) {
        Properties props = readMessageRouterProps(bundle);

        if (props != null) {
            msgRouter.modified(props);
        }
    }
669696
private static void addEntries(Bundle bundle, String path,
			String filePattern, List<URL> pathList) {
		Enumeration<?> e = bundle.findEntries(path, filePattern, false);
		while (e != null && e.hasMoreElements()) {
			URL u = (URL) e.nextElement();
			pathList.add(u);
		}
	}
741698
private static List<URL> parsePaths(List<PathElement> paths, Bundle bundle) {
		List<URL> pathList = new ArrayList<URL>();
		for (PathElement path : paths) {
			String name = path.getName();
			if (name.endsWith("/")) {
				// we have a directory
				addEntries(bundle, name, "*.*", pathList);
			} else {
				// we have a file name
				String baseName;
				String filePattern;
				int pos = name.lastIndexOf('/');
				if (pos < 0) {
					baseName = "/";
					filePattern = name;
				} else {
					baseName = name.substring(0, pos + 1);
					filePattern = name.substring(pos + 1);
				}
				if (hasWildcards(filePattern)) {
					addEntries(bundle, baseName, filePattern, pathList);
				} else {
					pathList.add(bundle.getEntry(name));
				}
			}
		}
		return pathList;
	}
1250784
private JoinableResourceBundle getBundleFromName(String name, List<JoinableResourceBundle> bundles) {

		JoinableResourceBundle bundle = null;
		for (JoinableResourceBundle aBundle : bundles) {
			if (aBundle.getName().equals(name)) {
				bundle = aBundle;
				break;
			}
		}

		return bundle;
	}
416720
@Override
	public void processBundles(GlobalPreprocessingContext ctx, List<JoinableResourceBundle> bundles) {

		ResourceReaderHandler rsHandler = ctx.getRsReaderHandler();

		Set<String> resourcePaths = getResourcePaths(bundles);
		JawrConfig jawrConfig = ctx.getJawrConfig();
		Charset charset = jawrConfig.getResourceCharset();

		BinaryResourcesHandler binaryRsHandler = (BinaryResourcesHandler) jawrConfig.getContext()
				.getAttribute(JawrConstant.BINARY_CONTEXT_ATTRIBUTE);

		generateSprites(rsHandler, binaryRsHandler, resourcePaths, jawrConfig, charset);

		// Update CSS resource handler
		CssSmartSpritesResourceReader cssSpriteResourceReader = new CssSmartSpritesResourceReader(
				rsHandler.getWorkingDirectory(), jawrConfig);

		updateBundlesDirtyState(bundles, cssSpriteResourceReader);

		ctx.getRsReaderHandler().addResourceReader(cssSpriteResourceReader);

		// Update image resource handler
		ResourceReaderHandler imgStreamRsHandler = binaryRsHandler.getRsReaderHandler();
		imgStreamRsHandler.addResourceReader(cssSpriteResourceReader);
	}
1234449
@Override
	public void processBundles(T ctx, List<JoinableResourceBundle> bundles) {
		globalPreprocessor.processBundles(ctx, bundles);
	}
77781
@Override
    public Collection<Bundle> getBundles() {
        if (mfDetails == null)
            throw new IllegalStateException("Method called outside of provisioining operation or without a registered service");

        Collection<Bundle> bundles = featureBundles.get();

        if (bundles == null) {
            bundles = new ArrayList<Bundle>();

            Collection<FeatureResource> bundlesInFeature = mfDetails.getConstituents(SubsystemContentType.BUNDLE_TYPE);

            BundleContext ctx = FrameworkUtil.getBundle(FrameworkUtil.class).getBundleContext();

            // symbolic name to bundle map. 
            for (FeatureResource bundle : bundlesInFeature) {
                String location = bundle.getLocation();
                Bundle b = ctx.getBundle(location);
                if (b != null) {
                    bundles.add(b);
                }
            }

            // make an unmodifiable version.
            bundles = Collections.unmodifiableCollection(bundles);

            // store it away if it hasn't already been read. If this is read by another
            // thread at once then this thread will get this collection, and others will
            // the winner's.
            featureBundles.compareAndSet(null, bundles);
        }

        return bundles;
    }
1297905
public static Component scan(Component root, ScannerMatcher matcher) {
        if (matcher.matches(root)) return root;
        if (!(root instanceof Container)) return null;
        Container container = (Container) root;
        for (Component component : container.getComponents()) {
            Component found = scan(component, matcher);
            if (found != null) return found;
        }
        return null;
    }
1096193
private void register( final Bundle bundle )
    {
        LOG.debug( "Scanning bundle [" + bundle.getSymbolicName() + "]" );
        final List<T> resources = m_scanner.scan( bundle );
        m_mappings.put( bundle, resources );
        if( resources != null && resources.size() > 0 )
        {
            LOG.debug( "Found resources " + resources );
		            for( final BundleObserver<T> observer : m_observers )
		            {
		                try
		                {
		                	//here the executor service completes the job in an extra thread. 
		                	executorService.submit(new Runnable() {
		                		public void run() {
		                		    try 
		                		    {
		                		        observer.addingEntries( bundle, Collections.unmodifiableList( resources ) );
		                		    }
		                		    catch (Throwable t)
		                		    {
		                		        LOG.error( "Exception in executor thread", t );
		                		    }
		                		}
		                	});
		                }
		                catch( Throwable ignore )
		                {
		                    LOG.error( "Ignored exception during register", ignore );
		                }
		            }
        }
    }
407518
public void scanJars() throws IOException {

        ClassLoader webappLoader = Thread.currentThread().getContextClassLoader();

        ClassLoader parentLoader = webappLoader.getParent();

        ResourceDelegatingBundleClassLoader classLoader = null;
        if (webappLoader instanceof ResourceDelegatingBundleClassLoader) {
            classLoader = (ResourceDelegatingBundleClassLoader) webappLoader;
        } else if (parentLoader instanceof ResourceDelegatingBundleClassLoader) {
            classLoader = (ResourceDelegatingBundleClassLoader) parentLoader;
        } else if (isTomcatWebLoader()) {
            ClassLoader parent = ((org.apache.catalina.loader.WebappClassLoader) webappLoader).getParent();
            if (parent instanceof ResourceDelegatingBundleClassLoader) {
                classLoader = (ResourceDelegatingBundleClassLoader) parent;
            }
        }

        List<Bundle> bundles = classLoader == null ? Collections.<Bundle>emptyList() : classLoader.getBundles();
        for (Bundle bundle : bundles) {
            Collection<Enumeration<URL>> enumerations;
            BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
            if (bundleWiring == null) {
                Enumeration<URL> urls = bundle.findEntries("META-INF", "*.tld", true);
                enumerations = Collections.singleton(urls);
            } else {
                Collection<String> resources = bundleWiring.listResources("META-INF", "*.tld",
                        BundleWiring.LISTRESOURCES_RECURSE);
                enumerations = new ArrayList<>(resources.size());
                for (String resource : resources) {
                    Enumeration<URL> urls = bundle.getResources(resource);
                    enumerations.add(urls);
                }
            }
            for (Enumeration<URL> urls : enumerations) {
                if (urls != null) {
                    while (urls.hasMoreElements()) {
                        URL url = urls.nextElement();
                        LOG.info("found TLD {}", url);
                        TldResourcePath tldResourcePath = new TldResourcePath(url, null, null);
                        try {
                            parseTld(tldResourcePath);
                        } catch (SAXException e) {
                            throw new IOException(e);
                        }
                    }
                }
            }
        }
    }
1230107
public static List<String> scanAsList(final Class<? extends Annotation> clas, final String... basePackage) {
		final List<String> classes = new ArrayList<>();
		scan(clas, basePackage, new AnnotationHandler() {

			@Override
			public void handleAnnotationFound(String className) {
				classes.add(className);
			}
		});
		return classes;
	}
676357
public java.util.List<String> getBundleIds() {
        if (bundleIds == null) {
            bundleIds = new com.amazonaws.internal.SdkInternalList<String>();
        }
        return bundleIds;
    }
737187
public static function load(BundleInterface $bundle)
    {
        if (is_dir($bundle->getPath())) {
            self::$bundlesLoaded[$bundle->getName()] = [
                'namespace' => $bundle->getNamespace(),
                'path' => $bundle->getPath()
            ];

            if (!self::$classLoader) {
                self::$classLoader = new ClassLoader();
            }

            self::$classLoader->addPsr4($bundle->getNamespace(), $bundle->getPath());
            self::$classLoader->register();
        } else {
            throw new MissingBundleException(sprintf('Bundle "%s" could not be found.', $bundle->getName()));
        }
    }
1177441
public List<String> scan() {
        try {
            JarFile jar = new JarFile(jarURL.getFile());
            try {
                List<String> result = new ArrayList<>();
                Enumeration<JarEntry> en = jar.entries();
                while (en.hasMoreElements()) {
                    JarEntry entry = en.nextElement();
                    String path = entry.getName();
                    boolean match = includes.size() == 0;
                    if (!match) {
                        for (String pattern : includes) {
                            if ( patternMatches(pattern, path)) {
                                match = true;
                                break;
                            }
                        }
                    }
                    if (match) {
                        for (String pattern : excludes) {
                            if ( patternMatches(pattern, path)) {
                                match = false;
                                break;
                            }
                        }
                    }
                    if (match) {
                        result.add(path);
                    }
                }
                return result;
            } finally {
                jar.close();
            }
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    }