Gets a bundle.  First tries to find one in the cache, then loads it if
it can't find one.
182761
private ResourceBundle getBundle() {
        String bundleKey = getBundleKey();
        if (bundles.containsKey(bundleKey)) {
            return bundles.get(bundleKey);
        } else {
            ResourceBundle bundle = loadBundle();
            bundles.put(bundleKey, bundle);
            return bundle;
        }
    }
1062646
protected function retrieveInstalledBundles()
    {
        $finder = new Finder();
        $autoloaders = $finder->files()->depth(0)->name('*.json')->in($this->autoloadersPath);
        foreach ($autoloaders as $autoloader) {
            $bundleName = strtolower(basename($autoloader->getFilename(), '.json'));
            $jsonAutoloader = new JsonAutoloader($bundleName, (string)$autoloader);
            $this->installedBundles[$bundleName] = $jsonAutoloader;
        }
    }
1231314
@Override
	public Bundle getBundle(String bundleName) {
		final String sourceMethod = "getBundle"; //$NON-NLS-1$
		boolean isTraceLogging = log.isLoggable(Level.FINER);
		if (isTraceLogging) {
			log.entering(FallbackBundleResolver.class.getName(), sourceMethod, new Object[]{bundleName});
		}
		Bundle result = Platform.getBundle(bundleName);
		if (isTraceLogging) {
			log.exiting(FallbackBundleResolver.class.getName(), sourceMethod, result);
		}
		return result;
	}
748967
protected ResourceBundle[] resolveBundles (HttpServletRequest req)
    {
        // first look to see if we've cached the bundles for this request in the request object
        ResourceBundle[] bundles = null;
        if (req != null) {
            bundles = (ResourceBundle[])req.getAttribute(getBundleCacheName());
        }
        if (bundles != null) {
            return bundles;
        }

        ClassLoader siteLoader = null;
        String siteString = null;
        if (_siteIdent != null) {
            int siteId = _siteIdent.identifySite(req);
            siteString = _siteIdent.getSiteString(siteId);

            // grab our site-specific class loader if we have one
            if (_siteLoader != null) {
                try {
                    siteLoader = _siteLoader.getSiteClassLoader(siteId);
                } catch (IOException ioe) {
                    log.warning("Unable to fetch site-specific classloader", "siteId", siteId,
                                "error", ioe);
                }
            }
        }

        // try looking up the appropriate bundles
        bundles = new ResourceBundle[2];

        // first from the site-specific classloader
        if (siteLoader != null) {
            bundles[0] = resolveBundle(req, _siteBundlePath, siteLoader, false);
        } else if (siteString != null) {
            // or just try prefixing the site string to the normal bundle path and see if that
            // turns something up
            bundles[0] = resolveBundle(req, siteString + "_" + _bundlePath,
                                       getClass().getClassLoader(), true);
        }

        // then from the default classloader
        bundles[1] = resolveBundle(req, _bundlePath, getClass().getClassLoader(), false);

        // if we found either or both bundles, cache 'em
        if (bundles[0] != null || bundles[1] != null && req != null) {
            req.setAttribute(getBundleCacheName(), bundles);
        }

        return bundles;
    }
863713
public static String get(String key, Object... args) {
        return get(BUNDLE_NAME, key, args);
    }
127523
def bundle(self):
        
        ca = self
        bundle = [ca]

        while ca.parent is not None:
            bundle.append(ca.parent)
            ca = ca.parent
        return bundle
465248
protected ResourceBundle resolveBundle (HttpServletRequest req, String bundlePath,
                                            ClassLoader loader, boolean silent)
    {
        ResourceBundle bundle = null;

        if (req != null) {
            Enumeration<?> locales = req.getLocales();
            while (locales.hasMoreElements()) {
                Locale locale = (Locale)locales.nextElement();

                try {
                    // java caches resource bundles, so we don't need to reinvent the wheel here.
                    // however, java also falls back from a specific bundle to a more general one
                    // if it can't find a specific bundle. that's real nice of it, but we want
                    // first to see whether or not we have exact matches on any of the preferred
                    // locales specified by the client. if we don't, then we can rely on java's
                    // fallback mechanisms
                    bundle = ResourceBundle.getBundle(bundlePath, locale, loader);

                    // if it's an exact match, off we go
                    if (bundle.getLocale().equals(locale)) {
                        break;
                    }

                } catch (MissingResourceException mre) {
                    // no need to freak out quite yet, see if we have something for one of the
                    // other preferred locales
                }
            }
        }

        // if we were unable to find an exact match for any of the user's preferred locales, take
        // their most preferred and let java perform it's fallback logic on that one
        if (bundle == null) {
            Locale locale = (req == null) ? _deflocale : req.getLocale();
            try {
                bundle = ResourceBundle.getBundle(bundlePath, locale, loader);
            } catch (MissingResourceException mre) {
                if (!silent) {
                    // if we were unable even to find a default bundle, we may want to log a
                    // warning
                    log.warning("Unable to resolve any message bundle", "req", getURL(req),
                                "locale", locale, "bundlePath", bundlePath, "classLoader", loader,
                                "siteBundlePath", _siteBundlePath, "siteLoader", _siteLoader);
                }
            }
        }

        return bundle;
    }
1050625
def bundle_dir():
    """"""
    if frozen():
        directory = sys._MEIPASS
    else:
        directory = os.path.dirname(os.path.abspath(stack()[1][1]))
    if os.path.exists(directory):
        return directory
87628
function (location, opts, callback) {
        resolve(location, function (err, fileUri) {
            if (err) {
                return callback(err)
            }

            bundle(fileUri, opts, callback)
        })
    }
1176681
@Override
    public Bundle getBundle() {
        return parent instanceof GatewayClassLoader ? ((GatewayClassLoader) parent).getBundle() : parent instanceof LibertyLoader ? ((LibertyLoader) parent).getBundle() : null;
    }
73034
private BundleContext getBundleContext(Bundle bundle, long timeout) {
        long endTime = System.currentTimeMillis() + timeout;
        BundleContext bc = null;
        while (bc == null) {
            bc = bundle.getBundleContext();
            if (bc == null) {
                if (System.currentTimeMillis() >= endTime) {
                    throw new TestContainerException(
                        "Unable to retrieve bundle context from bundle " + bundle);
                }
                try {
                    Thread.sleep(100);
                }
                catch (InterruptedException e) {
                    // Ignore
                }
            }
        }
        return bc;
    }
140934
def bundles():
    """"""
    per_page = int(request.args.get('per_page', 30))
    page = int(request.args.get('page', 1))
    query = store.bundles()

    query_page = query.paginate(page, per_page=per_page)
    data = []
    for bundle_obj in query_page.items:
        bundle_data = bundle_obj.to_dict()
        bundle_data['versions'] = [version.to_dict() for version in bundle_obj.versions]
        data.append(bundle_data)

    return jsonify(bundles=data)
1142247
@Override
    protected URL findResource(String name) {
        URL result = null;
        // Only check the parent bundle loader if the request is outside of "" or "/"
        if (!!!"".equals(name) && !!!"/".equals(name)) {
            // First try the bundleLoader
            result = bundleLoader.getResource(name);
        }
        // This doesn't have access to ALL split packages (it just gets one) so it's augmented with a resource provider  
        return result == null ? resourceProviders.findResource(name) : result;
    }
873598
public static function loadBundle(&$bundle)
    {
        if (sizeof($bundle->content) == 0) {
            return;
        }
        
        // check for cached, preloaded bundle
        $bundleCache = Cache::getInstance('MEMCACHE', 'APC', 'FILE_ENCODED');
        $bundleCachePath = "xqbundle/{$bundle->bundleId}";
        
        if (!DEBUG && ($bundleCache->available() && $bundleCache->hasCached($bundleCachePath))) {
            $bundle = $bundleCache->getCached($bundleCachePath);
            return;
        }
        
        // preload
        $bundle->lastModified = null;
        $bundle->files = array();
        
        $fileNames = array();
        foreach ($bundle->content as $file) {
            $preloaded = self::getBundleFileDetails($bundle, $file);
            
            $bundle->files[] = $preloaded;
            $fileNames[] = $preloaded->path;
        }
        
        $bundle->contentType = self::getBundleContentType($bundle);
        $bundle->tag = md5($bundle->lastModified . $bundle->bundleId . implode('-', $fileNames));
        
        $bundle->output = self::getBundleContent($bundle);
        
        if (!DEBUG && $bundleCache->available()) {
            $bundleCache->cache($bundleCachePath, $bundle);
        }
    }
400482
public static IPath getBundlePath(Bundle bundle) {
		IPath path = getBinFolderPath(bundle);
		if (path == null) {
			// common jar file case, no bin folder
			try {
				path = new Path(FileLocator.getBundleFile(bundle).getAbsolutePath());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return path;
	}
694409
public function getBundle($name)
    {
        $bundle = null;
        if ($this->getContainer()->has('bundle.'.$name)) {
            $bundle = $this->getContainer()->get('bundle.'.$name);
        }

        return $bundle;
    }
977216
public static String get(String bundleName, String key, Object[] args) {
        return get(bundleName, getLocale(), key, args);
    }