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


Java BundleContext.addFrameworkListener方法代码示例

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


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

示例1: activate

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
@Activate
void activate(BundleContext context) {
    this.context = context;
    context.addFrameworkListener(this.frameworkListener);
    context.addBundleListener(this.bundleListener);

    this.processorThread = new Thread(() -> {
        this.log.log(LogService.LOG_INFO, "Deployment Installer thread starting");
        debug("Deployment Install thread starting");
        while (!Thread.interrupted()) {
            try {
                Runnable job = waitForJob();
                job.run();
            } catch (InterruptedException e) {
                debug("Deployment Install thread interrupted");
                this.log.log(LogService.LOG_INFO, "Deployment Installer thread interrupted");
                break;
            } catch (Exception e) {
                this.log.log(LogService.LOG_ERROR, "Error processing job on Deployment Installer thread", e);
            }
        }
        debug("Deployment Install thread terminated.");
        this.log.log(LogService.LOG_INFO, "Deployment Installer thread terminated");
    });
    this.processorThread.start();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:27,代码来源:DeploymentInstaller.java

示例2: testActivation

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
public void testActivation() throws Exception {
    ModuleSystem ms = Main.getModuleSystem();
    mgr = ms.getManager();
    mgr.mutexPrivileged().enterWriteAccess();
    try {
        m1 = mgr.createBundle(simpleModule, null, false, false, false, 10);
        mgr.enable(m1);
    } finally {
        mgr.mutexPrivileged().exitWriteAccess();
    }

    Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
    Object s = main.getField("start").get(null);
    assertNull("Not started yet", s);

    Framework f = NetigsoServicesTest.findFramework();
    final BundleContext fc = f.getBundleContext();
    fc.addFrameworkListener(this);
    ServiceReference sr = fc.getServiceReference(StartLevel.class.getName());
    assertNotNull("Start level service found", sr);
    StartLevel level = (StartLevel) fc.getService(sr);
    assertNotNull("Start level found", level);
    level.setStartLevel(10);
    waitLevelChanged();
        
    s = main.getField("start").get(null);
    assertNotNull("Bundle started, its context provided", s);

    mgr.mutexPrivileged().enterWriteAccess();
    try {
        mgr.disable(m1);

        Object e = main.getField("stop").get(null);
        assertNotNull("Bundle stopped, its context provided", e);
    } finally {
        mgr.mutexPrivileged().exitWriteAccess();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:NetigsoStartLevelTest.java

示例3: start

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
public @Override void start(final BundleContext context) throws Exception {
        if (System.getProperty("netbeans.home") != null) {
            throw new IllegalStateException("Should not be run from inside regular NetBeans module system");
        }
        String storage = context.getProperty(Constants.FRAMEWORK_STORAGE);
        if (storage != null) {
            System.setProperty("netbeans.user", storage);
        }
        System.setProperty("TopSecurityManager.disable", "true");
        NbBundle.setBranding(System.getProperty("branding.token"));
        OSGiMainLookup.initialize(context);
        queue = new DependencyQueue<String,Bundle>();
        this.context = context;
        framework = ((Framework) context.getBundle(0));
        if (framework.getState() == Bundle.STARTING) {
            LOG.fine("framework still starting");
            final AtomicReference<FrameworkListener> frameworkListener = new AtomicReference<FrameworkListener>();
            frameworkListener.set(new FrameworkListener() {
                public @Override void frameworkEvent(FrameworkEvent event) {
                    if (event.getType() == FrameworkEvent.STARTED) {
//                        System.err.println("framework started");
                        context.removeFrameworkListener(frameworkListener.get());
                        context.addBundleListener(Activator.this);
                        processLoadedBundles();
                    }
                }
            });
            context.addFrameworkListener(frameworkListener.get());
        } else {
            LOG.fine("framework already started");
            context.addBundleListener(this);
            processLoadedBundles();
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:Activator.java

示例4: frameworkStart

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
@Override
public void frameworkStart(BundleContext bc) throws BundleException {
    bc.addFrameworkListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:NetbinoxHooks.java


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