Java Code Examples for org.osgi.framework.Bundle#getEntryPaths()
The following examples show how to use
org.osgi.framework.Bundle#getEntryPaths() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JspBundleCustomizer.java From packagedrone with Eclipse Public License 1.0 | 6 votes |
@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; }
Example 2
Source File: TagLibTracker.java From packagedrone with Eclipse Public License 1.0 | 6 votes |
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; }
Example 3
Source File: OSGIServiceLoader.java From incubator-tamaya with Apache License 2.0 | 6 votes |
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); } } }
Example 4
Source File: OSGIServiceLoader.java From incubator-tamaya with Apache License 2.0 | 6 votes |
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); } } }
Example 5
Source File: JavaProjectHelper.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
/** * 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); } } } }
Example 6
Source File: DataSetProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * 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; }
Example 7
Source File: ExtenderUtils.java From wisdom with Apache License 2.0 | 5 votes |
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; }
Example 8
Source File: AutomationResourceBundlesTracker.java From openhab-core with Eclipse Public License 2.0 | 2 votes |
/** * 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; }
Example 9
Source File: AutomationResourceBundlesTracker.java From smarthome with Eclipse Public License 2.0 | 2 votes |
/** * 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; }