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 java.util.Map;
 
 import  org.eclipse.equinox.region.Region;
Implementation of Artifact that delegates to an OSGi native bundle, this is in comparison to a DeployerBundleArtifact which delegates to a Kernel InstallArtifact.

Concurrent Semantics
Threadsafe

 
 final class NativeBundleArtifact extends AbstractArtifact {
 
     static final String TYPE = "bundle";
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
     private final PackageAdminUtil packageAdminUtil;
 
     private final Bundle bundle;
 
     
     public NativeBundleArtifact(@NonNull BundleContext bundleContext, @NonNull PackageAdminUtil packageAdminUtil, @NonNull Bundle bundle, @NonNull Region region, @NonNull SpringContextAccessor springContextAccessor) {
         super(bundleContextbundle.getSymbolicName(), bundle.getVersion(), region);
         this. = packageAdminUtil;
         this. = bundle;
         this. = springContextAccessor;
     }

    
 
     public ArtifactState getState() {
         return mapBundleState(this..getState());
     }

    
 
     public Map<StringStringgetProperties() {
         Map<StringStringproperties = new HashMap<StringString>();
         properties.put("Bundle Id", String.valueOf(this..getBundleId()));
         properties.put("Spring", String.valueOf(this..isSpringPowered()));
         return Collections.unmodifiableMap(properties);
     }
    
    
 
     public boolean refresh() {
         try {
             this..update();
             this..synchronouslyRefreshPackages(new Bundle[] { this. });
             return true;
         } catch (BundleException e) {
             .error("Unable to update bundle '{}:{}'"this..getSymbolicName(), this..getVersion());
             throw new RuntimeException(String.format("Unable to update bundle '%s:%s'"this..getSymbolicName(), this..getVersion()), e);
         }
     }

    
 
     public void start() {
         try {
             this..start();
         } catch (BundleException e) {
             .error("Unable to start bundle '{}:{}'"this..getSymbolicName(), this..getVersion());
             throw new RuntimeException(String.format("Unable to start bundle '%s:%s'"this..getSymbolicName(), this..getVersion()), e);
        }
    }

    
    public void stop() {
        try {
            this..stop();
        } catch (BundleException e) {
            .error("Unable to stop bundle '{}:{}'"this..getSymbolicName(), this..getVersion());
            throw new RuntimeException(String.format("Unable to stop bundle '%s:%s'"this..getSymbolicName(), this..getVersion()), e);
        }
    }

    
    public void uninstall() {
        try {
            this..uninstall();
        } catch (BundleException e) {
            .error("Unable to uninstall bundle '{}:{}'"this..getSymbolicName(), this..getVersion());
            throw new RuntimeException(String.format("Unable to uninstall bundle '%s:%s'"this..getSymbolicName(), this..getVersion()), e);
        }
    }
    static ArtifactState mapBundleState(int state) {
        if (. == state) {
            return .;
        } else if (. == state) {
            return .;
        } else if (. == state) {
            return .;
        } else if (. == state) {
            return .;
        } else if (. == state) {
            return .;
        } else if (. == state) {
            return .;
        } else {
            throw new IllegalArgumentException(String.format("Unknown bundle state '%d'"state));
        }
    }
    
New to GrepCode? Check out our FAQ X