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


Java BundleEvent类代码示例

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


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

示例1: bundleChanged

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
public @Override void bundleChanged(BundleEvent event) {
        Bundle bundle = event.getBundle();
        switch (event.getType()) {
        case BundleEvent.STARTED:
//            System.err.println("started " + bundle.getSymbolicName());
            Dictionary<?,?> headers = bundle.getHeaders();
            load(queue.offer(bundle, provides(headers), requires(headers), needs(headers)));
            break;
        case BundleEvent.STOPPED:
//            System.err.println("stopped " + bundle.getSymbolicName());
            if (framework.getState() == Bundle.STOPPING) {
//                System.err.println("fwork stopping during " + bundle.getSymbolicName());
//                ActiveQueue.stop();
            } else {
                unload(queue.retract(bundle));
            }
            break;
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:Activator.java

示例2: BundleImpl

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
/**
 * create a new bundle object from InputStream. This is used when a new bundle is installed.
 *
 * @param location the bundle location.
 * @param stream the input stream.
 * @throws BundleException if something goes wrong.
 * @throws IOException
 */
BundleImpl(final File bundleDir, final String location, final InputStream stream,
           final File file, String unique_tag, boolean installForCurrentVersion, long dexPatchVersion) throws BundleException, IOException{
    this.location = location;
    this.bundleDir = bundleDir;
    if(installForCurrentVersion) {
        Framework.notifyBundleListeners(BundleEvent.BEFORE_INSTALL, this);
    }
    if (stream != null) {
        this.archive = new BundleArchive(location,bundleDir, stream,unique_tag, dexPatchVersion);
    } else if (file != null) {
        this.archive = new BundleArchive(location,bundleDir, file,unique_tag, dexPatchVersion);
    }
    this.state = INSTALLED;
    if (installForCurrentVersion) {
        resolveBundle();
        Framework.bundles.put(location, this);
        // notify the listeners
        Framework.notifyBundleListeners(BundleEvent.INSTALLED, this);
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:29,代码来源:BundleImpl.java

示例3: startBundle

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
/**
 * the actual starting happens here.
 *
 * @throws BundleException if the bundle cannot be resolved or the Activator throws an exception.
 */
public synchronized void startBundle() {
    if (state == UNINSTALLED) {
        throw new IllegalStateException("Cannot start uninstalled bundle " + toString());
    }
    if (state == ACTIVE) {
        return;
    }
    if (state == INSTALLED) {
        throw new RuntimeException("can not start bundle which is not resolved");
    }
    state = STARTING;
    Framework.notifyBundleListeners(BundleEvent.BEFORE_STARTED, this);
    Framework.notifyBundleListeners(BundleEvent.STARTED, this);
    if (Framework.DEBUG_BUNDLES) {
        Log.i("Framework","Bundle " + toString() + " started.");
    }


}
 
开发者ID:alibaba,项目名称:atlas,代码行数:25,代码来源:BundleImpl.java

示例4: uninstall

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
/**
 * uninstall the bundle.
 * 
 * @throws BundleException if bundle is already uninstalled
 * @see org.osgi.framework.Bundle#uninstall()
 * @category Bundle
 */
public synchronized void uninstall() throws BundleException {

    if (state == UNINSTALLED) {
        throw new IllegalStateException("Bundle " + toString() + " is already uninstalled.");
    }
    if (state == ACTIVE) {
        try {
            stop();
        } catch (Throwable t) {
            Framework.notifyFrameworkListeners(FrameworkEvent.ERROR, this, t);
        }
    }

    state = UNINSTALLED;

    classloader.cleanup(true);
    classloader = null;

    Framework.bundles.remove(getLocation());
    Framework.notifyBundleListeners(BundleEvent.UNINSTALLED, this);
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:29,代码来源:BundleImpl.java

示例5: notifyBundleListeners

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
/**
 * notify all bundle listeners.
 *
 * @param state the new state.
 * @param bundle the bundle.
 */
static void notifyBundleListeners(final int state, final Bundle bundle) {
    if (syncBundleListeners.isEmpty() && bundleListeners.isEmpty()) {
        return;
    }

    final BundleEvent event = new BundleEvent(state, bundle);

    // inform the synchrounous bundle listeners first ...
    final BundleListener[] syncs = (BundleListener[]) syncBundleListeners.toArray(new BundleListener[syncBundleListeners.size()]);

    for (int i = 0; i < syncs.length; i++) {
        syncs[i].bundleChanged(event);
    }

    if (bundleListeners.isEmpty()) {
        return;
    }

    final BundleListener[] asyncs = (BundleListener[]) bundleListeners.toArray(new BundleListener[bundleListeners.size()]);
    for (int i = 0; i < asyncs.length; i++) {
        asyncs[i].bundleChanged(event);
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:30,代码来源:Framework.java

示例6: activate

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
@Activate
void activate(BundleContext ctx) {
    this.base = new File("").toURI();
    // Find the resolved vaadin bundle
    this.vaadinResourceBundles = new BundleTracker<Bundle>(ctx, Bundle.RESOLVED |
            Bundle.STARTING | Bundle.ACTIVE | Bundle.STOPPING,
                new BundleTrackerCustomizer<Bundle>() {
                    @Override
                    public Bundle addingBundle(Bundle bundle, BundleEvent event) {
                        return VAADIN_SERVER_BUNDLE.equals(bundle.getSymbolicName()) ?
                                bundle : null;
                    }

                    @Override
                    public void modifiedBundle(Bundle bundle, BundleEvent event, Bundle object) {

                    }

                    @Override
                    public void removedBundle(Bundle bundle, BundleEvent event, Bundle object) {
                    }
            });
    this.vaadinResourceBundles.open();
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:25,代码来源:UiServletContext.java

示例7: bundleChanged

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
/**
 * A bundle has been started, stopped, resolved, or unresolved. This method is a synchronous callback, do not do
 * any long-running work in this thread.
 *
 * @see org.osgi.framework.SynchronousBundleListener#bundleChanged
 */
public void bundleChanged(BundleEvent event) {

    boolean trace = log.isTraceEnabled();

    // check if the listener is still alive
    if (isClosed) {
        if (trace)
            log.trace("Listener is closed; events are being ignored");
        return;
    }
    if (trace) {
        log.trace("Processing bundle event [" + OsgiStringUtils.nullSafeToString(event) + "] for bundle ["
                + OsgiStringUtils.nullSafeSymbolicName(event.getBundle()) + "]");
    }
    try {
        handleEvent(event);
    } catch (Exception ex) {
        /* log exceptions before swallowing */
        log.warn("Got exception while handling event " + event, ex);
    }
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:28,代码来源:BaseListener.java

示例8: removedBundle

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
@Override
@SuppressWarnings("IllegalCatch")
public void removedBundle(final Bundle bundle, final BundleEvent event,
        final Collection<ObjectRegistration<YangModuleInfo>> regs) {
    if (regs == null) {
        return;
    }

    for (ObjectRegistration<YangModuleInfo> reg : regs) {
        try {
            reg.close();
        } catch (final Exception e) {
            LOG.error("Unable to unregister YangModuleInfo {}", reg.getInstance(), e);
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:ModuleInfoBundleTracker.java

示例9: addingBundle

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
@Override
public Boolean addingBundle(final Bundle bundle, final BundleEvent event) {
    URL resource = bundle.getEntry("META-INF/services/" + ModuleFactory.class.getName());
    LOG.trace("Got addingBundle event of bundle {}, resource {}, event {}", bundle, resource, event);
    if (resource != null) {
        try {
            for (String factoryClassName : Resources.readLines(resource, StandardCharsets.UTF_8)) {
                registerFactory(factoryClassName, bundle);
            }

            return Boolean.TRUE;
        } catch (final IOException e) {
            LOG.error("Error while reading {}", resource, e);
            throw new RuntimeException(e);
        }
    }

    return Boolean.FALSE;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:ModuleFactoryBundleTracker.java

示例10: removedBundle

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
@Override
public void removedBundle(final Bundle bundle, final BundleEvent event, final Future<T> object) {
    if (!object.isDone() && object.cancel(false)) {
        // We canceled adding event before it was processed
        // so it is safe to return
        LOG.trace("Adding Bundle event for {} was cancelled. No additional work required.", bundle);
        return;
    }
    try {
        LOG.trace("Invoking removedBundle event for {}", bundle);
        primaryTracker.removedBundle(bundle, event, object.get());
        forEachAdditionalBundle(tracker -> tracker.removedBundle(bundle, event, null));
        LOG.trace("Removed bundle event for {} finished successfully.", bundle);
    } catch (final ExecutionException | InterruptedException e) {
        LOG.error("Failed to remove bundle {}", bundle, e);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:ExtensibleBundleTracker.java

示例11: modifiedBundle

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
/**
 * Implemented from BundleTrackerCustomizer.
 */
@Override
public void modifiedBundle(final Bundle bundle, final BundleEvent event, final Bundle object) {
    if (shuttingDown) {
        return;
    }

    if (bundle.getState() == Bundle.ACTIVE) {
        List<Object> paths = findBlueprintPaths(bundle);

        if (!paths.isEmpty()) {
            LOG.info("Creating blueprint container for bundle {} with paths {}", bundle, paths);

            blueprintExtenderService.createContainer(bundle, paths);
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:BlueprintBundleTracker.java

示例12: BundleImpl

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
BundleImpl(File file) throws Exception {
    long currentTimeMillis = System.currentTimeMillis();
    DataInputStream dataInputStream = new DataInputStream(new FileInputStream(new File(file, "meta")));
    this.location = dataInputStream.readUTF();
    this.currentStartlevel = dataInputStream.readInt();
    this.persistently = dataInputStream.readBoolean();
    dataInputStream.close();

    this.bundleDir = file;
    this.state = BundleEvent.STARTED;
    try {
        this.archive = new BundleArchive(this.location, file);
        resolveBundle(false);
        Framework.bundles.put(this.location, this);
        Framework.notifyBundleListeners(BundleEvent.INSTALLED, this);
        if (Framework.DEBUG_BUNDLES && log.isInfoEnabled()) {
            log.info("Framework: Bundle " + toString() + " loaded. " + (System.currentTimeMillis() - currentTimeMillis) + " ms");
        }
    } catch (Exception e) {
        throw new BundleException("Could not load bundle " + this.location, e.getCause());
    }
}
 
开发者ID:bunnyblue,项目名称:ACDD,代码行数:23,代码来源:BundleImpl.java

示例13: startBundle

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
public synchronized void startBundle() throws BundleException {
    if (this.state == BundleEvent.INSTALLED) {
        throw new IllegalStateException("Cannot start uninstalled bundle "
                + toString());
    } else if (this.state != BundleEvent.RESOLVED) {
        if (this.state == BundleEvent.STARTED) {
            resolveBundle(true);
        }
        this.state = BundleEvent.UPDATED;
        try {

            isValid = true;
            this.state = BundleEvent.RESOLVED;
            Framework.notifyBundleListeners(BundleEvent.STARTED, this);
            if (Framework.DEBUG_BUNDLES && log.isInfoEnabled()) {
                log.info("Framework: Bundle " + toString() + " started.");
            }
        } catch (Throwable th) {

            Framework.clearBundleTrace(this);
            this.state = BundleEvent.STOPPED;
            String msg = "Error starting bundle " + toString();
            log.error(msg,th);
        }
    }
}
 
开发者ID:bunnyblue,项目名称:ACDD,代码行数:27,代码来源:BundleImpl.java

示例14: stopBundle

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
public synchronized void stopBundle() throws BundleException {
    if (this.state == BundleEvent.INSTALLED) {
        throw new IllegalStateException("Cannot stop uninstalled bundle "
                + toString());
    } else if (this.state == BundleEvent.RESOLVED) {
        this.state = BundleEvent.UNINSTALLED;
        try {
            if (Framework.DEBUG_BUNDLES && log.isInfoEnabled()) {
                log.info("Framework: Bundle " + toString() + " stopped.");
            }
            Framework.clearBundleTrace(this);
            this.state = BundleEvent.STOPPED;
            Framework.notifyBundleListeners(BundleEvent.STOPPED, this);
            isValid = false;
        } catch (Throwable th) {

            Framework.clearBundleTrace(this);
            this.state = BundleEvent.STOPPED;
            Framework.notifyBundleListeners(BundleEvent.STOPPED, this);
            isValid = false;
        }
    }
}
 
开发者ID:bunnyblue,项目名称:ACDD,代码行数:24,代码来源:BundleImpl.java

示例15: uninstall

import org.osgi.framework.BundleEvent; //导入依赖的package包/类
@Override
public synchronized void uninstall() throws BundleException {
    if (this.state == BundleEvent.INSTALLED) {
        throw new IllegalStateException("Bundle " + toString() + " is already uninstalled.");
    }
    if (this.state == BundleEvent.RESOLVED) {
        try {
            stopBundle();
        } catch (Throwable th) {
            Framework.notifyFrameworkListeners(BundleEvent.STARTED, this, th);
        }
    }
    this.state = BundleEvent.INSTALLED;
    new File(this.bundleDir, "meta").delete();
    this.classloader.cleanup(true);
    this.classloader = null;
    Framework.bundles.remove(this);
    Framework.notifyBundleListeners(BundleEvent.UNINSTALLED, this);
    isValid = false;



}
 
开发者ID:bunnyblue,项目名称:ACDD,代码行数:24,代码来源:BundleImpl.java


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