diff options
Diffstat (limited to 'container-core/src/main')
3 files changed, 24 insertions, 29 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java b/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java index 0a97a4d5d2f..2b3a272fadc 100644 --- a/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java +++ b/container-core/src/main/java/com/yahoo/container/core/config/BundleLoader.java @@ -46,9 +46,7 @@ public class BundleLoader { return osgi.install(file.getAbsolutePath()); } - /** - * @return the number of bundles installed by this call. - */ + /** Returns the number of bundles installed by this call. */ private int install(List<FileReference> references) { Set<FileReference> bundlesToInstall = new HashSet<>(references); bundlesToInstall.removeAll(reference2Bundles.keySet()); @@ -115,12 +113,12 @@ public class BundleLoader { } } - //all bundles must have been started first to ensure correct package resolution. + // All bundles must have been started first to ensure correct package resolution. private void startBundles() { for (List<Bundle> bundles : reference2Bundles.values()) { for (Bundle bundle : bundles) { try { - if (!isFragment(bundle)) + if ( ! isFragment(bundle)) bundle.start(); } catch(Exception e) { throw new RuntimeException("Could not start bundle '" + bundle.getSymbolicName() + "'", e); @@ -129,18 +127,15 @@ public class BundleLoader { } } - // The OSGi APIs are just getting worse... private boolean isFragment(Bundle bundle) { BundleRevision bundleRevision = bundle.adapt(BundleRevision.class); if (bundleRevision == null) throw new NullPointerException("Null bundle revision means that bundle has probably been uninstalled: " + - bundle.getSymbolicName() + ":" + bundle.getVersion()); + bundle.getSymbolicName() + ":" + bundle.getVersion()); return (bundleRevision.getTypes() & BundleRevision.TYPE_FRAGMENT) != 0; } - /** - * Returns the number of uninstalled bundles - */ + /** Returns the number of uninstalled bundles */ private int retainOnly(List<FileReference> newReferences) { Set<Bundle> bundlesToRemove = new HashSet<>(Arrays.asList(osgi.getBundles())); @@ -182,4 +177,5 @@ public class BundleLoader { sb.append("}"); return sb.toString(); } + } diff --git a/container-core/src/main/java/com/yahoo/osgi/Osgi.java b/container-core/src/main/java/com/yahoo/osgi/Osgi.java index 31f1146c311..c94eaf43deb 100644 --- a/container-core/src/main/java/com/yahoo/osgi/Osgi.java +++ b/container-core/src/main/java/com/yahoo/osgi/Osgi.java @@ -2,9 +2,7 @@ package com.yahoo.osgi; import com.yahoo.component.ComponentSpecification; -import com.yahoo.container.bundle.BundleInstantiationSpecification; import org.osgi.framework.Bundle; -import org.osgi.framework.ServiceReference; import java.util.List; diff --git a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java index 2e37a278387..8b2f20a1c13 100644 --- a/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java +++ b/container-core/src/main/java/com/yahoo/osgi/OsgiImpl.java @@ -2,17 +2,17 @@ package com.yahoo.osgi; import com.yahoo.component.ComponentSpecification; +import com.yahoo.component.Version; import com.yahoo.container.bundle.BundleInstantiationSpecification; import com.yahoo.jdisc.application.OsgiFramework; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; -import org.osgi.framework.ServiceReference; import java.util.List; -import java.util.logging.Logger; /** * @author Tony Vaagenes + * @author bratseth */ public class OsgiImpl implements Osgi { @@ -62,13 +62,13 @@ public class OsgiImpl implements Osgi { } private static void ensureBundleActive(Bundle bundle) throws IllegalStateException { - final int state = bundle.getState(); + int state = bundle.getState(); Throwable cause = null; if (state != Bundle.ACTIVE) { try { - //Get the reason why the bundle isn't active. - //Do not change this method to not fail if start is successful without carefully analyzing - //why there are non-active bundles. + // Get the reason why the bundle isn't active. + // Do not change this method to not fail if start is successful without carefully analyzing + // why there are non-active bundles. bundle.start(); } catch (BundleException e) { cause = e; @@ -81,29 +81,29 @@ public class OsgiImpl implements Osgi { * Returns the bundle of a given name having the highest matching version * * @param id the id of the component to return. May not include a version, or include - * an underspecified version, in which case the highest (mathcing) version which + * an underspecified version, in which case the highest (matching) version which * does not contain a qualifier is returned * @return the bundle match having the highest version, or null if there was no matches */ public Bundle getBundle(ComponentSpecification id) { - Bundle highestMatch=null; + Bundle highestMatch = null; for (Bundle bundle : getBundles()) { assert bundle.getSymbolicName() != null : "ensureHasBundleSymbolicName not called during installation"; if ( ! bundle.getSymbolicName().equals(id.getName())) continue; if ( ! id.getVersionSpecification().matches(versionOf(bundle))) continue; - if (highestMatch==null || versionOf(highestMatch).compareTo(versionOf(bundle))<0) - highestMatch=bundle; + if (highestMatch == null || versionOf(highestMatch).compareTo(versionOf(bundle)) < 0) + highestMatch = bundle; } return highestMatch; } - /** returns the version of a bundle, as specified by Bundle-Version in the manifest */ - private static com.yahoo.component.Version versionOf(Bundle bundle) { - Object bundleVersion=bundle.getHeaders().get("Bundle-Version"); - if (bundleVersion==null) return com.yahoo.component.Version.emptyVersion; - return new com.yahoo.component.Version(bundleVersion.toString()); + /** Returns the version of a bundle, as specified by Bundle-Version in the manifest */ + private static Version versionOf(Bundle bundle) { + Object bundleVersion = bundle.getHeaders().get("Bundle-Version"); + if (bundleVersion == null) return Version.emptyVersion; + return new Version(bundleVersion.toString()); } @Override @@ -116,8 +116,8 @@ public class OsgiImpl implements Osgi { } private static String normalizeLocation(String location) { - if (location.indexOf(':')<0) - location="file:" + location; + if (location.indexOf(':') < 0) + location = "file:" + location; return location; } @@ -134,4 +134,5 @@ public class OsgiImpl implements Osgi { public void refreshPackages() { jdiscOsgi.refreshPackages(); } + } |