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


Java Bundle.uninstall方法代码示例

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


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

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

示例2: uninstallBundle

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
@Deprecated
public void uninstallBundle(final String location) throws BundleException {
    Bundle bundle = Framework.getBundle(location);
    if (bundle != null) {
        BundleImpl b = (BundleImpl)bundle;
        File delDir = null;
        try {
            File soFile = b.getArchive().getArchiveFile();
            if(soFile.canWrite()){
                soFile.delete();
            }
            delDir = b.getArchive().getCurrentRevision().getRevisionDir();
            bundle.uninstall();
            if(delDir !=null ){
                Framework.deleteDirectory(delDir);
            }
        } catch (Exception e) {
        }

    } else {
        throw new BundleException("Could not uninstall bundle " + location + ", because could not find it");
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:24,代码来源:Atlas.java

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

示例4: testEventsForCtxThatWork

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

		listener = new OsgiBundleApplicationContextListener() {

			public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent event) {
				if (event instanceof OsgiBundleContextRefreshedEvent) {
					eventList.add(event);
					synchronized (lock) {
						lock.notify();
					}
				}
			}
		};

		registerEventListener();

		assertTrue("should start with an empty list", eventList.isEmpty());
		// install a simple osgi bundle and check the list of events

		Resource bundle = getLocator().locateArtifact("org.eclipse.gemini.blueprint.iandt", "simple.service",
			getSpringDMVersion());

		Bundle bnd = bundleContext.installBundle(bundle.getURL().toExternalForm());
		try {

			bnd.start();

			assertTrue("no event received", waitForEvent(TIME_OUT));
			System.out.println("events received " + eventList);
		}
		finally {
			bnd.uninstall();
		}
	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:35,代码来源:OsgiLifecycleNotificationTest.java

示例5: testEventsForCtxThatFail

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

		listener = new OsgiBundleApplicationContextListener() {

			public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent event) {
				if (event instanceof OsgiBundleContextFailedEvent) {
					eventList.add(event);
					synchronized (lock) {
						lock.notify();
					}
				}
			}
		};

		registerEventListener();

		assertTrue("should start with an empty list", eventList.isEmpty());
		// install a simple osgi bundle and check the list of events

		Resource bundle = getLocator().locateArtifact("org.eclipse.gemini.blueprint.iandt", "error", getSpringDMVersion());

		Bundle bnd = bundleContext.installBundle(bundle.getURL().toExternalForm());

		try {
			bnd.start();

			assertTrue("event not received", waitForEvent(TIME_OUT));
		}
		finally {
			bnd.uninstall();
		}
	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:33,代码来源:OsgiLifecycleNotificationTest.java

示例6: testDependencies

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

		// Simple Service bundle (provides the base package + 1 service)
		Bundle simpleServiceBundle = bundleContext.installBundle(getLocator().locateArtifact(
			"org.eclipse.gemini.blueprint.iandt", "simple.service", getSpringDMVersion()).getURL().toExternalForm());
		assertNotNull("Cannot find the simple service bundle", simpleServiceBundle);

		assertNotSame("simple service bundle is in the activated state!", new Integer(Bundle.ACTIVE), new Integer(
			simpleServiceBundle.getState()));
		startDependency(simpleServiceBundle);

		// Identical Simple Service bundle (+1 service)
		Bundle simpleServiceDuplicateBundle = bundleContext.installBundle(getLocator().locateArtifact(
			"org.eclipse.gemini.blueprint.iandt", "simple.service.identical", getSpringDMVersion()).getURL().toExternalForm());
		assertNotNull("Cannot find the simple service duplicate bundle", simpleServiceDuplicateBundle);
		assertNotSame("simple service 2 bundle is in the activated state!", new Integer(Bundle.ACTIVE), new Integer(
			simpleServiceDuplicateBundle.getState()));
		startDependency(simpleServiceDuplicateBundle);

		ServiceReference[] refs = bundleContext.getServiceReferences(DEPENDENT_CLASS_NAME, null);

		assertEquals(2, refs.length);

		MyService service1 = (MyService) bundleContext.getService(refs[0]);
		MyService service2 = (MyService) bundleContext.getService(refs[1]);

		assertNotNull(service1);
		assertNotNull(service2);

		String msg1 = service1.stringValue();
		String msg2 = service2.stringValue();

		String jmsg = "Bond.  James Bond.";
		String cmsg = "Connery.  Sean Connery #1";
		System.out.println(msg1);
		System.out.println(msg2);
		assertNotSame(msg1, msg2);
		assertTrue(msg1.equals(jmsg) || msg1.equals(cmsg));
		assertTrue(msg2.equals(jmsg) || msg2.equals(cmsg));

		bundleContext.ungetService(refs[0]);
		bundleContext.ungetService(refs[1]);

		// Uninstall duplicate 1
		simpleServiceDuplicateBundle.uninstall();
		// stop base bundle so that the package is still around but its service
		// is not
		simpleServiceBundle.stop();

		// Install something subtley different
		simpleServiceDuplicateBundle = bundleContext.installBundle(getLocator().locateArtifact(
			"org.eclipse.gemini.blueprint.iandt", "simple.service.2.identical", getSpringDMVersion()).getURL().toExternalForm());
		assertNotNull("Cannot find the simple service duplicate 2 bundle", simpleServiceDuplicateBundle);
		startDependency(simpleServiceDuplicateBundle);

		refs = bundleContext.getServiceReferences(DEPENDENT_CLASS_NAME, null);

		assertEquals(1, refs.length);

		service1 = (MyService) bundleContext.getService(refs[0]);

		assertNotNull(service1);

		msg1 = service1.stringValue();

		System.out.println(msg1);
		assertTrue(msg1.equals("Dalton.  Timothy Dalton #1"));
	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:69,代码来源:DuplicateClassTest.java


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