sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1804141 - in /sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature: analyser/ analyser/impl/ scanner/ scanner/impl/
Date Fri, 04 Aug 2017 16:34:33 GMT
Author: cziegeler
Date: Fri Aug  4 16:34:33 2017
New Revision: 1804141

URL: http://svn.apache.org/viewvc?rev=1804141&view=rev
Log:
Update descriptor classes to make them more usable

Removed:
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/ContainerDescriptorImpl.java
Modified:
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ApplicationDescriptor.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ArtifactDescriptor.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/BundleDescriptor.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ContainerDescriptor.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/Descriptor.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/FeatureDescriptor.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/Scanner.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/ApplicationDescriptorImpl.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/BundleDescriptorImpl.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/CheckBundleExportsImports.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/CheckRequirementsCapabilities.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/FeatureDescriptorImpl.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/scanner/FrameworkScanner.java
    sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/FelixFrameworkScanner.java

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ApplicationDescriptor.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ApplicationDescriptor.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ApplicationDescriptor.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ApplicationDescriptor.java
Fri Aug  4 16:34:33 2017
@@ -22,9 +22,9 @@ import org.apache.sling.feature.Applicat
  * Information about an application.
  * This is the aggregated information.
  */
-public interface ApplicationDescriptor extends ContainerDescriptor {
+public abstract class ApplicationDescriptor extends ContainerDescriptor {
 
-    Application getApplication();
+    public abstract Application getApplication();
 
-    Descriptor getFrameworkDescriptor();
+    public abstract BundleDescriptor getFrameworkDescriptor();
 }
\ No newline at end of file

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ArtifactDescriptor.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ArtifactDescriptor.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ArtifactDescriptor.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ArtifactDescriptor.java
Fri Aug  4 16:34:33 2017
@@ -16,31 +16,31 @@
  */
 package org.apache.sling.feature.analyser;
 
-import org.apache.sling.feature.Artifact;
-
 import java.io.File;
 import java.util.jar.Manifest;
 
+import org.apache.sling.feature.Artifact;
+
 /**
  * Information about an artifact
  */
-public interface ArtifactDescriptor extends Descriptor {
+public abstract class ArtifactDescriptor extends Descriptor {
 
     /**
      * Get the artifact file
      * @return The artifact file
      */
-    File getArtifactFile();
+    public abstract File getArtifactFile();
 
     /**
      * Get the artifact
      * @return The artifact
      */
-    Artifact getArtifact();
+    public abstract Artifact getArtifact();
 
     /**
      * If the artifact has a manifest, return it
      * @return The manifest or {@code null}
      */
-    Manifest getManifest();
+    public abstract Manifest getManifest();
 }
\ No newline at end of file

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/BundleDescriptor.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/BundleDescriptor.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/BundleDescriptor.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/BundleDescriptor.java
Fri Aug  4 16:34:33 2017
@@ -16,32 +16,76 @@
  */
 package org.apache.sling.feature.analyser;
 
+import org.apache.sling.feature.analyser.impl.BundleDescriptorImpl;
 import org.apache.sling.feature.support.util.PackageInfo;
 
 /**
  * Information about a bundle
  */
-public interface BundleDescriptor extends ArtifactDescriptor, Comparable<BundleDescriptor>
{
+public abstract class BundleDescriptor extends ArtifactDescriptor implements Comparable<BundleDescriptor>
{
 
     /**
      * Get the bundle symbolic name.
      * @return The bundle symbolic name
      */
-    String getBundleSymbolicName();
+    public abstract String getBundleSymbolicName();
 
     /**
      * Get the bundle version
      * @return The bundle version
      */
-    String getBundleVersion();
+    public abstract String getBundleVersion();
 
     /**
      * Get the start level
      * @return The start level.
      */
-    int getBundleStartLevel();
+    public abstract int getBundleStartLevel();
 
-    boolean isExportingPackage(String packageName);
-
-    boolean isExportingPackage(PackageInfo info);
+    public boolean isExportingPackage(final String packageName) {
+        if ( getExportedPackages() != null ) {
+            for(final PackageInfo i : getExportedPackages()) {
+                if ( i.getName().equals(packageName) ) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    public boolean isExportingPackage(final PackageInfo info) {
+        if ( getExportedPackages() != null ) {
+            for(final PackageInfo i : getExportedPackages()) {
+                if ( i.getName().equals(info.getName())
+                     && (info.getVersion() == null || info.getPackageVersionRange().includes(i.getPackageVersion())))
{
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if ( obj instanceof BundleDescriptorImpl ) {
+            return this.getBundleSymbolicName().equals(((BundleDescriptorImpl)obj).getBundleSymbolicName())
&& this.getBundleVersion().equals(((BundleDescriptorImpl)obj).getBundleVersion());
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return (this.getBundleSymbolicName() + ':' + this.getBundleVersion()).hashCode();
+
+    }
+
+    @Override
+    public String toString() {
+        return "BundleInfo [symbolicName=" + getBundleSymbolicName() + ", version=" + this.getBundleVersion()
+ "]";
+    }
+
+    @Override
+    public int compareTo(final BundleDescriptor o) {
+        return (this.getBundleSymbolicName() + ':' + this.getBundleVersion()).compareTo((o.getBundleSymbolicName()
+ ':' + o.getBundleVersion()));
+    }
 }
\ No newline at end of file

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ContainerDescriptor.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ContainerDescriptor.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ContainerDescriptor.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/ContainerDescriptor.java
Fri Aug  4 16:34:33 2017
@@ -16,13 +16,19 @@
  */
 package org.apache.sling.feature.analyser;
 
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.Set;
 
 /**
  * Information about a container (feature/application).
  * This is the aggregated information.
  */
-public interface ContainerDescriptor extends Descriptor {
+public abstract class ContainerDescriptor extends Descriptor {
+
+    private final Set<BundleDescriptor> bundles = new HashSet<>();
+
+    private final Set<ArtifactDescriptor> artifacts = new HashSet<>();
 
     /**
      * Return a set of bundle descriptors.
@@ -33,7 +39,9 @@ public interface ContainerDescriptor ext
      * {@link Descriptor#getExportedPackages()} and {@link Descriptor#getImportedPackages()}
      * @return The set of bundle descriptors (might be empty)
      */
-    Set<BundleDescriptor> getBundleDescriptors();
+    public final Set<BundleDescriptor> getBundleDescriptors() {
+        return this.isLocked() ? Collections.unmodifiableSet(bundles) : bundles;
+    }
 
     /**
      * Return a set of artifact descriptors
@@ -42,5 +50,18 @@ public interface ContainerDescriptor ext
      * {@link Descriptor#getRequirements()}.
      * @return The set of artifact descriptors (might be empty)
      */
-    Set<ArtifactDescriptor> getArtifactDescriptors();
+    public final Set<ArtifactDescriptor> getArtifactDescriptors() {
+        return this.isLocked() ? Collections.unmodifiableSet(artifacts) : artifacts;
+    }
+
+    @Override
+    public void lock() {
+        for(final BundleDescriptor bd : this.bundles) {
+            this.aggregate(bd);
+        }
+        for(final ArtifactDescriptor d : this.artifacts) {
+            this.aggregate(d);
+        }
+        super.lock();
+    }
 }
\ No newline at end of file

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/Descriptor.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/Descriptor.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/Descriptor.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/Descriptor.java
Fri Aug  4 16:34:33 2017
@@ -16,43 +16,78 @@
  */
 package org.apache.sling.feature.analyser;
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.apache.sling.feature.Capability;
 import org.apache.sling.feature.Requirement;
 import org.apache.sling.feature.support.util.PackageInfo;
 
-import java.util.Collections;
-import java.util.Set;
-
 /**
  * A descriptor holds information about requirements and capabilities
  */
-public interface Descriptor  {
+public abstract class Descriptor  {
+
+    private boolean locked;
+
+    private final Set<PackageInfo> exports = new HashSet<>();
+
+    private final Set<PackageInfo> imports = new HashSet<>();
+
+    private final Set<PackageInfo> dynImports = new HashSet<>();
+
+    private final Set<Requirement> reqs = new HashSet<>();
+
+    private final Set<Capability> caps = new HashSet<>();
+
+    public void lock() {
+        this.locked = true;
+    }
+
+    public final boolean isLocked() {
+        return this.locked;
+    }
+
+    protected void checkLocked() {
+        if (this.locked) {
+            throw new IllegalStateException("Descriptor is locked.");
+        }
+    }
+
+    protected void aggregate(final Descriptor d) {
+        reqs.addAll(d.getRequirements());
+        caps.addAll(d.getCapabilities());
+        dynImports.addAll(d.getDynamicImportedPackages());
+        imports.addAll(d.getImportedPackages());
+        exports.addAll(d.getExportedPackages());
+    }
 
-    default Set<PackageInfo> getExportedPackages() {
-        return Collections.emptySet();
+    public final Set<PackageInfo> getExportedPackages() {
+        return locked ? Collections.unmodifiableSet(exports) : exports;
     }
 
-    default Set<PackageInfo> getImportedPackages() {
-        return Collections.emptySet();
+    public final Set<PackageInfo> getImportedPackages() {
+        return locked ? Collections.unmodifiableSet(imports) : imports;
     }
 
-    default Set<PackageInfo> getDynamicImportedPackages() {
-        return Collections.emptySet();
+    public final Set<PackageInfo> getDynamicImportedPackages() {
+        return locked ? Collections.unmodifiableSet(dynImports) : dynImports;
     }
 
     /**
      * Return the list of requirements.
      * @return The list of requirements. The list might be empty.
      */
-    default Set<Requirement> getRequirements() {
-        return Collections.emptySet();
+    public final Set<Requirement> getRequirements() {
+        return locked ? Collections.unmodifiableSet(reqs) : reqs;
     }
 
     /**
      * Return the list of capabilities.
      * @return The list of capabilities. The list might be empty.
      */
-    default Set<Capability> getCapabilities() {
-        return Collections.emptySet();
+    public final Set<Capability> getCapabilities() {
+        return locked ?  Collections.unmodifiableSet(caps) : caps;
     }
 }
\ No newline at end of file

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/FeatureDescriptor.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/FeatureDescriptor.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/FeatureDescriptor.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/FeatureDescriptor.java
Fri Aug  4 16:34:33 2017
@@ -22,7 +22,7 @@ import org.apache.sling.feature.Feature;
  * Information about a feature.
  * This is the aggregated information.
  */
-public interface FeatureDescriptor extends ContainerDescriptor {
+public abstract class FeatureDescriptor extends ContainerDescriptor {
 
-    Feature getFeature();
+    public abstract Feature getFeature();
 }
\ No newline at end of file

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/Scanner.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/Scanner.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/Scanner.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/Scanner.java
Fri Aug  4 16:34:33 2017
@@ -31,7 +31,6 @@ import org.apache.sling.feature.Extensio
 import org.apache.sling.feature.Feature;
 import org.apache.sling.feature.analyser.impl.ApplicationDescriptorImpl;
 import org.apache.sling.feature.analyser.impl.BundleDescriptorImpl;
-import org.apache.sling.feature.analyser.impl.ContainerDescriptorImpl;
 import org.apache.sling.feature.analyser.impl.FeatureDescriptorImpl;
 import org.apache.sling.feature.scanner.ArtifactScanner;
 import org.apache.sling.feature.scanner.ExtensionScanner;
@@ -132,6 +131,8 @@ public class Scanner {
         if ( info == null ) {
             throw new IOException("No artifact scanner found for " + artifact.getId().toMvnId());
         }
+        info.lock();
+
         return info;
     }
 
@@ -158,7 +159,7 @@ public class Scanner {
      * @param desc The descriptor
      * @throws IOException If something goes wrong or no suitable scanner is found.
      */
-    private void getBundleInfos(final Bundles bundles, final ContainerDescriptorImpl desc)
+    private void getBundleInfos(final Bundles bundles, final ContainerDescriptor desc)
     throws IOException {
         for(final Map.Entry<Integer, List<Artifact>> entry : bundles.getBundlesByStartLevel().entrySet())
{
             for(final Artifact bundle : entry.getValue() ) {
@@ -174,7 +175,7 @@ public class Scanner {
         }
     }
 
-    private void scan(final Extensions extensions, final ContainerDescriptorImpl desc)
+    private void scan(final Extensions extensions, final ContainerDescriptor desc)
     throws IOException {
         for(final Extension ext : extensions) {
             ContainerDescriptor extDesc = null;
@@ -198,7 +199,7 @@ public class Scanner {
         }
     }
 
-    private void compact(final ContainerDescriptorImpl desc) {
+    private void compact(final ContainerDescriptor desc) {
         // TBD remove all import packages / dynamic import packages which are resolved by
this bundle set
         // same with requirements
 
@@ -219,6 +220,8 @@ public class Scanner {
 
         compact(desc);
 
+        desc.lock();
+
         return desc;
     }
 
@@ -243,7 +246,7 @@ public class Scanner {
             throw new IOException("Unable to find file for " + app.getFramework());
         }
 
-        Descriptor fwk = null;
+        BundleDescriptor fwk = null;
         for(final FrameworkScanner scanner : this.frameworkScanners) {
             fwk = scanner.scan(app.getFramework(), file, app.getFrameworkProperties());
             if ( fwk != null ) {
@@ -263,6 +266,7 @@ public class Scanner {
 
         desc.setFrameworkDescriptor(fwk);
 
+        desc.lock();
         return desc;
     }
 }

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/ApplicationDescriptorImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/ApplicationDescriptorImpl.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/ApplicationDescriptorImpl.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/ApplicationDescriptorImpl.java
Fri Aug  4 16:34:33 2017
@@ -18,17 +18,16 @@ package org.apache.sling.feature.analyse
 
 import org.apache.sling.feature.Application;
 import org.apache.sling.feature.analyser.ApplicationDescriptor;
-import org.apache.sling.feature.analyser.Descriptor;
+import org.apache.sling.feature.analyser.BundleDescriptor;
 
 /**
  * Information about an application.
  * This is the aggregated information.
  */
 public class ApplicationDescriptorImpl
-    extends ContainerDescriptorImpl
-    implements ApplicationDescriptor {
+    extends ApplicationDescriptor {
 
-    private Descriptor frameworkDescriptor = new Descriptor() {};
+    private BundleDescriptor frameworkDescriptor;
 
     private final Application app;
 
@@ -42,11 +41,12 @@ public class ApplicationDescriptorImpl
     }
 
     @Override
-    public Descriptor getFrameworkDescriptor() {
+    public BundleDescriptor getFrameworkDescriptor() {
         return frameworkDescriptor;
     }
 
-    public void setFrameworkDescriptor(final Descriptor frameworkDescriptor) {
+    public void setFrameworkDescriptor(final BundleDescriptor frameworkDescriptor) {
+        checkLocked();
         this.frameworkDescriptor = frameworkDescriptor;
     }
 }
\ No newline at end of file

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/BundleDescriptorImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/BundleDescriptorImpl.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/BundleDescriptorImpl.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/BundleDescriptorImpl.java
Fri Aug  4 16:34:33 2017
@@ -16,6 +16,11 @@
  */
 package org.apache.sling.feature.analyser.impl;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.Set;
+import java.util.jar.Manifest;
+
 import org.apache.sling.feature.Artifact;
 import org.apache.sling.feature.Capability;
 import org.apache.sling.feature.Requirement;
@@ -25,18 +30,11 @@ import org.apache.sling.feature.support.
 import org.apache.sling.feature.support.util.PackageInfo;
 import org.osgi.framework.Constants;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.jar.Manifest;
-
 /**
  * Information about a bundle
  */
 public class BundleDescriptorImpl
-    implements BundleDescriptor {
+    extends BundleDescriptor {
 
     /** The bundle symbolic name. */
     private String symbolicName;
@@ -47,15 +45,6 @@ public class BundleDescriptorImpl
     /** The start level of this artifact. */
     private final int startLevel;
 
-    /** Information about exported packages. */
-    private final Set<PackageInfo> exportedPackages = new HashSet<>();
-
-    /** Information about imported packages. */
-    private final Set<PackageInfo> importedPackages = new HashSet<>();
-
-    /** Information about dynamic imported packages. */
-    private final Set<PackageInfo> dynamicImportedPackages = new HashSet<>();
-
     /** Manifest */
     private final Manifest manifest;
 
@@ -65,10 +54,6 @@ public class BundleDescriptorImpl
     /** The corresponding artifact from the feature. */
     private final Artifact artifact;
 
-    private final Set<Capability> capabilities = new HashSet<>();
-
-    private final Set<Requirement> requirements = new HashSet<>();
-
     public BundleDescriptorImpl(final Artifact a,
             final File file,
             final int startLevel) throws IOException  {
@@ -81,18 +66,24 @@ public class BundleDescriptorImpl
             throw new IOException("File has no manifest");
         }
         this.analyze();
+        this.lock();
     }
 
     public BundleDescriptorImpl(final Artifact artifact,
-            final Set<PackageInfo> pcks) throws IOException {
+            final Set<PackageInfo> pcks,
+            final Set<Requirement> reqs,
+            final Set<Capability> caps) throws IOException {
         this.artifact = artifact;
         this.artifactFile = null;
         this.startLevel = 0;
 
         this.symbolicName = Constants.SYSTEM_BUNDLE_SYMBOLICNAME;
         this.bundleVersion = artifact.getId().getOSGiVersion().toString();
-        this.exportedPackages.addAll(pcks);
+        this.getExportedPackages().addAll(pcks);
+        this.getRequirements().addAll(reqs);
+        this.getCapabilities().addAll(caps);
         this.manifest = null;
+        this.lock();
     }
 
     /**
@@ -123,11 +114,6 @@ public class BundleDescriptorImpl
     }
 
     @Override
-    public Set<PackageInfo> getExportedPackages() {
-        return Collections.unmodifiableSet(this.exportedPackages);
-    }
-
-    @Override
     public File getArtifactFile() {
         return artifactFile;
     }
@@ -142,51 +128,6 @@ public class BundleDescriptorImpl
         return this.manifest;
     }
 
-    @Override
-    public boolean isExportingPackage(final String packageName) {
-        if ( getExportedPackages() != null ) {
-            for(final PackageInfo i : getExportedPackages()) {
-                if ( i.getName().equals(packageName) ) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public boolean isExportingPackage(final PackageInfo info) {
-        if ( getExportedPackages() != null ) {
-            for(final PackageInfo i : getExportedPackages()) {
-                if ( i.getName().equals(info.getName())
-                     && (info.getVersion() == null || info.getPackageVersionRange().includes(i.getPackageVersion())))
{
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public Set<PackageInfo> getImportedPackages() {
-        return Collections.unmodifiableSet(this.importedPackages);
-    }
-
-    @Override
-    public Set<PackageInfo> getDynamicImportedPackages() {
-        return Collections.unmodifiableSet(this.dynamicImportedPackages);
-    }
-
-    @Override
-    public Set<Capability> getCapabilities() {
-        return Collections.unmodifiableSet(capabilities);
-    }
-
-    @Override
-    public Set<Requirement> getRequirements() {
-        return Collections.unmodifiableSet(requirements);
-    }
-
     protected void analyze() throws IOException {
         final String name = this.manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
         if ( name != null ) {
@@ -201,13 +142,13 @@ public class BundleDescriptorImpl
                 this.symbolicName = newBundleName;
             }
 
-            this.exportedPackages.addAll(ManifestUtil.extractExportedPackages(this.manifest));
-            this.importedPackages.addAll(ManifestUtil.extractImportedPackages(this.manifest));
-            this.dynamicImportedPackages.addAll(ManifestUtil.extractDynamicImportedPackages(this.manifest));
+            this.getExportedPackages().addAll(ManifestUtil.extractExportedPackages(this.manifest));
+            this.getImportedPackages().addAll(ManifestUtil.extractImportedPackages(this.manifest));
+            this.getDynamicImportedPackages().addAll(ManifestUtil.extractDynamicImportedPackages(this.manifest));
             try {
                 ManifestParser parser = new ManifestParser(this.manifest);
-                this.capabilities.addAll(ManifestUtil.extractCapabilities(parser));
-                this.requirements.addAll(ManifestUtil.extractRequirements(parser));
+                this.getCapabilities().addAll(ManifestUtil.extractCapabilities(parser));
+                this.getRequirements().addAll(ManifestUtil.extractRequirements(parser));
             } catch (Exception ex) {
                 throw new IOException(ex);
             }
@@ -215,28 +156,4 @@ public class BundleDescriptorImpl
             throw new IOException("Unable to get bundle symbolic name from artifact " + getArtifact().getId().toMvnId());
         }
     }
-
-    @Override
-    public boolean equals(Object obj) {
-        if ( obj instanceof BundleDescriptorImpl ) {
-            return this.symbolicName.equals(((BundleDescriptorImpl)obj).symbolicName) &&
this.bundleVersion.equals(((BundleDescriptorImpl)obj).bundleVersion);
-        }
-        return false;
-    }
-
-    @Override
-    public int hashCode() {
-        return (this.symbolicName + ':' + this.bundleVersion).hashCode();
-
-    }
-
-    @Override
-    public String toString() {
-        return "BundleInfo [symbolicName=" + symbolicName + ", version=" + this.bundleVersion
+ "]";
-    }
-
-    @Override
-    public int compareTo(final BundleDescriptor o) {
-        return (this.symbolicName + ':' + this.bundleVersion).compareTo((o.getBundleSymbolicName()
+ ':' + o.getBundleVersion()));
-    }
 }
\ No newline at end of file

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/CheckBundleExportsImports.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/CheckBundleExportsImports.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/CheckBundleExportsImports.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/CheckBundleExportsImports.java
Fri Aug  4 16:34:33 2017
@@ -18,13 +18,6 @@
  */
 package org.apache.sling.feature.analyser.impl;
 
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.analyser.BundleDescriptor;
-import org.apache.sling.feature.analyser.task.AnalyserTask;
-import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
-import org.apache.sling.feature.support.util.PackageInfo;
-import org.osgi.framework.Version;
-
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -33,6 +26,12 @@ import java.util.Map;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
+import org.apache.sling.feature.analyser.BundleDescriptor;
+import org.apache.sling.feature.analyser.task.AnalyserTask;
+import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
+import org.apache.sling.feature.support.util.PackageInfo;
+import org.osgi.framework.Version;
+
 public class CheckBundleExportsImports implements AnalyserTask {
 
     @Override
@@ -115,12 +114,9 @@ public class CheckBundleExportsImports i
             list.add(bi);
         }
 
-        // create a synthetic bundle info for the system bundle
-        final BundleDescriptor system = new BundleDescriptorImpl(new Artifact(ctx.getApplication().getFramework()),
ctx.getDescriptor().getFrameworkDescriptor().getExportedPackages());
-
         // add all system packages
         final List<BundleDescriptor> exportingBundles = new ArrayList<>();
-        exportingBundles.add(system);
+        exportingBundles.add(ctx.getDescriptor().getFrameworkDescriptor());
 
         for(final Map.Entry<Integer, List<BundleDescriptor>> entry : bundlesMap.entrySet())
{
             // first add all exporting bundles

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/CheckRequirementsCapabilities.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/CheckRequirementsCapabilities.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/CheckRequirementsCapabilities.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/CheckRequirementsCapabilities.java
Fri Aug  4 16:34:33 2017
@@ -16,23 +16,20 @@
  */
 package org.apache.sling.feature.analyser.impl;
 
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.Capability;
-import org.apache.sling.feature.Requirement;
-import org.apache.sling.feature.analyser.ArtifactDescriptor;
-import org.apache.sling.feature.analyser.BundleDescriptor;
-import org.apache.sling.feature.analyser.task.AnalyserTask;
-import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
-import org.apache.sling.feature.support.util.CapabilityMatcher;
-
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.stream.Collectors;
 
+import org.apache.sling.feature.Requirement;
+import org.apache.sling.feature.analyser.ArtifactDescriptor;
+import org.apache.sling.feature.analyser.BundleDescriptor;
+import org.apache.sling.feature.analyser.task.AnalyserTask;
+import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
+import org.apache.sling.feature.support.util.CapabilityMatcher;
+
 public class CheckRequirementsCapabilities implements AnalyserTask {
     private final String format = "Artifact %s:%s requires %s in start level %d but %s";
 
@@ -55,22 +52,9 @@ public class CheckRequirementsCapabiliti
                     );
         }
 
-        // create a synthetic bundle info for the system bundle
-        final ArtifactDescriptor system = new BundleDescriptorImpl(new Artifact(ctx.getApplication().getFramework()),
ctx.getDescriptor().getFrameworkDescriptor().getExportedPackages()) {
-            @Override
-            public Set<Requirement> getRequirements() {
-                return  ctx.getDescriptor().getFrameworkDescriptor().getRequirements();
-            }
-
-            @Override
-            public Set<Capability> getCapabilities() {
-                return  ctx.getDescriptor().getFrameworkDescriptor().getCapabilities();
-            }
-        };
-
         // add system artifact
         final List<ArtifactDescriptor> artifacts = new ArrayList<>();
-        artifacts.add(system);
+        artifacts.add(ctx.getDescriptor().getFrameworkDescriptor());
 
         for(final Map.Entry<Integer, List<ArtifactDescriptor>> entry : artifactsMap.entrySet())
{
             // first add all providing artifacts

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/FeatureDescriptorImpl.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/FeatureDescriptorImpl.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/FeatureDescriptorImpl.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/analyser/impl/FeatureDescriptorImpl.java
Fri Aug  4 16:34:33 2017
@@ -24,8 +24,7 @@ import org.apache.sling.feature.analyser
  * This is the aggregated information.
  */
 public class FeatureDescriptorImpl
-    extends ContainerDescriptorImpl
-    implements FeatureDescriptor {
+    extends FeatureDescriptor {
 
     private final Feature feature;
 

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/scanner/FrameworkScanner.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/scanner/FrameworkScanner.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/scanner/FrameworkScanner.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/scanner/FrameworkScanner.java
Fri Aug  4 16:34:33 2017
@@ -16,13 +16,13 @@
  */
 package org.apache.sling.feature.scanner;
 
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.KeyValueMap;
-import org.apache.sling.feature.analyser.Descriptor;
-
 import java.io.File;
 import java.io.IOException;
 
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.KeyValueMap;
+import org.apache.sling.feature.analyser.BundleDescriptor;
+
 /**
  * The framework scanner scans the framework
  */
@@ -36,7 +36,7 @@ public interface FrameworkScanner  {
      * @return A descriptor or {@code null}
      * @throws IOException If an error occurs while scanning the platform or the artifact
is invalid
      */
-    Descriptor scan(ArtifactId framework,
+    BundleDescriptor scan(ArtifactId framework,
             File platformFile,
             KeyValueMap frameworkProps) throws IOException;
 }
\ No newline at end of file

Modified: sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/FelixFrameworkScanner.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/FelixFrameworkScanner.java?rev=1804141&r1=1804140&r2=1804141&view=diff
==============================================================================
--- sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/FelixFrameworkScanner.java
(original)
+++ sling/whiteboard/cziegeler/feature-analyser/src/main/java/org/apache/sling/feature/scanner/impl/FelixFrameworkScanner.java
Fri Aug  4 16:34:33 2017
@@ -16,43 +16,41 @@
  */
 package org.apache.sling.feature.scanner.impl;
 
-import org.apache.sling.commons.osgi.ManifestHeader;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Capability;
-import org.apache.sling.feature.KeyValueMap;
-import org.apache.sling.feature.analyser.Descriptor;
-import org.apache.sling.feature.scanner.FrameworkScanner;
-import org.apache.sling.feature.support.util.LambdaUtil;
-import org.apache.sling.feature.support.util.ManifestParser;
-import org.apache.sling.feature.support.util.ManifestUtil;
-import org.apache.sling.feature.support.util.PackageInfo;
-import org.osgi.framework.Constants;
+import static org.apache.sling.feature.support.util.LambdaUtil.rethrowFunction;
+import static org.apache.sling.feature.support.util.ManifestParser.convertProvideCapabilities;
+import static org.apache.sling.feature.support.util.ManifestParser.normalizeCapabilityClauses;
+import static org.apache.sling.feature.support.util.ManifestParser.parseStandardHeader;
 
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Properties;
 import java.util.Set;
+import java.util.jar.Manifest;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
-import static org.apache.sling.feature.support.util.LambdaUtil.rethrowFunction;
-import static org.apache.sling.feature.support.util.ManifestParser.convertProvideCapabilities;
-import static org.apache.sling.feature.support.util.ManifestParser.normalizeCapabilityClauses;
-import static org.apache.sling.feature.support.util.ManifestParser.parseStandardHeader;
+import org.apache.sling.commons.osgi.ManifestHeader;
+import org.apache.sling.feature.Artifact;
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.Capability;
+import org.apache.sling.feature.KeyValueMap;
+import org.apache.sling.feature.analyser.BundleDescriptor;
+import org.apache.sling.feature.scanner.FrameworkScanner;
+import org.apache.sling.feature.support.util.PackageInfo;
+import org.osgi.framework.Constants;
 
 public class FelixFrameworkScanner implements FrameworkScanner {
 
 
     @Override
-    public Descriptor scan(final ArtifactId framework,
+    public BundleDescriptor scan(final ArtifactId framework,
             final File platformFile,
             final KeyValueMap frameworkProps)
     throws IOException {
@@ -63,18 +61,42 @@ public class FelixFrameworkScanner imple
         final Set<PackageInfo> pcks = calculateSystemPackages(fwkProps);
         final Set<Capability> capabilities = calculateSystemCapabilities(fwkProps);
 
-        return new Descriptor() {
+        final BundleDescriptor d = new BundleDescriptor() {
+
+            @Override
+            public String getBundleSymbolicName() {
+                return Constants.SYSTEM_BUNDLE_SYMBOLICNAME;
+            }
+
+            @Override
+            public String getBundleVersion() {
+                return framework.getOSGiVersion().toString();
+            }
+
+            @Override
+            public int getBundleStartLevel() {
+                return 0;
+            }
+
+            @Override
+            public File getArtifactFile() {
+                return platformFile;
+            }
 
             @Override
-            public Set<PackageInfo> getExportedPackages() {
-                return pcks;
+            public Artifact getArtifact() {
+                return new Artifact(framework);
             }
 
             @Override
-            public Set<Capability> getCapabilities() {
-                return capabilities;
+            public Manifest getManifest() {
+                return null;
             }
         };
+        d.getCapabilities().addAll(capabilities);
+        d.getExportedPackages().addAll(pcks);
+        d.lock();
+        return d;
     }
 
     private Set<Capability> calculateSystemCapabilities(final KeyValueMap fwkProps)
{



Mime
View raw message