Search in sources :

Example 81 with Version

use of org.osgi.framework.Version in project linuxtools by eclipse.

the class LaunchConfigTabTest method testTrackOriginsValidity.

@Test
public void testTrackOriginsValidity() throws Exception {
    ILaunchConfigurationWorkingCopy wc = initConfig();
    IProject project = CDebugUtils.verifyCProject(config).getProject();
    Version ver = ValgrindLaunchPlugin.getDefault().getValgrindVersion(project);
    if (ver.compareTo(ValgrindLaunchPlugin.VER_3_4_0) >= 0) {
        dynamicTab.getTrackOriginsButton().setSelection(true);
        tab.performApply(wc);
        assertTrue(tab.isValid(wc));
        dynamicTab.getUndefValueButton().setSelection(false);
        tab.performApply(wc);
        assertFalse(tab.isValid(wc));
    }
}
Also used : Version(org.osgi.framework.Version) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 82 with Version

use of org.osgi.framework.Version in project linuxtools by eclipse.

the class ImageQuery method getJavaVersion.

public double getJavaVersion() {
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    String result = exec(new String[] { "sh", "-c", "java -version 2>&1 | grep version | cut -d\\\" -f2 | cut -d_ -f1" });
    if (result != null) {
        // $NON-NLS-1$ //$NON-NLS-2$
        result = result.replaceAll("\n", "");
        Version v = new Version(result);
        // $NON-NLS-1$
        String newV = v.getMajor() + "." + v.getMinor();
        return Double.valueOf(newV);
    } else {
        return 0;
    }
}
Also used : Version(org.osgi.framework.Version)

Example 83 with Version

use of org.osgi.framework.Version in project Lucee by lucee.

the class CFMLEngineFactory method _update.

/**
 * updates the engine when a update is available
 *
 * @return has updated
 * @throws IOException
 * @throws ServletException
 */
private boolean _update(final Identification id) throws IOException, ServletException {
    if (singelton != null)
        singelton.reset();
    final File newLucee = downloadCore(id);
    if (newLucee == null)
        return false;
    final Version v = null;
    try {
        bundleCollection = BundleLoader.loadBundles(this, getFelixCacheDirectory(), getBundleDirectory(), newLucee, bundleCollection);
        final CFMLEngine e = getEngine(bundleCollection);
        if (e == null)
            throw new IOException("can't load engine");
        version = e.getInfo().getVersion();
        // engine = e;
        setEngine(e);
        // e.reset();
        callListeners(e);
    } catch (final Exception e) {
        System.gc();
        try {
            newLucee.delete();
        } catch (final Exception ee) {
        }
        log(e);
        e.printStackTrace();
        return false;
    }
    log(Logger.LOG_DEBUG, "Version (" + v + ")installed");
    return true;
}
Also used : Version(org.osgi.framework.Version) IOException(java.io.IOException) JarFile(java.util.jar.JarFile) File(java.io.File) ServletException(javax.servlet.ServletException) BundleException(org.osgi.framework.BundleException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 84 with Version

use of org.osgi.framework.Version in project knime-core by knime.

the class NodeAndBundleInformation method load.

/**
 * Restores the information object from the given node settings object. Used in persistor.
 *
 * @param settings a node settings object
 * @param version the workflow version
 * @return bundle info object, at least the factory name will not be <code>null</code>
 * @throws InvalidSettingsException if the node settings contain invalid entries
 * @noreference This method is not intended to be referenced by clients.
 */
public static NodeAndBundleInformation load(final NodeSettingsRO settings, final FileWorkflowPersistor.LoadVersion version) throws InvalidSettingsException {
    String factoryClass = settings.getString("factory");
    if (factoryClass == null) {
        throw new InvalidSettingsException("Factory class is null");
    }
    String bundleSymbolicName;
    String bundleName;
    String bundleVendor;
    String nodeName;
    Version bundleVersion;
    String featureSymbolicName;
    String featureName;
    String featureVendor;
    Version featureVersion;
    if (version.ordinal() < FileWorkflowPersistor.LoadVersion.V260.ordinal()) {
        nodeName = null;
        bundleName = null;
        bundleVendor = null;
        bundleSymbolicName = null;
        featureSymbolicName = null;
        featureName = null;
        featureVendor = null;
        featureVersion = null;
    } else {
        nodeName = settings.getString("node-name");
        bundleName = settings.getString("node-bundle-name");
        bundleSymbolicName = fixExtensionName(settings.getString("node-bundle-symbolic-name"));
        bundleVendor = settings.getString("node-bundle-vendor");
        featureSymbolicName = fixExtensionName(settings.getString("node-feature-symbolic-name", null));
        featureName = settings.getString("node-feature-name", null);
        featureVendor = settings.getString("node-feature-vendor", null);
        String v = settings.getString("node-feature-version", "");
        try {
            if (!v.isEmpty()) {
                featureVersion = Version.parseVersion(v);
            } else {
                featureVersion = null;
            }
        } catch (IllegalArgumentException iae) {
            throw new InvalidSettingsException("Invalid feature version \"" + v + "\"", iae);
        }
    }
    String v = settings.getString("node-bundle-version", "");
    try {
        if (!v.isEmpty()) {
            bundleVersion = Version.parseVersion(v);
        } else {
            bundleVersion = null;
        }
    } catch (IllegalArgumentException iae) {
        throw new InvalidSettingsException("Invalid version \"" + v + "\"", iae);
    }
    return new NodeAndBundleInformation(factoryClass, bundleSymbolicName, bundleName, bundleVendor, nodeName, bundleVersion, featureSymbolicName, featureName, featureVendor, featureVersion);
}
Also used : Version(org.osgi.framework.Version)

Example 85 with Version

use of org.osgi.framework.Version in project knime-core by knime.

the class NodeAndBundleInformation method save.

/**
 * Saves the information into the given node settings object. Called by persistor.
 *
 * @param settings a node settings object
 * @noreference This method is not intended to be referenced by clients.
 */
public void save(final NodeSettingsWO settings) {
    settings.addString("factory", getFactoryClass());
    // new in 2.6
    settings.addString("node-name", getNodeName().orElse(null));
    settings.addString("node-bundle-name", getBundleName().orElse(null));
    settings.addString("node-bundle-symbolic-name", getBundleSymbolicName().orElse(null));
    settings.addString("node-bundle-vendor", getBundleVendor().orElse(null));
    // new in 2.10
    final Version bundleVersion = getBundleVersion().orElse(Version.emptyVersion);
    settings.addString("node-bundle-version", bundleVersion.toString());
    // new in 3.0
    settings.addString("node-feature-name", getFeatureName().orElse(null));
    settings.addString("node-feature-symbolic-name", getFeatureSymbolicName().orElse(null));
    settings.addString("node-feature-vendor", getFeatureVendor().orElse(null));
    final Version featureVersion = getFeatureVersion().orElse(Version.emptyVersion);
    settings.addString("node-feature-version", featureVersion.toString());
}
Also used : Version(org.osgi.framework.Version)

Aggregations

Version (org.osgi.framework.Version)222 Test (org.junit.Test)35 ArrayList (java.util.ArrayList)28 Bundle (org.osgi.framework.Bundle)27 File (java.io.File)23 HashMap (java.util.HashMap)21 Capability (org.osgi.resource.Capability)20 IOException (java.io.IOException)19 BundleException (org.osgi.framework.BundleException)15 Resource (org.osgi.resource.Resource)14 InputStream (java.io.InputStream)12 Map (java.util.Map)11 Manifest (java.util.jar.Manifest)11 List (java.util.List)10 URL (java.net.URL)8 HashSet (java.util.HashSet)8 Content (org.apache.aries.application.Content)8 AriesApplication (org.apache.aries.application.management.AriesApplication)8 VersionRange (org.apache.felix.utils.version.VersionRange)8 BundleRevision (org.osgi.framework.wiring.BundleRevision)8