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 http://www.eclipse.org/legal/epl-v10.html Contributors: VMware Inc. - initial contribution /
package org.eclipse.virgo.kernel.model.internal.bundle;
import  org.eclipse.equinox.region.Region;
import  org.eclipse.equinox.region.RegionDigraph;
Implementation of BundleListener that notices BundleEvent.INSTALLED and BundleEvent.UNINSTALLED events to add and remove respectively Artifacts from the RuntimeArtifactRepository

Concurrent Semantics
Threadsafe

final class ModelBundleListener implements SynchronousBundleListener {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    private final BundleContext bundleContext;
    private final PackageAdminUtil packageAdminUtil;
    private final RegionDigraph regionDigraph;
    public ModelBundleListener(@NonNull BundleContext bundleContext, @NonNull RuntimeArtifactRepository artifactRepository, @NonNull PackageAdminUtil packageAdminUtil, @NonNull RegionDigraph regionDigraph, @NonNull SpringContextAccessor springContextAccessor) {
        this. = bundleContext;
        this. = artifactRepository;
        this. = packageAdminUtil;
        this. = regionDigraph;
        this. = springContextAccessor;
    }

    
    public void bundleChanged(BundleEvent event) {
        if (. == event.getType()) {
            processInstalled(event);
        } else if (. == event.getType()) {
            processUninstalled(event);
        }
    }
    private void processInstalled(BundleEvent event) {
        Bundle bundle = event.getBundle();
        Region region = this..getRegion(bundle);
        .info("Processing installed event for bundle '{}:{}' in region '{}'"new Object[] {bundle.getSymbolicName(), bundle.getVersion().toString(), region.getName()});
        this..add(new NativeBundleArtifact(this.this.bundleregionthis.));
    }
    private void processUninstalled(BundleEvent event) {
        Bundle bundle = event.getBundle();
        for (Artifact artifact : this..getArtifacts()) {
            if (artifact.getType().equals(.) && 
                artifact.getName().equals(bundle.getSymbolicName()) && 
                artifact.getVersion().equals(bundle.getVersion()) ){
                if(artifact instanceof NativeBundleArtifact){
                    NativeBundleArtifact bundleArtifact = (NativeBundleArtifactartifact;
                    if(. == bundleArtifact.getState()){
                        this..remove(bundleArtifact);
                        .info("Processing uninstalled event for bundle '{}:{}' from region '{}'"new Object[] {bundleArtifact.getName(), bundleArtifact.getVersion().toString(), bundleArtifact.getRegion().getName()});
                    }
                }
            }
        }
    }
New to GrepCode? Check out our FAQ X