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


Java Framework类代码示例

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


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

示例1: DefaultFrameworkTemplate

import org.osgi.framework.launch.Framework; //导入依赖的package包/类
public DefaultFrameworkTemplate(Object target, Log log) {
	if (OsgiPlatformDetector.isR42()) {
		Assert.isInstanceOf(Framework.class, target);
		fwk = (Framework) target;
	} else {
		throw new IllegalStateException("Cannot use OSGi 4.2 Framework API in an OSGi 4.1 environment");
	}
	this.log = log;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:10,代码来源:DefaultFrameworkTemplate.java

示例2: installBundle

import org.osgi.framework.launch.Framework; //导入依赖的package包/类
protected Bundle installBundle(Framework fw, String bundleURL, String bundleName) throws Exception
{
    int numBundles = fw.getBundleContext().getBundles().length;
    
    // install bundle
    Bundle newBundle = fw.getBundleContext().installBundle(bundleURL);
    assertTrue("bundle should not be null", newBundle != null);        
    System.out.println("Bundle name is " + newBundle.getSymbolicName());
    
    // check that it was properly loaded
    assertEquals("Wrong number of loaded bundles", numBundles+1, fw.getBundleContext().getBundles().length);
    assertEquals("Unexpected bundle name", bundleName, newBundle.getSymbolicName());
    assertEquals("Bundle should be in INSTALLED state", Bundle.INSTALLED, newBundle.getState());
    
    return newBundle;
}
 
开发者ID:sensiasoft,项目名称:sensorhub,代码行数:17,代码来源:TestOsgi.java

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

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

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

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

示例7: waitForServerStop

import org.osgi.framework.launch.Framework; //导入依赖的package包/类
/**
 * Wait until this Framework has completely stopped.
 *
 * @param framework OSGi framework
 * @throws java.lang.Exception
 */
private void waitForServerStop(Framework framework) throws Exception {
    if (!isFrameworkActive()) {
        return;
    }

    while (true) {
        FrameworkEvent event = framework.waitForStop(0);

        // We should not stop the framework if the user has updated the system bundle via the OSGi console or
        //  programmatically. In this case, framework will shutdown and start itself.
        if (event.getType() != FrameworkEvent.STOPPED_UPDATE) {
            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "OSGi framework is stopped for update.");
            }
            break;
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-kernel,代码行数:25,代码来源:CarbonServer.java

示例8: _autoDeployBundles

import org.osgi.framework.launch.Framework; //导入依赖的package包/类
private static void _autoDeployBundles(File fileOrDir, Framework framework)
        throws FileNotFoundException, BundleException {
    if (fileOrDir.isFile() && fileOrDir.getName().endsWith(".jar")) {
        _deployBundle(fileOrDir.getName(), fileOrDir);
    } else {
        // make sure bundles are deployed and started in order!
        File[] files = fileOrDir.listFiles();
        if (files != null && files.length > 0) {
            Arrays.sort(files, new Comparator<File>() {
                @Override
                public int compare(File file1, File file2) {
                    return file1.compareTo(file2);
                }
            });
            for (File f : files) {
                if (!f.getName().startsWith(".")) {
                    _autoDeployBundles(f, framework);
                }
            }
        }
    }
}
 
开发者ID:DDTH,项目名称:osgiserver,代码行数:23,代码来源:StandaloneBootstrap.java

示例9: findFrameworkClassLoader

import org.osgi.framework.launch.Framework; //导入依赖的package包/类
@Override
protected ClassLoader findFrameworkClassLoader() {
    ClassLoader l = frameworkLoader;
    if (l != null) {
        return l;
    }
    Framework f = framework;
    if (f != null) {
        return frameworkLoader = f.getClass().getClassLoader();
    }
    return getClass().getClassLoader();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:Netigso.java

示例10: toActivate

import org.osgi.framework.launch.Framework; //导入依赖的package包/类
private static Set<String> toActivate(Framework f, Collection<? extends Module> allModules) {
    ServiceReference sr = f.getBundleContext().getServiceReference("org.osgi.service.packageadmin.PackageAdmin"); // NOI18N
    if (sr == null) {
        return null;
    }
    PackageAdmin pkgAdm = (PackageAdmin)f.getBundleContext().getService(sr);
    if (pkgAdm == null) {
        return null;
    }
    Set<String> allCnbs = new HashSet<String>(allModules.size() * 2);
    for (ModuleInfo m : allModules) {
        allCnbs.add(m.getCodeNameBase());
    }
    
    Set<String> needEnablement = new HashSet<String>();
    for (Bundle b : f.getBundleContext().getBundles()) {
        String loc = b.getLocation();
        if (loc.startsWith("netigso://")) {
            loc = loc.substring("netigso://".length());
        } else {
            continue;
        }
        RequiredBundle[] arr = pkgAdm.getRequiredBundles(loc);
        if (arr != null) for (RequiredBundle rb : arr) {
            for (Bundle n : rb.getRequiringBundles()) {
                if (allCnbs.contains(n.getSymbolicName().replace('-', '_'))) {
                    needEnablement.add(loc);
                }
            }
        }
    }
    return needEnablement;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:Netigso.java

示例11: NetigsoServices

import org.osgi.framework.launch.Framework; //导入依赖的package包/类
NetigsoServices(Netigso netigso, Framework f) {
    this.netigso = netigso;
    for (ServiceReference ref : f.getRegisteredServices()) {
        MainLookup.register(ref, this);
    }
    f.getBundleContext().addServiceListener(this);
    f.getBundleContext().addBundleListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:NetigsoServices.java

示例12: testCheckWhichContainerIsRunning

import org.osgi.framework.launch.Framework; //导入依赖的package包/类
@RandomlyFails // NB-Core-Build #8007: Framework found
public void testCheckWhichContainerIsRunning() throws Exception {
    ModuleManager mgr = Main.getModuleSystem().getManager();
    Module m1;
    mgr.mutexPrivileged().enterWriteAccess();
    try {
        String mf = "Bundle-SymbolicName: org.foo\n" +
            "Bundle-Version: 1.1.0\n" +
            "Bundle-ManifestVersion: 2\n" +
            "Export-Package: org.foo";

        LOG.info("about to enable module org.foo");
        File jj1 = NetigsoHid.changeManifest(getWorkDir(), j1, mf);
        m1 = mgr.create(jj1, null, false, false, false);
        mgr.enable(m1);
        LOG.info("Enabling is over");

        assertTrue("OSGi module is now enabled", m1.isEnabled());
    } finally {
        mgr.mutexPrivileged().exitWriteAccess();
    }

    Framework w = NetigsoUtil.framework(mgr);
    assertNotNull("Framework found", w);
    if (!w.getClass().getName().contains("felix")) {
        fail("By default the OSGi framework is felix: " + w.getClass());
    }


    ClassLoader fwloader = w.getClass().getClassLoader();
    Method addURLMethod = howEclipseFindsMethodToSupportFrameworks(fwloader.getClass());

    assertNotNull("addURL method found", addURLMethod);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:IntegrationTest.java

示例13: framework

import org.osgi.framework.launch.Framework; //导入依赖的package包/类
public static Framework framework(ModuleManager mgr) throws Exception {
    final Method nm = mgr.getClass().getDeclaredMethod("netigso");
    nm.setAccessible(true);
    final Netigso netigso = (Netigso) nm.invoke(mgr);
    Method m = Netigso.class.getDeclaredMethod("getFramework");
    m.setAccessible(true);
    Framework f = (Framework) m.invoke(netigso);
    return f;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:NetigsoUtil.java

示例14: bundle

import org.osgi.framework.launch.Framework; //导入依赖的package包/类
static Bundle bundle(Module module) throws Exception {
    Framework f = framework(module.getManager());
    for (Bundle b : f.getBundleContext().getBundles()) {
        if (b.getSymbolicName().equals(module.getCodeNameBase())) {
            return b;
        }
    }
    Assert.fail("no bundle found for " + module);
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:NetigsoUtil.java

示例15: newFramework

import org.osgi.framework.launch.Framework; //导入依赖的package包/类
@Override
public Framework newFramework(Map map) {
    NetigsoArchive archive = (NetigsoArchive) map.get("netigso.archive");
    assertNotNull("archive provided", archive);
    AtomicReference<BundleContext> ar = new AtomicReference<BundleContext>();
    return (Framework) delegate(new MockFramework(archive, ar), ar, Framework.class, BundleContext.class);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:NetigsoSelfQueryTest.java


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