本文整理匯總了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;
}
示例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 );
}
示例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);
}
}
示例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);
}
}
}
示例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();
}
示例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);
}
示例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());
}
示例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;
}
}
}
示例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;
}
示例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());
}
示例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);
}
}
示例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;
}
示例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;
}
示例14: id
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
public @Override String id(Bundle b) {
return b.getSymbolicName();
}
示例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();
}