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


Java Bundle.start方法代碼示例

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


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

示例1: setStartLevel

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
private void setStartLevel ( final String symbolicName, final int startLevel ) throws BundleException
{
    final Bundle bundle = findBundle ( symbolicName );
    if ( bundle == null )
    {
        return;
    }
    final BundleStartLevel bundleStartLevel = bundle.adapt ( BundleStartLevel.class );
    if ( bundleStartLevel == null )
    {
        return;
    }

    bundleStartLevel.setStartLevel ( startLevel < 0 ? this.defaultStartLevel : startLevel );
    bundle.start ();
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:17,代碼來源:Activator.java

示例2: testBehaviour

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
public void testBehaviour() throws Exception {
	String bundleId = "org.eclipse.gemini.blueprint.iandt, async-nowait-bundle,"
			+ getSpringDMVersion();

	// start it
	Bundle bundle = installBundle(bundleId);
	bundle.start();

	// wait for the bundle to start and fail
	Thread.sleep(3000);

	// put service up
	registration = bundleContext.registerService(Shape.class.getName(), new Area(), null);

	assertTrue("bundle " + bundle + "hasn't been fully started", OsgiBundleUtils.isBundleActive(bundle));

	// check that the appCtx is *not* published 
	// TODO: this fails sometimes on the build server - find out why
	// assertContextServiceIs(bundle, false, 1000);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:21,代碼來源:AsyncNoWaitTest.java

示例3: doServiceTestOn

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
protected void doServiceTestOn(String beanName, Class<?> type) throws Exception {
	ServiceReference ref = bundleContext.getServiceReference(type.getName());
	Object service = bundleContext.getService(ref);
	Assert.isInstanceOf(type, service);

	assertSame(applicationContext.getBean(beanName), service);
	Bundle dependency = getDependencyBundle();
	// stop bundle (and thus the exposed service)
	dependency.stop();
	// check if map is still published
	assertNull("exported for " + beanName + " should have been unpublished", ref.getBundle());
	// double check the service space
	assertNull(beanName + " service should be unregistered", bundleContext.getServiceReference(type.getName()));

	dependency.start();
	waitOnContextCreation(DEP_SYN_NAME);

	// the old reference remains invalid
	assertNull("the reference should remain invalid", ref.getBundle());
	// but the service should be back again
	assertSame(applicationContext.getBean(beanName), service);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:23,代碼來源:MultipleExportersDependingOnOneImporterTest.java

示例4: testBehaviour

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
public void testBehaviour() throws Exception {
	String bundleId = "org.eclipse.gemini.blueprint.iandt, nopublish-bundle,"
			+ getSpringDMVersion();

	// start it
	Bundle bundle = installBundle(bundleId);
	bundle.start();
	// wait for the listener to catch up
	Thread.sleep(1000);
	assertTrue("bundle " + bundle + "hasn't been fully started", OsgiBundleUtils.isBundleActive(bundle));

	// check that the appCtx is not publish
	assertContextServiceIs(bundle, false, 1000);

	// but the point service is
	assertNotNull("point service should have been published"
			+ bundleContext.getServiceReference(Point.class.getName()));
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:19,代碼來源:NoPublishTest.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: startBundle

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
/**
 * Starts the specified bundle and return true if successful.
 *
 * @param bundle the bundle
 * @return true, if successful
 */
public boolean startBundle(Bundle bundle) {
	boolean bundleStarted = false;
	try {
		bundle.start();
		bundleStarted = true;
		if (this.debug) System.out.println("=> ! " + bundle.getSymbolicName() + " started");
		
	} catch (BundleException bEx) {
		bEx.printStackTrace();
	}
	return bundleStarted;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:19,代碼來源:ProjectBundleLoader.java

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

示例8: preProcessBundleContext

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
protected void preProcessBundleContext(BundleContext platformBundleContext) throws Exception {
	super.preProcessBundleContext(platformBundleContext);
	if (!bundleInstalled) {
		logger.info("Installing OSGi-723 bundle...");
		InputStream stream = getClass().getResourceAsStream("/osgi-723.jar");
		Bundle bundle = platformBundleContext.installBundle("osgi-723", stream);
		bundle.start();
		bundleInstalled = true;
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:11,代碼來源:OSGI723Test.java

示例9: preProcessBundleContext

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
protected void preProcessBundleContext(BundleContext platformBundleContext) throws Exception {
	super.preProcessBundleContext(platformBundleContext);
	if (!noRootCPTestBundleInstalled) {
		logger.info("Installing no root cp bundle...");
		InputStream stream = getClass().getResourceAsStream("/norootcpbundle.jar");
		Bundle bundle = platformBundleContext.installBundle("norootcpbundle", stream);
		bundle.start();
		noRootCPTestBundleInstalled = true;
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:11,代碼來源:BundleClassPathWildcardTest.java

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

示例11: testBeanReference

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
public void testBeanReference() throws Exception {

		Bundle bundle = bundleContext.installBundle(getLocator().locateArtifact(
			"org.eclipse.gemini.blueprint.iandt", "recursive", getSpringDMVersion()).getURL().toExternalForm());
		bundle.start();
		waitOnContextCreation(bundle.getSymbolicName());
		System.out.println("started bundle [" + OsgiStringUtils.nullSafeSymbolicName(bundle) + "]");
	}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:9,代碼來源:RecursiveTypesTest.java

示例12: testBehaviour

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
public void testBehaviour() throws Exception {

		String bundleId = "org.eclipse.gemini.blueprint.iandt, sync-wait-bundle,"
				+ getSpringDMVersion();

		// locate bundle
		String tailBundleId = "org.eclipse.gemini.blueprint.iandt, sync-tail-bundle,"
				+ getSpringDMVersion();

		// start bundle first (no dependency)
		Bundle bundle = installBundle(bundleId);

		bundle.start();

		assertTrue("bundle " + bundle + "should have started", OsgiBundleUtils.isBundleActive(bundle));
		// start bundle dependency
		Bundle tailBundle = installBundle(tailBundleId);
		tailBundle.start();

		assertTrue("bundle " + tailBundle + "hasn't been fully started", OsgiBundleUtils.isBundleActive(tailBundle));

		// check appCtx hasn't been published
		assertContextServiceIs(bundle, false, 500);
		// check the dependency ctx
		assertContextServiceIs(tailBundle, true, 500);

		// restart the bundle (to catch the tail)
		bundle.stop();
		bundle.start();

		// check appCtx has been published
		assertContextServiceIs(bundle, true, 500);
	}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:34,代碼來源:SyncWaitWithoutDependencyTest.java

示例13: testErrorHandling

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
/**
 * While it may appear that this test is doing nothing, what it is doing is
 * testing what happens when the OSGi framework is shutdown while the
 * Spring/OSGi extender is deadlocked. If all goes well, the test will
 * gracefully end. If not, it will hang for quite a while.
 */
public void testErrorHandling() throws Exception {
	Resource errorResource = getLocator().locateArtifact("org.eclipse.gemini.blueprint.iandt", "deadlock",
		getSpringDMVersion());
	assertNotNull("bundle resource exists", errorResource);
	Bundle errorBundle = bundleContext.installBundle(errorResource.getURL().toExternalForm());
	assertNotNull("bundle exists", errorBundle);
	errorBundle.start();
	StringBuilder filter = new StringBuilder();

	filter.append("(&");
	filter.append("(").append(Constants.OBJECTCLASS).append("=").append(
		AbstractRefreshableApplicationContext.class.getName()).append(")");
	filter.append("(").append(ConfigurableOsgiBundleApplicationContext.APPLICATION_CONTEXT_SERVICE_PROPERTY_NAME);
	filter.append("=").append("org.eclipse.gemini.blueprint.iandt.deadlock").append(")");
	filter.append(")");
	ServiceTracker tracker = new ServiceTracker(bundleContext, bundleContext.createFilter(filter.toString()), null);

	try {
		tracker.open();

		AbstractRefreshableApplicationContext appContext = (AbstractRefreshableApplicationContext) tracker.waitForService(3000);
		assertNull("Deadlock context should not be published", appContext);
	}
	finally {
		tracker.close();
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:34,代碼來源:DeadlockHandlingTest.java

示例14: startDependency

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
private void startDependency(Bundle simpleService2Bundle) throws BundleException, InterruptedException {
	System.out.println("Starting dependency");
	simpleService2Bundle.start();

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

	System.out.println("Dependency started");
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:9,代碼來源:Cardinality0to1Test.java

示例15: waitForContextStartEvent

import org.osgi.framework.Bundle; //導入方法依賴的package包/類
private void waitForContextStartEvent(Bundle bundle) throws Exception {
	int eventNumber = eventList.size();
	bundle.start();
	waitOnContextCreation(bundle.getSymbolicName());
	while (eventList.size() < eventNumber + 1)
		waitForEvent(TIME_OUT);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:8,代碼來源:DepedencyEventTest.java


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