You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:25:26 UTC

[sling-org-apache-sling-commons-osgi] annotated tag org.apache.sling.commons.osgi-2.4.0 created (now 8875951)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git.


      at 8875951  (tag)
 tagging c59c07d3e8dbdc3137642478e2ae6ed3f6b7c3cd (commit)
      by Carsten Ziegeler
      on Mon Jan 4 15:25:32 2016 +0000

- Log -----------------------------------------------------------------
org.apache.sling.commons.osgi-2.4.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new df63e8f  First steps towards a Prototype of 'Everything is a Resource'
     new 341e8d7  Make OosgiUtil more generic and cleanup imports
     new 8b99d1f  Prevent NPE if the property value is null in toStringArray
     new d93b1e0  Remove adapter stuff from osgi/commons
     new ae3cfac  SLING-197 Merge resource integration concept into trunk
     new 53d562f  Use OSGi core and cmpendium jars from Felix project.
     new 5d64b45  SLING-204 - add svn ignore patterns for intellij
     new 9451bc4  Move licence and notice to top level dir.
     new 2ca28a2  Add incubator disclaimer.
     new 410331b  Write first element in pom in one line (to avoid problems with the maven release plugin) and minor pom fixes.
     new 8866927  Update notice files.
     new 8534b0e  SLING-402 Move osgi/commons to commons/osgi
     new eb6efe5  SLING-402: Move osgi/commons to commons/osgi - correct poms.
     new d353e24  SLING-402: Move osgi/commons to commons/osgi - refactor to commons package.
     new afb619a  Eclude maven-eclipse.xml generated by the maven eclipse plugin.
     new 0665281  SLING-456: Add manifest header parser and junit test.
     new 36986a1  Use new manifest parser in content loader.
     new b1bc9f4  SLING-460: Preserve order of attributes and directives.
     new 554a87f  SLING-442: Clean up exports, imports, dependencies and used plugins.
     new ff7572e  Add method for handling integer properties.
     new 2fb950c  Add method for handling integer properties.
     new 3ac6bd1  SLING-495 - NOTICE files generated using mknotice script
     new c913b91  SLING-495 - NOTICE files updated according to changes in revision 662927
     new 5b61be1  SLING-495 - NOTICE files regenerated with revision 663097 changes
     new 08a1bf1  Use released version of parent pom.
     new a2f82a9  Use released versions (or soon to be released versions).
     new 056094f  [maven-release-plugin] prepare release org.apache.sling.commons.osgi-2.0.0-incubator
     new 078fd76  [maven-release-plugin] prepare for next development iteration
     new 0288d72  Set version to next development version.
     new b65ac41  Fix reference to parent pom.
     new b13381d  SLING-521: Restore more notice files.
     new ddcb4d2  SLING-521: Separate between notice files for bin and src dists.
     new 997457a  SLING-521: Separate between notice files for bin and src dists.
     new 831ffe0  SLING-521: Separate between notice files for bin and src dists.
     new 1e008e6  Change copyright year to 2008.
     new 6ed3e27  Update to released versions.
     new 7c1fff4  [maven-release-plugin] prepare release org.apache.sling.commons.osgi-2.0.2-incubator
     new a039ceb  [maven-release-plugin] prepare for next development iteration
     new 0e2142e  Use latest snapshots again to make project buildable.
     new 0065d7f  Use released versions.
     new aaa7929  Use released parent pom where possible.
     new 07b69ff  Add a test case with several directives and multiple lines.
     new 6badaf3  SLING-555 : Update all poms to use the latest parent pom; update parent pom to include the incubator repo for plugins and use latest plugins.
     new 5c546cb  Add toStringArray method with additional default value.
     new 8869a12  Add more tests.
     new bbb03a8  SLING-782 - Remove dependency to Sling API
     new e2d30f4  SLING-808 : Increase version to 5-incubator-SNAPSHOT
     new acb81c8  Update notice files to include 2009 in copyright statement.
     new 019d7ff  SLING-829 Cosmetics to the bundle/project names
     new 362853f  SLING-833 Accept Collection values and do not require Vector values
     new 960e563  SLING-833 Accept Collection values and do not require Vector values
     new 78aaced  SLING-865 : Move to bundles
     new c0d258d  SLING-865 : Adjust reactor pom and svn information in each module.
     new d27c9ca  SLING-865 : Adjust path to parent pom and add profiles for samples and contrib
     new 256d3f4  Deprecate getProperty(Object, double) and add toDouble(Object, double) to align with the rest of the toTYPE methods taking the object and the default value.
     new 1efaf58  JavaDoc and use Java 5 annotation for deprecation
     new 543d7a9  Use release parent pom
     new d3fcb84  [maven-release-plugin] prepare release org.apache.sling.commons.osgi-2.0.4-incubator
     new b206e97  [maven-release-plugin] prepare for next development iteration
     new 2a6c3d7  Use next dev version of parent pom
     new ca93db2  Set parent pom to released version.
     new 50e721b  Move Sling to new TLP location
     new 428dbbb  SLING-1011 : Remove disclaimer file.
     new db20824  SLING-1011 : Adjust svn location
     new 0c6d1d4  SLING-1011 : Remove disclaimer from readme's, adjust links to webite, fix versions in poms.
     new b3d732e  SLING-1033 Upgrade to Sling parent POM 6 (and ensure web app has the leglize stuff, too)
     new 629278b  Use generics.
     new eef9262  SLING-1205 Upgrade all projects to parent POM 8 and use OSGi provided OSGi libraries
     new 8ad219e  Add some javadocs.
     new 404fc99  Correct javadocs.
     new fad56ae  Add some tests for the OsgiUtil
     new d475594  SLING-1278 - Utilities for bundle version extraction and comparison
     new 93f3b11  SLING-1278 - make BundleVersionInfo abstract and Comparable
     new db67575  SLING-1278 - comparison was reversed
     new cfe23d4  SLING-1285 - Launchpad did not start under Windows
     new 55158d5  Clean up code.
     new 24fb4d3  clean up code.
     new 8a4075e  SLING-1431 : Utility method to get the service ranking
     new 01b2201  SLING-1431 : Utility method to get the service ranking
     new 2602d92  SLING-1431 : Utility method to get the service ranking
     new 8093e62  Use new osgi util to order services based on their ranking
     new e40f3ef  SLING-1431 : Utility method to get the service ranking - implement equals and hashCode
     new 6f04ac5  formatting
     new 6c07ba6  [maven-release-plugin] prepare release org.apache.sling.commons.osgi-2.0.6
     new e510fc8  [maven-release-plugin] prepare for next development iteration
     new 39f6c65  Update some notice files
     new a88ca89  Use released parent pom.
     new e023c37  updating all modules to parent 10-SNAPSHOT in anticipation of emma additions to parent
     new 37f3bab  Update to recent snapshots
     new dd7c7bc  Use latest releases.
     new a4d182b  SLING-2008 : Move properties support to own class
     new 8b0b615  SLING-2081 : Bundle version manifest entry is a string (not a Version object)
     new 5f058cb  Remove obsolete licence and notice files
     new b40897c  SLING-2150 : Update plugins to use the latest available versions
     new e2843fd  Update to recent snapshot
     new 82d3a9a  Using latest released parent pom
     new 44c5dcc  [maven-release-plugin] prepare release org.apache.sling.commons.osgi-2.1.0
     new 591a844  [maven-release-plugin] prepare for next development iteration
     new 8d4d39b  SLING-2187 - adding new module to contain our custom notice file; adding remote-resources plugin configuration to parent pom and removing all existing appended-resources NOTICE files
     new 08b1fbb  temporarily using snapshots during release vote
     new d67d549  using latest releases
     new 2c7bc53  SLING-2480 : Add config for maven-sling-plugin to m2e configuration
     new 4f76a87  Update to latest parent pom
     new 33e3b0c  Use released versions
     new 39e39fd  SLING-2645 Move SortingServiceTracker from org.apache.sling.installer.core.impl to org.apache.sling.commons.osgi
     new f47b5ff   SLING-2625 Patch from Chetan Mehrotra to include utility method to convert config values to maps, applied. Thank you. Incremented version of the o.a.s.commons.osgi to 2.2.0 due to addition of new method.
     new 8e03546  [maven-release-plugin] prepare release org.apache.sling.commons.osgi-2.2.0
     new cb59820  [maven-release-plugin] prepare for next development iteration
     new bfdfa48  Use latest releases and update to new parent pom
     new 5b660af  Update to latest parent pom and use latest releases in launchpad
     new c9ad51f  SLING-2008 - indicate alternatives for deprecated OsgiUtil
     new 0226a7d  Correct reactor pom and update to parent pom 16
     new 1f333d4  SLING-2908 :  Replace StringBuffer with StringBuilder
     new b26b7af  Update to latest parent pom
     new 42cc86a  Update to parent pom 18
     new adb759e  Update to parent pom v19
     new 35e7cc9  Updated to parent version 20
     new 28d88e1  [maven-release-plugin] prepare release org.apache.sling.commons.osgi-2.2.2
     new 5729bba  [maven-release-plugin] prepare for next development iteration
     new fc370a0  Update to Sling Parent POM 22 with baselining enabled
     new a28aeaf  ignore deprecation warnings in unit tests
     new 0b498b4  SLING-4520 Commons OSGi: Define package versions via package-info.java this additionally exports the package org.apache.sling.commons.osgi.bundleversion which was not exported before, but i assume this was by accident
     new 609eaf5  SLING-4521 Commons OSGi: Add helper class for thread-safe access list of ranked service dependencies
     new 310f714  fix typo and javadoc
     new 08f3dd4  SLING-4553 - Avoid unneeded unboxing in PropertiesUtil
     new 86d830b  SLING-4698 - Set parent.relativePath to empty for all modules
     new 553cb5c  update javadocs
     new bf038e3  [maven-release-plugin] prepare release org.apache.sling.commons.osgi-2.3.0
     new d6f5cd8  [maven-release-plugin] prepare for next development iteration
     new 73ea9ab  fix typos
     new 19d0de3  Update to Sling Parent 23
     new 9cb82eb  set parent version to 24 and add empty relativePath where missing
     new 12d8a37  Update the main reactor to parent 25
     new 63162f5  SLING-5379 - support renaming of bundles in maven-slingstart-plugin. Contributed by David Bosschaert, thanks!
     new a64bf63  SLING-5379 - remove java 7 requirement, does not seem worth it just for try-with-resources
     new 669bde4  SLING-5379 - make BundleFileProcessor more generic
     new ad893b8  SLING-5379 - add BSNRenamer
     new 8fce546  SLING-5041 allow to explicitly give ordering in RankedServices and in ServiceUtil
     new 0d07478  SLING-5403 return List instead of Collection for RankedServices.get
     new f0f66df  SLING-5403 remove unnecessary import
     new bca857d  SLING-5403 revert fix (as it requires a major version increase)
     new 6da4543  SLING-5403 add new method to return a list to not enforce a new major package version
     new f4565ec  SLING-5041 make Order public
     new 0f479f0  Switch to parent pom 26
     new 2e792f1  Update readme
     new e951a25  [maven-release-plugin] prepare release org.apache.sling.commons.osgi-2.4.0
     new c59c07d  [maven-release-plugin] copy for tag org.apache.sling.commons.osgi-2.4.0

The 147 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-commons-osgi] 01/19: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit d6f5cd8a1b38764f9af705f34fe0305134dc3d12
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Fri May 22 20:05:19 2015 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1681225 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 624e8fc..c9a37c0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     </parent>
 
     <artifactId>org.apache.sling.commons.osgi</artifactId>
-    <version>2.3.0</version>
+    <version>2.3.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling Commons OSGi support</name>
     <description>Commons OSGi</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.osgi-2.3.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.osgi-2.3.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.osgi-2.3.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/osgi</url>
     </scm>
     
     <properties>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 04/19: set parent version to 24 and add empty relativePath where missing

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit 9cb82ebfc4794b45b3b42782013626747b7dfe28
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Tue Jul 7 08:09:17 2015 +0000

    set parent version to 24 and add empty relativePath where missing
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1689593 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 3e3cd60..97ebff2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,8 +23,8 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>23</version>
-        <relativePath />
+        <version>24</version>
+        <relativePath/>
     </parent>
 
     <artifactId>org.apache.sling.commons.osgi</artifactId>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 12/19: SLING-5403 remove unnecessary import

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit f0f66df2ccd9bdc6fa0cfd0df70cefee0d3563e2
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sat Dec 26 16:11:38 2015 +0000

    SLING-5403 remove unnecessary import
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1721740 13f79535-47bb-0310-9956-ffa450edef68
---
 src/main/java/org/apache/sling/commons/osgi/RankedServices.java | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/commons/osgi/RankedServices.java b/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
index 0cbfe04..f2c9cb4 100644
--- a/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
+++ b/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
@@ -19,7 +19,6 @@
 package org.apache.sling.commons.osgi;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 02/19: fix typos

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit 73ea9ab7215145393b0406b52333095e303bccd2
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Fri Jun 5 16:08:42 2015 +0000

    fix typos
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1683791 13f79535-47bb-0310-9956-ffa450edef68
---
 src/main/java/org/apache/sling/commons/osgi/PropertiesUtil.java | 2 +-
 src/main/java/org/apache/sling/commons/osgi/ServiceUtil.java    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/commons/osgi/PropertiesUtil.java b/src/main/java/org/apache/sling/commons/osgi/PropertiesUtil.java
index 673c9fa..be806db 100644
--- a/src/main/java/org/apache/sling/commons/osgi/PropertiesUtil.java
+++ b/src/main/java/org/apache/sling/commons/osgi/PropertiesUtil.java
@@ -26,7 +26,7 @@ import java.util.Map;
 
 /**
  * The <code>PropertiesUtil</code> is a utility class providing some
- * usefull utility methods for converting property types.
+ * useful utility methods for converting property types.
  *
  * @since 2.1
  */
diff --git a/src/main/java/org/apache/sling/commons/osgi/ServiceUtil.java b/src/main/java/org/apache/sling/commons/osgi/ServiceUtil.java
index fa5219d..2775252 100644
--- a/src/main/java/org/apache/sling/commons/osgi/ServiceUtil.java
+++ b/src/main/java/org/apache/sling/commons/osgi/ServiceUtil.java
@@ -25,7 +25,7 @@ import org.osgi.framework.ServiceReference;
 
 /**
  * The <code>ServiceUtil</code> is a utility class providing some
- * usefull utility methods for service handling.
+ * useful utility methods for service handling.
  * @since 2.1
  */
 public class ServiceUtil {

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 13/19: SLING-5403 revert fix (as it requires a major version increase)

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit bca857d887721c5c136cdf5b9e324517ff7eae23
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sun Dec 27 11:16:36 2015 +0000

    SLING-5403 revert fix (as it requires a major version increase)
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1721798 13f79535-47bb-0310-9956-ffa450edef68
---
 src/main/java/org/apache/sling/commons/osgi/RankedServices.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/commons/osgi/RankedServices.java b/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
index f2c9cb4..3a4e547 100644
--- a/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
+++ b/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
@@ -19,6 +19,7 @@
 package org.apache.sling.commons.osgi;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -155,7 +156,7 @@ public final class RankedServices<T> implements Iterable<T> {
    * (either ascending or descending depending on the order given in the constructor).
    * @return Collection of service instances
    */
-  public List<T> get() {
+  public Collection<T> get() {
     return sortedServices;
   }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 06/19: SLING-5379 - support renaming of bundles in maven-slingstart-plugin. Contributed by David Bosschaert, thanks!

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit 63162f5e1c383d93e099cce6b4d0a4845c852913
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Dec 21 15:11:26 2015 +0000

    SLING-5379 - support renaming of bundles in maven-slingstart-plugin. Contributed by David Bosschaert, thanks!
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1721185 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |   3 +-
 .../org/apache/sling/commons/osgi/BundleUtil.java  | 103 ++++++++++++++++
 .../apache/sling/commons/osgi/package-info.java    |   2 +-
 .../apache/sling/commons/osgi/BundleUtilTest.java  | 133 +++++++++++++++++++++
 4 files changed, 239 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 9d92362..35beb9d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,7 +28,7 @@
     </parent>
 
     <artifactId>org.apache.sling.commons.osgi</artifactId>
-    <version>2.3.1-SNAPSHOT</version>
+    <version>2.3.1-SNAPSHOT</version> <!-- next release version should be 2.4 given new BundleUtil -->
     <packaging>bundle</packaging>
 
     <name>Apache Sling Commons OSGi support</name>
@@ -41,6 +41,7 @@
     </scm>
     
     <properties>
+        <sling.java.version>7</sling.java.version>
         <test.jars.folder>${project.build.directory}/testjars</test.jars.folder>
     </properties>
 
diff --git a/src/main/java/org/apache/sling/commons/osgi/BundleUtil.java b/src/main/java/org/apache/sling/commons/osgi/BundleUtil.java
new file mode 100644
index 0000000..a1bcd95
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/osgi/BundleUtil.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.commons.osgi;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+/**
+ * The <code>BundleUtil</code> is a utility class providing some
+ * useful utility methods for bundle handling.
+ * @since 2.4
+ */
+public class BundleUtil {
+    /**
+     * Creates a new OSGi Bundle from a given bundle with the only difference that the
+     * symbolic name is changed. The original symbolic name is recorded in the Manifest
+     * using the {@code X-Original-Bundle-SymbolicName} header.
+     * @param bundleFile The original bundle file. This file will not be modified.
+     * @param newBSN The new Bundle-SymbolicName
+     * @param tempDir The temporary directory to use. This is where the new bundle will be
+     * written. This directory must exist.
+     * @return The new bundle with the altered Symbolic Name.
+     * @throws IOException If something goes wrong reading or writing.
+     */
+    public static File renameBSN(File bundleFile, String newBSN, File tempDir) throws IOException {
+        try (JarInputStream jis = new JarInputStream(new FileInputStream(bundleFile))) {
+            Manifest inputMF = jis.getManifest();
+
+            Attributes inputAttrs = inputMF.getMainAttributes();
+            String bver = inputAttrs.getValue("Bundle-Version");
+            String orgBSN = inputAttrs.getValue("Bundle-SymbolicName");
+            if (bver == null)
+                bver = "0.0.0";
+
+            File newBundle = new File(tempDir, newBSN + "-" + bver + ".jar");
+
+            Manifest newMF = new Manifest(inputMF);
+            Attributes outputAttrs = newMF.getMainAttributes();
+            outputAttrs.putValue("Bundle-SymbolicName", newBSN);
+            outputAttrs.putValue("X-Original-Bundle-SymbolicName", orgBSN);
+
+            try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(newBundle), newMF)) {
+                JarEntry je = null;
+                while ((je = jis.getNextJarEntry()) != null) {
+                    try {
+                        jos.putNextEntry(je);
+                        if (!je.isDirectory())
+                            pumpStream(jis, jos);
+                    } finally {
+                        jos.closeEntry();
+                        jis.closeEntry();;
+                    }
+                }
+            }
+
+            return newBundle;
+        }
+    }
+
+    static void pumpStream(InputStream is, OutputStream os) throws IOException {
+        byte[] bytes = new byte[65536];
+
+        int length = 0;
+        int offset = 0;
+
+        while ((length = is.read(bytes, offset, bytes.length - offset)) != -1) {
+            offset += length;
+
+            if (offset == bytes.length) {
+                os.write(bytes, 0, bytes.length);
+                offset = 0;
+            }
+        }
+        if (offset != 0) {
+            os.write(bytes, 0, offset);
+        }
+    }
+}
diff --git a/src/main/java/org/apache/sling/commons/osgi/package-info.java b/src/main/java/org/apache/sling/commons/osgi/package-info.java
index 243300d..1d589bd 100644
--- a/src/main/java/org/apache/sling/commons/osgi/package-info.java
+++ b/src/main/java/org/apache/sling/commons/osgi/package-info.java
@@ -16,5 +16,5 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-@aQute.bnd.annotation.Version("2.3")
+@aQute.bnd.annotation.Version("2.4")
 package org.apache.sling.commons.osgi;
diff --git a/src/test/java/org/apache/sling/commons/osgi/BundleUtilTest.java b/src/test/java/org/apache/sling/commons/osgi/BundleUtilTest.java
new file mode 100644
index 0000000..9e0fa5c
--- /dev/null
+++ b/src/test/java/org/apache/sling/commons/osgi/BundleUtilTest.java
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.commons.osgi;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class BundleUtilTest {
+    @Test
+    public void testBSNRenaming() throws IOException {
+        File tempDir = new File(System.getProperty("java.io.tmpdir"));
+
+        // Just take any bundle from the maven deps as an example...
+        File originalFile = getMavenArtifactFile(getMavenRepoRoot(), "com.google.guava", "guava", "15.0");
+
+        File generatedFile = BundleUtil.renameBSN(originalFile, "org.acme.baklava.guava", tempDir);
+
+        try {
+            compareJarContents(originalFile, generatedFile);
+
+            try (JarFile jfOrg = new JarFile(originalFile);
+                    JarFile jfNew = new JarFile(generatedFile)) {
+                    Manifest mfOrg = jfOrg.getManifest();
+                    Manifest mfNew = jfNew.getManifest();
+
+                    Attributes orgAttrs = mfOrg.getMainAttributes();
+                    Attributes newAttrs = mfNew.getMainAttributes();
+                    for (Object key : orgAttrs.keySet()) {
+                        String orgVal = orgAttrs.getValue(key.toString());
+                        String newVal = newAttrs.getValue(key.toString());
+
+                        if ("Bundle-SymbolicName".equals(key.toString())) {
+                            assertEquals("Should have recorded the original Bundle-SymbolicName",
+                                    orgVal, newAttrs.getValue("X-Original-Bundle-SymbolicName"));
+
+                            assertEquals("org.acme.baklava.guava", newVal);
+                        } else {
+                            assertEquals("Different keys: " + key, orgVal, newVal);
+                        }
+                    }
+                }
+
+        } finally {
+            assertTrue("Unable to delete temporary file", generatedFile.delete());
+        }
+    }
+
+    private static void compareJarContents(File orgJar, File actualJar) throws IOException {
+        try (JarInputStream jis1 = new JarInputStream(new FileInputStream(orgJar));
+            JarInputStream jis2 = new JarInputStream(new FileInputStream(actualJar))) {
+            JarEntry je1 = null;
+            while ((je1 = jis1.getNextJarEntry()) != null) {
+                if (je1.isDirectory())
+                    continue;
+
+                JarEntry je2 = null;
+                while((je2 = jis2.getNextJarEntry()) != null) {
+                    if (!je2.isDirectory())
+                        break;
+                }
+
+                assertEquals(je1.getName(), je2.getName());
+                assertEquals(je1.getSize(), je2.getSize());
+
+                try {
+                    byte[] buf1 = streamToByteArray(jis1);
+                    byte[] buf2 = streamToByteArray(jis2);
+
+                    assertArrayEquals("Contents not equal: " + je1.getName(), buf1, buf2);
+                } finally {
+                    jis1.closeEntry();
+                    jis2.closeEntry();
+                }
+            }
+        }
+    }
+
+    private static byte [] streamToByteArray(InputStream is) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        BundleUtil.pumpStream(is, baos);
+        return baos.toByteArray();
+    }
+
+    private static File getMavenArtifactFile(File repoRoot, String gid, String aid, String ver) {
+        return new File(repoRoot, gid.replace('.', '/') + '/' + aid + '/' + ver + '/' + aid + '-' + ver + ".jar");
+    }
+
+    private static File getMavenRepoRoot() throws IOException {
+        URL res = BundleUtilTest.class.getClassLoader().getResource(
+                Test.class.getName().replace('.', '/') + ".class");
+
+        String u = res.toExternalForm();
+        if (u.startsWith("jar:"))
+            u = u.substring(4);
+
+        int idx = u.indexOf("junit");
+        if (idx < 0)
+            throw new IllegalStateException("Cannot infer maven repo root: " + res);
+
+        return new File(new URL(u.substring(0, idx)).getFile());
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 15/19: SLING-5041 make Order public

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit f4565ec905f677689e7fcd003bd180074067c457
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sun Dec 27 13:01:46 2015 +0000

    SLING-5041 make Order public
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1721810 13f79535-47bb-0310-9956-ffa450edef68
---
 src/main/java/org/apache/sling/commons/osgi/Order.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/commons/osgi/Order.java b/src/main/java/org/apache/sling/commons/osgi/Order.java
index d70d872..d247230 100644
--- a/src/main/java/org/apache/sling/commons/osgi/Order.java
+++ b/src/main/java/org/apache/sling/commons/osgi/Order.java
@@ -23,7 +23,7 @@ package org.apache.sling.commons.osgi;
  * or {@link RankedServices}. Either {@link #ASCENDING} meaning services with lowest service ranking first or 
  * {@link #DESCENDING} meaning services with highest service ranking first.
  */
-enum Order {
+public enum Order {
     ASCENDING(-1, 1),
     DESCENDING(1, -1);
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 10/19: SLING-5041 allow to explicitly give ordering in RankedServices and in ServiceUtil

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit 8fce546d583f098cd80da0550e49e20ff4fc4d1b
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sat Dec 26 13:34:42 2015 +0000

    SLING-5041 allow to explicitly give ordering in RankedServices and in ServiceUtil
    
    deprecate constructors not having a dedicated order parameter
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1721731 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/commons/osgi/Order.java  | 37 ++++++++++++++++
 .../apache/sling/commons/osgi/RankedServices.java  | 51 ++++++++++++++++++----
 .../org/apache/sling/commons/osgi/ServiceUtil.java | 38 ++++++++++++----
 .../sling/commons/osgi/RankedServicesTest.java     | 28 +++++++++++-
 4 files changed, 136 insertions(+), 18 deletions(-)

diff --git a/src/main/java/org/apache/sling/commons/osgi/Order.java b/src/main/java/org/apache/sling/commons/osgi/Order.java
new file mode 100644
index 0000000..d70d872
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/osgi/Order.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.commons.osgi;
+
+/**
+ * Order for services being sorted by {@link ServiceUtil#getComparableForServiceRanking(java.util.Map, Order)}
+ * or {@link RankedServices}. Either {@link #ASCENDING} meaning services with lowest service ranking first or 
+ * {@link #DESCENDING} meaning services with highest service ranking first.
+ */
+enum Order {
+    ASCENDING(-1, 1),
+    DESCENDING(1, -1);
+
+    public final int lessThan;
+    public final int greaterThan;
+
+    private Order(int lessThan, int greaterThan) {
+        this.lessThan = lessThan;
+        this.greaterThan = greaterThan;
+    }
+}
\ No newline at end of file
diff --git a/src/main/java/org/apache/sling/commons/osgi/RankedServices.java b/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
index 8eecac0..13870f2 100644
--- a/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
+++ b/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
@@ -27,6 +27,8 @@ import java.util.Map;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
+import org.osgi.framework.BundleContext;
+
 import aQute.bnd.annotation.ConsumerType;
 import aQute.bnd.annotation.ProviderType;
 
@@ -39,7 +41,7 @@ import aQute.bnd.annotation.ProviderType;
  * <pre>
  * &#64;Reference(name = "myService", referenceInterface = MyService.class,
  *     cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC)
- * private final RankedServices&lt;MyService&gt; myServices = new RankedServices&lt;MyService&gt;();
+ * private final RankedServices&lt;MyService&gt; myServices = new RankedServices&lt;MyService&gt;(Order.DESCENDING);
  * </pre>
  * <p>2. Define bind/unbind methods that delegate to the RankedServices instance:</p>
  * <pre>
@@ -67,19 +69,50 @@ public final class RankedServices<T> implements Iterable<T> {
   private final ChangeListener changeListener;
   private final SortedMap<Comparable<Object>, T> serviceMap = new TreeMap<Comparable<Object>, T>();
   private volatile Collection<T> sortedServices = Collections.emptyList();
+  private final Order order;
 
   /**
-   * Instantiate without change listener.
+   * Instantiate without change listener in ascending order (lowest service ranking first).
+   * @deprecated Use {@link #RankedService(Order)}) to explicitly give the order.
    */
+  @Deprecated
   public RankedServices() {
-    this(null);
+    this(Order.ASCENDING, null);
+  }
+  
+  /**
+   * Instantiate with change listener in ascending order ((lowest service ranking first).
+   * @param changeListener Change listener
+   * @deprecated use {@link #RankedServices(Order order, ChangeListener changeListener)}  instead 
+   */
+  @Deprecated
+  public RankedServices(ChangeListener changeListener) {
+    this(Order.ASCENDING, changeListener);
+  }
+  
+  /**
+   * Instantiate without change listener but with a given order.
+   * @param order the order in which the services should be returned in {@link #iterator()} and {@link #get()}. 
+   *              Either {@link Order#ASCENDING} or {@link Order#DESCENDING}.
+   *              Use {@link Order#DESCENDING} if you want to have the service with the highest ranking returned first
+   *              (this is the service which would also be chosen by {@link BundleContext#getServiceReference(String)}).
+   * @since 2.4
+   */
+  public RankedServices(Order order) {
+    this(order, null);
   }
 
   /**
    * Instantiate with change listener.
+   * @param order the order in which the services should be returned in {@link #iterator()} and {@link #get()}. 
+   *              Either {@link Order#ASCENDING} or {@link Order#DESCENDING}.
+   *              Use {@link Order#DESCENDING} if you want to have the service with the highest ranking returned first
+   *              (this is the service which would also be chosen by {@link BundleContext#getServiceReference(String)}).
    * @param changeListener Change listener
+   * @since 2.4
    */
-  public RankedServices(ChangeListener changeListener) {
+  public RankedServices(Order order, ChangeListener changeListener) {
+    this.order = order;
     this.changeListener = changeListener;
   }
 
@@ -90,7 +123,7 @@ public final class RankedServices<T> implements Iterable<T> {
    */
   public void bind(T service, Map<String, Object> props) {
     synchronized (serviceMap) {
-      serviceMap.put(ServiceUtil.getComparableForServiceRanking(props), service);
+      serviceMap.put(ServiceUtil.getComparableForServiceRanking(props, order), service);
       updateSortedServices();
     }
   }
@@ -102,7 +135,7 @@ public final class RankedServices<T> implements Iterable<T> {
    */
   public void unbind(T service, Map<String, Object> props) {
     synchronized (serviceMap) {
-      serviceMap.remove(ServiceUtil.getComparableForServiceRanking(props));
+      serviceMap.remove(ServiceUtil.getComparableForServiceRanking(props, order));
       updateSortedServices();
     }
   }
@@ -119,7 +152,8 @@ public final class RankedServices<T> implements Iterable<T> {
   }
 
   /**
-   * Lists all services registered in OSGi, sorted by service ranking.
+   * Lists all services registered in OSGi, sorted by service ranking
+   * (either ascending or descending depending on the order given in the constructor).
    * @return Collection of service instances
    */
   public Collection<T> get() {
@@ -127,7 +161,8 @@ public final class RankedServices<T> implements Iterable<T> {
   }
 
   /**
-   * Iterates all services registered in OSGi, sorted by service ranking.
+   * Iterates all services registered in OSGi, sorted by service ranking
+   * (either ascending or descending depending on the order given in the constructor).
    * @return Iterator with service instances.
    */
   public Iterator<T> iterator() {
diff --git a/src/main/java/org/apache/sling/commons/osgi/ServiceUtil.java b/src/main/java/org/apache/sling/commons/osgi/ServiceUtil.java
index 2775252..de7d825 100644
--- a/src/main/java/org/apache/sling/commons/osgi/ServiceUtil.java
+++ b/src/main/java/org/apache/sling/commons/osgi/ServiceUtil.java
@@ -20,6 +20,7 @@ package org.apache.sling.commons.osgi;
 
 import java.util.Map;
 
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 
@@ -31,22 +32,41 @@ import org.osgi.framework.ServiceReference;
 public class ServiceUtil {
 
     /**
+     * @deprecated Use {@link #getComparableForServiceRanking(Map, Order)} instead.
+     * @param props The service properties.
+     * @return the same comparable as returned by {@link #getComparableForServiceRanking(Map, Order.ASCENDING)}
+     * @see #getComparableForServiceRanking(Map, Order)
+     */
+    @Deprecated
+    public static Comparable<Object> getComparableForServiceRanking(final Map<String, Object> props) {
+        return getComparableForServiceRanking(props, Order.ASCENDING);
+    }
+
+    /**
      * Create a comparable object out of the service properties. With the result
      * it is possible to compare service properties based on the service ranking
-     * of a service. Therefore this object acts like {@link ServiceReference#compareTo(Object)}.
+     * of a service. This object acts like {@link ServiceReference#compareTo(Object)}.
+     * The comparator will return the services in the given order. In ascending order the 
+     * service with the lowest ranking comes first, in descending order the service with the 
+     * highest ranking comes first. The latter is useful if you want to have the service 
+     * returned first which is also chosen by {@link BundleContext#getServiceReference(String)}).
      * @param props The service properties.
+     * @param order The order (either ascending or descending).
      * @return A comparable for the ranking of the service
+     * @since 2.4
      */
-    public static Comparable<Object> getComparableForServiceRanking(final Map<String, Object> props) {
-        return new ComparableImplementation(props);
+    public static Comparable<Object> getComparableForServiceRanking(final Map<String, Object> props, Order order) {
+        return new ComparableImplementation(props, order);
     }
 
     private static final class ComparableImplementation implements Comparable<Object> {
 
         private final Map<String, Object> props;
+        private final Order order;
 
-        private ComparableImplementation(Map<String, Object> props) {
+        private ComparableImplementation(Map<String, Object> props, Order order) {
             this.props = props;
+            this.order = order;
         }
 
         @SuppressWarnings("unchecked")
@@ -83,15 +103,15 @@ public class ServiceUtil {
             Integer otherRank = (otherRankObj instanceof Integer)
                 ? (Integer) otherRankObj : new Integer(0);
 
-            // Sort by rank in ascending order.
+            // Sort by rank.
             if (rank.compareTo(otherRank) < 0) {
-                return -1; // lower rank
+                return order.lessThan; // lower rank
             } else if (rank.compareTo(otherRank) > 0) {
-                return 1; // higher rank
+                return order.greaterThan; // higher rank
             }
 
-            // If ranks are equal, then sort by service id in descending order.
-            return (id.compareTo(otherId) < 0) ? 1 : -1;
+            // If ranks are equal, then sort by service id.
+            return (id.compareTo(otherId) < 0) ? order.greaterThan : order.lessThan;
         }
 
         @Override
diff --git a/src/test/java/org/apache/sling/commons/osgi/RankedServicesTest.java b/src/test/java/org/apache/sling/commons/osgi/RankedServicesTest.java
index 867e165..22ad6e4 100644
--- a/src/test/java/org/apache/sling/commons/osgi/RankedServicesTest.java
+++ b/src/test/java/org/apache/sling/commons/osgi/RankedServicesTest.java
@@ -45,7 +45,7 @@ public class RankedServicesTest {
       .put(Constants.SERVICE_RANKING, 100).put(Constants.SERVICE_ID, 3L).build();
 
   @Test
-  public void testSortedServices() {
+  public void testSortedServicesAscending() {
     RankedServices<Comparable> underTest = new RankedServices<Comparable>();
     assertEquals(0, underTest.get().size());
 
@@ -69,6 +69,32 @@ public class RankedServicesTest {
     assertSame(SERVICE_3, services[1]);
   }
 
+
+  @Test
+  public void testSortedServicesDescending() {
+    RankedServices<Comparable> underTest = new RankedServices<Comparable>(Order.DESCENDING);
+    assertEquals(0, underTest.get().size());
+
+    underTest.bind(SERVICE_1, SERVICE_1_PROPS);
+    assertEquals(1, underTest.get().size());
+    Comparable[] services = Iterators.toArray(underTest.get().iterator(), Comparable.class);
+    assertSame(SERVICE_1, services[0]);
+
+    underTest.bind(SERVICE_2, SERVICE_2_PROPS);
+    underTest.bind(SERVICE_3, SERVICE_3_PROPS);
+    assertEquals(3, underTest.get().size());
+    services = Iterators.toArray(underTest.get().iterator(), Comparable.class);
+    assertSame(SERVICE_3, services[0]);
+    assertSame(SERVICE_1, services[1]);
+    assertSame(SERVICE_2, services[2]);
+
+    underTest.unbind(SERVICE_2, SERVICE_2_PROPS);
+    assertEquals(2, underTest.get().size());
+    services = Iterators.toArray(underTest.get().iterator(), Comparable.class);
+    assertSame(SERVICE_3, services[0]);
+    assertSame(SERVICE_1, services[1]);
+  }
+
   @Test
   public void testChangeListener() {
     ChangeListener changeListener = mock(ChangeListener.class);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 17/19: Update readme

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit 2e792f10a0733851c36da350ceb8d22debe59759
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 4 15:17:50 2016 +0000

    Update readme
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1722888 13f79535-47bb-0310-9956-ffa450edef68
---
 README.txt | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/README.txt b/README.txt
index 289bf2c..326fa43 100644
--- a/README.txt
+++ b/README.txt
@@ -6,16 +6,16 @@ and components.
 Getting Started
 ===============
 
-This component uses a Maven 2 (http://maven.apache.org/) build
-environment. It requires a Java 5 JDK (or higher) and Maven (http://maven.apache.org/)
-2.0.7 or later. We recommend to use the latest Maven version.
+This component uses a Maven 3 (http://maven.apache.org/) build
+environment. It requires a Java 6 JDK (or higher) and Maven (http://maven.apache.org/)
+3.0.5 or later. We recommend to use the latest Maven version.
 
-If you have Maven 2 installed, you can compile and
+If you have Maven installed, you can compile and
 package the jar using the following command:
 
     mvn package
 
-See the Maven 2 documentation for other build features.
+See the Maven documentation for other build features.
 
 The latest source code for this component is available in the
 Subversion (http://subversion.tigris.org/) source repository of

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 09/19: SLING-5379 - add BSNRenamer

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit ad893b85cf3584bcf7ca5c8fbb81ce0d07eb066e
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Dec 21 16:20:50 2015 +0000

    SLING-5379 - add BSNRenamer
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1721206 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/commons/osgi/BSNRenamer.java  | 58 ++++++++++++++++++++++
 .../commons/osgi/BundleFileProcessorTest.java      | 27 ----------
 2 files changed, 58 insertions(+), 27 deletions(-)

diff --git a/src/main/java/org/apache/sling/commons/osgi/BSNRenamer.java b/src/main/java/org/apache/sling/commons/osgi/BSNRenamer.java
new file mode 100644
index 0000000..faf6730
--- /dev/null
+++ b/src/main/java/org/apache/sling/commons/osgi/BSNRenamer.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.commons.osgi;
+
+import java.io.File;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+/** Processes a bundle file by changing its Bundle-SymbolicName.
+ *  The original BSN is copied to a an {@link #X_ORIG_BSN} header,
+ *  to allow users to find out what happened.
+ * @since 2.4
+ */
+public class BSNRenamer extends BundleFileProcessor {
+    private final String newBSN;
+    public static final String BUNDLE_SYMBOLIC_NAME = "Bundle-SymbolicName";
+    public static final String X_ORIG_BSN = "X-Original-Bundle-SymbolicName"; 
+    public static final String BUNDLE_VERSION = "Bundle-Version"; 
+    
+    public BSNRenamer(File input, File outputFolder, String newBSN) {
+        super(input, outputFolder);
+        this.newBSN = newBSN;
+    }
+    
+    protected Manifest processManifest(Manifest inputMF) {
+        Attributes inputAttrs = inputMF.getMainAttributes();
+        String orgBSN = inputAttrs.getValue(BUNDLE_SYMBOLIC_NAME);
+        Manifest newMF = new Manifest(inputMF);
+        Attributes outputAttrs = newMF.getMainAttributes();
+        outputAttrs.putValue(BUNDLE_SYMBOLIC_NAME, newBSN);
+        outputAttrs.putValue(X_ORIG_BSN, orgBSN);
+        return newMF;
+    }
+    
+    protected String getTargetFilename(Manifest inputJarManifest) {
+        String bver = inputJarManifest.getMainAttributes().getValue(BUNDLE_VERSION);
+        if (bver == null) {
+            bver = "0.0.0";
+        }
+        return newBSN + "-" + bver + ".jar";
+    }
+}
diff --git a/src/test/java/org/apache/sling/commons/osgi/BundleFileProcessorTest.java b/src/test/java/org/apache/sling/commons/osgi/BundleFileProcessorTest.java
index c8d67b4..09822b9 100644
--- a/src/test/java/org/apache/sling/commons/osgi/BundleFileProcessorTest.java
+++ b/src/test/java/org/apache/sling/commons/osgi/BundleFileProcessorTest.java
@@ -46,33 +46,6 @@ public class BundleFileProcessorTest {
         }
     }
     
-    static class BSNRenamer extends BundleFileProcessor {
-        private final String newBSN;
-        
-        BSNRenamer(File input, File outputFolder, String newBSN) {
-            super(input, outputFolder);
-            this.newBSN = newBSN;
-        }
-        
-        protected Manifest processManifest(Manifest inputMF) {
-            Attributes inputAttrs = inputMF.getMainAttributes();
-            String orgBSN = inputAttrs.getValue("Bundle-SymbolicName");
-            Manifest newMF = new Manifest(inputMF);
-            Attributes outputAttrs = newMF.getMainAttributes();
-            outputAttrs.putValue("Bundle-SymbolicName", newBSN);
-            outputAttrs.putValue("X-Original-Bundle-SymbolicName", orgBSN);
-            return newMF;
-        }
-        
-        protected String getTargetFilename(Manifest inputJarManifest) {
-            String bver = inputJarManifest.getMainAttributes().getValue("Bundle-Version");
-            if (bver == null) {
-                bver = "0.0.0";
-            }
-            return newBSN + "-" + bver + ".jar";
-        }
-    }
-    
     @Test
     public void testBSNRenaming() throws IOException {
         File tempDir = new File(System.getProperty("java.io.tmpdir"));

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 16/19: Switch to parent pom 26

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit 0f479f0ffdd87c1b58264b306c40bed5178f7422
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Jan 3 14:07:46 2016 +0000

    Switch to parent pom 26
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1722720 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index aac2dc4..a49c65d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>25</version>
+        <version>26</version>
         <relativePath/>
     </parent>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 14/19: SLING-5403 add new method to return a list to not enforce a new major package version

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit 6da45439bcfb57be0ded1e08e52fa40192ddd174
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sun Dec 27 11:57:48 2015 +0000

    SLING-5403 add new method to return a list to not enforce a new major package version
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1721805 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/commons/osgi/RankedServices.java     | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/main/java/org/apache/sling/commons/osgi/RankedServices.java b/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
index 3a4e547..5d2ff6b 100644
--- a/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
+++ b/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
@@ -155,10 +155,20 @@ public final class RankedServices<T> implements Iterable<T> {
    * Lists all services registered in OSGi, sorted by service ranking
    * (either ascending or descending depending on the order given in the constructor).
    * @return Collection of service instances
+   * @deprecated Use {@link #getList()} instead
    */
   public Collection<T> get() {
     return sortedServices;
   }
+  
+  /**
+   * Lists all services registered in OSGi, sorted by service ranking
+   * (either ascending or descending depending on the order given in the constructor).
+   * @return List of service instances
+   */
+  public List<T> getList() {
+    return sortedServices;
+  }
 
   /**
    * Iterates all services registered in OSGi, sorted by service ranking

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 03/19: Update to Sling Parent 23

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit 19d0de380855677b146e29f77c2022a5a204980d
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Thu Jun 25 13:08:16 2015 +0000

    Update to Sling Parent 23
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1687500 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index c9a37c0..3e3cd60 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>22</version>
+        <version>23</version>
         <relativePath />
     </parent>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 18/19: [maven-release-plugin] prepare release org.apache.sling.commons.osgi-2.4.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit e951a25298fe167816183c4a16d4f5b42252d695
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 4 15:25:18 2016 +0000

    [maven-release-plugin] prepare release org.apache.sling.commons.osgi-2.4.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1722891 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index a49c65d..979b245 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,20 +24,20 @@
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
         <version>26</version>
-        <relativePath/>
+        <relativePath />
     </parent>
 
     <artifactId>org.apache.sling.commons.osgi</artifactId>
-    <version>2.3.1-SNAPSHOT</version> <!-- next release version should be 2.4 given new BundleUtil -->
+    <version>2.4.0</version> <!-- next release version should be 2.4 given new BundleUtil -->
     <packaging>bundle</packaging>
 
     <name>Apache Sling Commons OSGi support</name>
     <description>Commons OSGi</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/commons/osgi</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.osgi-2.4.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.osgi-2.4.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.commons.osgi-2.4.0</url>
     </scm>
     
     <properties>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 11/19: SLING-5403 return List instead of Collection for RankedServices.get

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit 0d074789cbb5fc65a3df7e2526f50e486aa9b5a1
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Sat Dec 26 16:10:51 2015 +0000

    SLING-5403 return List instead of Collection for RankedServices.get
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1721739 13f79535-47bb-0310-9956-ffa450edef68
---
 src/main/java/org/apache/sling/commons/osgi/RankedServices.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/sling/commons/osgi/RankedServices.java b/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
index 13870f2..0cbfe04 100644
--- a/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
+++ b/src/main/java/org/apache/sling/commons/osgi/RankedServices.java
@@ -68,7 +68,7 @@ public final class RankedServices<T> implements Iterable<T> {
 
   private final ChangeListener changeListener;
   private final SortedMap<Comparable<Object>, T> serviceMap = new TreeMap<Comparable<Object>, T>();
-  private volatile Collection<T> sortedServices = Collections.emptyList();
+  private volatile List<T> sortedServices = Collections.emptyList();
   private final Order order;
 
   /**
@@ -156,7 +156,7 @@ public final class RankedServices<T> implements Iterable<T> {
    * (either ascending or descending depending on the order given in the constructor).
    * @return Collection of service instances
    */
-  public Collection<T> get() {
+  public List<T> get() {
     return sortedServices;
   }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 05/19: Update the main reactor to parent 25

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit 12d8a371102025b997846b06c9097b910ec1ab50
Author: Robert Munteanu <ro...@apache.org>
AuthorDate: Mon Oct 5 10:03:45 2015 +0000

    Update the main reactor to parent 25
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1706780 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 97ebff2..9d92362 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling</artifactId>
-        <version>24</version>
+        <version>25</version>
         <relativePath/>
     </parent>
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 08/19: SLING-5379 - make BundleFileProcessor more generic

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit 669bde42eeb2b9e77d210c2265ea32ec929a0213
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Dec 21 15:48:12 2015 +0000

    SLING-5379 - make BundleFileProcessor more generic
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1721199 13f79535-47bb-0310-9956-ffa450edef68
---
 .../{BundleUtil.java => BundleFileProcessor.java}  | 55 +++++++++++-----------
 ...eUtilTest.java => BundleFileProcessorTest.java} | 35 ++++++++++++--
 2 files changed, 58 insertions(+), 32 deletions(-)

diff --git a/src/main/java/org/apache/sling/commons/osgi/BundleUtil.java b/src/main/java/org/apache/sling/commons/osgi/BundleFileProcessor.java
similarity index 63%
rename from src/main/java/org/apache/sling/commons/osgi/BundleUtil.java
rename to src/main/java/org/apache/sling/commons/osgi/BundleFileProcessor.java
index 5470bac..2804952 100644
--- a/src/main/java/org/apache/sling/commons/osgi/BundleUtil.java
+++ b/src/main/java/org/apache/sling/commons/osgi/BundleFileProcessor.java
@@ -24,47 +24,46 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.jar.Attributes;
 import java.util.jar.JarEntry;
 import java.util.jar.JarInputStream;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 
 /**
- * The <code>BundleUtil</code> is a utility class providing some
- * useful utility methods for bundle handling.
+ * The <code>BundleFileProcessor</code> can transform a bundle Manifest
+ * by creating a modified copy of the bundle file. 
  * @since 2.4
  */
-public class BundleUtil {
+public abstract class BundleFileProcessor {
+    
+    private final File input;
+    private final File outputFolder;
+    
+    public BundleFileProcessor(File input, File outputFolder) {
+        this.input = input;
+        this.outputFolder = outputFolder;
+    }
+    
+    /** Process the bundle Manifest. Can return the original
+     *  one if no changes are needed */
+    protected abstract Manifest processManifest(Manifest originalManifest);
+
+    /** Return the filename to use for the newly created bundle file */
+    protected abstract String getTargetFilename(Manifest inputJarManifest);
+    
     /**
-     * Creates a new OSGi Bundle from a given bundle with the only difference that the
-     * symbolic name is changed. The original symbolic name is recorded in the Manifest
-     * using the {@code X-Original-Bundle-SymbolicName} header.
-     * @param bundleFile The original bundle file. This file will not be modified.
-     * @param newBSN The new Bundle-SymbolicName
-     * @param tempDir The temporary directory to use. This is where the new bundle will be
-     * written. This directory must exist.
-     * @return The new bundle with the altered Symbolic Name.
+     * Creates a new OSGi Bundle from a given bundle, processing its manifest
+     * using the processManifest method.
+     * @return The new bundle file
      * @throws IOException If something goes wrong reading or writing.
      */
-    public static File renameBSN(File bundleFile, String newBSN, File tempDir) throws IOException {
+    public File process() throws IOException {
         JarInputStream jis = null;
         try {
-            jis = new JarInputStream(new FileInputStream(bundleFile));
-            Manifest inputMF = jis.getManifest();
-
-            Attributes inputAttrs = inputMF.getMainAttributes();
-            String bver = inputAttrs.getValue("Bundle-Version");
-            String orgBSN = inputAttrs.getValue("Bundle-SymbolicName");
-            if (bver == null)
-                bver = "0.0.0";
-
-            File newBundle = new File(tempDir, newBSN + "-" + bver + ".jar");
-
-            Manifest newMF = new Manifest(inputMF);
-            Attributes outputAttrs = newMF.getMainAttributes();
-            outputAttrs.putValue("Bundle-SymbolicName", newBSN);
-            outputAttrs.putValue("X-Original-Bundle-SymbolicName", orgBSN);
+            jis = new JarInputStream(new FileInputStream(input));
+            Manifest oldMF = jis.getManifest();
+            Manifest newMF = processManifest(oldMF);
+            File newBundle = new File(outputFolder, getTargetFilename(oldMF));
 
             JarOutputStream jos = null;
             try {
diff --git a/src/test/java/org/apache/sling/commons/osgi/BundleUtilTest.java b/src/test/java/org/apache/sling/commons/osgi/BundleFileProcessorTest.java
similarity index 80%
rename from src/test/java/org/apache/sling/commons/osgi/BundleUtilTest.java
rename to src/test/java/org/apache/sling/commons/osgi/BundleFileProcessorTest.java
index abb77fe..c8d67b4 100644
--- a/src/test/java/org/apache/sling/commons/osgi/BundleUtilTest.java
+++ b/src/test/java/org/apache/sling/commons/osgi/BundleFileProcessorTest.java
@@ -37,7 +37,7 @@ import java.util.jar.Manifest;
 
 import org.junit.Test;
 
-public class BundleUtilTest {
+public class BundleFileProcessorTest {
     
     private static void closeQuietly(Closeable c) {
         try {
@@ -46,6 +46,33 @@ public class BundleUtilTest {
         }
     }
     
+    static class BSNRenamer extends BundleFileProcessor {
+        private final String newBSN;
+        
+        BSNRenamer(File input, File outputFolder, String newBSN) {
+            super(input, outputFolder);
+            this.newBSN = newBSN;
+        }
+        
+        protected Manifest processManifest(Manifest inputMF) {
+            Attributes inputAttrs = inputMF.getMainAttributes();
+            String orgBSN = inputAttrs.getValue("Bundle-SymbolicName");
+            Manifest newMF = new Manifest(inputMF);
+            Attributes outputAttrs = newMF.getMainAttributes();
+            outputAttrs.putValue("Bundle-SymbolicName", newBSN);
+            outputAttrs.putValue("X-Original-Bundle-SymbolicName", orgBSN);
+            return newMF;
+        }
+        
+        protected String getTargetFilename(Manifest inputJarManifest) {
+            String bver = inputJarManifest.getMainAttributes().getValue("Bundle-Version");
+            if (bver == null) {
+                bver = "0.0.0";
+            }
+            return newBSN + "-" + bver + ".jar";
+        }
+    }
+    
     @Test
     public void testBSNRenaming() throws IOException {
         File tempDir = new File(System.getProperty("java.io.tmpdir"));
@@ -53,7 +80,7 @@ public class BundleUtilTest {
         // Just take any bundle from the maven deps as an example...
         File originalFile = getMavenArtifactFile(getMavenRepoRoot(), "com.google.guava", "guava", "15.0");
 
-        File generatedFile = BundleUtil.renameBSN(originalFile, "org.acme.baklava.guava", tempDir);
+        File generatedFile = new BSNRenamer(originalFile, tempDir, "org.acme.baklava.guava").process();
 
         try {
             compareJarContents(originalFile, generatedFile);
@@ -129,7 +156,7 @@ public class BundleUtilTest {
 
     private static byte [] streamToByteArray(InputStream is) throws IOException {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        BundleUtil.pumpStream(is, baos);
+        BundleFileProcessor.pumpStream(is, baos);
         return baos.toByteArray();
     }
 
@@ -138,7 +165,7 @@ public class BundleUtilTest {
     }
 
     private static File getMavenRepoRoot() throws IOException {
-        URL res = BundleUtilTest.class.getClassLoader().getResource(
+        URL res = BundleFileProcessorTest.class.getClassLoader().getResource(
                 Test.class.getName().replace('.', '/') + ".class");
 
         String u = res.toExternalForm();

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 07/19: SLING-5379 - remove java 7 requirement, does not seem worth it just for try-with-resources

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit a64bf63eb3b67744f1b5fc4bfe381186bd987351
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Mon Dec 21 15:25:28 2015 +0000

    SLING-5379 - remove java 7 requirement, does not seem worth it just for try-with-resources
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/commons/osgi@1721192 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                            |  1 -
 .../org/apache/sling/commons/osgi/BundleUtil.java  | 17 ++++++++--
 .../apache/sling/commons/osgi/BundleUtilTest.java  | 37 +++++++++++++++++-----
 3 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/pom.xml b/pom.xml
index 35beb9d..aac2dc4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,7 +41,6 @@
     </scm>
     
     <properties>
-        <sling.java.version>7</sling.java.version>
         <test.jars.folder>${project.build.directory}/testjars</test.jars.folder>
     </properties>
 
diff --git a/src/main/java/org/apache/sling/commons/osgi/BundleUtil.java b/src/main/java/org/apache/sling/commons/osgi/BundleUtil.java
index a1bcd95..5470bac 100644
--- a/src/main/java/org/apache/sling/commons/osgi/BundleUtil.java
+++ b/src/main/java/org/apache/sling/commons/osgi/BundleUtil.java
@@ -48,7 +48,9 @@ public class BundleUtil {
      * @throws IOException If something goes wrong reading or writing.
      */
     public static File renameBSN(File bundleFile, String newBSN, File tempDir) throws IOException {
-        try (JarInputStream jis = new JarInputStream(new FileInputStream(bundleFile))) {
+        JarInputStream jis = null;
+        try {
+            jis = new JarInputStream(new FileInputStream(bundleFile));
             Manifest inputMF = jis.getManifest();
 
             Attributes inputAttrs = inputMF.getMainAttributes();
@@ -64,7 +66,9 @@ public class BundleUtil {
             outputAttrs.putValue("Bundle-SymbolicName", newBSN);
             outputAttrs.putValue("X-Original-Bundle-SymbolicName", orgBSN);
 
-            try (JarOutputStream jos = new JarOutputStream(new FileOutputStream(newBundle), newMF)) {
+            JarOutputStream jos = null;
+            try {
+                jos = new JarOutputStream(new FileOutputStream(newBundle), newMF);
                 JarEntry je = null;
                 while ((je = jis.getNextJarEntry()) != null) {
                     try {
@@ -76,9 +80,16 @@ public class BundleUtil {
                         jis.closeEntry();;
                     }
                 }
+            } finally {
+                if(jos != null) {
+                    jos.close();
+                }
             }
-
             return newBundle;
+        } finally {
+            if(jis != null) {
+                jis.close();
+            }
         }
     }
 
diff --git a/src/test/java/org/apache/sling/commons/osgi/BundleUtilTest.java b/src/test/java/org/apache/sling/commons/osgi/BundleUtilTest.java
index 9e0fa5c..abb77fe 100644
--- a/src/test/java/org/apache/sling/commons/osgi/BundleUtilTest.java
+++ b/src/test/java/org/apache/sling/commons/osgi/BundleUtilTest.java
@@ -18,7 +18,12 @@
  */
 package org.apache.sling.commons.osgi;
 
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -32,11 +37,15 @@ import java.util.jar.Manifest;
 
 import org.junit.Test;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
 public class BundleUtilTest {
+    
+    private static void closeQuietly(Closeable c) {
+        try {
+            c.close();
+        } catch(IOException ignore) {
+        }
+    }
+    
     @Test
     public void testBSNRenaming() throws IOException {
         File tempDir = new File(System.getProperty("java.io.tmpdir"));
@@ -49,8 +58,11 @@ public class BundleUtilTest {
         try {
             compareJarContents(originalFile, generatedFile);
 
-            try (JarFile jfOrg = new JarFile(originalFile);
-                    JarFile jfNew = new JarFile(generatedFile)) {
+            JarFile jfOrg = null;
+            JarFile jfNew = null;
+            try {
+                    jfOrg = new JarFile(originalFile);
+                    jfNew = new JarFile(generatedFile);
                     Manifest mfOrg = jfOrg.getManifest();
                     Manifest mfNew = jfNew.getManifest();
 
@@ -69,6 +81,9 @@ public class BundleUtilTest {
                             assertEquals("Different keys: " + key, orgVal, newVal);
                         }
                     }
+                } finally {
+                    closeQuietly(jfOrg);
+                    closeQuietly(jfNew);
                 }
 
         } finally {
@@ -77,8 +92,11 @@ public class BundleUtilTest {
     }
 
     private static void compareJarContents(File orgJar, File actualJar) throws IOException {
-        try (JarInputStream jis1 = new JarInputStream(new FileInputStream(orgJar));
-            JarInputStream jis2 = new JarInputStream(new FileInputStream(actualJar))) {
+        JarInputStream jis1 = null;
+        JarInputStream jis2 = null;
+        try {
+            jis1 = new JarInputStream(new FileInputStream(orgJar));
+            jis2 = new JarInputStream(new FileInputStream(actualJar));
             JarEntry je1 = null;
             while ((je1 = jis1.getNextJarEntry()) != null) {
                 if (je1.isDirectory())
@@ -103,6 +121,9 @@ public class BundleUtilTest {
                     jis2.closeEntry();
                 }
             }
+        } finally {
+            closeQuietly(jis1);
+            closeQuietly(jis2);
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-commons-osgi] 19/19: [maven-release-plugin] copy for tag org.apache.sling.commons.osgi-2.4.0

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.commons.osgi-2.4.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-osgi.git

commit c59c07d3e8dbdc3137642478e2ae6ed3f6b7c3cd
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 4 15:25:32 2016 +0000

    [maven-release-plugin] copy for tag org.apache.sling.commons.osgi-2.4.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.commons.osgi-2.4.0@1722892 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.