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