当前位置: 首页>>代码示例>>Java>>正文


Java Bundle.getSymbolicName方法代码示例

本文整理汇总了Java中org.osgi.framework.Bundle.getSymbolicName方法的典型用法代码示例。如果您正苦于以下问题:Java Bundle.getSymbolicName方法的具体用法?Java Bundle.getSymbolicName怎么用?Java Bundle.getSymbolicName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.osgi.framework.Bundle的用法示例。


在下文中一共展示了Bundle.getSymbolicName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBundleDirectory

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Return the bundle directory.
 *
 * @param bundle the bundle
 * @return the bundle directory
 */
public String getBundleDirectory(Bundle bundle) {
	
	if (bundle == null) return null;

	// --- Get File URL of bundle --------------------- 
	URL pluginURL = null;
	try {
		pluginURL = FileLocator.resolve(bundle.getEntry("/"));
	} catch (IOException e) {
		throw new RuntimeException("Could not get installation directory of the plugin: " + bundle.getSymbolicName());
	}
	
	// --- Clean up the directory path ----------------
	String pluginInstallDir = pluginURL.getFile().trim();
	if (pluginInstallDir.length()==0) {
		throw new RuntimeException("Could not get installation directory of the plugin: " + bundle.getSymbolicName());
	}

	// --- Corrections, if we are under windows -------
	if (Platform.getOS().compareTo(Platform.OS_WIN32) == 0) {
		//pluginInstallDir = pluginInstallDir.substring(1);
	}
	return pluginInstallDir;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:31,代码来源:BundleEvaluator.java

示例2: testBundleActivation

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
@Test
public void testBundleActivation()
{
    String bundleName = getBundleName();

    boolean bundleFound = false;
    boolean bundleActive = false;
    Bundle[] bundles = context.getBundles();
    for ( Bundle bundle : bundles )
    {
        //System.out.println( "### bundle=" + bundle + " " + bundle.getState() );
        if ( bundle != null && bundle.getSymbolicName() != null && bundle.getSymbolicName().equals( bundleName ) )
        {
            bundleFound = true;
            if ( bundle.getState() == Bundle.ACTIVE )
            {
                bundleActive = true;
            }
        }
    }

    assertTrue( "Bundle " + bundleName + " not found.", bundleFound );
    assertTrue( "Bundle " + bundleName + " is not active.", bundleActive );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:ApiOsgiTestBase.java

示例3: parse

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
private static void parse(Bundle bundle, InputStream is, Collection<PersistenceUnit> punits) {
    SAXParserFactory parserFactory = SAXParserFactory.newInstance();
    try {
        SAXParser parser = parserFactory.newSAXParser();
        JPAHandler handler = new JPAHandler(bundle);
        parser.parse(is, handler);
        punits.addAll(handler.getPersistenceUnits());
    } catch (Exception e) {
        throw new RuntimeException("Error parsing persistence unit in bundle " + bundle.getSymbolicName(), e); // NOSONAR
    } finally {
        safeClose(is);
    }
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:14,代码来源:PersistenceUnitParser.java

示例4: WrappingTransformer

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public WrappingTransformer(ClassTransformer delegate, ServiceReference<?> persistenceProvider) {
    validate(delegate, persistenceProvider);
    this.delegate = delegate;

    Object packages = persistenceProvider.getProperty("org.apache.aries.jpa.container.weaving.packages");
    if (packages instanceof String[]) {
        for (String s : (String[])packages) {
            packageImportsToAdd.add(s);
        }
    } else {
        Bundle provider = persistenceProvider.getBundle();
        String suffix = ";" + Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE + "=" + provider.getSymbolicName()
                        + ";" + Constants.BUNDLE_VERSION_ATTRIBUTE + "=" + provider.getVersion();

        BundleRevision br = provider.adapt(BundleWiring.class).getRevision();
        for (BundleCapability bc : br.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE)) {
            packageImportsToAdd.add(bc.getAttributes().get(BundleRevision.PACKAGE_NAMESPACE) + suffix);
        }
    }
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:21,代码来源:WrappingTransformer.java

示例5: getPlatformName

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public static String getPlatformName(BundleContext bundleContext) {
	String vendorProperty = bundleContext.getProperty(Constants.FRAMEWORK_VENDOR);
	String frameworkVersion = bundleContext.getProperty(Constants.FRAMEWORK_VERSION);

	// get system bundle
	Bundle bundle = bundleContext.getBundle(0);
	String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
	String version = (String) bundle.getHeaders().get(Constants.BUNDLE_VERSION);
	String symName = bundle.getSymbolicName();

	StringBuilder buf = new StringBuilder();
	buf.append(name);
	buf.append(" ");
	buf.append(symName);
	buf.append("|");
	buf.append(version);
	buf.append("{");
	buf.append(frameworkVersion);
	buf.append(" ");
	buf.append(vendorProperty);
	buf.append("}");

	return buf.toString();
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:25,代码来源:OsgiUtils.java

示例6: testInstallBundle

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
@Test
public void testInstallBundle() throws Exception {
    final String installCommand ="bundle:install mvn:"
            + OSGIFX_GROUP_ID + "/"
            + IT_DUMMY_BUNDLE_ARTIFACT_ID + "/"
            + PROJECT_VERSION;
    session.execute(installCommand);
    Bundle dummyBundle = null;
    for (Bundle bundle : bundleContext.getBundles())
    {
        if (bundle.getSymbolicName() != null && bundle.getSymbolicName().equals(OSGIFX_GROUP_ID + "." + IT_DUMMY_BUNDLE_ARTIFACT_ID))
        {
            dummyBundle = bundle;
            break;
        }
    }
    assertNotNull(dummyBundle);
}
 
开发者ID:jtkb,项目名称:flexfx,代码行数:19,代码来源:DeployOsgiFxTest.java

示例7: testOsgiFxInstalled

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
@Test
public void testOsgiFxInstalled()
{
    Bundle osgiFxBundle = null;
    for (Bundle bundle : bundleContext.getBundles() )
    {
        if (bundle.getSymbolicName() != null && bundle.getSymbolicName().equals(OSGIFX_GROUP_ID + "." + OSGIFX_BOOT_ARTIFACT_ID))
        {
            osgiFxBundle = bundle;
            break;
        }
    }

    assertNotNull(osgiFxBundle);
    assertEquals(OSGIFX_GROUP_ID + "." + OSGIFX_BOOT_ARTIFACT_ID + " is not active.", Bundle.ACTIVE, osgiFxBundle.getState());
}
 
开发者ID:jtkb,项目名称:flexfx,代码行数:17,代码来源:DeployOsgiFxTest.java

示例8: bundleChanged

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
@Override
public void bundleChanged(BundleEvent event) {
	
	Bundle bundle = event.getBundle();
	if (this.debug==true) {
		String symbolicName = bundle.getSymbolicName();
		String type = this.getBundleEventAsString(event);
		System.out.println(this.getClass().getSimpleName() + "#bundleChanged(event): " + symbolicName + ", event.type: " + type);
	}
	
	// --- Make sure that only external bundles will be considered ------------------
	if (bundle.getSymbolicName().equals(PLUGIN_ID)==false) {
		switch (event.getType()) {
		case BundleEvent.STARTED:
			// --- Start searching for specific classes with the BundleEvaluator ----
			BundleEvaluator.getInstance().setBundleAdded(bundle);
			break;
			
		case BundleEvent.STOPPED:
			// --- Remove search results from the BundleEvaluator -------------------
			BundleEvaluator.getInstance().setBundleRemoved(bundle);
			break;

		default:
			break;
		}
	}
			
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:30,代码来源:PlugInActivator.java

示例9: getClassLocation

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Returns the ClassLocaton for the specified class name.
 * @param className the class name
 * @return the class location or null, if the class was not found
 */
public ClassLocaton getClassLocation(String className)  {
	
	if (className==null || className.equals("")==true) return null;
	
	// --- Plan A: Try to find class in the AbstractBundleClassFilter -----
	ClassLocaton classLocation = null;
	for (int i = 0; i < this.size(); i++) {
		AbstractBundleClassFilter abcf = this.get(i);
		if (abcf!=null) {
			classLocation = abcf.getClassLocation(className);
			if (classLocation!=null) break;
		}
	}
	
	// --- Plan B: If not found yet, try using direct bundle access -------
	if (classLocation==null) {
		Bundle[] bundles = this.bundleEvaluator.getBundles();
		for (int i = 0; i < bundles.length; i++) {
			Bundle bundle = bundles[i];
			try {
				Class<?> clazz = bundle.loadClass(className);
				if (clazz!=null) {
					classLocation = new ClassLocaton(className, bundle.getSymbolicName(), null);
					break;
				}
			} catch (ClassNotFoundException cnEx) {
				// cnEx.printStackTrace();
			}
		}
	}
	return classLocation;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:38,代码来源:EvaluationFilterResults.java

示例10: nullSafeSymbolicName

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Returns the given <code>Bundle</code> symbolic name.
 * 
 * @param bundle OSGi bundle (can be <code>null</code>)
 * @return the bundle, symbolic name
 */
public static String nullSafeSymbolicName(Bundle bundle) {
	if (bundle == null)
		return NULL_STRING;

	Dictionary headers = bundle.getHeaders();

	if (headers == null)
		return NULL_STRING;

	return (String) (bundle.getSymbolicName() == null ? NULL_STRING : bundle.getSymbolicName());
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:OsgiStringUtils.java

示例11: registerService

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
private void registerService(ApplicationContext applicationContext) {
	final Dictionary<String, Object> serviceProperties = new Hashtable<String, Object>();

	Bundle bundle = bundleContext.getBundle();
	String symName = bundle.getSymbolicName();
	serviceProperties.put(Constants.BUNDLE_SYMBOLICNAME, symName);
	serviceProperties.put(BLUEPRINT_SYMNAME, symName);

	Version version = OsgiBundleUtils.getBundleVersion(bundle);
	serviceProperties.put(Constants.BUNDLE_VERSION, version);
	serviceProperties.put(BLUEPRINT_VERSION, version);

	log.info("Publishing BlueprintContainer as OSGi service with properties " + serviceProperties);

	// export just the interface
	final String[] serviceNames = new String[] { BlueprintContainer.class.getName() };

	if (log.isDebugEnabled())
		log.debug("Publishing service under classes " + ObjectUtils.nullSafeToString(serviceNames));

	AccessControlContext acc = SecurityUtils.getAccFrom(applicationContext);

	// publish service
	if (System.getSecurityManager() != null) {
		registration = AccessController.doPrivileged(new PrivilegedAction<ServiceRegistration>() {
			public ServiceRegistration run() {
				return bundleContext.registerService(serviceNames, blueprintContainer, serviceProperties);
			}
		}, acc);
	} else {
		registration = bundleContext.registerService(serviceNames, blueprintContainer, serviceProperties);
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:34,代码来源:BlueprintContainerServicePublisher.java

示例12: getInstalledBundle

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
private Bundle getInstalledBundle(final String bundleSymbolicName)
{
    Bundle installedBundle = null;
    for (Bundle bundle : bundleContext.getBundles())
    {
        if (bundle.getSymbolicName() != null && bundle.getSymbolicName().equals(bundleSymbolicName))
        {
            installedBundle = bundle;
            break;
        }
    }
    return installedBundle;
}
 
开发者ID:jtkb,项目名称:flexfx,代码行数:14,代码来源:TFxTest.java

示例13: getXKConfigPathFromScriptView

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Get xk config path from script view
 *
 * @param view The View to fetch the xk config path from
 * @return xkConfigPath
 */
private static String getXKConfigPathFromScriptView(View view){
    String path = null;
    if (view != null){
        String viewPath = view.getPath();

        Properties p = view.getDefaultProperties();

        try {
            Bundle bundle = JahiaUtils.getBundle(view);
            String bundleSymbolicName = bundle.getSymbolicName();

            // This assumes that the path is of the form /modules/<bundle_symbolic_name>/<template_node>/<view>/<renderer_script>
            // And we intend to get the path  /<bundle_symbolic_name>/<template_node>/xk-config.json
            String pathWithoutRenderScript = viewPath.substring(0, viewPath.lastIndexOf(FILE_SEPARATOR));
            String pathWithoutViewType = pathWithoutRenderScript.substring(0, pathWithoutRenderScript.lastIndexOf(FILE_SEPARATOR));
            String[] pathWithoutSymbolicName = pathWithoutViewType.split(bundleSymbolicName);
            String processedPath = "";
            if (pathWithoutSymbolicName.length >1 ){
                processedPath = pathWithoutViewType.substring( pathWithoutViewType.indexOf(pathWithoutSymbolicName[1]) );
            }

            path = processedPath + FILE_SEPARATOR + XK_CONFIG_FILE;
        }catch (Exception e){
            LOG.error("Error getting parentPath from View Path: "+viewPath,e);
        }
    }
    return path;
}
 
开发者ID:DantaFramework,项目名称:JahiaDF,代码行数:35,代码来源:JahiaUtils.java

示例14: id

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public @Override String id(Bundle b) {
    return b.getSymbolicName();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:OSGiMainLookup.java

示例15: ClassElement2Display

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Instantiates a new class element to display in a JList.
 * @param clazz the class
 */
public ClassElement2Display(Class<?> clazz, Bundle bundle){
	this.className = clazz.getName();
	this.bundleName = bundle.getSymbolicName();
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:9,代码来源:ClassElement2Display.java


注:本文中的org.osgi.framework.Bundle.getSymbolicName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。