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


Java Bundle.getState方法代码示例

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


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

示例1: findResources

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
@Override
public Enumeration<URL> findResources(String name) {
    //Netigso.start();
    Bundle b = bundle;
    if (b == null) {
        LOG.log(Level.WARNING, "Trying to load resource before initialization finished {0}", name);
        return Enumerations.empty();
    }
    Enumeration ret = null;
    try {
        if (b.getState() != Bundle.UNINSTALLED) {
            ret = b.getResources(name);
        }
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
    return ret == null ? Enumerations.<URL>empty() : NbCollections.checkedEnumerationByFilter(ret, URL.class, true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:NetigsoLoader.java

示例2: stopAndUninstallBundles

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Stops and un-installs the current bundle.
 */
public void stopAndUninstallBundles() {
	
	// --- Get a copy of loaded bundles -----
	Vector<Bundle> bundlesToRemove = new Vector<>(this.getBundleVector());
	for (Bundle bundle: bundlesToRemove) {
		try {
			// --- Remove, if active --------
			if (bundle.getState()==Bundle.ACTIVE) {
				bundle.stop();
				bundle.uninstall();
			}
			// --- Remove from vector -------
			this.getBundleVector().remove(bundle);
			if (this.debug) System.out.println("=> - " + bundle.getSymbolicName() + " stoped & uninstalled");
			
		} catch (BundleException bEx) {
			bEx.printStackTrace();
		}
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:24,代码来源:ProjectBundleLoader.java

示例3: 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

示例4: modifiedBundle

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Implemented from BundleTrackerCustomizer.
 */
@Override
public void modifiedBundle(final Bundle bundle, final BundleEvent event, final Bundle object) {
    if (shuttingDown) {
        return;
    }

    if (bundle.getState() == Bundle.ACTIVE) {
        List<Object> paths = findBlueprintPaths(bundle);

        if (!paths.isEmpty()) {
            LOG.info("Creating blueprint container for bundle {} with paths {}", bundle, paths);

            blueprintExtenderService.createContainer(bundle, paths);
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:BlueprintBundleTracker.java

示例5: testSecondSceneServiceNotSelected

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Ensures that if a second SceneService is deployed, that is it not loaded into the Stage.
 */
@Test
public void testSecondSceneServiceNotSelected() throws Exception
{
    final String installDummyBundleTwoCommand ="bundle:install mvn:"
            + OSGIFX_GROUP_ID + "/"
            + DUMMY_TWO_BUNDLE_ARTIFACT_ID + "/"
            + PROJECT_VERSION;
    // Ensure the dummy bundle two is not installed.
    Bundle dummyTwoBundle = getInstalledBundle(OSGIFX_GROUP_ID + "." + DUMMY_TWO_BUNDLE_ARTIFACT_ID);
    assertNull("Dummy Bundle Two found to be already deployed.", dummyTwoBundle);

    session.execute(installDummyBundleTwoCommand);

    dummyTwoBundle = getInstalledBundle(OSGIFX_GROUP_ID + "." + DUMMY_TWO_BUNDLE_ARTIFACT_ID);
    assertNotNull("Dummy Bundle Two was not installed.", dummyTwoBundle);
    if (dummyTwoBundle.getState() != Bundle.ACTIVE)
    {
        dummyTwoBundle.start();
    }
    assertEquals("Dummy Two bundle not active.", Bundle.ACTIVE, dummyTwoBundle.getState());
    dummyTwoBundle.uninstall();

}
 
开发者ID:jtkb,项目名称:flexfx,代码行数:27,代码来源:TFxTest.java

示例6: addEvent

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
void addEvent(BlueprintEvent event) {
	// copy event
	BlueprintEvent replay = new BlueprintEvent(event, true);
	Bundle bnd = replay.getBundle();
	if (bnd.getState() == Bundle.ACTIVE || bnd.getState() == Bundle.STARTING || bnd.getState() == Bundle.STOPPING) {
		events.put(bnd, replay);
		if (log.isTraceEnabled())
			log.trace("Adding replay event  " + replay.getType() + " for bundle " + replay.getBundle());
	} else {
		if (log.isTraceEnabled()) {
			log.trace("Replay event " + replay.getType() + " ignored; " + "owning bundle has been uninstalled "
					+ bnd);
			events.remove(bnd);
		}
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:17,代码来源:ReplayEventManager.java

示例7: isBundleLazyActivated

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Indicates if the given bundle is lazily activated or not. That is, the
 * bundle has a lazy activation policy and a STARTING state. Bundles that
 * have been lazily started but have been activated will return false.
 * 
 * <p/>
 * On OSGi R4.0 platforms, this method will always return false.
 * 
 * @param bundle OSGi bundle
 * @return true if the bundle is lazily activated, false otherwise.
 */
@SuppressWarnings("unchecked")
public static boolean isBundleLazyActivated(Bundle bundle) {
	Assert.notNull(bundle, "bundle is required");

	if (OsgiPlatformDetector.isR41()) {
		if (bundle.getState() == Bundle.STARTING) {
			Dictionary<String, String> headers = bundle.getHeaders();
			if (headers != null) {
				Object val = headers.get(Constants.BUNDLE_ACTIVATIONPOLICY);
				if (val != null) {
					String value = ((String) val).trim();
					return (value.startsWith(Constants.ACTIVATION_LAZY));
				}
			}
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:30,代码来源:OsgiBundleUtils.java

示例8: isResolved

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
private static boolean isResolved(Bundle b) {
    if (b.getState() == Bundle.INSTALLED) {
        // try to ask for a known resource which is known to resolve 
        // the bundle
        b.findEntries("META-INF", "MANIFEST.MF", false); // NOI18N
    }
    return b.getState() != Bundle.INSTALLED;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:Netigso.java

示例9: findBundle

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public static Bundle findBundle(String bsn) throws Exception {
    Bundle[] arr = findFramework().getBundleContext().getBundles();
    Bundle candidate = null;
    for (Bundle b : arr) {
        if (bsn.equals(b.getSymbolicName())) {
            candidate = b;
            if ((b.getState() & Bundle.ACTIVE) != 0) {
                return b;
            }
        }
    }
    return candidate;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:NetigsoServicesTest.java

示例10: processLoadedBundles

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
private void processLoadedBundles() {
        List<Bundle> toLoad = new ArrayList<Bundle>();
        for (Bundle b : context.getBundles()) {
            if (b.getState() == Bundle.ACTIVE) {
                Dictionary<?,?> headers = b.getHeaders();
                toLoad.addAll(queue.offer(b, provides(headers), requires(headers), needs(headers)));
            }
        }
//        System.err.println("processing already loaded bundles: " + toLoad);
        load(toLoad);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:Activator.java

示例11: resolveBundles

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
/**
 * Helps to diagnose bundles that are not resolved as it will throw a detailed exception
 * 
 * @throws BundleException
 */
public void resolveBundles() throws BundleException {
    Bundle[] bundles = bundleContext.getBundles();
    for (Bundle bundle : bundles) {
        if (bundle.getState() == Bundle.INSTALLED) {
            System.out.println("Found non resolved bundle " + bundle.getBundleId() + ":"
                + bundle.getSymbolicName() + ":" + bundle.getVersion());
            bundle.start();
        }
    }
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:16,代码来源:AbstractJPAItest.java

示例12: readMetanodes

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
private void readMetanodes() {
	// iterate over the meta node config elements and create meta node templates
	IExtension[] metanodeExtensions = getExtensions(ID_META_NODE);
	for (IExtension mnExt : metanodeExtensions) {
		IConfigurationElement[] mnConfigElems = mnExt.getConfigurationElements();
		for (IConfigurationElement mnConfig : mnConfigElems) {

			try {
				MetaNodeTemplate metaNode = RepositoryFactory.createMetaNode(mnConfig);
				LOGGER.debug("Found meta node definition '" + metaNode.getID() + "': " + metaNode.getName());

				IContainerObject parentContainer = m_root.findContainer(metaNode.getCategoryPath());
				// If parent category is illegal, log an error and append the node to the
				// repository root.
				if (parentContainer == null) {
					LOGGER.warn("Invalid category-path for node contribution: '" + metaNode.getCategoryPath()
							+ "' - adding to root instead");
					m_root.addChild(metaNode);
				} else {
					// everything is fine, add the node to its parent category
					parentContainer.addChild(metaNode);
				}
			} catch (Throwable t) {
				String message = "MetaNode " + mnConfig.getAttribute("id") + "' from plugin '"
						+ mnConfig.getNamespaceIdentifier() + "' could not be created: " + t.getMessage();
				Bundle bundle = Platform.getBundle(mnConfig.getNamespaceIdentifier());

				if (bundle == null || bundle.getState() != Bundle.ACTIVE) {
					// if the plugin is null, the plugin could not be activated maybe due to a not
					// activateable plugin (plugin class cannot be found)
					message = message + " The corresponding plugin bundle could not be activated!";
				}

				LOGGER.error(message, t);
			}
		}
	}
}
 
开发者ID:qqilihq,项目名称:knime-json-node-doc-generator,代码行数:39,代码来源:RepositoryManager.java

示例13: findBundle

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
private Bundle findBundle(String bsn) {
    Bundle found = null;
    for (Bundle bundle : this.bundleContext.getBundles()) {
        if (bsn.equals(bundle.getSymbolicName()) && bundle.getState() != Bundle.UNINSTALLED) {
            if (found != null && bundle.getBundleId() != found.getBundleId()) {
                throw new IllegalArgumentException("Ambiguous bundle symbolic name " + bsn);
            }
            found = bundle;
        }
    }
    return found;
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:13,代码来源:InstallerIntegrationTest.java

示例14: testServiceListener

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public void testServiceListener() throws Exception {
	assertEquals("Expected initial binding of service", 1, MyListener.BOUND_COUNT);
	assertEquals("Unexpected initial unbinding of service", 0, MyListener.UNBOUND_COUNT);

	Bundle simpleServiceBundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext,
		"org.eclipse.gemini.blueprint.iandt.simpleservice");

	assertNotNull("Cannot find the simple service bundle", simpleServiceBundle);

	simpleServiceBundle.stop();
	while (simpleServiceBundle.getState() == Bundle.STOPPING) {
		Thread.sleep(100);
	}

	assertEquals("Expected one binding of service", 1, MyListener.BOUND_COUNT);
	assertTrue("Expected only one unbinding of service", MyListener.UNBOUND_COUNT < 2);
	assertEquals("Expected unbinding of service not seen", 1, MyListener.UNBOUND_COUNT);

	logger.debug("about to restart simple service");
	simpleServiceBundle.start();
	waitOnContextCreation("org.eclipse.gemini.blueprint.iandt.simpleservice");
	// wait some more to let the listener binding propagate
	Thread.sleep(1000);

	logger.debug("simple service succesfully restarted");
	assertTrue("Expected only two bindings of service", MyListener.BOUND_COUNT < 3);
	assertEquals("Expected binding of service not seen", 2, MyListener.BOUND_COUNT);
	assertEquals("Unexpected unbinding of service", 1, MyListener.UNBOUND_COUNT);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:30,代码来源:ServiceListenerTest.java

示例15: testReferenceProxyLifecycle

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
public void testReferenceProxyLifecycle() throws Exception {

		MyService reference = ServiceReferer.serviceReference;

		assertNotNull("reference not initialized", reference);
		assertNotNull("no value specified in the reference", reference.stringValue());

		Bundle simpleServiceBundle = OsgiBundleUtils.findBundleBySymbolicName(bundleContext,
			"org.eclipse.gemini.blueprint.iandt.simpleservice");

		assertNotNull("Cannot find the simple service bundle", simpleServiceBundle);
		System.out.println("stopping bundle");
		simpleServiceBundle.stop();

		while (simpleServiceBundle.getState() == Bundle.STOPPING) {
			System.out.println("waiting for bundle to stop");
			Thread.sleep(10);
		}
		System.out.println("bundle stopped");

		// Service should be unavailable
		try {
			reference.stringValue();
			fail("ServiceUnavailableException should have been thrown!");
		}
		catch (ServiceUnavailableException e) {
			// Expected
		}

		System.out.println("starting bundle");
		simpleServiceBundle.start();

		waitOnContextCreation("org.eclipse.gemini.blueprint.iandt.simpleservice");

		System.out.println("bundle started");
		// Service should be running
		assertNotNull(reference.stringValue());
	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:39,代码来源:ReferenceProxyTest.java


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