當前位置: 首頁>>代碼示例>>Java>>正文


Java Bundle.getEntry方法代碼示例

本文整理匯總了Java中org.osgi.framework.Bundle.getEntry方法的典型用法代碼示例。如果您正苦於以下問題:Java Bundle.getEntry方法的具體用法?Java Bundle.getEntry怎麽用?Java Bundle.getEntry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.osgi.framework.Bundle的用法示例。


在下文中一共展示了Bundle.getEntry方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createIcons

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
private void createIcons() {
	icons   = new HashMap<String, Image>(7);

	final IConfigurationElement[] eles = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.scanning.api.generator");
	for (IConfigurationElement e : eles) {
		final String     identity = e.getAttribute("id");

		final String icon = e.getAttribute("icon");
		if (icon !=null) {
			final String   cont  = e.getContributor().getName();
			final Bundle   bundle= Platform.getBundle(cont);
			final URL      entry = bundle.getEntry(icon);
			final ImageDescriptor des = ImageDescriptor.createFromURL(entry);
			icons.put(identity, des.createImage());
		}

	}
}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:19,代碼來源:GeneratorDescriptor.java

示例2: addingBundle

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
@Override
public Boolean addingBundle(final Bundle bundle, final BundleEvent event) {
    URL resource = bundle.getEntry("META-INF/services/" + ModuleFactory.class.getName());
    LOG.trace("Got addingBundle event of bundle {}, resource {}, event {}", bundle, resource, event);
    if (resource != null) {
        try {
            for (String factoryClassName : Resources.readLines(resource, StandardCharsets.UTF_8)) {
                registerFactory(factoryClassName, bundle);
            }

            return Boolean.TRUE;
        } catch (final IOException e) {
            LOG.error("Error while reading {}", resource, e);
            throw new RuntimeException(e);
        }
    }

    return Boolean.FALSE;
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:20,代碼來源:ModuleFactoryBundleTracker.java

示例3: resolveFile

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
private static File resolveFile(String pluginName, String path) {
	Bundle bundle = Platform.getBundle(pluginName);
	URL fileURL = bundle.getEntry(path);
	try {
		URL resolvedFileURL = FileLocator.toFileURL(fileURL);
		URI resolvedURI = new URI(resolvedFileURL.getProtocol(), resolvedFileURL.getPath(), null);
		return new File(resolvedURI);
	} catch (URISyntaxException | IOException e) {
		Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
	}
	return null;
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:13,代碼來源:ExamplesRegistry.java

示例4: resolveImage

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
private static Image resolveImage(String pluginName, String path) {
	Bundle bundle = Platform.getBundle(pluginName);
	URL fileURL = bundle.getEntry(path);
	try {
		URL resolvedFileURL = FileLocator.toFileURL(fileURL);
		return ImageDescriptor.createFromURL(resolvedFileURL).createImage();
	} catch (IOException e) {
		Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
	}
	return null;
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:12,代碼來源:ExamplesRegistry.java

示例5: getTemplateURI

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
/**
 * Finds the template in the plug-in. Returns the template plug-in URI.
 * 
 * @param bundleID
 *            is the plug-in ID
 * @param relativePath
 *            is the relative path of the template in the plug-in
 * @return the template URI
 * @throws IOException
 * @generated
 */
@SuppressWarnings("unchecked")
private URI getTemplateURI(String bundleID, IPath relativePath) throws IOException {
	Bundle bundle = Platform.getBundle(bundleID);
	if (bundle == null) {
		// no need to go any further
		return URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
	}
	URL url = bundle.getEntry(relativePath.toString());
	if (url == null && relativePath.segmentCount() > 1) {
		Enumeration<URL> entries = bundle.findEntries("/", "*.emtl", true);
		if (entries != null) {
			String[] segmentsRelativePath = relativePath.segments();
			while (url == null && entries.hasMoreElements()) {
				URL entry = entries.nextElement();
				IPath path = new Path(entry.getPath());
				if (path.segmentCount() > relativePath.segmentCount()) {
					path = path.removeFirstSegments(path.segmentCount() - relativePath.segmentCount());
				}
				String[] segmentsPath = path.segments();
				boolean equals = segmentsPath.length == segmentsRelativePath.length;
				for (int i = 0; equals && i < segmentsPath.length; i++) {
					equals = segmentsPath[i].equals(segmentsRelativePath[i]);
				}
				if (equals) {
					url = bundle.getEntry(entry.getPath());
				}
			}
		}
	}
	URI result;
	if (url != null) {
		result = URI.createPlatformPluginURI(new Path(bundleID).append(new Path(url.getPath())).toString(), false);
	} else {
		result = URI.createPlatformResourceURI(new Path(bundleID).append(relativePath).toString(), false);
	}
	return result;
}
 
開發者ID:occiware,項目名稱:OCCI-Studio,代碼行數:49,代碼來源:GenerateAll.java

示例6: bundleAdded

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
private void bundleAdded(final Bundle bundle) {
    URL resource = bundle.getEntry(serviceResourcePath);
    if (resource == null) {
        return;
    }

    LOG.debug("{}: Found {} resource in bundle {}", logName(), resource, bundle.getSymbolicName());

    try {
        for (String line : Resources.readLines(resource, StandardCharsets.UTF_8)) {
            int ci = line.indexOf('#');
            if (ci >= 0) {
                line = line.substring(0, ci);
            }

            line = line.trim();
            if (line.isEmpty()) {
                continue;
            }

            String serviceType = line;
            LOG.debug("{}: Retrieved service type {}", logName(), serviceType);
            expectedServiceTypes.add(serviceType);
        }
    } catch (final IOException e) {
        setFailure(String.format("%s: Error reading resource %s from bundle %s", logName(), resource,
                bundle.getSymbolicName()), e);
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:30,代碼來源:SpecificReferenceListMetadata.java

示例7: findResources

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
@Override
protected Enumeration<URL> findResources(Module m, String resName) {
    Bundle b = findBundle(m.getCodeNameBase());
    URL u = b.getEntry(resName);
    return u == null ? Enumerations.<URL>empty() : Enumerations.singleton(u);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:Netigso.java

示例8: testBundleResourceProtocol

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
@RandomlyFails
public void testBundleResourceProtocol() throws Exception {
    ModuleSystem ms = Main.getModuleSystem();
    ModuleManager mgr = ms.getManager();
    mgr.mutexPrivileged().enterWriteAccess();
    HashSet<Module> both = null;
    try {
        String mfBar = "Bundle-SymbolicName: org.bar\n" +
            "Bundle-Version: 1.1.0\n" +
            "Bundle-ManifestVersion: 2\n" +
            "Export-Package: org.bar\n" +
            "Require-Bundle: org.foo;bundle-version=\"[100.0,102.0)\"\n" +
            "\n\n";

        File j1 = new File(jars, "simple-module.jar");
        File j2 = changeManifest(new File(jars, "depends-on-simple-module.jar"), mfBar);
        LOG.log(Level.INFO, "Create {0}", j2);
        Module m1 = mgr.create(j1, null, false, false, false);
        LOG.log(Level.INFO, "Create {0}", j2);
        Module m2 = mgr.create(j2, null, false, false, false);
        HashSet<Module> b = new HashSet<Module>(Arrays.asList(m1, m2));
        LOG.log(Level.INFO, "enable {0}", b);
        mgr.enable(b);
        LOG.info("enabled Ok");
        both = b;

        Bundle bundle = NetigsoServicesTest.findBundle("org.foo");
        LOG.log(Level.INFO, "bundle org.foo: {0}", bundle);
        URL root = bundle.getEntry("/");
        LOG.log(Level.INFO, "Root entry {0}", root);
        assertNotNull("Root URL found", root);
        URL resRoot = new URL("bundleresource", root.getHost(), root.getPath());
        LOG.log(Level.INFO, "res root: {0}", resRoot);
        URL helloRes = new URL(resRoot, "org/foo/hello.txt");
        LOG.log(Level.INFO, "Assert content {0}", helloRes);
        assertURLContent(helloRes, "Hello resources!");
    } finally {
        LOG.info("Finally block started");
        if (both != null) {
            mgr.disable(both);
        }
        mgr.mutexPrivileged().exitWriteAccess();
        LOG.info("Finally block finished");
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:46,代碼來源:BundleResourceTest.java

示例9: testActivation

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
public void testActivation() throws Exception {
    ModuleSystem ms = Main.getModuleSystem();
    mgr = ms.getManager();
    mgr.mutexPrivileged().enterWriteAccess();
    Enumeration en;
    int checks = 0;
    
    System.setProperty("activated.checkentries", "/org/test/x.txt");
    try {
        m1 = mgr.create(simpleModule, null, false, false, false);
        mgr.enable(m1);

        Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
        Object s = main.getField("start").get(null);
        assertNotNull("Bundle started, its context provided", s);

        BundleContext bc = (BundleContext)s;
        StringBuilder sb = new StringBuilder();
        for (Bundle b : bc.getBundles()) {
            URL root = b.getEntry("/");
            if (root == null) {
                sb.append("No root URL for ").append(b.getSymbolicName()).append("\n");
            }
            
            en = b.findEntries("/", null, true);
            if (en == null) {
                sb.append("No entries for ").append(b.getSymbolicName()).append("\n");
                continue;
            }
            while (en.hasMoreElements()) {
                URL u = (URL) en.nextElement();
                final String ef = u.toExternalForm();
                int pref = ef.indexOf("/org/");
                int last = ef.lastIndexOf("/");
                if (pref != -1 && last != -1) {
                    String entry = ef.substring(pref + 1, last + 1);
                    assertTrue("/ is at the end", entry.endsWith("/"));
                    checks++;
                    final URL found = b.getEntry(entry);
                    assertNotNull("Entry found " + entry + " in " + b.getSymbolicName(), found);
                    
                    URL notFound = b.getEntry("non/existent/entry/");
                    assertNull("Entries for non-existing entries are not found", notFound);
                }
            }
        }
        if (sb.length() > 0) {
            fail(sb.toString());
        }
        if (checks == 0) {
            fail("There shall be some checks for entries");
        }
        String text = System.getProperty("activated.entry");
        assertEquals("Ahoj", text);

        String localURL = System.getProperty("activated.entry.local");
        assertNotNull("bundleentry read OK", localURL);
        assertTrue("external file is referred as file:/.... = " + localURL, localURL.startsWith("file:/"));
        assertEquals("Ahoj", readLine(localURL));

        String fileURL = System.getProperty("activated.entry.file");
        assertNotNull("fileURL found", fileURL);
        assertTrue("file:/..... = " + fileURL, fileURL.startsWith("file:/"));
        assertEquals("Ahoj", readLine(fileURL));

        mgr.disable(m1);

        Object e = main.getField("stop").get(null);
        assertNotNull("Bundle stopped, its context provided", e);
    } finally {
        mgr.mutexPrivileged().exitWriteAccess();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:74,代碼來源:ExternalDirectoryTest.java

示例10: getTemplateURI

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
/**
 * Finds the template in the plug-in. Returns the template plug-in URI.
 * 
 * @param bundleID
 *            is the plug-in ID
 * @param relativePath
 *            is the relative path of the template in the plug-in
 * @return the template URI
 * @throws IOException
 * @generated
 */
@SuppressWarnings ( "unused" )
private URI getTemplateURI ( final String bundleID, final IPath relativePath ) throws IOException
{
    final Bundle bundle = Platform.getBundle ( bundleID );
    if ( bundle == null )
    {
        // no need to go any further 
        return URI.createPlatformResourceURI ( new Path ( bundleID ).append ( relativePath ).toString (), false );
    }
    URL url = bundle.getEntry ( relativePath.toString () );
    if ( url == null && relativePath.segmentCount () > 1 )
    {
        final Enumeration<URL> entries = bundle.findEntries ( "/", "*.emtl", true );
        if ( entries != null )
        {
            final String[] segmentsRelativePath = relativePath.segments ();
            while ( url == null && entries.hasMoreElements () )
            {
                final URL entry = entries.nextElement ();
                IPath path = new Path ( entry.getPath () );
                if ( path.segmentCount () > relativePath.segmentCount () )
                {
                    path = path.removeFirstSegments ( path.segmentCount () - relativePath.segmentCount () );
                }
                final String[] segmentsPath = path.segments ();
                boolean equals = segmentsPath.length == segmentsRelativePath.length;
                for ( int i = 0; equals && i < segmentsPath.length; i++ )
                {
                    equals = segmentsPath[i].equals ( segmentsRelativePath[i] );
                }
                if ( equals )
                {
                    url = bundle.getEntry ( entry.getPath () );
                }
            }
        }
    }
    URI result;
    if ( url != null )
    {
        result = URI.createPlatformPluginURI ( new Path ( bundleID ).append ( new Path ( url.getPath () ) ).toString (), false );
    }
    else
    {
        result = URI.createPlatformResourceURI ( new Path ( bundleID ).append ( relativePath ).toString (), false );
    }
    return result;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:60,代碼來源:GenerateAll.java

示例11: createConnectionActions

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
private void createConnectionActions() {

		connectors.clear();

		String lastId = Activator.getDefault().getPreferenceStore().getString(DevicePreferenceConstants.STREAM_ID);


		final IConfigurationElement[] eles = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.scanning.api.stream");
		for (IConfigurationElement e : eles) {

			CheckableActionGroup group = new CheckableActionGroup();
			try {
				final IStreamConnection<ILazyDataset> connection = (IStreamConnection<ILazyDataset>)e.createExecutableExtension("stream");
				connectors.add(connection);
				connection.setId(e.getAttribute("id"));
				connection.setLabel(e.getAttribute("label"));

				final String iconPath = e.getAttribute("icon");
				ImageDescriptor icon=null;
			if (iconPath!=null) {
				final String   id    = e.getContributor().getName();
				final Bundle   bundle= Platform.getBundle(id);
				final URL      entry = bundle.getEntry(iconPath);
				icon = ImageDescriptor.createFromURL(entry);
			}

			final MenuAction menu = new MenuAction(connection.getLabel());
			final IAction connect = new Action(connection.getLabel(), IAction.AS_CHECK_BOX) {
				@Override
					public void run() {
					connect(connection);
				}
			};
			connect.setImageDescriptor(icon);
			connect.setChecked(lastId!=null && lastId.equals(connection.getId()));
			group.add(connect);
			menu.add(connect);
			menu.setSelectedAction(connect);

			final IAction configure = new Action("Configure...") {
				@Override
					public void run() {
					configure(connection);
				}
			};
			menu.add(configure);

			getViewSite().getActionBars().getToolBarManager().add(menu);

			} catch (Exception ne) {
				logger.error("Problem creating stream connection for "+e, ne);
			}

			getViewSite().getActionBars().getToolBarManager().add(new Separator());
		}

	}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:58,代碼來源:StreamView.java

示例12: tstGetEntryOnMetaInfEntryOnSystemBundle

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
public void tstGetEntryOnMetaInfEntryOnSystemBundle() throws Exception {
	Bundle sysBundle = bundleContext.getBundle(0);
	URL url = sysBundle.getEntry("/META-INF");
	assertNotNull("system bundle doesn't consider META-INF on classpath", url);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:6,代碼來源:BundleClassPathTest.java


注:本文中的org.osgi.framework.Bundle.getEntry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。