本文整理匯總了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"));
}