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 2015/03/09 15:07:52 UTC

[1/2] karaf git commit: Fix broken equinox support

Repository: karaf
Updated Branches:
  refs/heads/master 1b0c13f30 -> f8d9022f8


Fix broken equinox support

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

Branch: refs/heads/master
Commit: d8e8735281328d0f94cf348e2df9d5561ef789af
Parents: 1b0c13f
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Mon Mar 9 14:07:15 2015 +0100
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Mon Mar 9 14:07:15 2015 +0100

----------------------------------------------------------------------
 assemblies/features/base/pom.xml                | 25 ++++++++++++++++++++
 .../resources/etc/config.properties             |  2 +-
 assemblies/features/framework/pom.xml           | 24 -------------------
 3 files changed, 26 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/d8e87352/assemblies/features/base/pom.xml
----------------------------------------------------------------------
diff --git a/assemblies/features/base/pom.xml b/assemblies/features/base/pom.xml
index 120932f..b0afde1 100644
--- a/assemblies/features/base/pom.xml
+++ b/assemblies/features/base/pom.xml
@@ -144,11 +144,36 @@
                                     <artifactId>org.apache.felix.framework</artifactId>
                                     <outputDirectory>target/classes/resources/system/org/apache/felix/org.apache.felix.framework/${felix.framework.version}</outputDirectory>
                                 </artifactItem>
+                                <artifactItem>
+                                    <groupId>${equinox.groupId}</groupId>
+                                    <artifactId>${equinox.artifactId}</artifactId>
+                                    <outputDirectory>target/classes/resources/system/${equinox.path}/${equinox.artifactId}/${equinox.version}</outputDirectory>
+                                </artifactItem>
                             </artifactItems>
                         </configuration>
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>regex-property</id>
+                        <phase>validate</phase>
+                        <goals>
+                            <goal>regex-property</goal>
+                        </goals>
+                        <configuration>
+                            <name>equinox.path</name>
+                            <value>${equinox.groupId}</value>
+                            <regex>\.</regex>
+                            <replacement>/</replacement>
+                            <failIfNoMatch>false</failIfNoMatch>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/d8e87352/assemblies/features/base/src/main/filtered-resources/resources/etc/config.properties
----------------------------------------------------------------------
diff --git a/assemblies/features/base/src/main/filtered-resources/resources/etc/config.properties b/assemblies/features/base/src/main/filtered-resources/resources/etc/config.properties
index 2eaf24b..12933b1 100644
--- a/assemblies/features/base/src/main/filtered-resources/resources/etc/config.properties
+++ b/assemblies/features/base/src/main/filtered-resources/resources/etc/config.properties
@@ -50,7 +50,7 @@ karaf.framework=felix
 #
 # Location of the OSGi frameworks
 #
-karaf.framework.equinox=mvn\:org.eclipse/osgi/${equinox.version}
+karaf.framework.equinox=mvn\:${equinox.groupId}/${equinox.artifactId}/${equinox.version}
 karaf.framework.felix=mvn\:org.apache.felix/org.apache.felix.framework/${felix.framework.version}
 
 #

http://git-wip-us.apache.org/repos/asf/karaf/blob/d8e87352/assemblies/features/framework/pom.xml
----------------------------------------------------------------------
diff --git a/assemblies/features/framework/pom.xml b/assemblies/features/framework/pom.xml
index 7de8e8e..6c32293 100644
--- a/assemblies/features/framework/pom.xml
+++ b/assemblies/features/framework/pom.xml
@@ -236,16 +236,6 @@
                         <configuration>
                             <artifactItems>
                                 <artifactItem>
-                                    <groupId>${equinox.groupId}</groupId>
-                                    <artifactId>${equinox.artifactId}</artifactId>
-                                    <outputDirectory>target/classes/resources/system/${equinox.path}/${equinox.artifactId}/${equinox.version}</outputDirectory>
-                                </artifactItem>
-                                <artifactItem>
-                                    <groupId>org.apache.felix</groupId>
-                                    <artifactId>org.apache.felix.framework</artifactId>
-                                    <outputDirectory>target/classes/resources/system/org/apache/felix/org.apache.felix.framework/${felix.framework.version}</outputDirectory>
-                                </artifactItem>
-                                <artifactItem>
                                     <groupId>jline</groupId>
                                     <artifactId>jline</artifactId>
                                     <outputDirectory>target/classes/resources/system/jline/jline/${jline.version}</outputDirectory>
@@ -317,20 +307,6 @@
                             </artifacts>
                         </configuration>
                     </execution>
-                    <execution>
-                        <id>regex-property</id>
-                        <phase>validate</phase>
-                        <goals>
-                            <goal>regex-property</goal>
-                        </goals>
-                        <configuration>
-                            <name>equinox.path</name>
-                            <value>${equinox.groupId}</value>
-                            <regex>\.</regex>
-                            <replacement>/</replacement>
-                            <failIfNoMatch>false</failIfNoMatch>
-                        </configuration>
-                    </execution>
                 </executions>
             </plugin>
         </plugins>


[2/2] karaf git commit: [KARAF-3585] Snapshots are not updated by the features service

Posted by gn...@apache.org.
[KARAF-3585] Snapshots are not updated by the features service

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

Branch: refs/heads/master
Commit: f8d9022f85336e26714f704d7513645ce2d7d7d6
Parents: d8e8735
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Mon Mar 9 14:08:02 2015 +0100
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Mon Mar 9 14:08:02 2015 +0100

----------------------------------------------------------------------
 .../features/internal/service/Deployer.java     | 48 ++++++++++++++++----
 .../internal/service/FeaturesServiceImpl.java   |  1 +
 2 files changed, 41 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/f8d9022f/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
index ffa34ca..69e8edd 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
@@ -16,8 +16,12 @@
  */
 package org.apache.karaf.features.internal.service;
 
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLConnection;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -1088,19 +1092,47 @@ public class Deployer {
                                 LOGGER.debug("Update snapshot for " + bundle.getLocation());
                                 deployment.toUpdate.put(bundle, resource);
                             } else if (UPDATE_SNAPSHOTS_CRC.equalsIgnoreCase(request.updateSnaphots)) {
-                                // if the checksum are different
+                                // Retrieve current bundle checksum
+                                long oldCrc;
+                                if (dstate.state.bundleChecksums.containsKey(bundleId)) {
+                                    oldCrc = dstate.state.bundleChecksums.get(bundleId);
+                                } else {
+                                    // Load bundle checksums if not already done
+                                    // This is a bit hacky, but we can't get a hold on the real bundle location
+                                    // in a standard way in OSGi.  Therefore, hack into Felix/Equinox to obtain the
+                                    // corresponding jar url and use that one to compute the checksum of the bundle.
+                                    oldCrc = 0l;
+                                    try {
+                                        URL url = bundle.getResource("META-INF/MANIFEST.MF");
+                                        URLConnection con = url.openConnection();
+                                        Method method = con.getClass().getDeclaredMethod("getLocalURL");
+                                        method.setAccessible(true);
+                                        String jarUrl = ((URL) method.invoke(con)).toExternalForm();
+                                        if (jarUrl.startsWith("jar:")) {
+                                            String jar = jarUrl.substring("jar:".length(), jarUrl.indexOf("!/"));
+                                            jar = new URL(jar).getFile();
+                                            try (InputStream is = new FileInputStream(jar)) {
+                                                oldCrc = ChecksumUtils.checksum(is);
+                                            }
+                                            result.bundleChecksums.put(bundleId, oldCrc);
+                                        }
+                                    } catch (Throwable t) {
+                                        LOGGER.debug("Error calculating checksum for bundle: %s", bundle, t);
+                                    }
+                                }
+                                // Compute new bundle checksum
+                                long newCrc;
                                 try (
                                         InputStream is = getBundleInputStream(resource, resolver.getProviders())
                                 ) {
-                                    long newCrc = ChecksumUtils.checksum(is);
-                                    long oldCrc = dstate.state.bundleChecksums.containsKey(bundle.getBundleId())
-                                                    ? dstate.state.bundleChecksums.get(bundle.getBundleId()) : 0L;
-                                    if (newCrc != oldCrc) {
-                                        LOGGER.debug("New snapshot available for " + bundle.getLocation());
-                                        deployment.toUpdate.put(bundle, resource);
-                                    }
+                                    newCrc = ChecksumUtils.checksum(is);
                                     result.bundleChecksums.put(bundle.getBundleId(), newCrc);
                                 }
+                                // if the checksum are different
+                                if (newCrc != oldCrc) {
+                                    LOGGER.debug("New snapshot available for " + bundle.getLocation());
+                                    deployment.toUpdate.put(bundle, resource);
+                                }
                             }
                         }
                         // We're done for this resource

http://git-wip-us.apache.org/repos/asf/karaf/blob/f8d9022f/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 b5ce5d5..ceadf51 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
@@ -1012,6 +1012,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
         Deployer.DeploymentRequest request = new Deployer.DeploymentRequest();
         request.bundleUpdateRange = bundleUpdateRange;
         request.featureResolutionRange = featureResolutionRange;
+        request.updateSnaphots = updateSnaphots;
         request.globalRepository = globalRepository;
         request.overrides = Overrides.loadOverrides(overrides);
         request.requirements = requirements;