Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2008, 2010 VMware Inc. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at Contributors: VMware Inc. - initial contribution /
package org.eclipse.virgo.kernel.model.internal.bundle;
import  org.eclipse.equinox.region.RegionDigraph;
An initializer responsible for registering a ModelBundleListener and enumerating any existing Bundle objects from the OSGi Framework.

Concurrent Semantics
Thread safe

See also:
public final class ModelBundleListenerInitializer {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    private final PackageAdminUtil packageAdminUtil;
    private final BundleContext kernelBundleContext;
    private final BundleListener bundleListener;
    private final RegionDigraph regionDigraph;
    public ModelBundleListenerInitializer(@NonNull RuntimeArtifactRepository artifactRepository, @NonNull PackageAdminUtil packageAdminUtil, @NonNull BundleContext kernelBundleContext, @NonNull RegionDigraph regionDigraph, @NonNull SpringContextAccessor springContextAccessor) {
        this. = artifactRepository;
        this. = packageAdminUtil;
        this. = kernelBundleContext;
        this. = new ModelBundleListener(kernelBundleContextartifactRepositorypackageAdminUtilregionDigraphspringContextAccessor);
        this. = regionDigraph;
        this. = springContextAccessor;

Registers a BundleListener with the OSGi framework. Enumerates any existing Bundles that exist in the user region.
    public void initialize() {
        BundleContext systemBundleContext = getSystemBundleContext();
        // Register the listener with the system bundle context to see all bundles in all regions.
        // Find bundles that the listener has almost certainly missed.
        for (Bundle bundle : systemBundleContext.getBundles()) {
            try {
                this..add(new NativeBundleArtifact(this.this.bundlethis..getRegion(bundle), this.));
            } catch (Exception e) {
                this..error(String.format("Exception adding bundle '%s:%s' to the repository"bundle.getSymbolicName(),
                    bundle.getVersion().toString()), e);
        BundleContext systemBundleContext = this..getBundle(0L).getBundleContext();
        return systemBundleContext;

Unregisters the listener from the OSGi framework
    public void destroy() {
New to GrepCode? Check out our FAQ X