karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [1/2] karaf git commit: Extract InstallSupport and FeaturesConfig
Date Tue, 16 May 2017 09:53:53 GMT
Repository: karaf
Updated Branches:
  refs/heads/master af9b835e7 -> bb0e9b77e


http://git-wip-us.apache.org/repos/asf/karaf/blob/bb0e9b77/profile/src/main/java/org/apache/karaf/profile/assembly/AssemblyDeployCallback.java
----------------------------------------------------------------------
diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/AssemblyDeployCallback.java
b/profile/src/main/java/org/apache/karaf/profile/assembly/AssemblyDeployCallback.java
index 94615ee..78506ee 100644
--- a/profile/src/main/java/org/apache/karaf/profile/assembly/AssemblyDeployCallback.java
+++ b/profile/src/main/java/org/apache/karaf/profile/assembly/AssemblyDeployCallback.java
@@ -45,10 +45,12 @@ import org.apache.karaf.features.internal.model.ConfigFile;
 import org.apache.karaf.features.internal.model.Feature;
 import org.apache.karaf.features.internal.model.Features;
 import org.apache.karaf.features.internal.service.Blacklist;
+import org.apache.karaf.features.internal.service.BundleInstallSupport;
 import org.apache.karaf.features.internal.service.Deployer;
 import org.apache.karaf.features.internal.service.State;
 import org.apache.karaf.features.internal.util.MapUtils;
 import org.apache.karaf.util.maven.Parser;
+import org.eclipse.equinox.region.RegionDigraph;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.InvalidSyntaxException;
@@ -59,7 +61,7 @@ import org.osgi.resource.Wire;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class AssemblyDeployCallback implements Deployer.DeployCallback {
+public class AssemblyDeployCallback implements Deployer.DeployCallback, BundleInstallSupport
{
 
     private static final Logger LOGGER = LoggerFactory.getLogger(Builder.class);
 
@@ -127,13 +129,8 @@ public class AssemblyDeployCallback implements Deployer.DeployCallback
{
     }
 
     @Override
-    public void installFeature(org.apache.karaf.features.Feature feature) throws IOException,
InvalidSyntaxException {
-        // Check blacklist
-        if (Blacklist.isFeatureBlacklisted(builder.getBlacklistedFeatures(), feature.getName(),
feature.getVersion())) {
-            if (builder.getBlacklistPolicy() == Builder.BlacklistPolicy.Fail) {
-                throw new RuntimeException("Feature " + feature.getId() + " is blacklisted");
-            }
-        }
+    public void installConfigs(org.apache.karaf.features.Feature feature) throws IOException,
InvalidSyntaxException {
+        assertNotBlacklisted(feature);
         // Install
         Downloader downloader = manager.createDownloader();
         for (Config config : ((Feature) feature).getConfig()) {
@@ -173,6 +170,13 @@ public class AssemblyDeployCallback implements Deployer.DeployCallback
{
                 Files.copy(input, output, StandardCopyOption.REPLACE_EXISTING);
             });
         }
+    }
+
+    
+    @Override
+    public void installLibraries(org.apache.karaf.features.Feature feature) throws IOException
{
+        assertNotBlacklisted(feature);
+        Downloader downloader = manager.createDownloader();
         List<String> libraries = new ArrayList<>();
         for (Library library : ((Feature) feature).getLibraries()) {
             String lib = library.getLocation() +
@@ -192,6 +196,14 @@ public class AssemblyDeployCallback implements Deployer.DeployCallback
{
             throw new IOException("Error downloading configuration files", e);
         }
     }
+    
+    private void assertNotBlacklisted(org.apache.karaf.features.Feature feature) {
+        if (Blacklist.isFeatureBlacklisted(builder.getBlacklistedFeatures(), feature.getName(),
feature.getVersion())) {
+            if (builder.getBlacklistPolicy() == Builder.BlacklistPolicy.Fail) {
+                throw new RuntimeException("Feature " + feature.getId() + " is blacklisted");
+            }
+        }
+    }
 
     @Override
     public void callListeners(DeploymentEvent deployEvent) {
@@ -302,4 +314,13 @@ public class AssemblyDeployCallback implements Deployer.DeployCallback
{
         }
         return finalname;
     }
+
+    @Override
+    public void saveState() throws IOException {
+    }
+
+    @Override
+    public RegionDigraph getDiGraphCopy() throws BundleException {
+        return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/bb0e9b77/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
----------------------------------------------------------------------
diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
index 2b7d2b8..604b00d 100644
--- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
+++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
@@ -1401,7 +1401,7 @@ public class Builder {
                     Collection<String> optionals) throws Exception {
         BundleRevision systemBundle = getSystemBundle();
         AssemblyDeployCallback callback = new AssemblyDeployCallback(manager, this, systemBundle,
repositories);
-        Deployer deployer = new Deployer(manager, resolver, callback);
+        Deployer deployer = new Deployer(manager, resolver, callback, callback);
 
         // Install framework
         Deployer.DeploymentRequest request = createDeploymentRequest();

http://git-wip-us.apache.org/repos/asf/karaf/blob/bb0e9b77/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
index 1d74d9e..c1d2714 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
@@ -74,6 +74,7 @@ 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.Deployer;
+import org.apache.karaf.features.internal.service.BundleInstallSupport;
 import org.apache.karaf.features.internal.service.State;
 import org.apache.karaf.features.internal.util.MapUtils;
 import org.apache.karaf.features.internal.util.MultiException;
@@ -87,6 +88,7 @@ import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.plugins.annotations.ResolutionScope;
 import org.apache.maven.project.MavenProject;
+import org.eclipse.equinox.region.RegionDigraph;
 import org.ops4j.pax.url.mvn.MavenResolver;
 import org.ops4j.pax.url.mvn.MavenResolvers;
 import org.osgi.framework.Bundle;
@@ -417,7 +419,7 @@ public class VerifyMojo extends MojoSupport {
         try {
             Bundle systemBundle = getSystemBundle(getMetadata(properties, "metadata#"));
             DummyDeployCallback callback = new DummyDeployCallback(systemBundle, repositories.values());
-            Deployer deployer = new Deployer(manager, new ResolverImpl(new MavenResolverLog()),
callback);
+            Deployer deployer = new Deployer(manager, new ResolverImpl(new MavenResolverLog()),
callback, callback);
 
 
             // Install framework
@@ -756,7 +758,7 @@ public class VerifyMojo extends MojoSupport {
         }
     }
 
-    public static class DummyDeployCallback implements Deployer.DeployCallback {
+    public static class DummyDeployCallback implements Deployer.DeployCallback, BundleInstallSupport
{
 
         private final Bundle systemBundle;
         private final Deployer.DeploymentState dstate;
@@ -798,7 +800,11 @@ public class VerifyMojo extends MojoSupport {
         }
 
         @Override
-        public void installFeature(org.apache.karaf.features.Feature feature) throws IOException,
InvalidSyntaxException {
+        public void installConfigs(org.apache.karaf.features.Feature feature) throws IOException,
InvalidSyntaxException {
+        }
+        
+        @Override
+        public void installLibraries(org.apache.karaf.features.Feature feature) throws IOException
{
         }
 
         @Override
@@ -866,6 +872,15 @@ public class VerifyMojo extends MojoSupport {
         @Override
         public void replaceDigraph(Map<String, Map<String, Map<String, Set<String>>>>
policies, Map<String, Set<Long>> bundles) throws BundleException, InvalidSyntaxException
{
         }
+
+        @Override
+        public void saveState() throws IOException {
+        }
+
+        @Override
+        public RegionDigraph getDiGraphCopy() throws BundleException {
+            return null;
+        }
     }
 
     public class MavenResolverLog extends org.apache.felix.resolver.Logger {


Mime
View raw message