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


Java Framework.start方法代码示例

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


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

示例1: test2InstallBundle

import org.osgi.framework.launch.Framework; //导入方法依赖的package包/类
@Test
public void test2InstallBundle() throws Exception
{
    Framework fw = getFramework();
    fw.start();
    
    // install bundle w/o dependency
    Bundle newBundle = installBundle(fw, getClass().getResource("/test-nodep.jar").toString(), "org.sensorhub.test");
            
    // attempt to start it
    newBundle.start();
    assertEquals("Bundle should be in ACTIVE state", Bundle.ACTIVE, newBundle.getState());
    
    fw.stop();
    fw.waitForStop(0);
}
 
开发者ID:sensiasoft,项目名称:sensorhub,代码行数:17,代码来源:TestOsgi.java

示例2: test3BundleDependencies

import org.osgi.framework.launch.Framework; //导入方法依赖的package包/类
@Test
public void test3BundleDependencies() throws Exception
{
    Framework fw = getFramework();
    fw.start();
    
    assertEquals("Wrong number of loaded bundles", 1, fw.getBundleContext().getBundles().length);
    
    // install 1st bundle
    installBundle(fw, getClass().getResource("/test-nodep.jar").toString(), "org.sensorhub.test");
    
    // install 2nd bundle
    Bundle bundle2 = installBundle(fw, getClass().getResource("/test-withdep.jar").toString(), "org.sensorhub.test2");
    
    bundle2.start();
    assertEquals("Bundle " + bundle2.getSymbolicName() + " should be in ACTIVE state", Bundle.ACTIVE, bundle2.getState());
    
    fw.stop();
    fw.waitForStop(0);
}
 
开发者ID:sensiasoft,项目名称:sensorhub,代码行数:21,代码来源:TestOsgi.java

示例3: testGuiceWorksInOSGiContainer

import org.osgi.framework.launch.Framework; //导入方法依赖的package包/类
public void testGuiceWorksInOSGiContainer() throws Throwable {

    // ask framework to clear cache on startup
    Properties properties = new Properties();
    properties.setProperty("org.osgi.framework.storage", BUILD_TEST_DIR + "/bundle.cache");
    properties.setProperty("org.osgi.framework.storage.clean", "onFirstInit");

    // test each available OSGi framework in turn
    for (FrameworkFactory frameworkFactory : ServiceLoader.load(FrameworkFactory.class)) {
      Framework framework = frameworkFactory.newFramework(properties);

      framework.start();
      BundleContext systemContext = framework.getBundleContext();

      // load all the necessary bundles and start the OSGi test bundle
      /*if[AOP]*/
      systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/aopalliance.jar");
      /*end[AOP]*/
      systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/javax.inject.jar");
      systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/guava.jar");
      systemContext.installBundle("reference:file:" + GUICE_JAR);
      systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/osgitests.jar").start();

      framework.stop();
    }
  }
 
开发者ID:google,项目名称:guice,代码行数:27,代码来源:OSGiContainerTest.java

示例4: initAndStartOSGiFramework

import org.osgi.framework.launch.Framework; //导入方法依赖的package包/类
/**
 * Initializes and start framework. Framework will try to resolve all the bundles if their requirements
 * can be satisfied.
 *
 * @param framework osgiFramework
 * @throws BundleException
 */
private void initAndStartOSGiFramework(Framework framework) throws BundleException {
    if (logger.isLoggable(Level.FINE)) {
        logger.log(Level.FINE, "Initializing the OSGi framework.");
    }

    framework.init();

    // Starts the framework.
    if (logger.isLoggable(Level.FINE)) {
        logger.log(Level.FINE, "Starting the OSGi framework.");
    }

    framework.start();

    if (logger.isLoggable(Level.FINE)) {
        logger.log(Level.FINE, "Started the OSGi framework.");
    }
}
 
开发者ID:wso2,项目名称:carbon-kernel,代码行数:26,代码来源:CarbonServer.java

示例5: test1StartStopFramework

import org.osgi.framework.launch.Framework; //导入方法依赖的package包/类
@Test
public void test1StartStopFramework() throws Exception
{
    Framework fw = getFramework();
    fw.start();
    Thread.sleep(500);
    fw.stop();
    fw.waitForStop(0);
}
 
开发者ID:sensiasoft,项目名称:sensorhub,代码行数:10,代码来源:TestOsgi.java

示例6: testOSGIBundle

import org.osgi.framework.launch.Framework; //导入方法依赖的package包/类
@Test
public void testOSGIBundle () throws BundleException
{
  LSInput aRes;

  // Initializing Apache Felix as OSGI container is required to get the
  // "bundle" URL protocol installed correctly
  // Otherwise the first call would end up as a "file" resource ;-)
  final Framework aOSGI = new FrameworkFactory ().newFramework (new HashMap <String, String> ());
  aOSGI.start ();
  try
  {
    // Bundle 0 is the org.apache.felix.framework bundle
    final Bundle b = aOSGI.getBundleContext ().getBundle (0);
    assertNotNull (b);
    assertEquals (b.getState (), Bundle.ACTIVE);

    // No leading slash is important as the ClassLoader is used!
    assertNotNull (b.getResource ("org/apache/felix/framework/util/Mutex.class"));

    final LSResourceResolver aRR = new SimpleLSResourceResolver ();

    // No class loader
    aRes = aRR.resolveResource (XMLConstants.W3C_XML_SCHEMA_NS_URI,
                                null,
                                null,
                                "../Felix.class",
                                "bundle://0.0:1/org/apache/felix/framework/util/Mutex.class");
    assertTrue (aRes instanceof ResourceLSInput);
    final IHasInputStream aISP = ((ResourceLSInput) aRes).getInputStreamProvider ();
    assertTrue (aISP instanceof URLResource);
    // Path maybe a "jar:file:" resource
    assertTrue (((URLResource) aISP).getPath ().endsWith ("org/apache/felix/framework/Felix.class"));
  }
  finally
  {
    aOSGI.stop ();
  }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:40,代码来源:SimpleLSResourceResolverTest.java

示例7: initialize

import org.osgi.framework.launch.Framework; //导入方法依赖的package包/类
private void initialize() throws BundleException, URISyntaxException {

        Map<String, String> configMap = loadProperties();
        System.setProperty(LOG_CONFIG_FILE_PROPERTY, configMap.get(LOG_CONFIG_FILE_PROPERTY));
   
        System.out.println("Building OSGi Framework");
        FrameworkFactory frameworkFactory = ServiceLoader.load(FrameworkFactory.class).iterator().next();
        Framework framework = frameworkFactory.newFramework(configMap);

        framework.init();
        // (9) Use the system bundle context to process the auto-deploy
        // and auto-install/auto-start properties.
        AutoProcessor.process(configMap, framework.getBundleContext());
        // (10) Start the framework.
        System.out.println("Starting OSGi Framework");
        framework.start();
     
        BundleContext context = framework.getBundleContext();
        // declarative services dependency is necessary, otherwise they won't be picked up!
        loadScrBundle(context);

        try {
            framework.waitForStop(0);
        } catch (InterruptedException e) {
        	appendToFile(e);
        	showErrorMessage();
        }
        System.exit(0);
    }
 
开发者ID:burningrain,项目名称:planetBot,代码行数:30,代码来源:Launcher.java

示例8: testGuiceWorksInOSGiContainer

import org.osgi.framework.launch.Framework; //导入方法依赖的package包/类
public void testGuiceWorksInOSGiContainer()
      throws Throwable {

    // ask framework to clear cache on startup
    Properties properties = new Properties();
    properties.setProperty("org.osgi.framework.storage", BUILD_TEST_DIR + "/bundle.cache");
    properties.setProperty("org.osgi.framework.storage.clean", "onFirstInit");

    // test each available OSGi framework in turn
    Iterator<FrameworkFactory> f = ServiceRegistry.lookupProviders(FrameworkFactory.class);
    while (f.hasNext()) {
      Framework framework = f.next().newFramework(properties);

      framework.start();
      BundleContext systemContext = framework.getBundleContext();

      // load all the necessary bundles and start the OSGi test bundle
/*if[AOP]*/
      systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/aopalliance.jar");
/*end[AOP]*/
      systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/javax.inject.jar");
      systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/guava.jar");
      systemContext.installBundle("reference:file:" + GUICE_JAR);
      systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/osgitests.jar").start();

      framework.stop();
    }
  }
 
开发者ID:cgruber,项目名称:guice-old,代码行数:29,代码来源:OSGiContainerTest.java

示例9: testGuiceWorksInOSGiContainer

import org.osgi.framework.launch.Framework; //导入方法依赖的package包/类
public void testGuiceWorksInOSGiContainer()
      throws Throwable {

    // ask framework to clear cache on startup
    Properties properties = new Properties();
    properties.setProperty("org.osgi.framework.storage", BUILD_TEST_DIR + "/bundle.cache");
    properties.setProperty("org.osgi.framework.storage.clean", "onFirstInit");

    // test each available OSGi framework in turn
    Iterator<FrameworkFactory> f = ServiceRegistry.lookupProviders(FrameworkFactory.class);
    while (f.hasNext()) {
      Framework framework = f.next().newFramework(properties);

      framework.start();
      BundleContext systemContext = framework.getBundleContext();

      // load all the necessary bundles and start the OSGi test bundle
/*if[AOP]*/
      systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/aopalliance.jar");
/*end[AOP]*/
      systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/javax.inject.jar");
      systemContext.installBundle("reference:file:" + GUICE_JAR);
      systemContext.installBundle("reference:file:" + BUILD_TEST_DIR + "/osgitests.jar").start();

      framework.stop();
    }
  }
 
开发者ID:utopiazh,项目名称:google-guice,代码行数:28,代码来源:OSGiContainerTest.java

示例10: start

import org.osgi.framework.launch.Framework; //导入方法依赖的package包/类
public void start() 
{		
	frame = new SplashFrame();
	
	final SwingWorker<Void, Integer> worker = new SwingWorker<Void, Integer>() {
		protected Void doInBackground() throws Exception {
			try {
				String factoryClass = getFactoryClass();
				FrameworkFactory factory = (FrameworkFactory) Class.forName(factoryClass).newInstance();
				
				Framework framework = factory.newFramework(getLaunchProperties());
				framework.start();
				
				context = framework.getBundleContext();
				BundleLoader loader = new BundleLoader(context);
				
			 	/* load embedded bundles, i.e. all bundles that are inside pathvisio.jar */ 
		    	System.out.println("Installing bundles that are embedded in the jar.");
		    	
				Set<String> jarNames = loader.getResourceListing(PathVisioMain.class);
				int cnt = 0;
				int total = jarNames.size() + pluginLocations.size();
				
				for (String s : jarNames) 
				{
					String text = (s.length() > 50) ? s.substring(0, 50) : s;
					frame.getTextLabel().setText("<html>Install " + text + ".</html>");
					frame.repaint();
					publish(100 * (++cnt) / total);
					loader.installEmbeddedBundle(s);
				}

				frame.getTextLabel().setText("<html>Install active plugins.</html>");
				frame.repaint();
		    	System.out.println("Installing bundles from directories specified on the command-line.");
		    	for(String location : pluginLocations) {
		    		publish(100 * (++cnt) / total);
		    		loader.loadFromParameter(location);
				}
		    
				startBundles(context, loader.getBundles());
				
				frame.getTextLabel().setText("Start application.");
				frame.repaint();
			} catch(Exception ex) {
				reportException("Startup Error", ex);
				ex.printStackTrace();
			}
			return null;
		}
		
		protected void process(List<Integer> chunks) {
			for (Integer chunk : chunks) {
				frame.getProgressBar().setString("Installing modules..." + chunk + "%");
				frame.getProgressBar().setValue(chunk);
				frame.repaint();
			}
		}
			
		protected void done() {
			frame.setVisible(false);
		}
		
	};

	worker.execute();
}
 
开发者ID:PathVisio,项目名称:pathvisio,代码行数:68,代码来源:PathVisioMain.java

示例11: startOSGiContainer

import org.osgi.framework.launch.Framework; //导入方法依赖的package包/类
private Framework startOSGiContainer(final String[] bundleLocations,
    final String tempDirPath) throws BundleException {
  FrameworkFactory frameworkFactory = ServiceLoader
      .load(FrameworkFactory.class).iterator().next();

  Map<String, String> config = new HashMap<String, String>();
  config.put("org.osgi.framework.system.packages", "");
  config.put("osgi.configuration.area", tempDirPath);
  config.put("osgi.baseConfiguration.area", tempDirPath);
  config.put("osgi.sharedConfiguration.area", tempDirPath);
  config.put("osgi.instance.area", tempDirPath);
  config.put("osgi.user.area", tempDirPath);
  config.put("osgi.hook.configurators.exclude",
      "org.eclipse.core.runtime.internal.adaptor.EclipseLogHook");

  Framework framework = frameworkFactory.newFramework(config);
  framework.init();

  BundleContext systemBundleContext = framework.getBundleContext();

  org.apache.maven.artifact.Artifact equinoxCompatibilityStateArtifact =
      pluginArtifactMap.get("org.eclipse.tycho:org.eclipse.osgi.compatibility.state");

  URI compatibilityBundleURI = equinoxCompatibilityStateArtifact.getFile().toURI();

  systemBundleContext.installBundle("reference:" + compatibilityBundleURI.toString());

  framework.start();

  for (String bundleLocation : bundleLocations) {
    try {
      systemBundleContext.installBundle(bundleLocation);
    } catch (BundleException e) {
      getLog().warn("Could not install bundle " + bundleLocation, e);
    }
  }
  FrameworkWiring frameworkWiring = framework
      .adapt(FrameworkWiring.class);
  frameworkWiring.resolveBundles(null);

  return framework;
}
 
开发者ID:everit-org,项目名称:eosgi-maven-plugin,代码行数:43,代码来源:AnalyzeMojo.java


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