org.osgi.framework.Bundle#getEntryPaths ( )源码实例Demo

下面列出了org.osgi.framework.Bundle#getEntryPaths ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: packagedrone   文件: JspBundleCustomizer.java
@Override
public JspBundle addingBundle ( final Bundle bundle, final BundleEvent event )
{
    final Enumeration<String> result = bundle.getEntryPaths ( "/WEB-INF" );
    if ( result != null && result.hasMoreElements () )
    {
        try
        {
            return new JspBundle ( bundle, this.service, this.context );
        }
        catch ( ServletException | NamespaceException e )
        {
            logger.warn ( "Failed to register JSP bundle: " + bundle.getSymbolicName (), e );
            return null;
        }
    }

    return null;
}
 
源代码2 项目: packagedrone   文件: TagLibTracker.java
private boolean fillFromPlainBundle ( final Bundle bundle, final Map<String, URL> tlds )
{
    boolean added = false;

    final Enumeration<String> paths = bundle.getEntryPaths ( "/META-INF/" );
    while ( paths.hasMoreElements () )
    {
        final String name = paths.nextElement ();
        if ( name.endsWith ( ".tld" ) )
        {
            final String key = makeKey ( name );
            final URL entry = bundle.getEntry ( name );
            if ( entry != null )
            {
                logger.debug ( "Add plain mapping {} -> {} / {}", key, name, entry );
                tlds.put ( key, entry );
                added = true;
            }
        }
    }

    return added;
}
 
源代码3 项目: incubator-tamaya   文件: OSGIServiceLoader.java
private void checkAndUnloadBundle(Bundle bundle) {
    if (bundle.getEntry(META_INF_SERVICES) == null) {
        return;
    }
    synchronized (resourceBundles) {
        resourceBundles.remove(bundle);
        LOG.fine("Unregistered ServiceLoader bundle: " + bundle.getSymbolicName());
    }
    Enumeration<String> entryPaths = bundle.getEntryPaths(META_INF_SERVICES);
    while (entryPaths.hasMoreElements()) {
        String entryPath = entryPaths.nextElement();
        if (!entryPath.endsWith("/")) {
            removeEntryPath(bundle, entryPath);
        }
    }
}
 
源代码4 项目: incubator-tamaya   文件: OSGIServiceLoader.java
private void checkAndLoadBundle(Bundle bundle) {
    if (bundle.getEntry(META_INF_SERVICES) == null) {
        return;
    }
    synchronized (resourceBundles) {
        resourceBundles.add(bundle);
        LOG.info("Registered ServiceLoader bundle: " + bundle.getSymbolicName());
    }
    Enumeration<String> entryPaths = bundle.getEntryPaths(META_INF_SERVICES);
    while (entryPaths.hasMoreElements()) {
        String entryPath = entryPaths.nextElement();
        if (!entryPath.endsWith("/")) {
            processEntryPath(bundle, entryPath);
        }
    }
}
 
源代码5 项目: spotbugs   文件: JavaProjectHelper.java
/**
 * Imports resources from <code>bundleSourcePath</code> to
 * <code>importTarget</code>.
 *
 * @param importTarget
 *            the parent container
 * @param bundleSourcePath
 *            the path to a folder containing resources
 *
 * @throws CoreException
 *             import failed
 * @throws IOException
 *             import failed
 */
public static void importResources(IContainer importTarget, Bundle bundle, String bundleSourcePath) throws CoreException,
        IOException {
    Enumeration<?> entryPaths = bundle.getEntryPaths(bundleSourcePath);
    while (entryPaths.hasMoreElements()) {
        String path = (String) entryPaths.nextElement();
        IPath name = new Path(path.substring(bundleSourcePath.length()));
        if (path.endsWith("/.svn/")) {
            continue; // Ignore SVN folders
        } else if (path.endsWith("/")) {
            IFolder folder = importTarget.getFolder(name);
            if (folder.exists()) {
                folder.delete(true, null);
            }
            folder.create(true, true, null);
            importResources(folder, bundle, path);
        } else {
            URL url = bundle.getEntry(path);
            IFile file = importTarget.getFile(name);
            if (!file.exists()) {
                file.create(url.openStream(), true, null);
            } else {
                file.setContents(url.openStream(), true, false, null);
            }
        }
    }
}
 
源代码6 项目: birt   文件: DataSetProvider.java
/**
 * Return the URLs of ScriptLib jars.
 * 
 * @return
 */
private static List<URL> getDefaultViewerScriptLibURLs( )
{
	List<URL> urls = new ArrayList<URL>( );
	try
	{
		Bundle bundle = Platform.getBundle( VIEWER_NAMESPACE );

		// Prepare ScriptLib location
		Enumeration bundleFile = bundle.getEntryPaths( BIRT_SCRIPTLIB );
		while ( bundleFile.hasMoreElements( ) )
		{
			String o = bundleFile.nextElement( ).toString( );
			if ( o.endsWith( ".jar" ) )
				urls.add( bundle.getResource( o ) );
		}
		URL classes = bundle.getEntry( BIRT_CLASSES );
		if ( classes != null )
		{
			urls.add( classes );
		}
	}
	catch ( Exception e )
	{

	}
	return urls;
}
 
源代码7 项目: wisdom   文件: ExtenderUtils.java
public static List<I18nExtension> analyze(String path, Bundle bundle) {
    List<I18nExtension> list = new ArrayList<>();
    Enumeration<String> paths = bundle.getEntryPaths(path);
    if (paths != null) {
        while (paths.hasMoreElements()) {
            String entry = paths.nextElement();
            if (! entry.endsWith("/")) {
                // It's a file, as entries ending with / are directories.
                String file = entry.substring(path.length() - 1);
                Locale locale = getLocaleFromResourceName(file);
                URL url = bundle.getEntry(entry);
                if (url != null) {
                    I18nExtension extension = new I18nExtension(url, locale, bundle);
                    try {
                        extension.load();
                        list.add(extension);
                    } catch (IOException e) {
                        LOGGER.error("Cannot load resource bundle from " + path + " within " + bundle.getSymbolicName(), e);
                    }
                } else {
                    LOGGER.error("Cannot open " + entry + " from " + bundle.getSymbolicName());
                }
            }
        }
    }
    return list;
}
 
/**
 * This method is used to check if the specified {@code Bundle} contains resource files providing automation
 * resources.
 *
 * @param bundle is a {@link Bundle} object to check.
 * @return <tt>true</tt> if the specified {@link Bundle} contains resource files providing automation
 *         resources, <tt>false</tt> otherwise.
 */
private boolean isAnAutomationProvider(Bundle bundle) {
    return bundle.getEntryPaths(AbstractResourceBundleProvider.ROOT_DIRECTORY) != null;
}
 
/**
 * This method is used to check if the specified {@code Bundle} contains resource files providing automation
 * resources.
 *
 * @param bundle is a {@link Bundle} object to check.
 * @return <tt>true</tt> if the specified {@link Bundle} contains resource files providing automation
 *         resources, <tt>false</tt> otherwise.
 */
private boolean isAnAutomationProvider(Bundle bundle) {
    return bundle.getEntryPaths(AbstractResourceBundleProvider.ROOT_DIRECTORY) != null;
}