You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2014/04/22 16:42:18 UTC

[4/5] git commit: [KARAF-2923] Cleanup imports

[KARAF-2923] Cleanup imports

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/bed052f2
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/bed052f2
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/bed052f2

Branch: refs/heads/master
Commit: bed052f22ee1569978f2693f58832d11ca6641e6
Parents: 6b947ea
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Tue Apr 22 16:41:33 2014 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Tue Apr 22 16:41:33 2014 +0200

----------------------------------------------------------------------
 .../download/simple/SimpleDownloader.java       |  4 +++-
 .../features/internal/region/Subsystem.java     |  4 ++--
 .../region/SubsystemResolveContext.java         | 24 ++++++++++++-------
 .../internal/service/FeaturesServiceImpl.java   | 25 ++++++++++----------
 4 files changed, 33 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/bed052f2/features/core/src/main/java/org/apache/karaf/features/internal/download/simple/SimpleDownloader.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/download/simple/SimpleDownloader.java b/features/core/src/main/java/org/apache/karaf/features/internal/download/simple/SimpleDownloader.java
index 4569fe2..9c35199 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/download/simple/SimpleDownloader.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/download/simple/SimpleDownloader.java
@@ -35,6 +35,8 @@ import org.apache.karaf.features.internal.download.Downloader;
 import org.apache.karaf.features.internal.download.StreamProvider;
 import org.apache.karaf.features.internal.util.MultiException;
 
+ import static java.util.jar.JarFile.MANIFEST_NAME;
+
 public class SimpleDownloader implements DownloadManager, Downloader {
 
     protected final MultiException exception = new MultiException("Error");
@@ -102,7 +104,7 @@ public class SimpleDownloader implements DownloadManager, Downloader {
                 ZipInputStream zis = new ZipInputStream(is);
                 ZipEntry entry;
                 while ((entry = zis.getNextEntry()) != null) {
-                    if ("META-INF/MANIFEST.MF".equals(entry.getName())) {
+                    if (MANIFEST_NAME.equals(entry.getName())) {
                         Attributes attributes = new Manifest(zis).getMainAttributes();
                         Map<String, String> headers = new HashMap<String, String>();
                         for (Map.Entry attr : attributes.entrySet()) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/bed052f2/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java b/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
index 98d5f60..c49d4af 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/region/Subsystem.java
@@ -43,7 +43,6 @@ import org.apache.karaf.features.internal.resolver.ResourceBuilder;
 import org.apache.karaf.features.internal.resolver.ResourceImpl;
 import org.apache.karaf.features.internal.resolver.ResourceUtils;
 import org.apache.karaf.features.internal.service.Overrides;
-import org.eclipse.equinox.region.RegionFilter;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Version;
 import org.osgi.resource.Capability;
@@ -54,6 +53,7 @@ import static org.apache.karaf.features.internal.resolver.ResourceUtils.TYPE_FEA
 import static org.apache.karaf.features.internal.resolver.ResourceUtils.TYPE_SUBSYSTEM;
 import static org.apache.karaf.features.internal.resolver.ResourceUtils.addIdentityRequirement;
 import static org.apache.karaf.features.internal.util.MapUtils.addToMapSet;
+import static org.eclipse.equinox.region.RegionFilter.VISIBLE_ALL_NAMESPACE;
 import static org.osgi.framework.namespace.IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE;
 import static org.osgi.framework.namespace.IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE;
 import static org.osgi.framework.namespace.IdentityNamespace.IDENTITY_NAMESPACE;
@@ -71,7 +71,7 @@ public class Subsystem extends ResourceImpl {
     // Everything is visible
     private static final Map<String, Set<String>> SHARE_ALL_POLICY =
             Collections.singletonMap(
-                    RegionFilter.VISIBLE_ALL_NAMESPACE,
+                    VISIBLE_ALL_NAMESPACE,
                     Collections.singleton(ALL_FILTER));
 
     // Nothing (but systems) is visible

http://git-wip-us.apache.org/repos/asf/karaf/blob/bed052f2/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolveContext.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolveContext.java b/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolveContext.java
index e5c6532..d5a3113 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolveContext.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/region/SubsystemResolveContext.java
@@ -30,8 +30,6 @@ import org.eclipse.equinox.region.Region;
 import org.eclipse.equinox.region.RegionDigraph;
 import org.eclipse.equinox.region.RegionFilter;
 import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.namespace.IdentityNamespace;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
@@ -40,6 +38,14 @@ import org.osgi.service.repository.Repository;
 import org.osgi.service.resolver.HostedCapability;
 import org.osgi.service.resolver.ResolveContext;
 
+import static org.eclipse.equinox.region.RegionFilter.VISIBLE_BUNDLE_NAMESPACE;
+import static org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE;
+import static org.osgi.framework.Constants.BUNDLE_VERSION_ATTRIBUTE;
+import static org.osgi.framework.Constants.RESOLUTION_DIRECTIVE;
+import static org.osgi.framework.Constants.RESOLUTION_OPTIONAL;
+import static org.osgi.framework.namespace.IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE;
+import static org.osgi.framework.namespace.IdentityNamespace.IDENTITY_NAMESPACE;
+
 public class SubsystemResolveContext extends ResolveContext {
 
     private final Subsystem root;
@@ -145,9 +151,9 @@ public class SubsystemResolveContext extends ResolveContext {
 
     @Override
     public boolean isEffective(Requirement requirement) {
-        String resolution = requirement.getDirectives().get(Constants.RESOLUTION_DIRECTIVE);
-        return requirement.getNamespace().equals(IdentityNamespace.IDENTITY_NAMESPACE)
-                || !Constants.RESOLUTION_OPTIONAL.equals(resolution);
+        String resolution = requirement.getDirectives().get(RESOLUTION_DIRECTIVE);
+        return requirement.getNamespace().equals(IDENTITY_NAMESPACE)
+                || !RESOLUTION_OPTIONAL.equals(resolution);
     }
 
     @Override
@@ -172,13 +178,13 @@ public class SubsystemResolveContext extends ResolveContext {
                 return true;
             }
             Resource resource = candidate.getResource();
-            List<Capability> identities = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
+            List<Capability> identities = resource.getCapabilities(IDENTITY_NAMESPACE);
             if (identities != null && !identities.isEmpty()) {
                 Capability identity = identities.iterator().next();
                 Map<String, Object> attrs = new HashMap<String, Object>();
-                attrs.put(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, identity.getAttributes().get(IdentityNamespace.IDENTITY_NAMESPACE));
-                attrs.put(Constants.BUNDLE_VERSION_ATTRIBUTE, identity.getAttributes().get(IdentityNamespace.CAPABILITY_VERSION_ATTRIBUTE));
-                return filter.isAllowed(RegionFilter.VISIBLE_BUNDLE_NAMESPACE, attrs);
+                attrs.put(BUNDLE_SYMBOLICNAME_ATTRIBUTE, identity.getAttributes().get(IDENTITY_NAMESPACE));
+                attrs.put(BUNDLE_VERSION_ATTRIBUTE, identity.getAttributes().get(CAPABILITY_VERSION_ATTRIBUTE));
+                return filter.isAllowed(VISIBLE_BUNDLE_NAMESPACE, attrs);
             }
             return false;
         }

http://git-wip-us.apache.org/repos/asf/karaf/blob/bed052f2/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
index a8ccd0a..bb3c00f 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
@@ -67,7 +67,6 @@ import org.osgi.framework.FrameworkEvent;
 import org.osgi.framework.FrameworkListener;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.Version;
-import org.osgi.framework.namespace.IdentityNamespace;
 import org.osgi.framework.startlevel.BundleStartLevel;
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.framework.wiring.BundleWire;
@@ -80,10 +79,17 @@ import org.slf4j.LoggerFactory;
 
 import static org.apache.felix.resolver.Util.getSymbolicName;
 import static org.apache.felix.resolver.Util.getVersion;
+import static org.apache.karaf.features.internal.resolver.ResourceUtils.getFeatureId;
+import static org.apache.karaf.features.internal.resolver.ResourceUtils.getUri;
 import static org.apache.karaf.features.internal.util.MapUtils.addToMapSet;
 import static org.apache.karaf.features.internal.util.MapUtils.copyMapSet;
-import static org.apache.karaf.features.internal.resolver.ResourceUtils.*;
 import static org.apache.karaf.features.internal.util.MapUtils.removeFromMapSet;
+import static org.osgi.framework.Bundle.ACTIVE;
+import static org.osgi.framework.Bundle.RESOLVED;
+import static org.osgi.framework.Bundle.STARTING;
+import static org.osgi.framework.Bundle.STOPPING;
+import static org.osgi.framework.Bundle.STOP_TRANSIENT;
+import static org.osgi.framework.Bundle.UNINSTALLED;
 
 /**
  *
@@ -878,11 +884,6 @@ public class FeaturesServiceImpl implements FeaturesService {
         List<String> delFeatures = new ArrayList<String>(installed.get(ROOT_REGION));
         delFeatures.removeAll(installedFeatureIds);
 
-        //
-        // Compute list of installable resources (those with uris)
-        //
-        Map<Resource, String> resources = resolver.getBundles();
-
         // Compute information for each bundle
         Map<String, BundleInfo> bundleInfos = new HashMap<String, BundleInfo>();
         for (Feature feature : getFeatures(repositories, getFeatureIds(allResources))) {
@@ -1025,14 +1026,14 @@ public class FeaturesServiceImpl implements FeaturesService {
             toStop.addAll(regionDeployment.toUpdate.keySet());
             toStop.addAll(regionDeployment.toDelete);
         }
-        removeFragmentsAndBundlesInState(toStop, Bundle.UNINSTALLED | Bundle.RESOLVED | Bundle.STOPPING);
+        removeFragmentsAndBundlesInState(toStop, UNINSTALLED | RESOLVED | STOPPING);
         if (!toStop.isEmpty()) {
             print("Stopping bundles:", verbose);
             while (!toStop.isEmpty()) {
                 List<Bundle> bs = getBundlesToStop(toStop);
                 for (Bundle bundle : bs) {
                     print("  " + bundle.getSymbolicName() + " / " + bundle.getVersion(), verbose);
-                    bundle.stop(Bundle.STOP_TRANSIENT);
+                    bundle.stop(STOP_TRANSIENT);
                     toStop.remove(bundle);
                 }
             }
@@ -1241,14 +1242,14 @@ public class FeaturesServiceImpl implements FeaturesService {
         if (!noRefresh) {
             toStop = new HashSet<Bundle>();
             toStop.addAll(toRefresh);
-            removeFragmentsAndBundlesInState(toStop, Bundle.UNINSTALLED | Bundle.RESOLVED | Bundle.STOPPING);
+            removeFragmentsAndBundlesInState(toStop, UNINSTALLED | RESOLVED | STOPPING);
             if (!toStop.isEmpty()) {
                 print("Stopping bundles:", verbose);
                 while (!toStop.isEmpty()) {
                     List<Bundle> bs = getBundlesToStop(toStop);
                     for (Bundle bundle : bs) {
                         print("  " + bundle.getSymbolicName() + " / " + bundle.getVersion(), verbose);
-                        bundle.stop(Bundle.STOP_TRANSIENT);
+                        bundle.stop(STOP_TRANSIENT);
                         toStop.remove(bundle);
                         toStart.add(bundle);
                     }
@@ -1267,7 +1268,7 @@ public class FeaturesServiceImpl implements FeaturesService {
         }
 
         // Compute bundles to start
-        removeFragmentsAndBundlesInState(toStart, Bundle.UNINSTALLED | Bundle.ACTIVE | Bundle.STARTING);
+        removeFragmentsAndBundlesInState(toStart, UNINSTALLED | ACTIVE | STARTING);
         if (!toStart.isEmpty()) {
             // Compute correct start order
             List<Exception> exceptions = new ArrayList<Exception>();