本文整理汇总了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();
}
}
}
示例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");
}
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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"));
}