[karaf] branch master updated: Use streams in ScrBundleStateService
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/karaf.git The following commit(s) were added to refs/heads/master by this push: new e7201d4 Use streams in ScrBundleStateService e7201d4 is described below commit e7201d42fc4e9a13b32c9f42dda5ae40a9648be5 Author: Christian Schneider AuthorDate: Thu Apr 4 17:16:40 2019 +0200 Use streams in ScrBundleStateService --- scr/state/pom.xml | 13 ++-- .../java/org/apache/karaf/scr/state/Activator.java | 38 - .../karaf/scr/state/ScrBundleStateService.java | 91 ++ 3 files changed, 45 insertions(+), 97 deletions(-) diff --git a/scr/state/pom.xml b/scr/state/pom.xml index 36fe268..5c18452 100644 --- a/scr/state/pom.xml +++ b/scr/state/pom.xml @@ -60,6 +60,11 @@ org.apache.karaf.bundle.core +org.osgi +org.osgi.service.component.annotations +1.3.0 + + org.apache.felix org.apache.felix.scr @@ -83,16 +88,8 @@ -org.apache.karaf.tooling -karaf-services-maven-plugin - - org.apache.felix maven-bundle-plugin - - - - diff --git a/scr/state/src/main/java/org/apache/karaf/scr/state/Activator.java b/scr/state/src/main/java/org/apache/karaf/scr/state/Activator.java deleted file mode 100644 index a5c9d35..000 --- a/scr/state/src/main/java/org/apache/karaf/scr/state/Activator.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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.karaf.scr.state; - -import org.apache.karaf.bundle.core.BundleStateService; -import org.apache.karaf.util.tracker.BaseActivator; -import org.apache.karaf.util.tracker.annotation.ProvideService; -import org.apache.karaf.util.tracker.annotation.RequireService; -import org.apache.karaf.util.tracker.annotation.Services; -import org.osgi.service.component.runtime.ServiceComponentRuntime; - -@Services(requires = @RequireService(ServiceComponentRuntime.class), - provides = @ProvideService(BundleStateService.class)) -public class Activator extends BaseActivator { - -@Override -protected void doStart() throws Exception { -ServiceComponentRuntime scr = getTrackedService(ServiceComponentRuntime.class); -if (scr != null) { -register(BundleStateService.class, new ScrBundleStateService(scr)); -} -} - -} diff --git a/scr/state/src/main/java/org/apache/karaf/scr/state/ScrBundleStateService.java b/scr/state/src/main/java/org/apache/karaf/scr/state/ScrBundleStateService.java index 03485a4..8d4b1b7 100644 --- a/scr/state/src/main/java/org/apache/karaf/scr/state/ScrBundleStateService.java +++ b/scr/state/src/main/java/org/apache/karaf/scr/state/ScrBundleStateService.java @@ -16,21 +16,25 @@ */ package org.apache.karaf.scr.state; +import static java.lang.String.join; +import static java.util.Arrays.asList; +import static java.util.stream.Collectors.joining; + +import java.util.stream.Stream; + import org.apache.karaf.bundle.core.BundleState; import org.apache.karaf.bundle.core.BundleStateService; import org.osgi.framework.Bundle; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.osgi.service.component.runtime.ServiceComponentRuntime; import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO; -import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO; -import org.osgi.service.component.runtime.dto.UnsatisfiedReferenceDTO; +@Component public class ScrBundleStateService implements BundleStateService { -ServiceComponentRuntime scr; - -public ScrBundleStateService(ServiceComponentRuntime scr) { -this.scr = scr; -} +@Reference +private ServiceComponentRuntime scr; @Override public String getName() { @@ -39
[karaf] branch master updated: Add feature repo for aries jax rs whiteboard
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/karaf.git The following commit(s) were added to refs/heads/master by this push: new 4e1ddff Add feature repo for aries jax rs whiteboard 4e1ddff is described below commit 4e1ddffcbbf41db2a1a7586891e5fb0bb7b6a841 Author: Christian Schneider AuthorDate: Fri Mar 15 09:06:05 2019 +0100 Add feature repo for aries jax rs whiteboard --- .../karaf/instance/resources/etc/org.apache.karaf.features.repos.cfg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.features.repos.cfg b/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.features.repos.cfg index 41b4b3b..4a631c8 100644 --- a/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.features.repos.cfg +++ b/instance/src/main/resources/org/apache/karaf/instance/resources/etc/org.apache.karaf.features.repos.cfg @@ -48,8 +48,10 @@ decanter=mvn:org.apache.karaf.decanter/apache-karaf-decanter/RELEASE/xml/feature eclipsesource-jaxrs=mvn:com.eclipsesource.jaxrs/features/RELEASE/xml/features aries-jpa=mvn:org.apache.aries.jpa/jpa-features/RELEASE/xml/features aries-rsa=mvn:org.apache.aries.rsa/rsa-features/RELEASE/xml/features +aries-jax-rs=mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.features/RELEASE/xml hibernate=mvn:org.hibernate/hibernate-osgi/RELEASE/xml/karaf ignite=mvn:org.apache.ignite/ignite-osgi-karaf/RELEASE/xml/features openjpa=mvn:org.apache.openjpa/openjpa-features/RELEASE/xml/features artemis=mvn:org.apache.activemq/artemis-features/RELEASE/xml/features -brave=mvn:io.zipkin.brave.karaf/brave-features/RELEASE/xml/features \ No newline at end of file +brave=mvn:io.zipkin.brave.karaf/brave-features/RELEASE/xml/features +
svn commit: r1850740 - /karaf/site/production/stories.html
Author: cschneider Date: Tue Jan 8 12:40:11 2019 New Revision: 1850740 URL: http://svn.apache.org/viewvc?rev=1850740=rev Log: [scm-publish] Updating main website contents Modified: karaf/site/production/stories.html Modified: karaf/site/production/stories.html URL: http://svn.apache.org/viewvc/karaf/site/production/stories.html?rev=1850740=1850739=1850740=diff == --- karaf/site/production/stories.html (original) +++ karaf/site/production/stories.html Tue Jan 8 12:40:11 2019 @@ -122,7 +122,7 @@ - OpenHAB + openHAB The openHAB project is a very popular open source home automation solution written in Java and OSGi. It is meant to run on embedded hardware like a Raspberry Pi and acts as a central hub in the local network that integrates all smart home devices in a vendor-neutral way. Apache Karaf was chosen as a basis for openHAB due to its versatile feature management, which nicely supports the modular architecture of openHAB and lets users dynamically add features to their system through UIs at runtime. Additionally, the container management functionalities are unmatched for OSGi-based solutions and hugely helpful in many situations - just think of the powerful console, the remote ssh access or the flexible logging support. While openHAB is by far not using all features of Karaf, it definitely nicely benefits from it. - Kai Kreuzer https://www.openhab.org/; target="_blank">https://www.openhab.org/
[karaf-site] branch trunk updated: Fix openHAB name
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/karaf-site.git The following commit(s) were added to refs/heads/trunk by this push: new 4fcfcec Fix openHAB name 4fcfcec is described below commit 4fcfcec8f9504831a50bac19b95a8fd83e3a14c2 Author: Christian Schneider AuthorDate: Tue Jan 8 13:39:53 2019 +0100 Fix openHAB name --- src/main/webapp/stories.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/stories.html b/src/main/webapp/stories.html index 1c3b779..718187d 100644 --- a/src/main/webapp/stories.html +++ b/src/main/webapp/stories.html @@ -122,7 +122,7 @@ - OpenHAB + openHAB The openHAB project is a very popular open source home automation solution written in Java and OSGi. It is meant to run on embedded hardware like a Raspberry Pi and acts as a central hub in the local network that integrates all smart home devices in a vendor-neutral way. Apache Karaf was chosen as a basis for openHAB due to its versatile feature management, which nicely supports the modular architecture of openHAB and lets users dynamically add features to their system through UIs at runtime. Additionally, the container management functionalities are unmatched for OSGi-based solutions and hugely helpful in many situations - just think of the powerful console, the remote ssh access or the flexible logging support. While openHAB is by f [...] https://www.openhab.org/; target="_blank">https://www.openhab.org/
svn commit: r1850727 - in /karaf/site/production: .DS_Store images/openhab.png stories.html
Author: cschneider Date: Tue Jan 8 10:57:35 2019 New Revision: 1850727 URL: http://svn.apache.org/viewvc?rev=1850727=rev Log: [scm-publish] Updating main website contents Added: karaf/site/production/.DS_Store (with props) karaf/site/production/images/openhab.png (with props) Modified: karaf/site/production/stories.html Added: karaf/site/production/.DS_Store URL: http://svn.apache.org/viewvc/karaf/site/production/.DS_Store?rev=1850727=auto == Binary file - no diff available. Propchange: karaf/site/production/.DS_Store -- svn:mime-type = application/octet-stream Added: karaf/site/production/images/openhab.png URL: http://svn.apache.org/viewvc/karaf/site/production/images/openhab.png?rev=1850727=auto == Binary file - no diff available. Propchange: karaf/site/production/images/openhab.png -- svn:mime-type = application/octet-stream Modified: karaf/site/production/stories.html URL: http://svn.apache.org/viewvc/karaf/site/production/stories.html?rev=1850727=1850726=1850727=diff == --- karaf/site/production/stories.html (original) +++ karaf/site/production/stories.html Tue Jan 8 10:57:35 2019 @@ -122,8 +122,9 @@ - OpenHAB - A vendor and technology agnostic open source automation software for your home. + OpenHAB + The openHAB project is a very popular open source home automation solution written in Java and OSGi. It is meant to run on embedded hardware like a Raspberry Pi and acts as a central hub in the local network that integrates all smart home devices in a vendor-neutral way. + Apache Karaf was chosen as a basis for openHAB due to its versatile feature management, which nicely supports the modular architecture of openHAB and lets users dynamically add features to their system through UIs at runtime. Additionally, the container management functionalities are unmatched for OSGi-based solutions and hugely helpful in many situations - just think of the powerful console, the remote ssh access or the flexible logging support. While openHAB is by far not using all features of Karaf, it definitely nicely benefits from it. - Kai Kreuzer https://www.openhab.org/; target="_blank">https://www.openhab.org/
[karaf-site] branch trunk updated: Improved openhab description with permission from Kai Kreuzer
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/karaf-site.git The following commit(s) were added to refs/heads/trunk by this push: new a8e5275 Improved openhab description with permission from Kai Kreuzer a8e5275 is described below commit a8e5275de4dc786269e13e8b19375264e0e298fb Author: Christian Schneider AuthorDate: Tue Jan 8 11:56:41 2019 +0100 Improved openhab description with permission from Kai Kreuzer --- .gitignore | 1 + src/main/webapp/images/openhab.png | Bin 0 -> 13810 bytes src/main/webapp/stories.html | 5 +++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index dea9182..2e367f3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ target .project .idea *.i?? +.DS_Store diff --git a/src/main/webapp/images/openhab.png b/src/main/webapp/images/openhab.png new file mode 100644 index 000..034d76f Binary files /dev/null and b/src/main/webapp/images/openhab.png differ diff --git a/src/main/webapp/stories.html b/src/main/webapp/stories.html index 6e5962d..1c3b779 100644 --- a/src/main/webapp/stories.html +++ b/src/main/webapp/stories.html @@ -122,8 +122,9 @@ - OpenHAB - A vendor and technology agnostic open source automation software for your home. + OpenHAB + The openHAB project is a very popular open source home automation solution written in Java and OSGi. It is meant to run on embedded hardware like a Raspberry Pi and acts as a central hub in the local network that integrates all smart home devices in a vendor-neutral way. + Apache Karaf was chosen as a basis for openHAB due to its versatile feature management, which nicely supports the modular architecture of openHAB and lets users dynamically add features to their system through UIs at runtime. Additionally, the container management functionalities are unmatched for OSGi-based solutions and hugely helpful in many situations - just think of the powerful console, the remote ssh access or the flexible logging support. While openHAB is by f [...] https://www.openhab.org/; target="_blank">https://www.openhab.org/
svn commit: r1848949 - /karaf/site/production/stories.html
Author: cschneider Date: Fri Dec 14 15:09:09 2018 New Revision: 1848949 URL: http://svn.apache.org/viewvc?rev=1848949=rev Log: [scm-publish] Updating main website contents Modified: karaf/site/production/stories.html Modified: karaf/site/production/stories.html URL: http://svn.apache.org/viewvc/karaf/site/production/stories.html?rev=1848949=1848948=1848949=diff == --- karaf/site/production/stories.html (original) +++ karaf/site/production/stories.html Fri Dec 14 15:09:09 2018 @@ -76,7 +76,7 @@ Powered by Apache Karaf - Custom distribution powered by Apache Karaf. + Custom distribution powered by Apache Karaf. @@ -94,7 +94,7 @@ ONOS is the only SDN controller platform that supports the transition from legacy brown field networks to SDN green field networks. This enables exciting new capabilities, and disruptive deployment and operational cost points for network operators. https://onosproject.org/; target="_blank">https://onosproject.org/ - + @@ -136,15 +136,7 @@ Run on Apache Karaf - Software using Apache Karaf as runtime. - - - - - - Liferay - Build portals, intranets, websites and connected experiences on the most flexible platform around. - https://www.liferay.com/; target="_blank">https://www.liferay.com/ + Software using Apache Karaf as runtime. @@ -163,7 +155,7 @@ https://www.redhat.com/en/technologies/jboss-middleware/fuse/; target="_blank">https://www.redhat.com/en/technologies/jboss-middleware/fuse/ - + @@ -174,7 +166,7 @@ - + @@ -184,12 +176,12 @@ Read Documentation Back to top - 2018 https://www.apache.org;>Apache Software Foundation - -Privacy Policy - -https://www.apache.org/events/current-event.html; title="Apache Events">Apache Events - -https://www.apache.org/licenses/; title="Licenses">Licenses - -https://www.apache.org/security/; title="Security">Security - -https://www.apache.org/foundation/sponsorship.html; title="Sponsorship">Sponsorship - + 2018 https://www.apache.org;>Apache Software Foundation - +Privacy Policy - +https://www.apache.org/events/current-event.html; title="Apache Events">Apache Events - +https://www.apache.org/licenses/; title="Licenses">Licenses - +https://www.apache.org/security/; title="Security">Security - +https://www.apache.org/foundation/sponsorship.html; title="Sponsorship">Sponsorship - https://www.apache.org/foundation/thanks.html; title="Thanks">Thanks Apache Karaf, Karaf, Apache, the Apache feather logo, and the Apache Karaf project logo are trademarks of The Apache Software Foundation.
[karaf-site] branch trunk updated: Removed story about liferay by request of Ray as liferay does not run on apache karaf
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/karaf-site.git The following commit(s) were added to refs/heads/trunk by this push: new a6f09bc Removed story about liferay by request of Ray as liferay does not run on apache karaf a6f09bc is described below commit a6f09bcd15183a5d3f79d4d1c7eaa9fe32409a2b Author: Christian Schneider AuthorDate: Fri Dec 14 16:07:32 2018 +0100 Removed story about liferay by request of Ray as liferay does not run on apache karaf --- src/main/webapp/stories.html | 32 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/src/main/webapp/stories.html b/src/main/webapp/stories.html index c35ea9a..2c1ab92 100644 --- a/src/main/webapp/stories.html +++ b/src/main/webapp/stories.html @@ -76,7 +76,7 @@ Powered by Apache Karaf - Custom distribution powered by Apache Karaf. + Custom distribution powered by Apache Karaf. @@ -94,7 +94,7 @@ ONOS is the only SDN controller platform that supports the transition from legacy brown field networks to SDN green field networks. This enables exciting new capabilities, and disruptive deployment and operational cost points for network operators. https://onosproject.org/; target="_blank">https://onosproject.org/ - + @@ -136,15 +136,7 @@ Run on Apache Karaf - Software using Apache Karaf as runtime. - - - - - - Liferay - Build portals, intranets, websites and connected experiences on the most flexible platform around. - https://www.liferay.com/; target="_blank">https://www.liferay.com/ + Software using Apache Karaf as runtime. @@ -163,7 +155,7 @@ https://www.redhat.com/en/technologies/jboss-middleware/fuse/; target="_blank">https://www.redhat.com/en/technologies/jboss-middleware/fuse/ - + @@ -174,7 +166,7 @@ - + @@ -184,12 +176,12 @@ Read Documentation Back to top - 2018 https://www.apache.org;>Apache Software Foundation - -Privacy Policy - -https://www.apache.org/events/current-event.html; title="Apache Events">Apache Events - -https://www.apache.org/licenses/; title="Licenses">Licenses - -https://www.apache.org/security/; title="Security">Security - -https://www.apache.org/foundation/sponsorship.html; title="Sponsorship">Sponsorship - + 2018 https://www.apache.org;>Apache Software Foundation - +Privacy Policy - +https://www.apache.org/events/current-event.html; title="Apache Events">Apache Events - +https://www.apache.org/licenses/; title="Licenses">Licenses - +https://www.apache.org/security/; title="Security">Security - +https://www.apache.org/foundation/sponsorship.html; title="Sponsorship">Sponsorship - https://www.apache.org/foundation/thanks.html; title="Thanks">Thanks Apache Karaf, Karaf, Apache, the Apache feather logo, and the Apache Karaf project logo are trademarks of The Apache Software Foundation. @@ -202,4 +194,4 @@ - \ No newline at end of file +
[karaf] 01/01: Merge pull request #671 from apache/revert-670-master
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/karaf.git commit 1b877aa1a5811974f635b5891d6163bc58286f26 Merge: 0140a42 3f36202 Author: Christian Schneider AuthorDate: Mon Dec 3 15:33:23 2018 +0100 Merge pull request #671 from apache/revert-670-master Revert "[ARIES-1793] Upgrade to blueprint-core 1.10.0" pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[karaf] branch master updated (0140a42 -> 1b877aa)
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/karaf.git. from 0140a42 Merge pull request #670 from Smasherr/master add 3f36202 Revert "[ARIES-1793] Upgrade to blueprint-core 1.10.0" new 1b877aa Merge pull request #671 from apache/revert-670-master The 1 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. Summary of changes: pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[karaf] 01/01: Revert "[ARIES-1793] Upgrade to blueprint-core 1.10.0"
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch revert-670-master in repository https://gitbox.apache.org/repos/asf/karaf.git commit 3f362026b6f038a927ffc13d2cb3ddc1dde4 Author: Christian Schneider AuthorDate: Mon Dec 3 15:32:13 2018 +0100 Revert "[ARIES-1793] Upgrade to blueprint-core 1.10.0" --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 36fcad3..81f8d40 100644 --- a/pom.xml +++ b/pom.xml @@ -218,7 +218,7 @@ 1.0.0 1.0.0 1.0.1 -1.10.0 +1.9.0 1.0.0 1.2.0 1.0.1
[karaf] branch revert-670-master created (now 3f36202)
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a change to branch revert-670-master in repository https://gitbox.apache.org/repos/asf/karaf.git. at 3f36202 Revert "[ARIES-1793] Upgrade to blueprint-core 1.10.0" This branch includes the following new commits: new 3f36202 Revert "[ARIES-1793] Upgrade to blueprint-core 1.10.0" The 1 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.
[karaf] 01/01: Merge pull request #670 from Smasherr/master
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/karaf.git commit 0140a421850ca4e5af6fd16e7a33911db6be3acc Merge: 55418db 62e832c Author: Christian Schneider AuthorDate: Mon Dec 3 15:12:14 2018 +0100 Merge pull request #670 from Smasherr/master [ARIES-1793] Upgrade to blueprint-core 1.10.0 pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[karaf] branch master updated (55418db -> 0140a42)
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/karaf.git. from 55418db [KARAF-6024] Do not use blacklisted, dependent feature repositories add 62e832c [ARIES-1793] Upgrade to blueprint-core 1.10.0 new 0140a42 Merge pull request #670 from Smasherr/master The 1 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. Summary of changes: pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
[karaf-site] branch trunk updated: New location for tutorials
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/karaf-site.git The following commit(s) were added to refs/heads/trunk by this push: new 0ce0274 New location for tutorials 0ce0274 is described below commit 0ce02749ddf78c65f2f00013d28c25569df045ce Author: Christian Schneider AuthorDate: Wed Jul 4 11:09:16 2018 +0200 New location for tutorials --- src/main/webapp/documentation.html | 22 ++ 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/main/webapp/documentation.html b/src/main/webapp/documentation.html index 3f7ada7..4d020e1 100644 --- a/src/main/webapp/documentation.html +++ b/src/main/webapp/documentation.html @@ -456,25 +456,7 @@ Tutorials - http://www.liquid-reality.de/x/DIBZ;>Karaf Tutorial Part 1 - Installation and First application - - http://www.liquid-reality.de/x/G4Be;>Karaf Tutorial Part 2 - Using the Configuration Admin Service - - http://www.liquid-reality.de/x/KoBe;>Karaf Tutorial Part 3 - Improving configuration editing using the OSGI Metatype Service - - http://www.liquid-reality.de/x/EoBk;>Karaf Tutorial Part 4 - CXF Services in OSGi - - http://www.liquid-reality.de/x/G4Bk;>Karaf Tutorial Part 5 - Running Apache Camel integrations in OSGi - - http://www.liquid-reality.de/x/LYBk;>Karaf Tutorial Part 6 - Database Access - - http://www.liquid-reality.de/x/JgBz;>Karaf Tutorial Part 7 - Camel JPA and JTA transactions - - http://www.liquid-reality.de/x/D4C;>Karaf Tutorial Part 8 - Distributed OSGi - - http://www.liquid-reality.de/x/C4DK;>Karaf Tutorial Part 9 - Annotation based blueprint and JPA - - http://www.liquid-reality.de/x/BIDe;>Karaf Tutorial Part 10 - Declarative Services + https://cschneider.github.io/Karaf-Tutorial/;>Karaf Tutorials (Declarative Services, Blueprint, Config Admin, Database Access, REST, Camel, ...) http://davidvaleri.wordpress.com/2010/08/13/combining-karaf-features-pax-url-and-maven-to-deploy-a-plain-jar-as-an-osgi-bundle/;>Combining Karaf Features, PAX URL, and Maven to deploy a plain JAR as an OSGi bundle @@ -538,4 +520,4 @@ - \ No newline at end of file +
[karaf] branch master updated: [KARAF-5578] Add repo url for sling
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/karaf.git The following commit(s) were added to refs/heads/master by this push: new 2e650ad [KARAF-5578] Add repo url for sling 2e650ad is described below commit 2e650adab6d67771947a9af5a385104c84368c2e Author: Christian Schneider <cschn...@adobe.com> AuthorDate: Wed Jan 24 15:14:16 2018 +0100 [KARAF-5578] Add repo url for sling --- .../features/standard/src/main/feature/feature.xml | 17 + 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/assemblies/features/standard/src/main/feature/feature.xml b/assemblies/features/standard/src/main/feature/feature.xml index a0f6313..6242f11 100644 --- a/assemblies/features/standard/src/main/feature/feature.xml +++ b/assemblies/features/standard/src/main/feature/feature.xml @@ -120,6 +120,7 @@ openjpa=mvn:org.apache.openjpa/openjpa-features/RELEASE/xml/features artemis=mvn:org.apache.activemq/artemis-features/RELEASE/xml/features brave=mvn:io.zipkin.brave.karaf/brave-features/RELEASE/xml/features + sling=mvn:org.apache.sling/org.apache.sling.karaf-features/RELEASE/xml/features shell @@ -214,7 +215,7 @@ # # This configuration file defines the ACLs for scope bundles -# +# features=org.apache.karaf.features.command jaas=org.apache.karaf.jaas.command admin=org.apache.karaf.admin.command @@ -838,7 +839,7 @@ pax-war mvn:org.apache.karaf.web/org.apache.karaf.web.core/${project.version} - + mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.activation-api-1.1/${servicemix.specs.version} mvn:${servlet.spec.groupId}/${servlet.spec.artifactId}/${servlet.spec.version} @@ -1001,7 +1002,7 @@ # # Generic JMX ACL # -# This file defines the roles required for MBean operations for MBeans that +# This file defines the roles required for MBean operations for MBeans that # do not have this defined explicitly. # # The definition of ACLs for JMX operations works as follows: @@ -1018,7 +1019,7 @@ # this: # test : admin # getVal : manager, viewer -# +# # The system looks for required roles using the following process: # The most specific configuration file/pid is tried first. E.g. in the # above example the jmx.acl.foo.bar.Test.cfg is looked at first. In this @@ -1038,9 +1039,9 @@ # associated with the longest match are used. So if you have te* and * and # the method invoked is 'test', then the roles defined with te* are used, # not the ones defined with *. -# If no matching definition is found in the current configuration file, a -# more general configuration file is looked for. So jmx.acl.foo.bar.cfg is -# tried next, this matches the domain of the MBean. If there is no match +# If no matching definition is found in the current configuration file, a +# more general configuration file is looked for. So jmx.acl.foo.bar.cfg is +# tried next, this matches the domain of the MBean. If there is no match # found in the domain the most generic configuration file is consulted # (jmx.acl.cfg). # If a matching definition is found, this is used and the process will not @@ -1378,7 +1379,7 @@ mvn:org.apache.felix/org.apache.felix.webconsole.plugins.event/${felix.eventadmin.webconsole.plugin.version} - + jaas mvn:commons-codec/commons-codec/${commons-codec.version} -- To stop receiving notification emails like this one, please contact cschnei...@apache.org.
[karaf-reactive-components] branch master updated: Improve logging
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/karaf-reactive-components.git The following commit(s) were added to refs/heads/master by this push: new 8e55686 Improve logging 8e55686 is described below commit 8e55686852e3fefe61fbbc4b2db214ae09330a36 Author: Christian Schneider <cschn...@adobe.com> AuthorDate: Wed Oct 25 09:12:51 2017 +0200 Improve logging --- .gitignore | 3 +-- rcomp-app/etc/org.ops4j.pax.logging.cfg | 8 rcomp-app/pom.xml | 21 ++--- rcomp-app/rcomp-example.bndrun | 14 -- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index dbe1aef..01a5e53 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,7 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* - +.DS_store target .settings .classpath @@ -28,4 +28,3 @@ target paho* generated cnf - diff --git a/rcomp-app/etc/org.ops4j.pax.logging.cfg b/rcomp-app/etc/org.ops4j.pax.logging.cfg new file mode 100644 index 000..066f499 --- /dev/null +++ b/rcomp-app/etc/org.ops4j.pax.logging.cfg @@ -0,0 +1,8 @@ +log4j.rootLogger=INFO, file + + +log4j.appender.file=org.apache.log4j.RollingFileAppender +log4j.appender.file.File=./target/logging.log + +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d{-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n diff --git a/rcomp-app/pom.xml b/rcomp-app/pom.xml index 0dfc568..3acedc0 100644 --- a/rcomp-app/pom.xml +++ b/rcomp-app/pom.xml @@ -45,7 +45,7 @@ ${rcomp.version} - + org.apache.felix org.apache.felix.framework @@ -136,7 +136,7 @@ org.ops4j.pax.logging pax-logging-service -1.8.5 +1.10.1 @@ -204,23 +204,6 @@ commons-collections 3.2.2 - diff --git a/rcomp-app/rcomp-example.bndrun b/rcomp-app/rcomp-example.bndrun index 6f0f767..2446c61 100644 --- a/rcomp-app/rcomp-example.bndrun +++ b/rcomp-app/rcomp-example.bndrun @@ -31,5 +31,15 @@ felix.fileinstall.noInitialDelay=true,\ felix.fileinstall.enableConfigSave=false -runrequires: \ - osgi.identity;filter:='(osgi.identity=rcomp-examples)',\ - osgi.identity;filter:='(osgi.identity=rcomp-feature-shell)' + osgi.identity;filter:='(osgi.identity=rcomp-feature-shell)',\ + osgi.identity;filter:='(osgi.identity=org.ops4j.pax.logging.pax-logging-service)' +-runbundles: \ + org.apache.felix.bundlerepository;version='[2.0.10,2.0.11)',\ + org.apache.felix.configadmin;version='[1.8.8,1.8.9)',\ + org.apache.felix.gogo.command;version='[1.0.0,1.0.1)',\ + org.apache.felix.gogo.jline;version='[1.0.6,1.0.7)',\ + org.apache.felix.gogo.runtime;version='[1.0.0,1.0.1)',\ + org.jline;version='[3.3.1,3.3.2)',\ + rcomp-feature-shell;version='[1.0.0,1.0.1)',\ + org.ops4j.pax.logging.pax-logging-api;version='[1.10.1,1.10.2)',\ + org.ops4j.pax.logging.pax-logging-service;version='[1.10.1,1.10.2)' \ No newline at end of file -- To stop receiving notification emails like this one, please contact ['"commits@karaf.apache.org" <commits@karaf.apache.org>'].
[karaf-reactive-components] branch master updated: Add Closeable support
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/karaf-reactive-components.git The following commit(s) were added to refs/heads/master by this push: new 1709e0b Add Closeable support 1709e0b is described below commit 1709e0b082ce1282ba10e312a577e216a305b92a Author: Christian Schneider <cschn...@adobe.com> AuthorDate: Mon Oct 23 15:51:33 2017 +0200 Add Closeable support --- .../{RComponent.java => CloseableSubscriber.java} | 8 +-- .../rcomp/api/CloseableSubscriberAdapter.java | 58 ++ .../java/org/apache/karaf/rcomp/api/ProvComp.java | 16 ++ .../org/apache/karaf/rcomp/api/RComponent.java | 3 +- .../apache/karaf/rcomp/camel/CamelComponent.java | 7 +-- .../rcomp/eventadmin/EventAdminComponent.java | 4 +- .../rcomp/eventadmin/EventAdminDestination.java| 13 +++-- .../{mqtt => eventadmin}/EventAdminExample.java| 2 +- .../karaf/rcomp/examples/mqtt/MqttEmitter.java | 2 - .../karaf/rcomp/examples/mqtt/MqttReceiver.java| 1 - .../apache/karaf/rcomp/kafka/KafkaComponent.java | 4 +- .../apache/karaf/rcomp/kafka/KafkaDestination.java | 6 +-- .../org/apache/karaf/rcomp/mail/MailComponent.java | 4 +- .../apache/karaf/rcomp/mail/MailDestination.java | 9 +++- .../org/apache/karaf/rcomp/mqtt/MqttComponent.java | 21 ++-- .../apache/karaf/rcomp/mqtt/MqttDestination.java | 6 +-- 16 files changed, 98 insertions(+), 66 deletions(-) diff --git a/rcomp-api/src/main/java/org/apache/karaf/rcomp/api/RComponent.java b/rcomp-api/src/main/java/org/apache/karaf/rcomp/api/CloseableSubscriber.java similarity index 82% copy from rcomp-api/src/main/java/org/apache/karaf/rcomp/api/RComponent.java copy to rcomp-api/src/main/java/org/apache/karaf/rcomp/api/CloseableSubscriber.java index 323ecff..3506888 100644 --- a/rcomp-api/src/main/java/org/apache/karaf/rcomp/api/RComponent.java +++ b/rcomp-api/src/main/java/org/apache/karaf/rcomp/api/CloseableSubscriber.java @@ -16,10 +16,10 @@ */ package org.apache.karaf.rcomp.api; -import org.reactivestreams.Publisher; +import java.io.Closeable; + import org.reactivestreams.Subscriber; -public interface RComponent { - Publisher from(String destination, Class type); - Subscriber to(String destination, Class type); +public interface CloseableSubscriber extends Subscriber, Closeable { + } diff --git a/rcomp-mail/src/main/java/org/apache/karaf/rcomp/mail/MailDestination.java b/rcomp-api/src/main/java/org/apache/karaf/rcomp/api/CloseableSubscriberAdapter.java similarity index 51% copy from rcomp-mail/src/main/java/org/apache/karaf/rcomp/mail/MailDestination.java copy to rcomp-api/src/main/java/org/apache/karaf/rcomp/api/CloseableSubscriberAdapter.java index ac5d00c..d724f16 100644 --- a/rcomp-mail/src/main/java/org/apache/karaf/rcomp/mail/MailDestination.java +++ b/rcomp-api/src/main/java/org/apache/karaf/rcomp/api/CloseableSubscriberAdapter.java @@ -14,57 +14,53 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.karaf.rcomp.mail; +package org.apache.karaf.rcomp.api; -import javax.mail.Address; -import javax.mail.Message; -import javax.mail.Transport; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeMessage; +import java.io.Closeable; +import java.io.IOException; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; -public class MailDestination implements Subscriber { - -private String destination; -private Subscription subscription; +/** + * Adapts an arbitrary subscriber implementing Closeable to CloseableSubscriber + */ +public class CloseableSubscriberAdapter implements CloseableSubscriber { + +private Subscriber subscriber; -public MailDestination(String destination, Class type) { -this.destination = destination; -if (! type.equals(MimeMessage.class)) { -throw new IllegalArgumentException("Curently only MimeMessage is supported"); -} +public CloseableSubscriberAdapter(Subscriber subscriber) { +//if (!(subscriber instanceof Closeable)) { +//throw new IllegalArgumentException("Subscriber must implement Closeable"); +//} +this.subscriber = subscriber; } @Override public void onSubscribe(Subscription s) { -this.subscription = s; -s.request(1); +subscriber.onSubscribe(s); } @Override -public void onNext(T message) { -try { -Address[] addresses = new Address[]{new InternetAddress(destination)}; -Transport.send(convertTo(message), addresses); -} catch (Exception e) { -throw new RuntimeException(e); -} finally { -subscription.request(1); -} -} -
[karaf-reactive-components] branch master created (now 90e35c2)
This is an automated email from the ASF dual-hosted git repository. cschneider pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/karaf-reactive-components.git. at 90e35c2 Update to current versions This branch includes the following new commits: new 9faab78 Initial commit new 3555848 experiments with reactor new f20b873 Some fixes and added documentation new 06e701f Improved doc new 69f8180 Add EventAdmin component and refine component interface new bb53501 Use destination instead of topic new e11d8d2 Also add topic new 817f8ae Add mail component new b956459 Add missing dependency new b2865e1 Updated readme new 6d941f7 Updated readme new 4d56f41 Remove converter new c3625ea Cleanup new 042cdd2 Switch API to use Subscriber new b2c266e Split into bundles and add test with cxf jax-rs new 984b521 Allow to specify a type to deliver / consume in the API new ccf50b6 Use the more common T letter new 27e2d36 Add bndtools launcher new 564dca1 Fixes new 9b97fa2 Adapt generics new 6d71d6a Make mqtt component cope with restarts. Improve examples and starter new f97a3d7 Make mqtt component cope with restarts. Improve examples and starter new 25d3763 Update osgi deps new 0534437 Rename MComponent to RComponent new 9770377 Initial version of kafka component new c1e6ceb Fix kafka component new b6a3c01 Fix new 93cc188 Add kafka appender example new 4217326 Add doc for decanter example new d723041 Create rcomp features and update README new 88564bd Improve docs new cd627be Improve docs new 0538b72 Improve docs new 4407606 Add pax exam test support for bndrun new 25bdc28 Add docs. Small refactoring new e71b8c3 Remove unnecessary output new fda6ab7 PAx exam test using bndrun new 4e16a04 Add apache parent new b60c23e Use Apache license headers new a06e1cd Change package names to karaf conventions new 1f11156 Add embedded mqtt server for test new 89b621f Ignore kafka tests until we have an embedded kafka test server new cfe25b7 Change groupid to karaf new 0d353cf Adapt features new 68b5399 Add annotation based requires and provides. Create feature bundle for shell deps new 66908e4 Removing repeatable as it is not yet supported new 981f9a4 Add camel bridge as reactive component new f5c2ac7 Update to new dependency versions new ad88bfa reformat new 5cb6e12 Update to current versions new 90e35c2 Update to current versions The 51 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@karaf.apache.org" <commits@karaf.apache.org>'].
[2/3] karaf git commit: Cache unmarshalled Features
Cache unmarshalled Features If we are processing a deep feature tree with multiple dependencies referencing same features (like in the case of OpenDaylight), we end up unmarshalling the same features over and over again. Rather than doing that, instantiate a cache, which will hold a weak reference to features already encountered. Before: real1m46.523s user1m59.258s sys 0m17.048s After: real0m42.642s user1m0.892s sys 0m10.148s Signed-off-by: Robert VargaProject: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/82e2439f Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/82e2439f Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/82e2439f Branch: refs/heads/karaf-4.1.x Commit: 82e2439f2c97f7d510998529dad6fba91e727e07 Parents: e2415b8 Author: Robert Varga Authored: Sun Aug 13 19:38:26 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 23 17:19:52 2017 +0200 -- .../features/GenerateDescriptorMojo.java| 30 1 file changed, 24 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/82e2439f/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java -- diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java index 222c51f..6eb5ef1 100644 --- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java +++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java @@ -39,6 +39,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.WeakHashMap; import java.util.jar.JarInputStream; import java.util.jar.Manifest; @@ -459,7 +460,8 @@ public class GenerateDescriptorMojo extends MojoSupport { // the feature's Maven artifact to allow for multi-feature repositories) // TODO Initialise the repositories from the existing feature file if any Map otherFeatures = new HashMap<>(); -Map featureRepositories = new HashMap (); +Map featureRepositories = new HashMap<>(); +FeaturesCache cache = new FeaturesCache(); for (final LocalDependency entry : localDependencies) { Object artifact = entry.getArtifact(); @@ -467,9 +469,11 @@ public class GenerateDescriptorMojo extends MojoSupport { continue; } -processFeatureArtifact(features, feature, otherFeatures, featureRepositories, artifact, entry.getParent(), -true); +processFeatureArtifact(features, feature, otherFeatures, featureRepositories, cache, artifact, +entry.getParent(), true); } +// Do not retain cache beyond this point +cache = null; // Second pass to look for bundles if (addBundlesToPrimaryFeature) { @@ -561,7 +565,7 @@ public class GenerateDescriptorMojo extends MojoSupport { } private void processFeatureArtifact(Features features, Feature feature, Map otherFeatures, -Map featureRepositories, +Map featureRepositories, FeaturesCache cache, Object artifact, Object parent, boolean add) throws MojoExecutionException, XMLStreamException, JAXBException, IOException { if (this.dependencyHelper.isArtifactAFeature(artifact) && FEATURE_CLASSIFIER.equals( @@ -571,9 +575,9 @@ public class GenerateDescriptorMojo extends MojoSupport { throw new MojoExecutionException( "Cannot locate file for feature: " + artifact + " at " + featuresFile); } -Features includedFeatures = readFeaturesFile(featuresFile); +Features includedFeatures = cache.get(featuresFile); for (String repository : includedFeatures.getRepository()) { -processFeatureArtifact(features, feature, otherFeatures, featureRepositories, +processFeatureArtifact(features, feature, otherFeatures, featureRepositories, cache, new DefaultArtifact(MavenUtil.mvnToAether(repository)), parent, false); } for (Feature includedFeature : includedFeatures.getFeature()) { @@ -940,4
[3/3] karaf git commit: Use java.util.file.Files.newInputStream()
Use java.util.file.Files.newInputStream() Instead of wiring to FileInputStream, which is hard to GC due to the presence of finalize(), use Files.newInputStream. Brings down feature generation time in OpenDaylight, before: real2m5.828s user2m14.886s sys 0m20.849s after: real1m46.523s user1m59.258s sys 0m17.048s Signed-off-by: Robert VargaProject: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/e2415b8a Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/e2415b8a Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/e2415b8a Branch: refs/heads/karaf-4.1.x Commit: e2415b8af82db7b223054e7814eaefb733a64aeb Parents: 74bbcc4 Author: Robert Varga Authored: Sun Aug 13 18:56:29 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 23 17:19:52 2017 +0200 -- .../features/GenerateDescriptorMojo.java| 36 +--- .../apache/karaf/tooling/utils/MojoSupport.java | 12 +++ 2 files changed, 22 insertions(+), 26 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/e2415b8a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java -- diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java index c6dc9fc..222c51f 100644 --- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java +++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java @@ -23,7 +23,6 @@ import static org.apache.karaf.deployer.kar.KarArtifactInstaller.FEATURE_CLASSIF import java.io.BufferedInputStream; import java.io.BufferedWriter; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -31,6 +30,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.StringWriter; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -605,7 +605,7 @@ public class GenerateDescriptorMojo extends MojoSupport { } } -private Dependency findMatchingDependency(List dependencies, Dependency reference) { +private static Dependency findMatchingDependency(List dependencies, Dependency reference) { String referenceName = reference.getName(); for (Dependency dependency : dependencies) { if (referenceName.equals(dependency.getName())) { @@ -615,7 +615,7 @@ public class GenerateDescriptorMojo extends MojoSupport { return null; } -private void mergeDependencies(Dependency target, Dependency source) { +private static void mergeDependencies(Dependency target, Dependency source) { if (target.getVersion() == null || Feature.DEFAULT_VERSION.equals(target.getVersion())) { target.setVersion(source.getVersion()); } @@ -646,30 +646,28 @@ public class GenerateDescriptorMojo extends MojoSupport { */ private Manifest getManifest(File file) throws IOException { -InputStream is; +final InputStream is; try { -is = new BufferedInputStream(new FileInputStream(file)); +is = Files.newInputStream(file.toPath()); } catch (Exception e) { getLog().warn("Error while opening artifact", e); return null; } -try { -is.mark(256 * 1024); -JarInputStream jar = new JarInputStream(is); -Manifest m = jar.getManifest(); -if (m == null) { -getLog().warn("Manifest not present in the first entry of the zip - " + file.getName()); +try (BufferedInputStream bis = new BufferedInputStream(is)) { +bis.mark(256 * 1024); + +try (JarInputStream jar = new JarInputStream(bis)) { +Manifest m = jar.getManifest(); +if (m == null) { +getLog().warn("Manifest not present in the first entry of the zip - " + file.getName()); +} +return m; } -jar.close(); -return m; -} finally { -// just in case when we did not open bundle -is.close(); } } -private Features readFeaturesFile(File featuresFile) throws XMLStreamException, JAXBException, IOException { +private static Features readFeaturesFile(File featuresFile) throws
[1/3] karaf git commit: Reuse extracted manifest
Repository: karaf Updated Branches: refs/heads/karaf-4.1.x 74bbcc47c -> ecf0bde71 Reuse extracted manifest Obtaining the manifest can cost us some IO. Treat it as an invariant when determining whether a file is a bundle. Signed-off-by: Robert VargaProject: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/ecf0bde7 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/ecf0bde7 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/ecf0bde7 Branch: refs/heads/karaf-4.1.x Commit: ecf0bde71d92fa4203230ee6137fa221f9d58677 Parents: 82e2439 Author: Robert Varga Authored: Sun Aug 13 20:26:17 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 23 17:19:52 2017 +0200 -- .../apache/karaf/tooling/features/GenerateDescriptorMojo.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/ecf0bde7/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java -- diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java index 6eb5ef1..f975dbf 100644 --- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java +++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java @@ -487,8 +487,6 @@ public class GenerateDescriptorMojo extends MojoSupport { if (!this.dependencyHelper.isArtifactAFeature(artifact)) { String bundleName = this.dependencyHelper.artifactToMvn(artifact, getVersionOrRange(entry.getParent(), artifact)); -File bundleFile = this.dependencyHelper.resolve(artifact, getLog()); -Manifest manifest = getManifest(bundleFile); for (ConfigFile cf : feature.getConfigfile()) { if (bundleName.equals(cf.getLocation().replace('\n', ' ').trim())) { @@ -497,7 +495,9 @@ public class GenerateDescriptorMojo extends MojoSupport { } } -if (manifest == null || !ManifestUtils.isBundle(getManifest(bundleFile))) { +File bundleFile = this.dependencyHelper.resolve(artifact, getLog()); +Manifest manifest = getManifest(bundleFile); +if (manifest == null || !ManifestUtils.isBundle(manifest)) { bundleName = "wrap:" + bundleName; needWrap = true; }
[1/3] karaf git commit: Use java.util.file.Files.newInputStream()
Repository: karaf Updated Branches: refs/heads/master 49e484437 -> edcda0b0e Use java.util.file.Files.newInputStream() Instead of wiring to FileInputStream, which is hard to GC due to the presence of finalize(), use Files.newInputStream. Brings down feature generation time in OpenDaylight, before: real2m5.828s user2m14.886s sys 0m20.849s after: real1m46.523s user1m59.258s sys 0m17.048s Signed-off-by: Robert VargaProject: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/ed797960 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/ed797960 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/ed797960 Branch: refs/heads/master Commit: ed797960d2a43eee8c04a9572478320af2420cfb Parents: 49e4844 Author: Robert Varga Authored: Sun Aug 13 18:56:29 2017 +0200 Committer: Robert Varga Committed: Wed Aug 23 14:22:20 2017 +0200 -- .../features/GenerateDescriptorMojo.java| 36 +--- .../apache/karaf/tooling/utils/MojoSupport.java | 12 +++ 2 files changed, 22 insertions(+), 26 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/ed797960/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java -- diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java index 1b84004..a6141ba 100644 --- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java +++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java @@ -23,7 +23,6 @@ import static org.apache.karaf.deployer.kar.KarArtifactInstaller.FEATURE_CLASSIF import java.io.BufferedInputStream; import java.io.BufferedWriter; import java.io.File; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; @@ -31,6 +30,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.StringWriter; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; @@ -601,7 +601,7 @@ public class GenerateDescriptorMojo extends MojoSupport { } } -private Dependency findMatchingDependency(List dependencies, Dependency reference) { +private static Dependency findMatchingDependency(List dependencies, Dependency reference) { String referenceName = reference.getName(); for (Dependency dependency : dependencies) { if (referenceName.equals(dependency.getName())) { @@ -611,7 +611,7 @@ public class GenerateDescriptorMojo extends MojoSupport { return null; } -private void mergeDependencies(Dependency target, Dependency source) { +private static void mergeDependencies(Dependency target, Dependency source) { if (target.getVersion() == null || Feature.DEFAULT_VERSION.equals(target.getVersion())) { target.setVersion(source.getVersion()); } @@ -642,30 +642,28 @@ public class GenerateDescriptorMojo extends MojoSupport { */ private Manifest getManifest(File file) throws IOException { -InputStream is; +final InputStream is; try { -is = new BufferedInputStream(new FileInputStream(file)); +is = Files.newInputStream(file.toPath()); } catch (Exception e) { getLog().warn("Error while opening artifact", e); return null; } -try { -is.mark(256 * 1024); -JarInputStream jar = new JarInputStream(is); -Manifest m = jar.getManifest(); -if (m == null) { -getLog().warn("Manifest not present in the first entry of the zip - " + file.getName()); +try (BufferedInputStream bis = new BufferedInputStream(is)) { +bis.mark(256 * 1024); + +try (JarInputStream jar = new JarInputStream(bis)) { +Manifest m = jar.getManifest(); +if (m == null) { +getLog().warn("Manifest not present in the first entry of the zip - " + file.getName()); +} +return m; } -jar.close(); -return m; -} finally { -// just in case when we did not open bundle -is.close(); } } -private Features readFeaturesFile(File featuresFile) throws XMLStreamException, JAXBException, IOException { +private static Features
[3/3] karaf git commit: Reuse extracted manifest
Reuse extracted manifest Obtaining the manifest can cost us some IO. Treat it as an invariant when determining whether a file is a bundle. Signed-off-by: Robert VargaProject: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/edcda0b0 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/edcda0b0 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/edcda0b0 Branch: refs/heads/master Commit: edcda0b0ea4a50ae8e8019af1eaff161507e3ee4 Parents: 9714d76 Author: Robert Varga Authored: Sun Aug 13 20:26:17 2017 +0200 Committer: Robert Varga Committed: Wed Aug 23 14:23:01 2017 +0200 -- .../apache/karaf/tooling/features/GenerateDescriptorMojo.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/edcda0b0/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java -- diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java index e4bcf07..f262ac3 100644 --- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java +++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java @@ -483,8 +483,6 @@ public class GenerateDescriptorMojo extends MojoSupport { if (!this.dependencyHelper.isArtifactAFeature(artifact)) { String bundleName = this.dependencyHelper.artifactToMvn(artifact, getVersionOrRange(entry.getParent(), artifact)); -File bundleFile = this.dependencyHelper.resolve(artifact, getLog()); -Manifest manifest = getManifest(bundleFile); for (ConfigFile cf : feature.getConfigfile()) { if (bundleName.equals(cf.getLocation().replace('\n', ' ').trim())) { @@ -493,7 +491,9 @@ public class GenerateDescriptorMojo extends MojoSupport { } } -if (manifest == null || !ManifestUtils.isBundle(getManifest(bundleFile))) { +File bundleFile = this.dependencyHelper.resolve(artifact, getLog()); +Manifest manifest = getManifest(bundleFile); +if (manifest == null || !ManifestUtils.isBundle(manifest)) { bundleName = "wrap:" + bundleName; needWrap = true; }
[2/3] karaf git commit: Cache unmarshalled Features
Cache unmarshalled Features If we are processing a deep feature tree with multiple dependencies referencing same features (like in the case of OpenDaylight), we end up unmarshalling the same features over and over again. Rather than doing that, instantiate a cache, which will hold a weak reference to features already encountered. Before: real1m46.523s user1m59.258s sys 0m17.048s After: real0m42.642s user1m0.892s sys 0m10.148s Signed-off-by: Robert VargaProject: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/9714d76b Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/9714d76b Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/9714d76b Branch: refs/heads/master Commit: 9714d76be6442faca13e6f45f02a27eac52b8ebb Parents: ed79796 Author: Robert Varga Authored: Sun Aug 13 19:38:26 2017 +0200 Committer: Robert Varga Committed: Wed Aug 23 14:22:59 2017 +0200 -- .../features/GenerateDescriptorMojo.java| 28 1 file changed, 23 insertions(+), 5 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/9714d76b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java -- diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java index a6141ba..e4bcf07 100644 --- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java +++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/features/GenerateDescriptorMojo.java @@ -38,6 +38,7 @@ import java.util.HashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.WeakHashMap; import java.util.jar.JarInputStream; import java.util.jar.Manifest; @@ -456,6 +457,7 @@ public class GenerateDescriptorMojo extends MojoSupport { // TODO Initialise the repositories from the existing feature file if any Map otherFeatures = new HashMap<>(); Map featureRepositories = new HashMap<>(); +FeaturesCache cache = new FeaturesCache(); for (final LocalDependency entry : localDependencies) { Object artifact = entry.getArtifact(); @@ -463,9 +465,11 @@ public class GenerateDescriptorMojo extends MojoSupport { continue; } -processFeatureArtifact(features, feature, otherFeatures, featureRepositories, artifact, entry.getParent(), -true); +processFeatureArtifact(features, feature, otherFeatures, featureRepositories, cache, artifact, +entry.getParent(), true); } +// Do not retain cache beyond this point +cache = null; // Second pass to look for bundles if (addBundlesToPrimaryFeature) { @@ -557,7 +561,7 @@ public class GenerateDescriptorMojo extends MojoSupport { } private void processFeatureArtifact(Features features, Feature feature, Map otherFeatures, -Map featureRepositories, +Map featureRepositories, FeaturesCache cache, Object artifact, Object parent, boolean add) throws MojoExecutionException, XMLStreamException, JAXBException, IOException { if (this.dependencyHelper.isArtifactAFeature(artifact) && FEATURE_CLASSIFIER.equals( @@ -567,9 +571,9 @@ public class GenerateDescriptorMojo extends MojoSupport { throw new MojoExecutionException( "Cannot locate file for feature: " + artifact + " at " + featuresFile); } -Features includedFeatures = readFeaturesFile(featuresFile); +Features includedFeatures = cache.get(featuresFile); for (String repository : includedFeatures.getRepository()) { -processFeatureArtifact(features, feature, otherFeatures, featureRepositories, +processFeatureArtifact(features, feature, otherFeatures, featureRepositories, cache, new DefaultArtifact(MavenUtil.mvnToAether(repository)), parent, false); } for (Feature includedFeature : includedFeatures.getFeature()) { @@ -921,4 +925,18 @@ public class GenerateDescriptorMojo extends MojoSupport { return "\tTree listing is saved here: " + treeListFile.getAbsolutePath() + "\n"; } +private static
[4/4] karaf git commit: Fix warnings
Fix warnings Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/3db554d4 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/3db554d4 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/3db554d4 Branch: refs/heads/master Commit: 3db554d453e3f80dc5ffb71d2cbcb655b2ddc277 Parents: d6edb10 Author: Christian SchneiderAuthored: Tue Aug 22 16:34:21 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 22 16:34:21 2017 +0200 -- .../karaf/jaas/modules/audit/AbstractAuditLoginModule.java| 2 +- .../karaf/jaas/modules/audit/EventAdminAuditLoginModule.java | 2 +- .../apache/karaf/jaas/modules/audit/FileAuditLoginModule.java | 2 +- .../apache/karaf/jaas/modules/audit/LogAuditLoginModule.java | 2 +- .../java/org/apache/karaf/jaas/modules/impl/KarafRealm.java | 2 -- .../org/apache/karaf/jaas/modules/krb5/Krb5LoginModule.java | 1 + .../apache/karaf/jaas/modules/osgi/OsgiConfigLoginModule.java | 2 +- .../jaas/modules/properties/DigestPasswordLoginModule.java| 4 ++-- .../karaf/jaas/modules/properties/PropertiesLoginModule.java | 2 +- .../jaas/modules/publickey/PublickeyBackingEngineFactory.java | 7 +++ 10 files changed, 12 insertions(+), 14 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/3db554d4/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/AbstractAuditLoginModule.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/AbstractAuditLoginModule.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/AbstractAuditLoginModule.java index 5349246..140ba40 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/AbstractAuditLoginModule.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/AbstractAuditLoginModule.java @@ -38,7 +38,7 @@ public abstract class AbstractAuditLoginModule implements LoginModule { private boolean enabled; public void initialize(Subject subject, CallbackHandler callbackHandler, - Map sharedState, Map options) { + Map sharedState, Map options) { this.subject = subject; enabled = Boolean.parseBoolean((String) options.get("enabled")); handler = callbackHandler; http://git-wip-us.apache.org/repos/asf/karaf/blob/3db554d4/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/EventAdminAuditLoginModule.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/EventAdminAuditLoginModule.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/EventAdminAuditLoginModule.java index 8375013..54ce6aa 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/EventAdminAuditLoginModule.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/EventAdminAuditLoginModule.java @@ -38,7 +38,7 @@ public class EventAdminAuditLoginModule extends AbstractAuditLoginModule { private String topic; public void initialize(Subject subject, CallbackHandler callbackHandler, - Map sharedState, Map options) { + Map sharedState, Map options) { super.initialize(subject, callbackHandler, sharedState, options); bundleContext = (BundleContext) options.get(BundleContext.class.getName()); topic = (String) options.get("topic"); http://git-wip-us.apache.org/repos/asf/karaf/blob/3db554d4/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/FileAuditLoginModule.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/FileAuditLoginModule.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/FileAuditLoginModule.java index eda7c71..6134964 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/FileAuditLoginModule.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/audit/FileAuditLoginModule.java @@ -36,7 +36,7 @@ public class FileAuditLoginModule extends AbstractAuditLoginModule { private String logFile; public void initialize(Subject subject, CallbackHandler callbackHandler, - Map sharedState, Map options) { + Map sharedState, Map options) { super.initialize(subject, callbackHandler, sharedState, options); logFile = (String) options.get(LOG_FILE_OPTION); }
[1/4] karaf git commit: Fix warnings
Repository: karaf Updated Branches: refs/heads/master 09c445c38 -> 3db554d45 Fix warnings Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/ab04a21b Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/ab04a21b Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/ab04a21b Branch: refs/heads/master Commit: ab04a21b151d17b73f4f834ff2547abde28049f8 Parents: 09c445c Author: Christian SchneiderAuthored: Tue Aug 22 10:32:46 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 22 10:32:46 2017 +0200 -- .../java/org/apache/karaf/profile/command/ProfileDisplay.java | 1 - .../java/org/apache/karaf/profile/command/ProfileEdit.java | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/ab04a21b/profile/src/main/java/org/apache/karaf/profile/command/ProfileDisplay.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/command/ProfileDisplay.java b/profile/src/main/java/org/apache/karaf/profile/command/ProfileDisplay.java index 9e54cef..e6d4619 100644 --- a/profile/src/main/java/org/apache/karaf/profile/command/ProfileDisplay.java +++ b/profile/src/main/java/org/apache/karaf/profile/command/ProfileDisplay.java @@ -91,7 +91,6 @@ public class ProfileDisplay implements Action { List agentProperties = new ArrayList<>(); List systemProperties = new ArrayList<>(); List configProperties = new ArrayList<>(); -List otherResources = new ArrayList<>(); for (Map.Entry entry : agentConfiguration.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); http://git-wip-us.apache.org/repos/asf/karaf/blob/ab04a21b/profile/src/main/java/org/apache/karaf/profile/command/ProfileEdit.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/command/ProfileEdit.java b/profile/src/main/java/org/apache/karaf/profile/command/ProfileEdit.java index 1b986ee..596731a 100644 --- a/profile/src/main/java/org/apache/karaf/profile/command/ProfileEdit.java +++ b/profile/src/main/java/org/apache/karaf/profile/command/ProfileEdit.java @@ -407,10 +407,10 @@ public class ProfileEdit implements Action { } private void openInEditor(Profile profile, String resource) throws Exception { +/* TODO:JLINE String id = profile.getId(); String location = id + " " + resource; //Call the editor -/* TODO:JLINE ConsoleEditor editor = editorFactory.create("simple", getTerminal()); editor.setTitle("Profile"); editor.setOpenEnabled(false); @@ -462,8 +462,8 @@ public class ProfileEdit implements Action { try { Configuration[] configuration = configurationAdmin.listConfigurations("(service.pid=" + pid + ")"); if (configuration != null && configuration.length > 0) { -Dictionary dictionary = configuration[0].getProperties(); -Enumeration keyEnumeration = dictionary.keys(); +Dictionary dictionary = configuration[0].getProperties(); +Enumeration keyEnumeration = dictionary.keys(); while (keyEnumeration.hasMoreElements()) { String key = String.valueOf(keyEnumeration.nextElement()); //file.install.filename needs to be skipped as it specific to the current container.
[3/4] karaf git commit: [KARAF-5316] Make EncryptionSupport easier to use
[KARAF-5316] Make EncryptionSupport easier to use Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/d6edb10e Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/d6edb10e Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/d6edb10e Branch: refs/heads/master Commit: d6edb10e0cf65f1d9eafb98154add8f007f70653 Parents: e380f88 Author: Christian SchneiderAuthored: Tue Aug 22 16:29:42 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 22 16:29:42 2017 +0200 -- .../jaas/modules/AbstractKarafLoginModule.java | 47 + .../modules/encryption/EncryptionSupport.java | 71 +++- .../jaas/modules/jdbc/JDBCBackingEngine.java| 14 +--- .../properties/AutoEncryptionSupport.java | 28 +--- .../properties/PropertiesBackingEngine.java | 19 ++ 5 files changed, 66 insertions(+), 113 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/d6edb10e/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/AbstractKarafLoginModule.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/AbstractKarafLoginModule.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/AbstractKarafLoginModule.java index 7f7807b..a6601d0 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/AbstractKarafLoginModule.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/AbstractKarafLoginModule.java @@ -68,7 +68,7 @@ public abstract class AbstractKarafLoginModule implements LoginModule { user = null; } -public void initialize(Subject sub, CallbackHandler handler, Map options) { +public void initialize(Subject sub, CallbackHandler handler, Map options) { this.subject = sub; this.callbackHandler = handler; this.options = options; @@ -81,50 +81,9 @@ public abstract class AbstractKarafLoginModule implements LoginModule { encryptionSupport = new EncryptionSupport(options); } - -public String getEncryptedPassword(String password) { -Encryption encryption = encryptionSupport.getEncryption(); -String encryptionPrefix = encryptionSupport.getEncryptionPrefix(); -String encryptionSuffix = encryptionSupport.getEncryptionSuffix(); - -if (encryption == null) { -return password; -} else { -boolean prefix = encryptionPrefix == null || password.startsWith(encryptionPrefix); -boolean suffix = encryptionSuffix == null || password.endsWith(encryptionSuffix); -if (prefix && suffix) { -return password; -} else { -String p = encryption.encryptPassword(password); -if (encryptionPrefix != null) { -p = encryptionPrefix + p; -} -if (encryptionSuffix != null) { -p = p + encryptionSuffix; -} -return p; -} -} -} - public boolean checkPassword(String plain, String encrypted) { -Encryption encryption = encryptionSupport.getEncryption(); -String encryptionPrefix = encryptionSupport.getEncryptionPrefix(); -String encryptionSuffix = encryptionSupport.getEncryptionSuffix(); - -if (encryption == null) { -return plain.equals(encrypted); -} else { -boolean prefix = encryptionPrefix == null || encrypted.startsWith(encryptionPrefix); -boolean suffix = encryptionSuffix == null || encrypted.endsWith(encryptionSuffix); -if (prefix && suffix) { -encrypted = encrypted.substring(encryptionPrefix != null ? encryptionPrefix.length() : 0, -encrypted.length() - (encryptionSuffix != null ? encryptionSuffix.length() : 0)); -return encryption.checkPassword(plain, encrypted); -} else { -return plain.equals(encrypted); -} -} +String newEncrypted = encryptionSupport.encrypt(plain); +return encrypted.equals(newEncrypted); } } http://git-wip-us.apache.org/repos/asf/karaf/blob/d6edb10e/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java index 036fc9b..61e28f0 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java
[2/4] karaf git commit: Refactor EncryptionSupport to use tracker
Refactor EncryptionSupport to use tracker Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/e380f888 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/e380f888 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/e380f888 Branch: refs/heads/master Commit: e380f888a6c2d7f08513129e8c74a37c5d2afd4a Parents: ab04a21 Author: Christian SchneiderAuthored: Tue Aug 22 13:58:52 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 22 13:58:52 2017 +0200 -- .../modules/encryption/EncryptionSupport.java | 162 ++- 1 file changed, 82 insertions(+), 80 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/e380f888/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java index ff2f12a..036fc9b 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/encryption/EncryptionSupport.java @@ -17,115 +17,117 @@ package org.apache.karaf.jaas.modules.encryption; import org.apache.karaf.jaas.modules.Encryption; import org.apache.karaf.jaas.modules.EncryptionService; import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceReference; +import org.osgi.util.tracker.ServiceTracker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.SortedMap; public class EncryptionSupport { - private final Logger logger = LoggerFactory.getLogger(EncryptionSupport.class); private BundleContext bundleContext; - private Encryption encryption; private String encryptionPrefix; private String encryptionSuffix; -protected Map options; +private boolean debug; +private boolean enabled; +private String name; -protected boolean debug; +private Map encOpts; public EncryptionSupport(Map options) { -this.options = options; this.debug = Boolean.parseBoolean((String) options.get("debug")); // the bundle context is set in the Config JaasRealm by default this.bundleContext = (BundleContext) options.get(BundleContext.class.getName()); +encOpts = new HashMap<>(); +for (String key : options.keySet()) { +if (key.startsWith("encryption.")) { +encOpts.put(key.substring("encryption.".length()), options.get(key).toString()); +} +} +encryptionPrefix = encOpts.remove("prefix"); +encryptionSuffix = encOpts.remove("suffix"); +enabled = Boolean.parseBoolean(encOpts.remove("enabled")); +if (!enabled) { +if (debug) { +logger.debug("Encryption is disabled."); +} +} +name = encOpts.remove("name"); +if (debug) { +if (name != null && name.length() > 0) { +logger.debug("Encryption is enabled. Using service " + name + " with options " + encOpts); +} else { +logger.debug("Encryption is enabled. Using options " + encOpts); +} +} } public Encryption getEncryption() { -if (encryption == null) { -Map encOpts = new HashMap<>(); -for (String key : options.keySet()) { -if (key.startsWith("encryption.")) { -encOpts.put(key.substring("encryption.".length()), options.get(key).toString()); -} -} -encryptionPrefix = encOpts.remove("prefix"); -encryptionSuffix = encOpts.remove("suffix"); -boolean enabled = Boolean.parseBoolean(encOpts.remove("enabled")); +if (encryption != null) { +return encryption; +} +if (!enabled) { +return null; +} -if (!enabled) { -if (debug) { -logger.debug("Encryption is disabled."); -} -} else { -String name = encOpts.remove("name"); -if (debug) { -if (name != null && name.length() > 0) { -logger.debug("Encryption is enabled. Using service " + name + " with options " + encOpts); -} else { -
[2/2] karaf git commit: Fix warnings, Remove unnecessary code
Fix warnings, Remove unnecessary code Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/09c445c3 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/09c445c3 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/09c445c3 Branch: refs/heads/master Commit: 09c445c38538202bf5f9f767bf49a316ab5fb0e3 Parents: 188d355 Author: Christian SchneiderAuthored: Tue Aug 22 09:24:21 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 22 09:24:21 2017 +0200 -- .../java/org/apache/karaf/itests/MavenTest.java | 19 --- 1 file changed, 4 insertions(+), 15 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/09c445c3/itests/src/test/java/org/apache/karaf/itests/MavenTest.java -- diff --git a/itests/src/test/java/org/apache/karaf/itests/MavenTest.java b/itests/src/test/java/org/apache/karaf/itests/MavenTest.java index 4ee914c..22eb4fc 100644 --- a/itests/src/test/java/org/apache/karaf/itests/MavenTest.java +++ b/itests/src/test/java/org/apache/karaf/itests/MavenTest.java @@ -18,7 +18,7 @@ package org.apache.karaf.itests; import java.io.File; import java.io.IOException; -import java.net.ServerSocket; +import java.nio.charset.Charset; import java.util.Arrays; import java.util.Dictionary; import java.util.LinkedList; @@ -28,6 +28,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; + import javax.inject.Inject; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -40,7 +41,6 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.AbstractHandler; import org.junit.AfterClass; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.ops4j.pax.exam.Configuration; @@ -135,17 +135,6 @@ public class MavenTest /*extends KarafTestSupport*/ { return probe; } -private int getAvailablePort(int min, int max) { -for (int i = min; i <= max; i++) { -try { -ServerSocket socket = new ServerSocket(i); -return socket.getLocalPort(); -} catch (Exception ignored) { -} -} -throw new IllegalStateException("Can't find available network ports"); -} - @Configuration public Option[] config() { MavenArtifactUrlReference karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf").versionAsInProject().type("tar.gz"); @@ -228,9 +217,9 @@ public class MavenTest /*extends KarafTestSupport*/ { private void updateSettings() throws IOException { File settingsFile = new File(System.getProperty("karaf.home"), "etc/maven-settings.xml"); -String settings = FileUtils.readFileToString(settingsFile); +String settings = FileUtils.readFileToString(settingsFile, Charset.forName("UTF-8")); settings = settings.replace("@@port@@", Integer.toString(port)); -FileUtils.write(settingsFile, settings); +FileUtils.write(settingsFile, settings, Charset.forName("UTF-8")); } /**
[1/2] karaf git commit: Tabs to Spaces, Extract constant
Repository: karaf Updated Branches: refs/heads/master 7afb05828 -> 09c445c38 Tabs to Spaces, Extract constant Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/188d3557 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/188d3557 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/188d3557 Branch: refs/heads/master Commit: 188d35571670b0fab308ca07fd3a5a066bdf82c6 Parents: 7afb058 Author: Christian SchneiderAuthored: Tue Aug 22 09:20:29 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 22 09:20:29 2017 +0200 -- .../apache/karaf/itests/KarafTestSupport.java | 75 ++-- 1 file changed, 38 insertions(+), 37 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/188d3557/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java -- diff --git a/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java b/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java index 17413bd..57648d7 100644 --- a/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java +++ b/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java @@ -88,6 +88,7 @@ import org.slf4j.LoggerFactory; public class KarafTestSupport { +private static final EnumSet NO_AUTO_REFRESH = EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles); public static final String MIN_RMI_SERVER_PORT = "4"; public static final String MAX_RMI_SERVER_PORT = "6"; public static final String MIN_HTTP_PORT = "9080"; @@ -534,25 +535,25 @@ public class KarafTestSupport { Assert.assertFalse("Should not contain '" + expectedPart + "' but was : " + actual, actual.contains(expectedPart)); } - protected void assertBundleInstalled(String name) { - Assert.assertNotNull("Bundle " + name + " should be installed", findBundleByName(name)); - } +protected void assertBundleInstalled(String name) { +Assert.assertNotNull("Bundle " + name + " should be installed", findBundleByName(name)); +} - protected void assertBundleNotInstalled(String name) { - Assert.assertNull("Bundle " + name + " should not be installed", findBundleByName(name)); - } +protected void assertBundleNotInstalled(String name) { +Assert.assertNull("Bundle " + name + " should not be installed", findBundleByName(name)); +} - protected Bundle findBundleByName(String symbolicName) { - for (Bundle bundle : bundleContext.getBundles()) { - if (bundle.getSymbolicName().equals(symbolicName)) { - return bundle; - } - } - return null; - } +protected Bundle findBundleByName(String symbolicName) { +for (Bundle bundle : bundleContext.getBundles()) { +if (bundle.getSymbolicName().equals(symbolicName)) { +return bundle; +} +} +return null; +} protected void installAndAssertFeature(String feature) throws Exception { -featureService.installFeature(feature, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles)); +featureService.installFeature(feature, NO_AUTO_REFRESH); assertFeatureInstalled(feature); } @@ -563,23 +564,23 @@ public class KarafTestSupport { protected void installAssertAndUninstallFeatures(String... feature) throws Exception { boolean success = false; Set features = new HashSet<>(Arrays.asList(feature)); - try { +try { System.out.println("Installing " + features); -featureService.installFeatures(features, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles)); - for (String curFeature : feature) { - assertFeatureInstalled(curFeature); - } +featureService.installFeatures(features, NO_AUTO_REFRESH); +for (String curFeature : feature) { +assertFeatureInstalled(curFeature); +} success = true; - } finally { +} finally { System.out.println("Uninstalling " + features); try { -featureService.uninstallFeatures(features, EnumSet.of(FeaturesService.Option.NoAutoRefreshBundles)); +featureService.uninstallFeatures(features, NO_AUTO_REFRESH); } catch (Exception e) { if (success) { throw e; } } - } +} } /** @@ -589,30 +590,30 @@ public class KarafTestSupport { * @param featuresBefore *
[1/3] karaf git commit: KARAF-5314 Added a features cache that increases the performance of the filtering of the required features from the available features.
Repository: karaf Updated Branches: refs/heads/karaf-4.1.x 052fa3f7d -> b22e3c44c KARAF-5314 Added a features cache that increases the performance of the filtering of the required features from the available features. The performance of the filtering logic decresed when the java streams API was used in 4.1 compared to for loops in 4.0. I reverted the filtering logic to use for loops and also introduced a features cache. This increased the performance by a huge margin, almost 20X faster when there are ~900 available features and ~300 required features from a highly complex and huge feature dependency tree. Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/4e839355 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/4e839355 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/4e839355 Branch: refs/heads/karaf-4.1.x Commit: 4e8393552a2724ea0f416a055026f0ae9704ad50 Parents: 052fa3f Author: Vinay Shankar (e24113)Authored: Fri Aug 18 13:55:58 2017 -0500 Committer: Christian Schneider Committed: Mon Aug 21 17:26:39 2017 +0200 -- .../apache/karaf/profile/assembly/Builder.java | 38 +++- 1 file changed, 30 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/4e839355/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java index 89b95a8..e3fc26c 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java @@ -39,6 +39,7 @@ import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -48,7 +49,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.jar.Attributes; import java.util.jar.Manifest; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -794,10 +794,11 @@ public class Builder { allInstalledFeatures.addAll(repo.getFeature()); } Set installedFeatures = new LinkedHashSet<>(); +Map > featuresCache = new HashMap<>(); // Add boot features for search allInstalledFeatures.addAll(allBootFeatures); for (String feature : installedEffective.getFeatures()) { -addFeatures(allInstalledFeatures, feature, installedFeatures, true); +addFeatures(allInstalledFeatures, feature, installedFeatures, true, featuresCache); } for (Feature feature : installedFeatures) { LOGGER.info(" Feature {} is defined as an installed feature", feature.getId()); @@ -869,7 +870,8 @@ public class Builder { // Compute startup feature dependencies Set bootFeatures = new HashSet<>(); -addFeatures(allBootFeatures, generated.getName(), bootFeatures, true); +Map > featuresCache = new HashMap<>(); +addFeatures(allBootFeatures, generated.getName(), bootFeatures, true, featuresCache); for (Feature feature : bootFeatures) { // the feature is a startup feature, updating startup.properties file LOGGER.info(" Feature " + feature.getId() + " is defined as a boot feature"); @@ -1248,14 +1250,16 @@ public class Builder { } } -private void addFeatures(Set allFeatures, String feature, Set features, boolean mandatory) { +private void addFeatures(Set allFeatures, String feature, Set features, boolean mandatory, Map > featuresCache) { String name; +Version osgiVersion; VersionRange range; int idx = feature.indexOf('/'); if (idx > 0) { name = feature.substring(0, idx); String version = feature.substring(idx + 1); version = version.trim(); +osgiVersion = VersionTable.getVersion(version); if (version.equals(org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION)) { range = new VersionRange(Version.emptyVersion); } else { @@ -1263,18 +1267,36 @@ public class Builder { } } else { name = feature; +osgiVersion = Version.emptyVersion; range = new VersionRange(Version.emptyVersion); } -Set set = allFeatures.stream() -
[2/3] karaf git commit: [KARAF-5314] Extract addFeatures into class FeatureSelector
[KARAF-5314] Extract addFeatures into class FeatureSelector Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/cc758635 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/cc758635 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/cc758635 Branch: refs/heads/karaf-4.1.x Commit: cc758635a4a20fc4f68b3ca1c8d557ae17705c3a Parents: 4e83935 Author: Christian SchneiderAuthored: Sun Aug 20 12:14:31 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 17:31:51 2017 +0200 -- .../apache/karaf/profile/assembly/Builder.java | 105 ++- .../karaf/profile/assembly/FeatureSelector.java | 94 + 2 files changed, 100 insertions(+), 99 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/cc758635/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java index e3fc26c..1fe2848 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java @@ -39,7 +39,6 @@ import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -56,8 +55,6 @@ import org.apache.felix.resolver.ResolverImpl; import org.apache.felix.utils.manifest.Clause; import org.apache.felix.utils.properties.InterpolationHelper; import org.apache.felix.utils.properties.Properties; -import org.apache.felix.utils.version.VersionRange; -import org.apache.felix.utils.version.VersionTable; import org.apache.karaf.features.FeaturesService; import org.apache.karaf.features.Library; import org.apache.karaf.features.internal.download.DownloadCallback; @@ -90,13 +87,13 @@ import org.apache.karaf.util.maven.Parser; import org.ops4j.pax.url.mvn.MavenResolver; import org.ops4j.pax.url.mvn.MavenResolvers; import org.osgi.framework.Constants; -import org.osgi.framework.Version; import org.osgi.framework.wiring.BundleRevision; import org.osgi.resource.Resource; import org.osgi.service.resolver.Resolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static java.util.Collections.singletonList; import static java.util.jar.JarFile.MANIFEST_NAME; import static org.apache.karaf.features.internal.service.Blacklist.TYPE_REPOSITORY; import static org.apache.karaf.profile.assembly.Builder.Stage.Startup; @@ -793,13 +790,11 @@ public class Builder { for (Features repo : installedRepositories.values()) { allInstalledFeatures.addAll(repo.getFeature()); } -Set installedFeatures = new LinkedHashSet<>(); -Map > featuresCache = new HashMap<>(); + // Add boot features for search allInstalledFeatures.addAll(allBootFeatures); -for (String feature : installedEffective.getFeatures()) { -addFeatures(allInstalledFeatures, feature, installedFeatures, true, featuresCache); -} +FeatureSelector selector = new FeatureSelector(allInstalledFeatures); +Set installedFeatures = selector.selectMatching(installedEffective.getFeatures()); for (Feature feature : installedFeatures) { LOGGER.info(" Feature {} is defined as an installed feature", feature.getId()); for (Bundle bundle : feature.getBundle()) { @@ -869,9 +864,8 @@ public class Builder { Downloader downloader = manager.createDownloader(); // Compute startup feature dependencies -Set bootFeatures = new HashSet<>(); -Map > featuresCache = new HashMap<>(); -addFeatures(allBootFeatures, generated.getName(), bootFeatures, true, featuresCache); +FeatureSelector selector = new FeatureSelector(allBootFeatures); +Set bootFeatures = selector.selectMatching(singletonList(generated.getName())); for (Feature feature : bootFeatures) { // the feature is a startup feature, updating startup.properties file LOGGER.info(" Feature " + feature.getId() + " is defined as a boot feature"); @@ -1250,93 +1244,6 @@ public class Builder { } } -private void addFeatures(Set allFeatures, String feature, Set features, boolean mandatory, Map > featuresCache) { -String name; -Version osgiVersion; -VersionRange range; -int idx = feature.indexOf('/'); -if (idx >
[3/3] karaf git commit: [KARAF-5314] Only recurse into dependencies once per feature
[KARAF-5314] Only recurse into dependencies once per feature Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/b22e3c44 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/b22e3c44 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/b22e3c44 Branch: refs/heads/karaf-4.1.x Commit: b22e3c44cdd09edbf6f1bff4199826fc98a3f405 Parents: cc75863 Author: Christian SchneiderAuthored: Sun Aug 20 16:20:09 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 17:32:07 2017 +0200 -- .../org/apache/karaf/profile/assembly/FeatureSelector.java| 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/b22e3c44/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java b/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java index 1e453d6..156cb46 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java @@ -55,9 +55,10 @@ public class FeatureSelector { throw new IllegalStateException("Could not find matching feature for " + feature); } for (Feature f : set) { -features.add(f); -for (Dependency dep : f.getFeature()) { -addFeatures(dep.toString(), features, isMandatory(dep)); +if (features.add(f)) { +for (Dependency dep : f.getFeature()) { +addFeatures(dep.toString(), features, isMandatory(dep)); +} } } }
[1/2] karaf git commit: Documentation and small refactoring
Repository: karaf Updated Branches: refs/heads/master b3281c12a -> 7afb05828 Documentation and small refactoring Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/70ea94e7 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/70ea94e7 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/70ea94e7 Branch: refs/heads/master Commit: 70ea94e77e5e386e264d083bd38366cbb1f6a2a4 Parents: b3281c1 Author: Christian SchneiderAuthored: Mon Aug 21 15:27:15 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 15:27:15 2017 +0200 -- .../profile/assembly/ArtifactInstaller.java | 46 .../apache/karaf/profile/assembly/Builder.java | 4 +- .../karaf/profile/assembly/FeatureSelector.java | 9 +++- 3 files changed, 37 insertions(+), 22 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/70ea94e7/profile/src/main/java/org/apache/karaf/profile/assembly/ArtifactInstaller.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/ArtifactInstaller.java b/profile/src/main/java/org/apache/karaf/profile/assembly/ArtifactInstaller.java index 2dcf2be..273d9e4 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/ArtifactInstaller.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/ArtifactInstaller.java @@ -16,6 +16,8 @@ */ package org.apache.karaf.profile.assembly; +import static org.apache.karaf.features.internal.download.impl.DownloadManagerHelper.stripUrl; + import java.net.MalformedURLException; import java.net.URI; import java.nio.file.Files; @@ -25,12 +27,15 @@ import java.nio.file.StandardCopyOption; import java.util.List; import org.apache.karaf.features.internal.download.Downloader; -import org.apache.karaf.features.internal.download.impl.DownloadManagerHelper; import org.apache.karaf.features.internal.service.Blacklist; import org.apache.karaf.util.maven.Parser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * Downloads a maven artifact and installs it into the given system directory. + * The layout follows the conventions of a maven local repository. + */ public class ArtifactInstaller { private static final Logger LOGGER = LoggerFactory.getLogger(ArtifactInstaller.class); @@ -46,26 +51,29 @@ public class ArtifactInstaller { public void installArtifact(String location) throws Exception { LOGGER.info(" adding maven artifact: " + location); -location = DownloadManagerHelper.stripUrl(location); -if (location.startsWith("mvn:")) { -if (location.endsWith("/")) { -// for bad formed URL (like in Camel for mustache-compiler), we remove the trailing / -location = location.substring(0, location.length() - 1); -} -downloader.download(location, provider -> { -String uri = provider.getUrl(); -if (blacklist.isBundleBlacklisted(uri)) { -throw new RuntimeException("Bundle " + uri + " is blacklisted"); -} -Path path = pathFromProviderUrl(systemDirectory, uri); -synchronized (provider) { -Files.createDirectories(path.getParent()); -Files.copy(provider.getFile().toPath(), path, StandardCopyOption.REPLACE_EXISTING); -} -}); -} else { +location = removeTrailingSlash(stripUrl(location)); +if (!location.startsWith("mvn:")) { LOGGER.warn("Ignoring non maven artifact " + location); +return; } +downloader.download(location, provider -> { +String uri = provider.getUrl(); +if (blacklist.isBundleBlacklisted(uri)) { +throw new RuntimeException("Bundle " + uri + " is blacklisted"); +} +Path path = pathFromProviderUrl(systemDirectory, uri); +synchronized (provider) { +Files.createDirectories(path.getParent()); +Files.copy(provider.getFile().toPath(), path, StandardCopyOption.REPLACE_EXISTING); +} +}); +} + +/** + * for bad formed URL (like in Camel for mustache-compiler), we remove the trailing / + */ +private String removeTrailingSlash(String location) { +return location.endsWith("/") ? location.substring(0, location.length() - 1) : location; } public static Path pathFromProviderUrl(Path systemDirectory, String url) throws MalformedURLException {
[2/2] karaf git commit: Extract ConfigInstaller
Extract ConfigInstaller Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/b3281c12 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/b3281c12 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/b3281c12 Branch: refs/heads/master Commit: b3281c12a72d11831e152e4d2981c655623353eb Parents: 6190984 Author: Christian SchneiderAuthored: Mon Aug 21 12:37:22 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 12:37:22 2017 +0200 -- .../apache/karaf/profile/assembly/Builder.java | 143 +- .../karaf/profile/assembly/ConfigInstaller.java | 187 +++ 2 files changed, 191 insertions(+), 139 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/b3281c12/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java index 2fdd5f0..f837a18 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java @@ -48,7 +48,6 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.function.Function; import java.util.jar.Attributes; import java.util.jar.Manifest; -import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -63,9 +62,7 @@ import org.apache.karaf.features.internal.download.Downloader; import org.apache.karaf.features.internal.download.StreamProvider; import org.apache.karaf.features.internal.model.Bundle; import org.apache.karaf.features.internal.model.Conditional; -import org.apache.karaf.features.internal.model.Config; import org.apache.karaf.features.internal.model.ConfigFile; -import org.apache.karaf.features.internal.model.Content; import org.apache.karaf.features.internal.model.Dependency; import org.apache.karaf.features.internal.model.Feature; import org.apache.karaf.features.internal.model.Features; @@ -921,36 +918,9 @@ public class Builder { } } } -List contents = new ArrayList<>(); -contents.add(feature); -contents.addAll(feature.getConditional()); -for (Content content : contents) { -// Install config files -for (Config config : content.getConfig()) { -if (config.isExternal()) { -installer.installArtifact(config.getValue().trim()); -} -} -for (ConfigFile configFile : content.getConfigfile()) { -installer.installArtifact(configFile.getLocation().trim()); -} -// Extract configs -for (Config config : content.getConfig()) { -if (pidMatching(config.getName())) { -Path configFile = etcDirectory.resolve(config.getName() + ".cfg"); -LOGGER.info(" adding config file: {}", homeDirectory.relativize(configFile)); -if (config.isExternal()) { -downloader.download(config.getValue().trim(), provider -> { -synchronized (provider) { -Files.copy(provider.getFile().toPath(), configFile, StandardCopyOption.REPLACE_EXISTING); -} -}); -} else { -Files.write(configFile, config.getValue().getBytes()); -} -} -} -} + +new ConfigInstaller(etcDirectory, pidsToExtract) +.installConfigs(feature, downloader, installer); // Install libraries List libraries = new ArrayList<>(); for (Library library : feature.getLibraries()) { @@ -1019,112 +989,7 @@ public class Builder { return allBootFeatures; } -private boolean pidMatching(String name) { -if (pidsToExtract == null) { -return true; -} -for (String p : pidsToExtract) { -boolean negated = false; -if (p.startsWith("!")) { -negated = true; -p = p.substring(1); -} -String r = globToRegex(p); -if (Pattern.matches(r, name)) { -return !negated; -} -} -return false; -} - -private String globToRegex(String pattern) { -StringBuilder sb = new
[1/2] karaf git commit: Remove unused code
Repository: karaf Updated Branches: refs/heads/master 1c4149b6f -> b3281c12a Remove unused code Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/61909845 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/61909845 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/61909845 Branch: refs/heads/master Commit: 61909845158be8cabd43b22dbe798205a58061b9 Parents: 1c4149b Author: Christian SchneiderAuthored: Mon Aug 21 12:07:47 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 12:07:47 2017 +0200 -- .../profile/versioning/ComparableVersion.java | 441 --- .../karaf/profile/versioning/VersionUtils.java | 76 .../profile/versioning/VersionUtilsTest.java| 40 -- 3 files changed, 557 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/61909845/profile/src/main/java/org/apache/karaf/profile/versioning/ComparableVersion.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/versioning/ComparableVersion.java b/profile/src/main/java/org/apache/karaf/profile/versioning/ComparableVersion.java deleted file mode 100644 index 0362183..000 --- a/profile/src/main/java/org/apache/karaf/profile/versioning/ComparableVersion.java +++ /dev/null @@ -1,441 +0,0 @@ -/* - * This file is taken from the "maven-artifact" project because the artifact lacks OSGi informations. - */ -package org.apache.karaf.profile.versioning; - -/* - * 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. - */ -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Properties; -import java.util.Stack; - -/** - * Generic implementation of version comparison. - * - * - * Features: - * - * mixing of '-' (hyphen) and '.' (dot) separators, - * transition between characters and digits also constitutes a separator: - * 1.0alpha1 = [1, 0, alpha, 1] - * unlimited number of version components, - * version components in the text can be digits or strings, - * strings are checked for well-known qualifiers and the qualifier ordering is used for version ordering. Well-known - * qualifiers (case insensitive) are: - * alpha or a - * beta or b - * milestone or m - * rc or cr - * snapshot - * (the empty string) or ga or final - * sp - * - * Unknown qualifiers are considered after known qualifiers, with lexical order (always case insensitive), - * - * a hyphen usually precedes a qualifier, and is always less important than something preceded with a dot. - * - * - * @see https://cwiki.apache.org/confluence/display/MAVENOLD/Versioning;>"Versioning" on Maven Wiki - * @author mailto:ken...@apache.org;>Kenney Westerhof - * @author mailto:hbout...@apache.org;>Hervé Boutemy - */ -public class ComparableVersion -implements Comparable { - -private String value; - -private String canonical; - -private ListItem items; - -private interface Item { - -int INTEGER_ITEM = 0; -int STRING_ITEM = 1; -int LIST_ITEM = 2; - -int compareTo(Item item); - -int getType(); - -boolean isNull(); -} - -/** - * Represents a numeric item in the version item list. - */ -private static class IntegerItem -implements Item { - -private static final BigInteger BIG_INTEGER_ZERO = new BigInteger("0"); - -private final BigInteger value; - -public static final IntegerItem ZERO = new IntegerItem(); - -private IntegerItem() { -this.value = BIG_INTEGER_ZERO; -} - -public IntegerItem(String str) { -this.value = new BigInteger(str); -} - -public int getType() { -return INTEGER_ITEM; -} - -public boolean isNull() { -return BIG_INTEGER_ZERO.equals(value); -} - -public int compareTo(Item
[3/4] karaf git commit: [KARAF-5300] Split install into add and upgrade
[KARAF-5300] Split install into add and upgrade Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/4328939b Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/4328939b Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/4328939b Branch: refs/heads/master Commit: 4328939b10fd970cdde77bb52d523cae9eb1a044 Parents: 571d6ea Author: Christian SchneiderAuthored: Thu Aug 10 11:23:10 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 10:58:39 2017 +0200 -- .../internal/service/FeaturesServiceImpl.java | 114 +-- 1 file changed, 55 insertions(+), 59 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/4328939b/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 5562390..2767bc8 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 @@ -83,6 +83,8 @@ import org.osgi.service.resolver.Resolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static java.util.Collections.emptyMap; +import static java.util.stream.Collectors.toSet; import static org.apache.karaf.features.internal.service.StateStorage.toStringStringSetMap; import static org.apache.karaf.features.internal.util.MapUtils.add; import static org.apache.karaf.features.internal.util.MapUtils.copy; @@ -787,28 +789,39 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall @Override public void installFeatures(Set featuresIn, String region, EnumSet options) throws Exception { -Set featureReqs = new HashSet<>(); +Set toInstall = new HashSet<>(); for (String feature : featuresIn) { -featureReqs.add(new FeatureReq(feature)); +toInstall.add(new FeatureReq(feature)); } State state = copyState(); Map requires = copy(state.requirements); if (region == null || region.isEmpty()) { region = ROOT_REGION; } -Set requiredForRegion = requires.computeIfAbsent(region, k -> new HashSet<>()); -computeRequirements(options, featureReqs, requiredForRegion); -Map > stateChanges = Collections.emptyMap(); -doProvisionInThread(requires, stateChanges, state, getFeaturesById(), options); -} +Set requirements = requires.computeIfAbsent(region, k -> new HashSet<>()); +Set existingFeatures = requirements.stream().map(r -> toFeatureReq(r)).collect(toSet()); + +Set toAdd = computeFeaturesToAdd(options, toInstall); +toAdd.stream().forEach(f -> requirements.add(toRequirement(f))); +print("Adding features: " + join(toAdd), options.contains(Option.Verbose)); + +if (options.contains(Option.Upgrade)) { +Set toRemove = computeFeaturesToRemoveOnUpdate(toAdd, existingFeatures); +toRemove.stream().forEach(f -> requirements.remove(toRequirement(f))); +if (!toRemove.isEmpty()) { +print("Removing features: " + join(toRemove), options.contains(Option.Verbose)); +} +} -void computeRequirements(EnumSet options, Set featureReqs, - Set requirements) -throws Exception { +doProvisionInThread(requires, emptyMap(), state, getFeaturesById(), options); +} + +private Set computeFeaturesToAdd(EnumSet options, + Set toInstall) throws Exception { +Feature[] installedFeatures = listInstalledFeatures(); Map > allFeatures = getFeatureCache(); -List featuresToAdd = new ArrayList<>(); -List featuresToRemove = new ArrayList<>(); -for (FeatureReq feature : featureReqs) { +Set toAdd = new HashSet<>(); +for (FeatureReq feature : toInstall) { Pattern pattern = Pattern.compile(feature.getName()); boolean matched = false; for (String fKey : allFeatures.keySet()) { @@ -816,8 +829,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall if (matcher.matches()) { Feature f = getFeatureMatching(fKey, feature.getVersionRange()); if (f !=
[1/4] karaf git commit: [KARAF-5300] Reuse and extract feature matching code
Repository: karaf Updated Branches: refs/heads/master 5a8133dbb -> 1c4149b6f [KARAF-5300] Reuse and extract feature matching code Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/1c4149b6 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/1c4149b6 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/1c4149b6 Branch: refs/heads/master Commit: 1c4149b6f510be94522b4bfa529b163c610f87a3 Parents: 4328939 Author: Christian SchneiderAuthored: Thu Aug 10 15:30:59 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 10:58:39 2017 +0200 -- .../internal/service/FeaturesServiceImpl.java | 79 +++- 1 file changed, 43 insertions(+), 36 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/1c4149b6/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 2767bc8..574998a 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 @@ -520,15 +520,15 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall @Override public Feature[] getFeatures(String nameOrId) throws Exception { -return getFeatures(new FeatureReq(nameOrId)); +return toArray(getFeatures(new FeatureReq(nameOrId))); } @Override public Feature[] getFeatures(String name, String version) throws Exception { -return getFeatures(new FeatureReq(name, version)); +return toArray(getFeatures(new FeatureReq(name, version))); } -private Feature[] getFeatures(FeatureReq featureReq) throws Exception { +private Collection getFeatures(FeatureReq featureReq) throws Exception { List features = new ArrayList<>(); Pattern pattern = Pattern.compile(featureReq.getName()); Map > allFeatures = getFeatureCache(); @@ -541,6 +541,10 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall } } } +return features; +} + +private Feature[] toArray(Collection features) { return features.toArray(new Feature[features.size()]); } @@ -819,33 +823,33 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall private Set computeFeaturesToAdd(EnumSet options, Set toInstall) throws Exception { Feature[] installedFeatures = listInstalledFeatures(); -Map > allFeatures = getFeatureCache(); Set toAdd = new HashSet<>(); -for (FeatureReq feature : toInstall) { -Pattern pattern = Pattern.compile(feature.getName()); -boolean matched = false; -for (String fKey : allFeatures.keySet()) { -Matcher matcher = pattern.matcher(fKey); -if (matcher.matches()) { -Feature f = getFeatureMatching(fKey, feature.getVersionRange()); -if (f != null) { -toAdd.add(new FeatureReq(f)); -for (Feature installedFeature : installedFeatures) { -if (installedFeature.getName().equals(f.getName()) && installedFeature.getVersion().equals(f.getVersion())) { -LOGGER.info("The specified feature: '{}' version '{}' {}",f.getName(),f.getVersion(),f.getVersion().endsWith("SNAPSHOT") ? "has been upgraded": "is already installed"); -} -} -matched = true; +for (FeatureReq featureReq : toInstall) { +Collection matching = getFeatures(featureReq); +for (Feature f: matching) { +toAdd.add(new FeatureReq(f)); +for (Feature installedFeature : installedFeatures) { +if (isSameFeature(f, installedFeature)) { +logInstalledOrUpdated(f); } } } -if (!matched && !options.contains(Option.NoFailOnFeatureNotFound)) { -throw new IllegalArgumentException("No matching features for " + feature); +if (matching.isEmpty() && !options.contains(Option.NoFailOnFeatureNotFound)) { +
[4/4] karaf git commit: [KARAF-5300] Use FeatureReq instead of string for FeaturesService
[KARAF-5300] Use FeatureReq instead of string for FeaturesService Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/b84126c6 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/b84126c6 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/b84126c6 Branch: refs/heads/master Commit: b84126c6cc91bdb46a4a24cef76e037f206d1140 Parents: 5a8133d Author: Christian SchneiderAuthored: Wed Aug 9 17:39:06 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 10:58:39 2017 +0200 -- .../features/internal/service/FeatureReq.java | 84 .../internal/service/FeaturesServiceImpl.java | 204 --- .../service/FeaturesServiceImplTest.java| 46 - .../karaf/features/internal/service/f09.xml | 24 +++ 4 files changed, 229 insertions(+), 129 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/b84126c6/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java -- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java new file mode 100644 index 000..2e1f652 --- /dev/null +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java @@ -0,0 +1,84 @@ +/* + * 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.karaf.features.internal.service; + +import org.apache.karaf.features.Feature; +import org.osgi.framework.Version; +import org.osgi.framework.VersionRange; + +/** + * Requirement for a feature + */ +public class FeatureReq { +public static final String VERSION_SEPARATOR = "/"; +private static Version HIGHEST = new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); +private static final VersionRange RANGE_ALL = new VersionRange(VersionRange.LEFT_CLOSED, Version.emptyVersion, HIGHEST, VersionRange.RIGHT_CLOSED); +private String name; +private VersionRange versionRange; + +public FeatureReq(String nameAndRange) { +String[] parts = nameAndRange.trim().split(VERSION_SEPARATOR); +this.name = parts[0]; +this.versionRange = (parts.length == 1) ? RANGE_ALL : range(parts[1]); +} + +public FeatureReq(String name, String versionRange) { +this.name = name; +this.versionRange = range(versionRange); +} + +private VersionRange range(String versionRange) { +if (versionRange == null) { +return RANGE_ALL; +} +versionRange = versionRange.trim(); +if ("0.0.0".equals(versionRange)) { +return RANGE_ALL; +} +if (versionRange.contains(",")) { +return new VersionRange(versionRange); +} else { +return exactVersion(versionRange); +} +} + +private static VersionRange exactVersion(String versionRange) { +return new VersionRange(VersionRange.LEFT_CLOSED, new Version(versionRange), new Version(versionRange), VersionRange.RIGHT_CLOSED); +} + +public FeatureReq(String name, VersionRange versionRange) { +this.name = name; +this.versionRange = versionRange; +} + +public FeatureReq(Feature feature) { +this(feature.getName(), exactVersion(feature.getVersion())); +} + +public String getName() { +return name; +} + +public VersionRange getVersionRange() { +return versionRange; +} + +@Override +public String toString() { +return this.name + "/" + this.getVersionRange().toString(); +} +} http://git-wip-us.apache.org/repos/asf/karaf/blob/b84126c6/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java -- diff --git
[2/4] karaf git commit: [KARAF-5300] Add documentation
[KARAF-5300] Add documentation Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/571d6ea3 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/571d6ea3 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/571d6ea3 Branch: refs/heads/master Commit: 571d6ea36408ecfd3dd3b762a43267e115fac18e Parents: b84126c Author: Christian SchneiderAuthored: Thu Aug 10 10:33:22 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 10:58:39 2017 +0200 -- .../karaf/features/internal/service/FeatureReq.java | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/571d6ea3/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java -- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java index 2e1f652..1bac816 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java @@ -22,6 +22,15 @@ import org.osgi.framework.VersionRange; /** * Requirement for a feature + * + * The syntax of a requirement as a String is name[/versionRange]. + * If no versionRange is given then a range of [0,) is assumeed which matches all versions. + * + * + * - name: Can be a feature name or a glob like myfeat* + * - versionRange: version or range + * - version: Will specify a specific version. Like [version,version]. An exemption is 0.0.0 which matches all versions. + * - range: Like defined in OSGi VersionRange. Example: [1.0.0, 1.1.0) */ public class FeatureReq { public static final String VERSION_SEPARATOR = "/"; @@ -57,7 +66,10 @@ public class FeatureReq { } private static VersionRange exactVersion(String versionRange) { -return new VersionRange(VersionRange.LEFT_CLOSED, new Version(versionRange), new Version(versionRange), VersionRange.RIGHT_CLOSED); +return new VersionRange(VersionRange.LEFT_CLOSED, +new Version(versionRange), +new Version(versionRange), +VersionRange.RIGHT_CLOSED); } public FeatureReq(String name, VersionRange versionRange) {
[4/9] karaf git commit: [KARAF-5314] Extract addFeatures into class FeatureSelector
[KARAF-5314] Extract addFeatures into class FeatureSelector Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/0ed141da Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/0ed141da Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/0ed141da Branch: refs/heads/model_features Commit: 0ed141dafd5ffb321bc851886e88457b616c1c06 Parents: 3cbd810 Author: Christian SchneiderAuthored: Sun Aug 20 12:14:31 2017 +0200 Committer: Christian Schneider Committed: Sun Aug 20 12:14:31 2017 +0200 -- .../apache/karaf/profile/assembly/Builder.java | 71 ++- .../karaf/profile/assembly/FeatureSelector.java | 94 2 files changed, 100 insertions(+), 65 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/0ed141da/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java index e9cc67e..2fdd5f0 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java @@ -39,7 +39,6 @@ import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -56,8 +55,6 @@ import java.util.zip.ZipInputStream; import org.apache.felix.resolver.ResolverImpl; import org.apache.felix.utils.manifest.Clause; import org.apache.felix.utils.properties.Properties; -import org.apache.felix.utils.version.VersionRange; -import org.apache.felix.utils.version.VersionTable; import org.apache.karaf.features.FeaturesService; import org.apache.karaf.features.Library; import org.apache.karaf.features.internal.download.DownloadCallback; @@ -89,13 +86,13 @@ import org.apache.karaf.util.maven.Parser; import org.ops4j.pax.url.mvn.MavenResolver; import org.ops4j.pax.url.mvn.MavenResolvers; import org.osgi.framework.Constants; -import org.osgi.framework.Version; import org.osgi.framework.wiring.BundleRevision; import org.osgi.resource.Resource; import org.osgi.service.resolver.Resolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static java.util.Collections.singletonList; import static java.util.jar.JarFile.MANIFEST_NAME; import static org.apache.karaf.features.internal.service.Blacklist.TYPE_REPOSITORY; import static org.apache.karaf.profile.assembly.Builder.Stage.Startup; @@ -804,13 +801,11 @@ public class Builder { for (Features repo : installedRepositories.values()) { allInstalledFeatures.addAll(repo.getFeature()); } -Set installedFeatures = new LinkedHashSet<>(); -Map > featuresCache = new HashMap<>(); + // Add boot features for search allInstalledFeatures.addAll(allBootFeatures); -for (String feature : installedEffective.getFeatures()) { -addFeatures(allInstalledFeatures, feature, installedFeatures, true, featuresCache); -} +FeatureSelector selector = new FeatureSelector(allInstalledFeatures); +Set installedFeatures = selector.selectMatching(installedEffective.getFeatures()); ArtifactInstaller installer = new ArtifactInstaller(systemDirectory, downloader, blacklistedBundles); for (Feature feature : installedFeatures) { LOGGER.info(" Feature {} is defined as an installed feature", feature.getId()); @@ -882,9 +877,8 @@ public class Builder { Downloader downloader = manager.createDownloader(); // Compute startup feature dependencies -Set bootFeatures = new HashSet<>(); -Map > featuresCache = new HashMap<>(); -addFeatures(allBootFeatures, generated.getName(), bootFeatures, true, featuresCache); +FeatureSelector selector = new FeatureSelector(allBootFeatures); +Set bootFeatures = selector.selectMatching(singletonList(generated.getName())); for (Feature feature : bootFeatures) { // the feature is a startup feature, updating startup.properties file LOGGER.info(" Feature " + feature.getId() + " is defined as a boot feature"); @@ -1241,57 +1235,6 @@ public class Builder { return startupEffective; } -private void addFeatures(Set allFeatures, String feature, Set features, boolean mandatory, Map > featuresCache) { -String name; -Version osgiVersion; -VersionRange range; -
[9/9] karaf git commit: [KARAF-5300] Use FeatureReq instead of string for FeaturesService
[KARAF-5300] Use FeatureReq instead of string for FeaturesService Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/b84126c6 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/b84126c6 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/b84126c6 Branch: refs/heads/model_features Commit: b84126c6cc91bdb46a4a24cef76e037f206d1140 Parents: 5a8133d Author: Christian SchneiderAuthored: Wed Aug 9 17:39:06 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 10:58:39 2017 +0200 -- .../features/internal/service/FeatureReq.java | 84 .../internal/service/FeaturesServiceImpl.java | 204 --- .../service/FeaturesServiceImplTest.java| 46 - .../karaf/features/internal/service/f09.xml | 24 +++ 4 files changed, 229 insertions(+), 129 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/b84126c6/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java -- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java new file mode 100644 index 000..2e1f652 --- /dev/null +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java @@ -0,0 +1,84 @@ +/* + * 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.karaf.features.internal.service; + +import org.apache.karaf.features.Feature; +import org.osgi.framework.Version; +import org.osgi.framework.VersionRange; + +/** + * Requirement for a feature + */ +public class FeatureReq { +public static final String VERSION_SEPARATOR = "/"; +private static Version HIGHEST = new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); +private static final VersionRange RANGE_ALL = new VersionRange(VersionRange.LEFT_CLOSED, Version.emptyVersion, HIGHEST, VersionRange.RIGHT_CLOSED); +private String name; +private VersionRange versionRange; + +public FeatureReq(String nameAndRange) { +String[] parts = nameAndRange.trim().split(VERSION_SEPARATOR); +this.name = parts[0]; +this.versionRange = (parts.length == 1) ? RANGE_ALL : range(parts[1]); +} + +public FeatureReq(String name, String versionRange) { +this.name = name; +this.versionRange = range(versionRange); +} + +private VersionRange range(String versionRange) { +if (versionRange == null) { +return RANGE_ALL; +} +versionRange = versionRange.trim(); +if ("0.0.0".equals(versionRange)) { +return RANGE_ALL; +} +if (versionRange.contains(",")) { +return new VersionRange(versionRange); +} else { +return exactVersion(versionRange); +} +} + +private static VersionRange exactVersion(String versionRange) { +return new VersionRange(VersionRange.LEFT_CLOSED, new Version(versionRange), new Version(versionRange), VersionRange.RIGHT_CLOSED); +} + +public FeatureReq(String name, VersionRange versionRange) { +this.name = name; +this.versionRange = versionRange; +} + +public FeatureReq(Feature feature) { +this(feature.getName(), exactVersion(feature.getVersion())); +} + +public String getName() { +return name; +} + +public VersionRange getVersionRange() { +return versionRange; +} + +@Override +public String toString() { +return this.name + "/" + this.getVersionRange().toString(); +} +} http://git-wip-us.apache.org/repos/asf/karaf/blob/b84126c6/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java -- diff --git
[8/9] karaf git commit: [KARAF-5300] Split install into add and upgrade
[KARAF-5300] Split install into add and upgrade Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/4328939b Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/4328939b Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/4328939b Branch: refs/heads/model_features Commit: 4328939b10fd970cdde77bb52d523cae9eb1a044 Parents: 571d6ea Author: Christian SchneiderAuthored: Thu Aug 10 11:23:10 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 10:58:39 2017 +0200 -- .../internal/service/FeaturesServiceImpl.java | 114 +-- 1 file changed, 55 insertions(+), 59 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/4328939b/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 5562390..2767bc8 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 @@ -83,6 +83,8 @@ import org.osgi.service.resolver.Resolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static java.util.Collections.emptyMap; +import static java.util.stream.Collectors.toSet; import static org.apache.karaf.features.internal.service.StateStorage.toStringStringSetMap; import static org.apache.karaf.features.internal.util.MapUtils.add; import static org.apache.karaf.features.internal.util.MapUtils.copy; @@ -787,28 +789,39 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall @Override public void installFeatures(Set featuresIn, String region, EnumSet options) throws Exception { -Set featureReqs = new HashSet<>(); +Set toInstall = new HashSet<>(); for (String feature : featuresIn) { -featureReqs.add(new FeatureReq(feature)); +toInstall.add(new FeatureReq(feature)); } State state = copyState(); Map requires = copy(state.requirements); if (region == null || region.isEmpty()) { region = ROOT_REGION; } -Set requiredForRegion = requires.computeIfAbsent(region, k -> new HashSet<>()); -computeRequirements(options, featureReqs, requiredForRegion); -Map > stateChanges = Collections.emptyMap(); -doProvisionInThread(requires, stateChanges, state, getFeaturesById(), options); -} +Set requirements = requires.computeIfAbsent(region, k -> new HashSet<>()); +Set existingFeatures = requirements.stream().map(r -> toFeatureReq(r)).collect(toSet()); + +Set toAdd = computeFeaturesToAdd(options, toInstall); +toAdd.stream().forEach(f -> requirements.add(toRequirement(f))); +print("Adding features: " + join(toAdd), options.contains(Option.Verbose)); + +if (options.contains(Option.Upgrade)) { +Set toRemove = computeFeaturesToRemoveOnUpdate(toAdd, existingFeatures); +toRemove.stream().forEach(f -> requirements.remove(toRequirement(f))); +if (!toRemove.isEmpty()) { +print("Removing features: " + join(toRemove), options.contains(Option.Verbose)); +} +} -void computeRequirements(EnumSet options, Set featureReqs, - Set requirements) -throws Exception { +doProvisionInThread(requires, emptyMap(), state, getFeaturesById(), options); +} + +private Set computeFeaturesToAdd(EnumSet options, + Set toInstall) throws Exception { +Feature[] installedFeatures = listInstalledFeatures(); Map > allFeatures = getFeatureCache(); -List featuresToAdd = new ArrayList<>(); -List featuresToRemove = new ArrayList<>(); -for (FeatureReq feature : featureReqs) { +Set toAdd = new HashSet<>(); +for (FeatureReq feature : toInstall) { Pattern pattern = Pattern.compile(feature.getName()); boolean matched = false; for (String fKey : allFeatures.keySet()) { @@ -816,8 +829,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall if (matcher.matches()) { Feature f = getFeatureMatching(fKey, feature.getVersionRange()); if
[2/9] karaf git commit: Update assembly, dependency and war plugins
Update assembly, dependency and war plugins Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/658ee488 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/658ee488 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/658ee488 Branch: refs/heads/model_features Commit: 658ee488febb5d2fc5bbfa7402c49e87d4078699 Parents: ebf22fb Author: Christian SchneiderAuthored: Fri Aug 18 23:07:02 2017 +0200 Committer: Christian Schneider Committed: Fri Aug 18 23:14:05 2017 +0200 -- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/658ee488/pom.xml -- diff --git a/pom.xml b/pom.xml index 45271e1..d23cc25 100644 --- a/pom.xml +++ b/pom.xml @@ -1890,7 +1890,7 @@ org.apache.maven.plugins maven-assembly-plugin -3.0.0 +3.1.0 org.apache.maven.plugins @@ -1933,7 +1933,7 @@ org.apache.maven.plugins maven-dependency-plugin -3.0.0 +3.0.1 org.codehaus.mojo @@ -1948,7 +1948,7 @@ org.apache.maven.plugins maven-war-plugin -3.0.0 +3.1.0 org.apache.karaf.tooling
[5/9] karaf git commit: [KARAF-5314] Only recurse into dependencies once per feature
[KARAF-5314] Only recurse into dependencies once per feature Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/5a8133db Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/5a8133db Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/5a8133db Branch: refs/heads/model_features Commit: 5a8133dbbfe7ede7366bcb943e2bd04937d8eff5 Parents: 0ed141d Author: Christian SchneiderAuthored: Sun Aug 20 16:20:09 2017 +0200 Committer: Christian Schneider Committed: Sun Aug 20 16:20:09 2017 +0200 -- .../org/apache/karaf/profile/assembly/FeatureSelector.java| 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/5a8133db/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java b/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java index 1e453d6..156cb46 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java @@ -55,9 +55,10 @@ public class FeatureSelector { throw new IllegalStateException("Could not find matching feature for " + feature); } for (Feature f : set) { -features.add(f); -for (Dependency dep : f.getFeature()) { -addFeatures(dep.toString(), features, isMandatory(dep)); +if (features.add(f)) { +for (Dependency dep : f.getFeature()) { +addFeatures(dep.toString(), features, isMandatory(dep)); +} } } }
[7/9] karaf git commit: [KARAF-5300] Reuse and extract feature matching code
[KARAF-5300] Reuse and extract feature matching code Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/1c4149b6 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/1c4149b6 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/1c4149b6 Branch: refs/heads/model_features Commit: 1c4149b6f510be94522b4bfa529b163c610f87a3 Parents: 4328939 Author: Christian SchneiderAuthored: Thu Aug 10 15:30:59 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 10:58:39 2017 +0200 -- .../internal/service/FeaturesServiceImpl.java | 79 +++- 1 file changed, 43 insertions(+), 36 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/1c4149b6/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 2767bc8..574998a 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 @@ -520,15 +520,15 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall @Override public Feature[] getFeatures(String nameOrId) throws Exception { -return getFeatures(new FeatureReq(nameOrId)); +return toArray(getFeatures(new FeatureReq(nameOrId))); } @Override public Feature[] getFeatures(String name, String version) throws Exception { -return getFeatures(new FeatureReq(name, version)); +return toArray(getFeatures(new FeatureReq(name, version))); } -private Feature[] getFeatures(FeatureReq featureReq) throws Exception { +private Collection getFeatures(FeatureReq featureReq) throws Exception { List features = new ArrayList<>(); Pattern pattern = Pattern.compile(featureReq.getName()); Map > allFeatures = getFeatureCache(); @@ -541,6 +541,10 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall } } } +return features; +} + +private Feature[] toArray(Collection features) { return features.toArray(new Feature[features.size()]); } @@ -819,33 +823,33 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall private Set computeFeaturesToAdd(EnumSet options, Set toInstall) throws Exception { Feature[] installedFeatures = listInstalledFeatures(); -Map > allFeatures = getFeatureCache(); Set toAdd = new HashSet<>(); -for (FeatureReq feature : toInstall) { -Pattern pattern = Pattern.compile(feature.getName()); -boolean matched = false; -for (String fKey : allFeatures.keySet()) { -Matcher matcher = pattern.matcher(fKey); -if (matcher.matches()) { -Feature f = getFeatureMatching(fKey, feature.getVersionRange()); -if (f != null) { -toAdd.add(new FeatureReq(f)); -for (Feature installedFeature : installedFeatures) { -if (installedFeature.getName().equals(f.getName()) && installedFeature.getVersion().equals(f.getVersion())) { -LOGGER.info("The specified feature: '{}' version '{}' {}",f.getName(),f.getVersion(),f.getVersion().endsWith("SNAPSHOT") ? "has been upgraded": "is already installed"); -} -} -matched = true; +for (FeatureReq featureReq : toInstall) { +Collection matching = getFeatures(featureReq); +for (Feature f: matching) { +toAdd.add(new FeatureReq(f)); +for (Feature installedFeature : installedFeatures) { +if (isSameFeature(f, installedFeature)) { +logInstalledOrUpdated(f); } } } -if (!matched && !options.contains(Option.NoFailOnFeatureNotFound)) { -throw new IllegalArgumentException("No matching features for " + feature); +if (matching.isEmpty() && !options.contains(Option.NoFailOnFeatureNotFound)) { +throw new IllegalArgumentException("No matching features for " +
[3/9] karaf git commit: KARAF-5314 Added a features cache that increases the performance of the filtering of the required features from the available features.
KARAF-5314 Added a features cache that increases the performance of the filtering of the required features from the available features. The performance of the filtering logic decresed when the java streams API was used in 4.1 compared to for loops in 4.0. I reverted the filtering logic to use for loops and also introduced a features cache. This increased the performance by a huge margin, almost 20X faster when there are ~900 available features and ~300 required features from a highly complex and huge feature dependency tree. Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/3cbd810e Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/3cbd810e Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/3cbd810e Branch: refs/heads/model_features Commit: 3cbd810ea37e837950f1f8427f793c878423ba7a Parents: 658ee48 Author: Vinay Shankar (e24113)Authored: Fri Aug 18 13:55:58 2017 -0500 Committer: Christian Schneider Committed: Fri Aug 18 23:22:25 2017 +0200 -- .../apache/karaf/profile/assembly/Builder.java | 38 +++- 1 file changed, 30 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/3cbd810e/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java index 27b83a6..e9cc67e 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java @@ -39,6 +39,7 @@ import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -49,7 +50,6 @@ import java.util.function.Function; import java.util.jar.Attributes; import java.util.jar.Manifest; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -805,10 +805,11 @@ public class Builder { allInstalledFeatures.addAll(repo.getFeature()); } Set installedFeatures = new LinkedHashSet<>(); +Map > featuresCache = new HashMap<>(); // Add boot features for search allInstalledFeatures.addAll(allBootFeatures); for (String feature : installedEffective.getFeatures()) { -addFeatures(allInstalledFeatures, feature, installedFeatures, true); +addFeatures(allInstalledFeatures, feature, installedFeatures, true, featuresCache); } ArtifactInstaller installer = new ArtifactInstaller(systemDirectory, downloader, blacklistedBundles); for (Feature feature : installedFeatures) { @@ -882,7 +883,8 @@ public class Builder { // Compute startup feature dependencies Set bootFeatures = new HashSet<>(); -addFeatures(allBootFeatures, generated.getName(), bootFeatures, true); +Map > featuresCache = new HashMap<>(); +addFeatures(allBootFeatures, generated.getName(), bootFeatures, true, featuresCache); for (Feature feature : bootFeatures) { // the feature is a startup feature, updating startup.properties file LOGGER.info(" Feature " + feature.getId() + " is defined as a boot feature"); @@ -1239,14 +1241,16 @@ public class Builder { return startupEffective; } -private void addFeatures(Set allFeatures, String feature, Set features, boolean mandatory) { +private void addFeatures(Set allFeatures, String feature, Set features, boolean mandatory, Map > featuresCache) { String name; +Version osgiVersion; VersionRange range; int idx = feature.indexOf('/'); if (idx > 0) { name = feature.substring(0, idx); String version = feature.substring(idx + 1); version = version.trim(); +osgiVersion = VersionTable.getVersion(version); if (version.equals(org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION)) { range = new VersionRange(Version.emptyVersion); } else { @@ -1254,18 +1258,36 @@ public class Builder { } } else { name = feature; +osgiVersion = Version.emptyVersion; range = new VersionRange(Version.emptyVersion); } -Set set = allFeatures.stream() -.filter(f -> f.getName().equals(name) &&
[6/9] karaf git commit: [KARAF-5300] Add documentation
[KARAF-5300] Add documentation Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/571d6ea3 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/571d6ea3 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/571d6ea3 Branch: refs/heads/model_features Commit: 571d6ea36408ecfd3dd3b762a43267e115fac18e Parents: b84126c Author: Christian SchneiderAuthored: Thu Aug 10 10:33:22 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 21 10:58:39 2017 +0200 -- .../karaf/features/internal/service/FeatureReq.java | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/571d6ea3/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java -- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java index 2e1f652..1bac816 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java @@ -22,6 +22,15 @@ import org.osgi.framework.VersionRange; /** * Requirement for a feature + * + * The syntax of a requirement as a String is name[/versionRange]. + * If no versionRange is given then a range of [0,) is assumeed which matches all versions. + * + * + * - name: Can be a feature name or a glob like myfeat* + * - versionRange: version or range + * - version: Will specify a specific version. Like [version,version]. An exemption is 0.0.0 which matches all versions. + * - range: Like defined in OSGi VersionRange. Example: [1.0.0, 1.1.0) */ public class FeatureReq { public static final String VERSION_SEPARATOR = "/"; @@ -57,7 +66,10 @@ public class FeatureReq { } private static VersionRange exactVersion(String versionRange) { -return new VersionRange(VersionRange.LEFT_CLOSED, new Version(versionRange), new Version(versionRange), VersionRange.RIGHT_CLOSED); +return new VersionRange(VersionRange.LEFT_CLOSED, +new Version(versionRange), +new Version(versionRange), +VersionRange.RIGHT_CLOSED); } public FeatureReq(String name, VersionRange versionRange) {
[1/9] karaf git commit: Remove lifecycle ignore as the current plugin version should be integrated with eclipse [Forced Update!]
Repository: karaf Updated Branches: refs/heads/model_features 8b1cc7bf8 -> 1c4149b6f (forced update) Remove lifecycle ignore as the current plugin version should be integrated with eclipse Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/ebf22fb3 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/ebf22fb3 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/ebf22fb3 Branch: refs/heads/model_features Commit: ebf22fb3a56c2b367ef34bda31e3ff39309b7b2d Parents: 8f94e29 Author: Christian SchneiderAuthored: Fri Aug 18 23:12:58 2017 +0200 Committer: Christian Schneider Committed: Fri Aug 18 23:13:51 2017 +0200 -- pom.xml | 13 - 1 file changed, 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/ebf22fb3/pom.xml -- diff --git a/pom.xml b/pom.xml index 9ff6755..45271e1 100644 --- a/pom.xml +++ b/pom.xml @@ -2015,19 +2015,6 @@ - - - org.apache.servicemix.tooling - depends-maven-plugin -[0,) - -generate-depends-file - - - - - -
[karaf] Git Push Summary
Repository: karaf Updated Branches: refs/heads/KARAF-5314-2 [deleted] 5a8133dbb
[1/3] karaf git commit: KARAF-5314 Added a features cache that increases the performance of the filtering of the required features from the available features.
Repository: karaf Updated Branches: refs/heads/master 658ee488f -> 5a8133dbb KARAF-5314 Added a features cache that increases the performance of the filtering of the required features from the available features. The performance of the filtering logic decresed when the java streams API was used in 4.1 compared to for loops in 4.0. I reverted the filtering logic to use for loops and also introduced a features cache. This increased the performance by a huge margin, almost 20X faster when there are ~900 available features and ~300 required features from a highly complex and huge feature dependency tree. Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/3cbd810e Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/3cbd810e Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/3cbd810e Branch: refs/heads/master Commit: 3cbd810ea37e837950f1f8427f793c878423ba7a Parents: 658ee48 Author: Vinay Shankar (e24113)Authored: Fri Aug 18 13:55:58 2017 -0500 Committer: Christian Schneider Committed: Fri Aug 18 23:22:25 2017 +0200 -- .../apache/karaf/profile/assembly/Builder.java | 38 +++- 1 file changed, 30 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/3cbd810e/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java index 27b83a6..e9cc67e 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java @@ -39,6 +39,7 @@ import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -49,7 +50,6 @@ import java.util.function.Function; import java.util.jar.Attributes; import java.util.jar.Manifest; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -805,10 +805,11 @@ public class Builder { allInstalledFeatures.addAll(repo.getFeature()); } Set installedFeatures = new LinkedHashSet<>(); +Map > featuresCache = new HashMap<>(); // Add boot features for search allInstalledFeatures.addAll(allBootFeatures); for (String feature : installedEffective.getFeatures()) { -addFeatures(allInstalledFeatures, feature, installedFeatures, true); +addFeatures(allInstalledFeatures, feature, installedFeatures, true, featuresCache); } ArtifactInstaller installer = new ArtifactInstaller(systemDirectory, downloader, blacklistedBundles); for (Feature feature : installedFeatures) { @@ -882,7 +883,8 @@ public class Builder { // Compute startup feature dependencies Set bootFeatures = new HashSet<>(); -addFeatures(allBootFeatures, generated.getName(), bootFeatures, true); +Map > featuresCache = new HashMap<>(); +addFeatures(allBootFeatures, generated.getName(), bootFeatures, true, featuresCache); for (Feature feature : bootFeatures) { // the feature is a startup feature, updating startup.properties file LOGGER.info(" Feature " + feature.getId() + " is defined as a boot feature"); @@ -1239,14 +1241,16 @@ public class Builder { return startupEffective; } -private void addFeatures(Set allFeatures, String feature, Set features, boolean mandatory) { +private void addFeatures(Set allFeatures, String feature, Set features, boolean mandatory, Map > featuresCache) { String name; +Version osgiVersion; VersionRange range; int idx = feature.indexOf('/'); if (idx > 0) { name = feature.substring(0, idx); String version = feature.substring(idx + 1); version = version.trim(); +osgiVersion = VersionTable.getVersion(version); if (version.equals(org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION)) { range = new VersionRange(Version.emptyVersion); } else { @@ -1254,18 +1258,36 @@ public class Builder { } } else { name = feature; +osgiVersion = Version.emptyVersion; range = new VersionRange(Version.emptyVersion); } -Set set =
[2/3] karaf git commit: [KARAF-5314] Extract addFeatures into class FeatureSelector
[KARAF-5314] Extract addFeatures into class FeatureSelector Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/0ed141da Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/0ed141da Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/0ed141da Branch: refs/heads/master Commit: 0ed141dafd5ffb321bc851886e88457b616c1c06 Parents: 3cbd810 Author: Christian SchneiderAuthored: Sun Aug 20 12:14:31 2017 +0200 Committer: Christian Schneider Committed: Sun Aug 20 12:14:31 2017 +0200 -- .../apache/karaf/profile/assembly/Builder.java | 71 ++- .../karaf/profile/assembly/FeatureSelector.java | 94 2 files changed, 100 insertions(+), 65 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/0ed141da/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java index e9cc67e..2fdd5f0 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java @@ -39,7 +39,6 @@ import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -56,8 +55,6 @@ import java.util.zip.ZipInputStream; import org.apache.felix.resolver.ResolverImpl; import org.apache.felix.utils.manifest.Clause; import org.apache.felix.utils.properties.Properties; -import org.apache.felix.utils.version.VersionRange; -import org.apache.felix.utils.version.VersionTable; import org.apache.karaf.features.FeaturesService; import org.apache.karaf.features.Library; import org.apache.karaf.features.internal.download.DownloadCallback; @@ -89,13 +86,13 @@ import org.apache.karaf.util.maven.Parser; import org.ops4j.pax.url.mvn.MavenResolver; import org.ops4j.pax.url.mvn.MavenResolvers; import org.osgi.framework.Constants; -import org.osgi.framework.Version; import org.osgi.framework.wiring.BundleRevision; import org.osgi.resource.Resource; import org.osgi.service.resolver.Resolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static java.util.Collections.singletonList; import static java.util.jar.JarFile.MANIFEST_NAME; import static org.apache.karaf.features.internal.service.Blacklist.TYPE_REPOSITORY; import static org.apache.karaf.profile.assembly.Builder.Stage.Startup; @@ -804,13 +801,11 @@ public class Builder { for (Features repo : installedRepositories.values()) { allInstalledFeatures.addAll(repo.getFeature()); } -Set installedFeatures = new LinkedHashSet<>(); -Map > featuresCache = new HashMap<>(); + // Add boot features for search allInstalledFeatures.addAll(allBootFeatures); -for (String feature : installedEffective.getFeatures()) { -addFeatures(allInstalledFeatures, feature, installedFeatures, true, featuresCache); -} +FeatureSelector selector = new FeatureSelector(allInstalledFeatures); +Set installedFeatures = selector.selectMatching(installedEffective.getFeatures()); ArtifactInstaller installer = new ArtifactInstaller(systemDirectory, downloader, blacklistedBundles); for (Feature feature : installedFeatures) { LOGGER.info(" Feature {} is defined as an installed feature", feature.getId()); @@ -882,9 +877,8 @@ public class Builder { Downloader downloader = manager.createDownloader(); // Compute startup feature dependencies -Set bootFeatures = new HashSet<>(); -Map > featuresCache = new HashMap<>(); -addFeatures(allBootFeatures, generated.getName(), bootFeatures, true, featuresCache); +FeatureSelector selector = new FeatureSelector(allBootFeatures); +Set bootFeatures = selector.selectMatching(singletonList(generated.getName())); for (Feature feature : bootFeatures) { // the feature is a startup feature, updating startup.properties file LOGGER.info(" Feature " + feature.getId() + " is defined as a boot feature"); @@ -1241,57 +1235,6 @@ public class Builder { return startupEffective; } -private void addFeatures(Set allFeatures, String feature, Set features, boolean mandatory, Map > featuresCache) { -String name; -Version osgiVersion; -VersionRange range; -int
[3/3] karaf git commit: [KARAF-5314] Only recurse into dependencies once per feature
[KARAF-5314] Only recurse into dependencies once per feature Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/5a8133db Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/5a8133db Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/5a8133db Branch: refs/heads/master Commit: 5a8133dbbfe7ede7366bcb943e2bd04937d8eff5 Parents: 0ed141d Author: Christian SchneiderAuthored: Sun Aug 20 16:20:09 2017 +0200 Committer: Christian Schneider Committed: Sun Aug 20 16:20:09 2017 +0200 -- .../org/apache/karaf/profile/assembly/FeatureSelector.java| 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/5a8133db/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java b/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java index 1e453d6..156cb46 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java @@ -55,9 +55,10 @@ public class FeatureSelector { throw new IllegalStateException("Could not find matching feature for " + feature); } for (Feature f : set) { -features.add(f); -for (Dependency dep : f.getFeature()) { -addFeatures(dep.toString(), features, isMandatory(dep)); +if (features.add(f)) { +for (Dependency dep : f.getFeature()) { +addFeatures(dep.toString(), features, isMandatory(dep)); +} } } }
karaf git commit: [KARAF-5314] Only recurse into dependencies once per feature
Repository: karaf Updated Branches: refs/heads/KARAF-5314-2 0ed141daf -> 5a8133dbb [KARAF-5314] Only recurse into dependencies once per feature Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/5a8133db Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/5a8133db Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/5a8133db Branch: refs/heads/KARAF-5314-2 Commit: 5a8133dbbfe7ede7366bcb943e2bd04937d8eff5 Parents: 0ed141d Author: Christian SchneiderAuthored: Sun Aug 20 16:20:09 2017 +0200 Committer: Christian Schneider Committed: Sun Aug 20 16:20:09 2017 +0200 -- .../org/apache/karaf/profile/assembly/FeatureSelector.java| 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/5a8133db/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java b/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java index 1e453d6..156cb46 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/FeatureSelector.java @@ -55,9 +55,10 @@ public class FeatureSelector { throw new IllegalStateException("Could not find matching feature for " + feature); } for (Feature f : set) { -features.add(f); -for (Dependency dep : f.getFeature()) { -addFeatures(dep.toString(), features, isMandatory(dep)); +if (features.add(f)) { +for (Dependency dep : f.getFeature()) { +addFeatures(dep.toString(), features, isMandatory(dep)); +} } } }
[1/2] karaf git commit: KARAF-5314 Added a features cache that increases the performance of the filtering of the required features from the available features.
Repository: karaf Updated Branches: refs/heads/KARAF-5314-2 [created] 0ed141daf KARAF-5314 Added a features cache that increases the performance of the filtering of the required features from the available features. The performance of the filtering logic decresed when the java streams API was used in 4.1 compared to for loops in 4.0. I reverted the filtering logic to use for loops and also introduced a features cache. This increased the performance by a huge margin, almost 20X faster when there are ~900 available features and ~300 required features from a highly complex and huge feature dependency tree. Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/3cbd810e Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/3cbd810e Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/3cbd810e Branch: refs/heads/KARAF-5314-2 Commit: 3cbd810ea37e837950f1f8427f793c878423ba7a Parents: 658ee48 Author: Vinay Shankar (e24113)Authored: Fri Aug 18 13:55:58 2017 -0500 Committer: Christian Schneider Committed: Fri Aug 18 23:22:25 2017 +0200 -- .../apache/karaf/profile/assembly/Builder.java | 38 +++- 1 file changed, 30 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/3cbd810e/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java -- diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java index 27b83a6..e9cc67e 100644 --- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java +++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java @@ -39,6 +39,7 @@ import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; @@ -49,7 +50,6 @@ import java.util.function.Function; import java.util.jar.Attributes; import java.util.jar.Manifest; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; @@ -805,10 +805,11 @@ public class Builder { allInstalledFeatures.addAll(repo.getFeature()); } Set installedFeatures = new LinkedHashSet<>(); +Map > featuresCache = new HashMap<>(); // Add boot features for search allInstalledFeatures.addAll(allBootFeatures); for (String feature : installedEffective.getFeatures()) { -addFeatures(allInstalledFeatures, feature, installedFeatures, true); +addFeatures(allInstalledFeatures, feature, installedFeatures, true, featuresCache); } ArtifactInstaller installer = new ArtifactInstaller(systemDirectory, downloader, blacklistedBundles); for (Feature feature : installedFeatures) { @@ -882,7 +883,8 @@ public class Builder { // Compute startup feature dependencies Set bootFeatures = new HashSet<>(); -addFeatures(allBootFeatures, generated.getName(), bootFeatures, true); +Map > featuresCache = new HashMap<>(); +addFeatures(allBootFeatures, generated.getName(), bootFeatures, true, featuresCache); for (Feature feature : bootFeatures) { // the feature is a startup feature, updating startup.properties file LOGGER.info(" Feature " + feature.getId() + " is defined as a boot feature"); @@ -1239,14 +1241,16 @@ public class Builder { return startupEffective; } -private void addFeatures(Set allFeatures, String feature, Set features, boolean mandatory) { +private void addFeatures(Set allFeatures, String feature, Set features, boolean mandatory, Map > featuresCache) { String name; +Version osgiVersion; VersionRange range; int idx = feature.indexOf('/'); if (idx > 0) { name = feature.substring(0, idx); String version = feature.substring(idx + 1); version = version.trim(); +osgiVersion = VersionTable.getVersion(version); if (version.equals(org.apache.karaf.features.internal.model.Feature.DEFAULT_VERSION)) { range = new VersionRange(Version.emptyVersion); } else { @@ -1254,18 +1258,36 @@ public class Builder { } } else { name = feature; +osgiVersion = Version.emptyVersion; range = new VersionRange(Version.emptyVersion); } -Set set =
[1/2] karaf git commit: Remove lifecycle ignore as the current plugin version should be integrated with eclipse
Repository: karaf Updated Branches: refs/heads/master 8f94e291d -> 658ee488f Remove lifecycle ignore as the current plugin version should be integrated with eclipse Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/ebf22fb3 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/ebf22fb3 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/ebf22fb3 Branch: refs/heads/master Commit: ebf22fb3a56c2b367ef34bda31e3ff39309b7b2d Parents: 8f94e29 Author: Christian SchneiderAuthored: Fri Aug 18 23:12:58 2017 +0200 Committer: Christian Schneider Committed: Fri Aug 18 23:13:51 2017 +0200 -- pom.xml | 13 - 1 file changed, 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/ebf22fb3/pom.xml -- diff --git a/pom.xml b/pom.xml index 9ff6755..45271e1 100644 --- a/pom.xml +++ b/pom.xml @@ -2015,19 +2015,6 @@ - - - org.apache.servicemix.tooling - depends-maven-plugin -[0,) - -generate-depends-file - - - - - -
[2/2] karaf git commit: Update assembly, dependency and war plugins
Update assembly, dependency and war plugins Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/658ee488 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/658ee488 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/658ee488 Branch: refs/heads/master Commit: 658ee488febb5d2fc5bbfa7402c49e87d4078699 Parents: ebf22fb Author: Christian SchneiderAuthored: Fri Aug 18 23:07:02 2017 +0200 Committer: Christian Schneider Committed: Fri Aug 18 23:14:05 2017 +0200 -- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/658ee488/pom.xml -- diff --git a/pom.xml b/pom.xml index 45271e1..d23cc25 100644 --- a/pom.xml +++ b/pom.xml @@ -1890,7 +1890,7 @@ org.apache.maven.plugins maven-assembly-plugin -3.0.0 +3.1.0 org.apache.maven.plugins @@ -1933,7 +1933,7 @@ org.apache.maven.plugins maven-dependency-plugin -3.0.0 +3.0.1 org.codehaus.mojo @@ -1948,7 +1948,7 @@ org.apache.maven.plugins maven-war-plugin -3.0.0 +3.1.0 org.apache.karaf.tooling
[1/2] karaf git commit: Update assembly, dependency and war plugins
Repository: karaf Updated Branches: refs/heads/model_features 6576f4765 -> 8b1cc7bf8 Update assembly, dependency and war plugins Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/6baf97cb Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/6baf97cb Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/6baf97cb Branch: refs/heads/model_features Commit: 6baf97cb1239590bf6092542e3f115575fa5577e Parents: 6576f47 Author: Christian SchneiderAuthored: Fri Aug 18 23:07:02 2017 +0200 Committer: Christian Schneider Committed: Fri Aug 18 23:07:02 2017 +0200 -- pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/6baf97cb/pom.xml -- diff --git a/pom.xml b/pom.xml index 9ff6755..5bd8afb 100644 --- a/pom.xml +++ b/pom.xml @@ -1890,7 +1890,7 @@ org.apache.maven.plugins maven-assembly-plugin -3.0.0 +3.1.0 org.apache.maven.plugins @@ -1933,7 +1933,7 @@ org.apache.maven.plugins maven-dependency-plugin -3.0.0 +3.0.1 org.codehaus.mojo @@ -1948,7 +1948,7 @@ org.apache.maven.plugins maven-war-plugin -3.0.0 +3.1.0 org.apache.karaf.tooling
[2/2] karaf git commit: Remove lifecycle ignore as the current plugin version should be integrated with eclipse
Remove lifecycle ignore as the current plugin version should be integrated with eclipse Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/8b1cc7bf Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/8b1cc7bf Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/8b1cc7bf Branch: refs/heads/model_features Commit: 8b1cc7bf8f56b0aceca1c19521322a30263353d2 Parents: 6baf97c Author: Christian SchneiderAuthored: Fri Aug 18 23:12:58 2017 +0200 Committer: Christian Schneider Committed: Fri Aug 18 23:12:58 2017 +0200 -- pom.xml | 13 - 1 file changed, 13 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/8b1cc7bf/pom.xml -- diff --git a/pom.xml b/pom.xml index 5bd8afb..d23cc25 100644 --- a/pom.xml +++ b/pom.xml @@ -2015,19 +2015,6 @@ - - - org.apache.servicemix.tooling - depends-maven-plugin -[0,) - -generate-depends-file - - - - - -
[06/27] karaf git commit: Extract port update into class
Extract port update into class Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/ecf6a8dc Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/ecf6a8dc Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/ecf6a8dc Branch: refs/heads/model_features Commit: ecf6a8dc79cb6f36054f13376772428d9d58634e Parents: 8a18da5 Author: Christian SchneiderAuthored: Tue Aug 15 16:41:45 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 16:41:45 2017 +0200 -- .../karaf/jaas/modules/ldap/LdapCacheTest.java | 26 +- .../modules/ldap/LdapCaseInsensitiveDNTest.java | 28 +- .../jaas/modules/ldap/LdapLoginModuleTest.java | 31 +-- .../ldap/LdapLoginModuleWithEscapesTest.java| 32 +--- .../jaas/modules/ldap/LdapPropsUpdater.java | 54 .../ldap/LdapSpecialCharsInPasswordTest.java| 26 +- 6 files changed, 61 insertions(+), 136 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/ecf6a8dc/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCacheTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCacheTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCacheTest.java index 87dde8f..1b88a16 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCacheTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCacheTest.java @@ -23,12 +23,9 @@ import javax.naming.directory.DirContext; import javax.security.auth.Subject; import javax.security.auth.callback.CallbackHandler; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.security.Principal; -import org.apache.commons.io.IOUtils; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; import org.apache.directory.server.core.annotations.ApplyLdifFiles; @@ -57,30 +54,9 @@ import static org.junit.Assert.assertTrue; ) public class LdapCacheTest extends AbstractLdapTestUnit { -private static boolean portUpdated; - @Before public void updatePort() throws Exception { -if (!portUpdated) { -String basedir = System.getProperty("basedir"); -if (basedir == null) { -basedir = new File(".").getCanonicalPath(); -} - -// Read in ldap.properties and substitute in the correct port -File f = new File(basedir + "/src/test/resources/org/apache/karaf/jaas/modules/ldap/ldap.properties"); - -FileInputStream inputStream = new FileInputStream(f); -String content = IOUtils.toString(inputStream, "UTF-8"); -inputStream.close(); -content = content.replaceAll("portno", "" + getLdapServer().getPort()); - -File f2 = new File(basedir + "/target/test-classes/org/apache/karaf/jaas/modules/ldap/ldap.properties"); -FileOutputStream outputStream = new FileOutputStream(f2); -IOUtils.write(content, outputStream, "UTF-8"); -outputStream.close(); -portUpdated = true; -} + LdapPropsUpdater.updatePort("org/apache/karaf/jaas/modules/ldap/ldap.properties", getLdapServer().getPort()); } @After http://git-wip-us.apache.org/repos/asf/karaf/blob/ecf6a8dc/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCaseInsensitiveDNTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCaseInsensitiveDNTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCaseInsensitiveDNTest.java index e4d2035..bcf460d 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCaseInsensitiveDNTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCaseInsensitiveDNTest.java @@ -19,20 +19,17 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.security.Principal; import javax.security.auth.Subject; -import org.apache.commons.io.IOUtils; -import org.apache.directory.server.core.integ.FrameworkRunner; import org.apache.directory.server.annotations.CreateLdapServer; import org.apache.directory.server.annotations.CreateTransport; import org.apache.directory.server.core.annotations.ApplyLdifFiles; import
[19/27] karaf git commit: Avoid using commons io. Allow to specify replacement function
Avoid using commons io. Allow to specify replacement function Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/fd743966 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/fd743966 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/fd743966 Branch: refs/heads/model_features Commit: fd74396648a0bb42ba2d01c5bed1c6c7bbef1694 Parents: 0853a35 Author: Christian SchneiderAuthored: Wed Aug 16 14:16:53 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 14:16:53 2017 +0200 -- jaas/modules/pom.xml| 5 --- .../modules/ldap/GSSAPILdapLoginModuleTest.java | 35 .../karaf/jaas/modules/ldap/LdapCacheTest.java | 4 ++- .../modules/ldap/LdapCaseInsensitiveDNTest.java | 4 ++- .../jaas/modules/ldap/LdapLoginModuleTest.java | 9 +++-- .../ldap/LdapLoginModuleWithEscapesTest.java| 5 ++- .../jaas/modules/ldap/LdapPropsUpdater.java | 35 .../ldap/LdapSpecialCharsInPasswordTest.java| 5 ++- 8 files changed, 40 insertions(+), 62 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/fd743966/jaas/modules/pom.xml -- diff --git a/jaas/modules/pom.xml b/jaas/modules/pom.xml index b6be3d8..8038102 100644 --- a/jaas/modules/pom.xml +++ b/jaas/modules/pom.xml @@ -91,11 +91,6 @@ test -commons-io -commons-io -test - - org.apache.directory.server apacheds-core-integ ${directory-version} http://git-wip-us.apache.org/repos/asf/karaf/blob/fd743966/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java index b664bc3..9d049d8 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java @@ -14,13 +14,12 @@ */ package org.apache.karaf.jaas.modules.ldap; +import static org.apache.karaf.jaas.modules.ldap.LdapPropsUpdater.ldapProps; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.security.Principal; import java.util.Collections; @@ -30,7 +29,6 @@ import javax.security.auth.kerberos.KerberosPrincipal; import javax.security.auth.kerberos.KerberosTicket; import javax.security.auth.login.LoginException; -import org.apache.commons.io.IOUtils; import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms; import org.apache.directory.api.ldap.model.entry.DefaultEntry; import org.apache.directory.api.ldap.model.entry.Entry; @@ -131,8 +129,6 @@ import org.junit.runner.RunWith; }) public class GSSAPILdapLoginModuleTest extends KarafKerberosITest { -private static boolean loginConfigUpdated; - @Before public void setUp() throws Exception { super.setUp(); @@ -153,32 +149,13 @@ public class GSSAPILdapLoginModuleTest extends KarafKerberosITest { System.setProperty("java.security.auth.login.config", config.toString()); -updatePort(); +ldapProps("org/apache/karaf/jaas/modules/ldap/gssapi.ldap.properties", + GSSAPILdapLoginModuleTest::replacePortAndAddress); } -public void updatePort() throws Exception { -if (!loginConfigUpdated) { -String basedir = System.getProperty("basedir"); -if (basedir == null) { -basedir = new File(".").getCanonicalPath(); -} - -// Read in ldap.properties and substitute in the correct port -File f = new File(basedir + "/src/test/resources/org/apache/karaf/jaas/modules/ldap/gssapi.ldap.properties"); - -FileInputStream inputStream = new FileInputStream(f); -String content = IOUtils.toString(inputStream, "UTF-8"); -inputStream.close(); -content = content.replaceAll("portno", "" + getLdapServer().getPort()); -content = content.replaceAll("address", KerberosTestUtils.getHostName()); - -File f2 = new File(basedir + "/target/test-classes/org/apache/karaf/jaas/modules/ldap/gssapi.ldap.properties"); -FileOutputStream outputStream
[07/27] karaf git commit: Suppress logging of WriteToClosedSessionException
Suppress logging of WriteToClosedSessionException Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/b4969149 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/b4969149 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/b4969149 Branch: refs/heads/model_features Commit: b4969149ff1dc52890f0a4c204258e904e84 Parents: ecf6a8d Author: Christian SchneiderAuthored: Tue Aug 15 17:13:07 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 17:13:07 2017 +0200 -- jaas/modules/src/test/resources/log4j.properties | 3 +++ 1 file changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/b4969149/jaas/modules/src/test/resources/log4j.properties -- diff --git a/jaas/modules/src/test/resources/log4j.properties b/jaas/modules/src/test/resources/log4j.properties index a75bae2..485e43b 100644 --- a/jaas/modules/src/test/resources/log4j.properties +++ b/jaas/modules/src/test/resources/log4j.properties @@ -20,6 +20,9 @@ # log4j.rootLogger=INFO, console, file +# Suppress logging of WriteToClosedSessionException +log4j.logger.org.apache.directory.server.ldap.LdapProtocolHandler=OFF + # Console will only display warnings log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout
[21/27] karaf git commit: Extract common code
Extract common code Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/db2bf32c Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/db2bf32c Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/db2bf32c Branch: refs/heads/model_features Commit: db2bf32c780aadae38136e6ea6adeb8ed38950c4 Parents: c79e2ba Author: Christian SchneiderAuthored: Wed Aug 16 18:00:43 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 18:00:43 2017 +0200 -- .../apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/db2bf32c/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java index 3d6eb66..1e194b6 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java @@ -101,10 +101,11 @@ public class SyncopeLoginModule extends AbstractKarafLoginModule { LOGGER.debug("Populating principals with user"); principals.add(new UserPrincipal(user)); LOGGER.debug("Retrieving user {} roles", user); +String responseSt = EntityUtils.toString(response.getEntity()); if (version.equals("2.x") || version.equals("2")) { -roles = extractingRolesSyncope2(EntityUtils.toString(response.getEntity())); +roles = extractingRolesSyncope2(responseSt); } else { -roles = extractingRolesSyncope1(EntityUtils.toString(response.getEntity())); +roles = extractingRolesSyncope1(responseSt); } } catch (Exception e) { LOGGER.error("User {} authentication failed", user, e); @@ -162,6 +163,7 @@ public class SyncopeLoginModule extends AbstractKarafLoginModule { * @return the list of user roles. * @throws Exception in case of extractiong failure. */ +@SuppressWarnings("unchecked") protected List extractingRolesSyncope2(String response) throws Exception { List roles = new ArrayList<>(); if (response != null && !response.isEmpty()) {
[26/27] karaf git commit: [KARAF-5300] Split install into add and upgrade
[KARAF-5300] Split install into add and upgrade Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/69fcb369 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/69fcb369 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/69fcb369 Branch: refs/heads/model_features Commit: 69fcb3696b5cc2b2707c40e532d06b7b4308aeca Parents: 99c2188 Author: Christian SchneiderAuthored: Thu Aug 10 11:23:10 2017 +0200 Committer: Christian Schneider Committed: Thu Aug 17 16:29:30 2017 +0200 -- .../internal/service/FeaturesServiceImpl.java | 114 +-- 1 file changed, 55 insertions(+), 59 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/69fcb369/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 5562390..2767bc8 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 @@ -83,6 +83,8 @@ import org.osgi.service.resolver.Resolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static java.util.Collections.emptyMap; +import static java.util.stream.Collectors.toSet; import static org.apache.karaf.features.internal.service.StateStorage.toStringStringSetMap; import static org.apache.karaf.features.internal.util.MapUtils.add; import static org.apache.karaf.features.internal.util.MapUtils.copy; @@ -787,28 +789,39 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall @Override public void installFeatures(Set featuresIn, String region, EnumSet options) throws Exception { -Set featureReqs = new HashSet<>(); +Set toInstall = new HashSet<>(); for (String feature : featuresIn) { -featureReqs.add(new FeatureReq(feature)); +toInstall.add(new FeatureReq(feature)); } State state = copyState(); Map requires = copy(state.requirements); if (region == null || region.isEmpty()) { region = ROOT_REGION; } -Set requiredForRegion = requires.computeIfAbsent(region, k -> new HashSet<>()); -computeRequirements(options, featureReqs, requiredForRegion); -Map > stateChanges = Collections.emptyMap(); -doProvisionInThread(requires, stateChanges, state, getFeaturesById(), options); -} +Set requirements = requires.computeIfAbsent(region, k -> new HashSet<>()); +Set existingFeatures = requirements.stream().map(r -> toFeatureReq(r)).collect(toSet()); + +Set toAdd = computeFeaturesToAdd(options, toInstall); +toAdd.stream().forEach(f -> requirements.add(toRequirement(f))); +print("Adding features: " + join(toAdd), options.contains(Option.Verbose)); + +if (options.contains(Option.Upgrade)) { +Set toRemove = computeFeaturesToRemoveOnUpdate(toAdd, existingFeatures); +toRemove.stream().forEach(f -> requirements.remove(toRequirement(f))); +if (!toRemove.isEmpty()) { +print("Removing features: " + join(toRemove), options.contains(Option.Verbose)); +} +} -void computeRequirements(EnumSet options, Set featureReqs, - Set requirements) -throws Exception { +doProvisionInThread(requires, emptyMap(), state, getFeaturesById(), options); +} + +private Set computeFeaturesToAdd(EnumSet options, + Set toInstall) throws Exception { +Feature[] installedFeatures = listInstalledFeatures(); Map > allFeatures = getFeatureCache(); -List featuresToAdd = new ArrayList<>(); -List featuresToRemove = new ArrayList<>(); -for (FeatureReq feature : featureReqs) { +Set toAdd = new HashSet<>(); +for (FeatureReq feature : toInstall) { Pattern pattern = Pattern.compile(feature.getName()); boolean matched = false; for (String fKey : allFeatures.keySet()) { @@ -816,8 +829,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall if (matcher.matches()) { Feature f = getFeatureMatching(fKey, feature.getVersionRange()); if
[05/27] karaf git commit: [KARAF-5309] Upgrade to directory server 2.0.0-M24
[KARAF-5309] Upgrade to directory server 2.0.0-M24 Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/8a18da51 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/8a18da51 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/8a18da51 Branch: refs/heads/model_features Commit: 8a18da5194126831c1962ea08d8419fee5a9a296 Parents: 5b4da2c Author: Christian SchneiderAuthored: Tue Aug 15 16:23:19 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 16:23:19 2017 +0200 -- jaas/modules/pom.xml | 5 + pom.xml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/8a18da51/jaas/modules/pom.xml -- diff --git a/jaas/modules/pom.xml b/jaas/modules/pom.xml index fa4c264..8313005 100644 --- a/jaas/modules/pom.xml +++ b/jaas/modules/pom.xml @@ -91,6 +91,11 @@ test +commons-io +commons-io +test + + org.apache.directory.server apacheds-core-integ ${directory-version} http://git-wip-us.apache.org/repos/asf/karaf/blob/8a18da51/pom.xml -- diff --git a/pom.xml b/pom.xml index 791578a..9ff6755 100644 --- a/pom.xml +++ b/pom.xml @@ -294,7 +294,7 @@ 1.6.0 10.12.1.1 -2.0.0-M20 +2.0.0-M24 1.3.10_1 3.18 2.11.0_1
[14/27] karaf git commit: Use matcher in tests
Use matcher in tests Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/6aa806d2 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/6aa806d2 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/6aa806d2 Branch: refs/heads/model_features Commit: 6aa806d2ad0df30d162693f8daa013dc6b0f110f Parents: 01d0aae Author: Christian SchneiderAuthored: Wed Aug 16 11:34:37 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 11:34:37 2017 +0200 -- .../karaf/jaas/modules/PrincipalAssert.java | 40 .../karaf/jaas/modules/PrincipalHelper.java | 29 + .../karaf/jaas/modules/ldap/LdapCacheTest.java | 67 +--- .../properties/PropertiesBackingEngineTest.java | 2 +- .../properties/PropertiesLoginModuleTest.java | 14 ++-- 5 files changed, 67 insertions(+), 85 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/6aa806d2/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java deleted file mode 100644 index c19fd2b..000 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed 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. - * under the License. - */ -package org.apache.karaf.jaas.modules; - -import static java.util.stream.Collectors.toList; - -import java.security.Principal; -import java.util.List; -import java.util.stream.Collectors; - -import javax.security.auth.Subject; - -import org.junit.Assert; - -public class PrincipalAssert { - -public static List names(List principals) { -return principals.stream().map(r->r.getName()).collect(toList()); -} - -public static void assertPrincipalNamed(Subject subject, Class clazz, String expectedName) { -Long numMatching = subject.getPrincipals(clazz).stream() -.filter(pr -> expectedName.equals(pr.getName())) -.collect(Collectors.counting()); -Assert.assertEquals("Expected " + clazz.getSimpleName() + " principal in subject with name=" + expectedName, -1l, numMatching.intValue()); -} -} http://git-wip-us.apache.org/repos/asf/karaf/blob/6aa806d2/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalHelper.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalHelper.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalHelper.java new file mode 100644 index 000..9893193 --- /dev/null +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalHelper.java @@ -0,0 +1,29 @@ +/* + * Licensed 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. + * under the License. + */ +package org.apache.karaf.jaas.modules; + +import static java.util.stream.Collectors.toList; + +import java.security.Principal; +import java.util.Collection; +import java.util.List; + +public class PrincipalHelper { + +public static List names(Collection principals) { +return principals.stream().map(r->r.getName()).collect(toList()); +} + +} http://git-wip-us.apache.org/repos/asf/karaf/blob/6aa806d2/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCacheTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCacheTest.java
[15/27] karaf git commit: Replace deprecated call
Replace deprecated call Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/71b136ed Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/71b136ed Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/71b136ed Branch: refs/heads/model_features Commit: 71b136ed8307f6470e32874dfed627844c9fc666 Parents: 6aa806d Author: Christian SchneiderAuthored: Wed Aug 16 11:44:38 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 11:44:38 2017 +0200 -- .../apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/71b136ed/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java index 47ea240..b0152f1 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java @@ -61,6 +61,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.charset.Charset; import java.security.Principal; import java.util.Collections; @@ -342,7 +343,7 @@ public class GSSAPILdapLoginModuleTest extends AbstractKerberosITest { data += "." + Strings.lowerCaseAscii(REALM) + " = " + REALM + SystemUtils.LINE_SEPARATOR; data += Strings.lowerCaseAscii(REALM) + " = " + REALM + SystemUtils.LINE_SEPARATOR; -FileUtils.writeStringToFile(file, data); +FileUtils.writeStringToFile(file, data, Charset.defaultCharset()); return file.getAbsolutePath(); }
[20/27] karaf git commit: Cleanup jdbc tests
Cleanup jdbc tests Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/c79e2ba2 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/c79e2ba2 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/c79e2ba2 Branch: refs/heads/model_features Commit: c79e2ba2b30349f220d2d2affb1d1aed410042fb Parents: fd74396 Author: Christian SchneiderAuthored: Wed Aug 16 15:53:10 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 15:53:10 2017 +0200 -- .../karaf/jaas/modules/jdbc/JDBCUtils.java | 4 +- .../jaas/modules/jdbc/JdbcLoginModuleTest.java | 116 --- 2 files changed, 52 insertions(+), 68 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/c79e2ba2/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/jdbc/JDBCUtils.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/jdbc/JDBCUtils.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/jdbc/JDBCUtils.java index 4e1cda8..5be25b0 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/jdbc/JDBCUtils.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/jdbc/JDBCUtils.java @@ -75,9 +75,9 @@ public final class JDBCUtils { if (tokens.length > 1) { filter = tokens[1]; } -ServiceReference[] references = bc.getServiceReferences(clazz, filter); +ServiceReference[] references = bc.getServiceReferences(clazz, filter); if (references != null) { -ServiceReference ref = references[0]; +ServiceReference ref = references[0]; Object ds = bc.getService(ref); bc.ungetService(ref); return ds; http://git-wip-us.apache.org/repos/asf/karaf/blob/c79e2ba2/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/jdbc/JdbcLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/jdbc/JdbcLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/jdbc/JdbcLoginModuleTest.java index cd960ed..66eebb6 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/jdbc/JdbcLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/jdbc/JdbcLoginModuleTest.java @@ -24,7 +24,7 @@ import java.util.Map; import javax.security.auth.Subject; import javax.sql.DataSource; -import org.apache.derby.jdbc.EmbeddedDataSource40; +import org.apache.derby.jdbc.EmbeddedDataSource; import org.apache.karaf.jaas.boot.principal.GroupPrincipal; import org.apache.karaf.jaas.boot.principal.RolePrincipal; import org.apache.karaf.jaas.boot.principal.UserPrincipal; @@ -42,54 +42,42 @@ import static org.junit.Assert.assertTrue; public class JdbcLoginModuleTest { -private EmbeddedDataSource40 dataSource; +private EmbeddedDataSource dataSource; private Map options; +@SuppressWarnings("unchecked") @Before public void setUp() throws Exception { System.setProperty("derby.stream.error.file", "target/derby.log"); // Create datasource -dataSource = new EmbeddedDataSource40(); +dataSource = new EmbeddedDataSource(); dataSource.setDatabaseName("memory:db"); dataSource.setCreateDatabase("create"); // Delete tables try (Connection connection = dataSource.getConnection()) { connection.setAutoCommit(true); -try { -try (Statement statement = connection.createStatement()) { +try (Statement statement = connection.createStatement()) { statement.execute("drop table USERS"); -} } catch (SQLException e) { // Ignore } -try { -try (Statement statement = connection.createStatement()) { -statement.execute("drop table ROLES"); -} +try (Statement statement = connection.createStatement()) { +statement.execute("drop table ROLES"); } catch (SQLException e) { // Ignore } -connection.commit(); -} - -// Create tables -try (Connection connection = dataSource.getConnection()) { try (Statement statement = connection.createStatement()) { statement.execute("create table USERS (USERNAME VARCHAR(32) PRIMARY KEY, PASSWORD VARCHAR(32))"); -} -try (Statement statement = connection.createStatement()) {
[11/27] karaf git commit: Avoid excessive logging
Avoid excessive logging Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/767012d2 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/767012d2 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/767012d2 Branch: refs/heads/model_features Commit: 767012d2544be03ab5818f3288912f1578d0e0c2 Parents: 1bf544b Author: Christian SchneiderAuthored: Tue Aug 15 17:57:24 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 17:57:24 2017 +0200 -- jaas/blueprint/jasypt/src/test/resources/log4j.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/767012d2/jaas/blueprint/jasypt/src/test/resources/log4j.properties -- diff --git a/jaas/blueprint/jasypt/src/test/resources/log4j.properties b/jaas/blueprint/jasypt/src/test/resources/log4j.properties index e1cbdd1..3822bad 100644 --- a/jaas/blueprint/jasypt/src/test/resources/log4j.properties +++ b/jaas/blueprint/jasypt/src/test/resources/log4j.properties @@ -18,7 +18,7 @@ # # The logging properties used during tests.. # -log4j.rootLogger=DEBUG, console, file +log4j.rootLogger=INFO, console, file # Console will only display warnnings log4j.appender.console=org.apache.log4j.ConsoleAppender
[16/27] karaf git commit: Use simple PrintStream
Use simple PrintStream Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/e973e3c7 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/e973e3c7 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/e973e3c7 Branch: refs/heads/model_features Commit: e973e3c73cd431492bfc6ed6f1fb336f4f71ceaa Parents: 71b136e Author: Christian SchneiderAuthored: Wed Aug 16 11:50:58 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 11:50:58 2017 +0200 -- .../modules/ldap/GSSAPILdapLoginModuleTest.java | 77 +--- 1 file changed, 33 insertions(+), 44 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/e973e3c7/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java index b0152f1..11daa72 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java @@ -14,9 +14,24 @@ */ package org.apache.karaf.jaas.modules.ldap; -import org.apache.commons.io.FileUtils; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.security.Principal; +import java.util.Collections; + +import javax.security.auth.Subject; +import javax.security.auth.kerberos.KerberosPrincipal; +import javax.security.auth.kerberos.KerberosTicket; +import javax.security.auth.login.LoginException; + import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.SystemUtils; import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms; import org.apache.directory.api.ldap.model.entry.DefaultEntry; import org.apache.directory.api.ldap.model.entry.Entry; @@ -53,22 +68,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import javax.security.auth.Subject; -import javax.security.auth.kerberos.KerberosPrincipal; -import javax.security.auth.kerberos.KerberosTicket; -import javax.security.auth.login.LoginException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.charset.Charset; -import java.security.Principal; -import java.util.Collections; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - @RunWith(FrameworkRunner.class) @CreateDS(name = "GSSAPILdapLoginModuleTest-class", partitions = @@ -317,34 +316,24 @@ public class GSSAPILdapLoginModuleTest extends AbstractKerberosITest { private String createKrb5Conf(ChecksumType checksumType, EncryptionType encryptionType, boolean isTcp) throws IOException { File file = folder.newFile("krb5.conf"); - -String data = ""; - -data += "[libdefaults]" + SystemUtils.LINE_SEPARATOR; -data += "default_realm = " + REALM + SystemUtils.LINE_SEPARATOR; -data += "default_tkt_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR; -data += "default_tgs_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR; -data += "permitted_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR; -//data += "default_checksum = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR; -//data += "ap_req_checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR; -data += "default-checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR; - +PrintStream out = new PrintStream(file); +out.println("[libdefaults]"); +out.println("default_realm = " + REALM); +out.println("default_tkt_enctypes = " + encryptionType.getName()); +out.println("default_tgs_enctypes = " + encryptionType.getName()); +out.println("permitted_enctypes = " + encryptionType.getName()); +out.println("default-checksum_type = " + checksumType.getName()); if (isTcp) { -data += "udp_preference_limit = 1" + SystemUtils.LINE_SEPARATOR; +out.println("udp_preference_limit = 1"); } - - -data += "[realms]" + SystemUtils.LINE_SEPARATOR; -data += REALM + " = {" +
[17/27] karaf git commit: Simplify assertions
Simplify assertions Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/3b72701c Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/3b72701c Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/3b72701c Branch: refs/heads/model_features Commit: 3b72701cdbf06961d2185348b29cbfd5e1f92763 Parents: e973e3c Author: Christian SchneiderAuthored: Wed Aug 16 11:52:11 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 11:52:11 2017 +0200 -- .../modules/ldap/LdapCaseInsensitiveDNTest.java | 20 +-- .../jaas/modules/ldap/LdapLoginModuleTest.java | 131 +++ 2 files changed, 23 insertions(+), 128 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/3b72701c/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCaseInsensitiveDNTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCaseInsensitiveDNTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCaseInsensitiveDNTest.java index bcf460d..8e3a56e 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCaseInsensitiveDNTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCaseInsensitiveDNTest.java @@ -15,12 +15,14 @@ */ package org.apache.karaf.jaas.modules.ldap; +import static org.apache.karaf.jaas.modules.PrincipalHelper.names; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.io.File; import java.io.IOException; -import java.security.Principal; import javax.security.auth.Subject; @@ -65,20 +67,8 @@ public class LdapCaseInsensitiveDNTest extends LdapLoginModuleTest { assertTrue(module.commit()); assertEquals(2, subject.getPrincipals().size()); - -boolean foundUser = false; -boolean foundRole = false; -for (Principal pr : subject.getPrincipals()) { -if (pr instanceof UserPrincipal) { -assertEquals("admin", pr.getName()); -foundUser = true; -} else if (pr instanceof RolePrincipal) { -assertEquals("admin", pr.getName()); -foundRole = true; -} -} -assertTrue(foundUser); -assertTrue(foundRole); +assertThat(names(subject.getPrincipals(UserPrincipal.class)), containsInAnyOrder("admin")); +assertThat(names(subject.getPrincipals(RolePrincipal.class)), containsInAnyOrder("admin")); assertTrue(module.logout()); assertEquals("Principals should be gone as the user has logged out", 0, subject.getPrincipals().size()); http://git-wip-us.apache.org/repos/asf/karaf/blob/3b72701c/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java index 140d5df..847dcf3 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java @@ -27,6 +27,7 @@ import org.apache.karaf.jaas.boot.principal.RolePrincipal; import org.apache.karaf.jaas.boot.principal.UserPrincipal; import org.apache.karaf.jaas.modules.NamePasswordCallbackHandler; import org.apache.log4j.Level; +import org.hamcrest.Matchers; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -37,13 +38,12 @@ import javax.security.auth.login.LoginException; import java.io.File; import java.io.IOException; -import java.security.Principal; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; +import static org.apache.karaf.jaas.modules.PrincipalHelper.names; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -79,20 +79,8 @@ public class LdapLoginModuleTest extends AbstractLdapTestUnit { assertTrue(module.commit()); assertEquals(2, subject.getPrincipals().size()); - -boolean foundUser = false; -boolean foundRole = false; -for (Principal pr : subject.getPrincipals()) { -if (pr instanceof UserPrincipal) { -
[22/27] karaf git commit: Extract response data. Improve assertions
Extract response data. Improve assertions Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/b57bceae Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/b57bceae Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/b57bceae Branch: refs/heads/model_features Commit: b57bceae1855e610e3941c73b1b1260bea264c0d Parents: db2bf32 Author: Christian SchneiderAuthored: Wed Aug 16 18:01:20 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 18:01:20 2017 +0200 -- .../modules/syncope/SyncopeLoginModuleTest.java | 131 +++ .../jaas/modules/syncope/syncope1Response.xml | 70 ++ .../jaas/modules/syncope/syncope2Response.json | 55 3 files changed, 146 insertions(+), 110 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/b57bceae/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModuleTest.java index 560879a..1156585 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModuleTest.java @@ -16,131 +16,42 @@ */ package org.apache.karaf.jaas.modules.syncope; -import org.junit.Test; -import org.junit.Assert; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.junit.Assert.assertThat; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.List; +import java.util.stream.Collectors; + +import org.junit.Test; public class SyncopeLoginModuleTest { @Test public void testRolesExtractionSyncope1() throws Exception { -String syncopeResponse = "\n" + -"\n" + -"\n" + -"\n" + -"false\n" + -"cool\n" + -"false\n" + -"\n" + -"\n" + -"false\n" + -"email\n" + -"ka...@example.net\n" + -"\n" + -"\n" + -"false\n" + -"fullname\n" + -"karaf\n" + -"\n" + -"\n" + -"false\n" + -"gender\n" + -"M\n" + -"\n" + -"\n" + -"false\n" + -"surname\n" + -"karaf\n" + -"\n" + -"\n" + -"false\n" + -"userId\n" + -"ka...@example.net\n" + -"\n" + -"\n" + -"\n" + -"100\n" + -"\n" + -"\n" + -"\n" + -" 2014-08-12T18:37:09.202+02:00\n" + -"0\n" + -" 2014-08-13T09:38:02.204+02:00\n" + -"\n" + -"\n" + -"\n" + -"\n" + -"100\n" + -"\n" + -"\n" + -"\n" + -"\n" + -"100\n" + -"admin\n" + -"\n" + -"\n" + -"\n" + -"\n" + -"101\n" + -"\n" + -"\n" + -"\n" + -"\n" + -"101\n" + -"another\n" + -"\n" + -"\n" + -" 36460D3A3C1E27C0DB2AF23344475EE712DD3C9D\n" + -"active\n" + -"karaf\n" + -"\n"; +String syncopeResponse = read("syncope1Response.xml"); SyncopeLoginModule syncopeLoginModule = new SyncopeLoginModule(); List
[18/27] karaf git commit: Extract common code in test
Extract common code in test Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/0853a353 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/0853a353 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/0853a353 Branch: refs/heads/model_features Commit: 0853a353afa4c8eabad38327e3943b1543fd4c0a Parents: 3b72701 Author: Christian SchneiderAuthored: Wed Aug 16 13:41:17 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 13:41:17 2017 +0200 -- .../jaas/modules/krb5/KarafKerberosITest.java | 51 ++ .../jaas/modules/krb5/Krb5LoginModuleTest.java | 102 +++ .../modules/ldap/GSSAPILdapLoginModuleTest.java | 29 +- 3 files changed, 66 insertions(+), 116 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/0853a353/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/krb5/KarafKerberosITest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/krb5/KarafKerberosITest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/krb5/KarafKerberosITest.java new file mode 100644 index 000..0b57930 --- /dev/null +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/krb5/KarafKerberosITest.java @@ -0,0 +1,51 @@ +/* + * Licensed 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. + * under the License. + */ +package org.apache.karaf.jaas.modules.krb5; + +import java.io.File; +import java.io.IOException; +import java.io.PrintStream; + +import org.apache.directory.api.util.Strings; +import org.apache.directory.server.kerberos.kdc.AbstractKerberosITest; +import org.apache.directory.shared.kerberos.codec.types.EncryptionType; +import org.apache.directory.shared.kerberos.crypto.checksum.ChecksumType; + +public class KarafKerberosITest extends AbstractKerberosITest { + +protected String createKrb5Conf(ChecksumType checksumType, EncryptionType encryptionType, boolean isTcp) throws IOException { +File file = folder.newFile("krb5.conf"); +PrintStream out = new PrintStream(file); +out.println("[libdefaults]"); +out.println("default_realm = " + REALM); +out.println("default_tkt_enctypes = " + encryptionType.getName()); +out.println("default_tgs_enctypes = " + encryptionType.getName()); +out.println("permitted_enctypes = " + encryptionType.getName()); +out.println("default-checksum_type = " + checksumType.getName()); +if (isTcp) { +out.println("udp_preference_limit = 1"); +} +out.println("[realms]"); +out.println(REALM + " = {"); +out.println("kdc = " + HOSTNAME + ":" + kdcServer.getTransports()[0].getPort()); +out.println("}"); +out.println("[domain_realm]"); +out.println("." + Strings.lowerCaseAscii(REALM) + " = " + REALM); +out.println(Strings.lowerCaseAscii(REALM) + " = " + REALM); +out.close(); +return file.getAbsolutePath(); +} + +} http://git-wip-us.apache.org/repos/asf/karaf/blob/0853a353/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/krb5/Krb5LoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/krb5/Krb5LoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/krb5/Krb5LoginModuleTest.java index e6caf7b..d88955d 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/krb5/Krb5LoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/krb5/Krb5LoginModuleTest.java @@ -16,13 +16,10 @@ */ package org.apache.karaf.jaas.modules.krb5; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.SystemUtils; import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms; import org.apache.directory.api.ldap.model.entry.DefaultEntry; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.exception.LdapException; -import org.apache.directory.api.util.Strings; import org.apache.directory.ldap.client.api.Krb5LoginConfiguration; import
[04/27] karaf git commit: Extract methods
Extract methods Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/5b4da2cd Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/5b4da2cd Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/5b4da2cd Branch: refs/heads/model_features Commit: 5b4da2cd85b527b335d59ff4fc2ec686ee913558 Parents: 5497403 Author: Christian SchneiderAuthored: Tue Aug 15 16:05:13 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 16:05:13 2017 +0200 -- .../jaas/modules/ldap/LdapLoginModuleTest.java | 24 1 file changed, 15 insertions(+), 9 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/5b4da2cd/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java index ea29eef..186bdb2 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java @@ -38,6 +38,7 @@ import javax.security.auth.login.LoginException; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.security.Principal; @@ -59,6 +60,7 @@ import static org.junit.Assert.fail; ) public class LdapLoginModuleTest extends AbstractLdapTestUnit { +private static final String PROPS_PATH = "org/apache/karaf/jaas/modules/ldap/ldap.properties"; private static boolean portUpdated; @Before @@ -70,18 +72,22 @@ public class LdapLoginModuleTest extends AbstractLdapTestUnit { } // Read in ldap.properties and substitute in the correct port -File f = new File(basedir + "/src/test/resources/org/apache/karaf/jaas/modules/ldap/ldap.properties"); - -FileInputStream inputStream = new FileInputStream(f); -String content = IOUtils.toString(inputStream, "UTF-8"); -inputStream.close(); +String content = readProperties(basedir + "/src/test/resources/" + PROPS_PATH); content = content.replaceAll("portno", "" + getLdapServer().getPort()); +writeProperties(basedir + "/target/test-classes/" + PROPS_PATH, content); +portUpdated = true; +} +} -File f2 = new File(basedir + "/target/test-classes/org/apache/karaf/jaas/modules/ldap/ldap.properties"); -FileOutputStream outputStream = new FileOutputStream(f2); +private String readProperties(String path) throws FileNotFoundException, IOException { +try (FileInputStream inputStream = new FileInputStream(new File(path))) {; +return IOUtils.toString(inputStream, "UTF-8"); +} +} + +private void writeProperties(String path, String content) throws FileNotFoundException, IOException { +try (FileOutputStream outputStream = new FileOutputStream(new File(path))) { IOUtils.write(content, outputStream, "UTF-8"); -outputStream.close(); -portUpdated = true; } }
[27/27] karaf git commit: [KARAF-5300] Use FeatureReq instead of string for FeaturesService
[KARAF-5300] Use FeatureReq instead of string for FeaturesService Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/3b900267 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/3b900267 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/3b900267 Branch: refs/heads/model_features Commit: 3b900267c4710302198cd66c02a869e1b74ff0f0 Parents: 8f94e29 Author: Christian SchneiderAuthored: Wed Aug 9 17:39:06 2017 +0200 Committer: Christian Schneider Committed: Thu Aug 17 16:29:30 2017 +0200 -- .../features/internal/service/FeatureReq.java | 84 .../internal/service/FeaturesServiceImpl.java | 204 --- .../service/FeaturesServiceImplTest.java| 46 - .../karaf/features/internal/service/f09.xml | 24 +++ 4 files changed, 229 insertions(+), 129 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/3b900267/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java -- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java new file mode 100644 index 000..2e1f652 --- /dev/null +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java @@ -0,0 +1,84 @@ +/* + * 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.karaf.features.internal.service; + +import org.apache.karaf.features.Feature; +import org.osgi.framework.Version; +import org.osgi.framework.VersionRange; + +/** + * Requirement for a feature + */ +public class FeatureReq { +public static final String VERSION_SEPARATOR = "/"; +private static Version HIGHEST = new Version(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); +private static final VersionRange RANGE_ALL = new VersionRange(VersionRange.LEFT_CLOSED, Version.emptyVersion, HIGHEST, VersionRange.RIGHT_CLOSED); +private String name; +private VersionRange versionRange; + +public FeatureReq(String nameAndRange) { +String[] parts = nameAndRange.trim().split(VERSION_SEPARATOR); +this.name = parts[0]; +this.versionRange = (parts.length == 1) ? RANGE_ALL : range(parts[1]); +} + +public FeatureReq(String name, String versionRange) { +this.name = name; +this.versionRange = range(versionRange); +} + +private VersionRange range(String versionRange) { +if (versionRange == null) { +return RANGE_ALL; +} +versionRange = versionRange.trim(); +if ("0.0.0".equals(versionRange)) { +return RANGE_ALL; +} +if (versionRange.contains(",")) { +return new VersionRange(versionRange); +} else { +return exactVersion(versionRange); +} +} + +private static VersionRange exactVersion(String versionRange) { +return new VersionRange(VersionRange.LEFT_CLOSED, new Version(versionRange), new Version(versionRange), VersionRange.RIGHT_CLOSED); +} + +public FeatureReq(String name, VersionRange versionRange) { +this.name = name; +this.versionRange = versionRange; +} + +public FeatureReq(Feature feature) { +this(feature.getName(), exactVersion(feature.getVersion())); +} + +public String getName() { +return name; +} + +public VersionRange getVersionRange() { +return versionRange; +} + +@Override +public String toString() { +return this.name + "/" + this.getVersionRange().toString(); +} +} http://git-wip-us.apache.org/repos/asf/karaf/blob/3b900267/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java -- diff --git
[08/27] karaf git commit: Avoid excessive logging
Avoid excessive logging Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/fcf9b7c1 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/fcf9b7c1 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/fcf9b7c1 Branch: refs/heads/model_features Commit: fcf9b7c19b9c9edf56aa75ab29675a30c237e741 Parents: b496914 Author: Christian SchneiderAuthored: Tue Aug 15 17:47:03 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 17:47:03 2017 +0200 -- jaas/jasypt/src/test/resources/log4j.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/fcf9b7c1/jaas/jasypt/src/test/resources/log4j.properties -- diff --git a/jaas/jasypt/src/test/resources/log4j.properties b/jaas/jasypt/src/test/resources/log4j.properties index e1cbdd1..3822bad 100644 --- a/jaas/jasypt/src/test/resources/log4j.properties +++ b/jaas/jasypt/src/test/resources/log4j.properties @@ -18,7 +18,7 @@ # # The logging properties used during tests.. # -log4j.rootLogger=DEBUG, console, file +log4j.rootLogger=INFO, console, file # Console will only display warnnings log4j.appender.console=org.apache.log4j.ConsoleAppender
[24/27] karaf git commit: [KARAF-5300] Add documentation
[KARAF-5300] Add documentation Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/99c21882 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/99c21882 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/99c21882 Branch: refs/heads/model_features Commit: 99c21882335430c2bbcf84973a46afd16e178ee7 Parents: 3b90026 Author: Christian SchneiderAuthored: Thu Aug 10 10:33:22 2017 +0200 Committer: Christian Schneider Committed: Thu Aug 17 16:29:30 2017 +0200 -- .../karaf/features/internal/service/FeatureReq.java | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/99c21882/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java -- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java index 2e1f652..1bac816 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeatureReq.java @@ -22,6 +22,15 @@ import org.osgi.framework.VersionRange; /** * Requirement for a feature + * + * The syntax of a requirement as a String is name[/versionRange]. + * If no versionRange is given then a range of [0,) is assumeed which matches all versions. + * + * + * - name: Can be a feature name or a glob like myfeat* + * - versionRange: version or range + * - version: Will specify a specific version. Like [version,version]. An exemption is 0.0.0 which matches all versions. + * - range: Like defined in OSGi VersionRange. Example: [1.0.0, 1.1.0) */ public class FeatureReq { public static final String VERSION_SEPARATOR = "/"; @@ -57,7 +66,10 @@ public class FeatureReq { } private static VersionRange exactVersion(String versionRange) { -return new VersionRange(VersionRange.LEFT_CLOSED, new Version(versionRange), new Version(versionRange), VersionRange.RIGHT_CLOSED); +return new VersionRange(VersionRange.LEFT_CLOSED, +new Version(versionRange), +new Version(versionRange), +VersionRange.RIGHT_CLOSED); } public FeatureReq(String name, VersionRange versionRange) {
[10/27] karaf git commit: Do not print each classpath Element
Do not print each classpath Element Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/1bf544b9 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/1bf544b9 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/1bf544b9 Branch: refs/heads/model_features Commit: 1bf544b95aa03ad6f4c4ec6a9060b047430615a5 Parents: 011c9b0 Author: Christian SchneiderAuthored: Tue Aug 15 17:48:10 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 17:48:10 2017 +0200 -- .../org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/1bf544b9/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java -- diff --git a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java index 2d44bfd..7b0fd37 100644 --- a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java +++ b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java @@ -194,7 +194,6 @@ public class GenerateServiceMetadata extends AbstractMojo { File file = artifact.getFile(); if ( file != null ) { urls.add( file.toURI().toURL() ); -System.out.println("classpath: " + file); } } ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());
[25/27] karaf git commit: [KARAF-5300] Reuse and extract feature matching code
[KARAF-5300] Reuse and extract feature matching code Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/6576f476 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/6576f476 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/6576f476 Branch: refs/heads/model_features Commit: 6576f476581367a83e7c42ac0e516bb710d3d7db Parents: 69fcb36 Author: Christian SchneiderAuthored: Thu Aug 10 15:30:59 2017 +0200 Committer: Christian Schneider Committed: Thu Aug 17 16:29:30 2017 +0200 -- .../internal/service/FeaturesServiceImpl.java | 79 +++- 1 file changed, 43 insertions(+), 36 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/6576f476/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 2767bc8..574998a 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 @@ -520,15 +520,15 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall @Override public Feature[] getFeatures(String nameOrId) throws Exception { -return getFeatures(new FeatureReq(nameOrId)); +return toArray(getFeatures(new FeatureReq(nameOrId))); } @Override public Feature[] getFeatures(String name, String version) throws Exception { -return getFeatures(new FeatureReq(name, version)); +return toArray(getFeatures(new FeatureReq(name, version))); } -private Feature[] getFeatures(FeatureReq featureReq) throws Exception { +private Collection getFeatures(FeatureReq featureReq) throws Exception { List features = new ArrayList<>(); Pattern pattern = Pattern.compile(featureReq.getName()); Map > allFeatures = getFeatureCache(); @@ -541,6 +541,10 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall } } } +return features; +} + +private Feature[] toArray(Collection features) { return features.toArray(new Feature[features.size()]); } @@ -819,33 +823,33 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall private Set computeFeaturesToAdd(EnumSet options, Set toInstall) throws Exception { Feature[] installedFeatures = listInstalledFeatures(); -Map > allFeatures = getFeatureCache(); Set toAdd = new HashSet<>(); -for (FeatureReq feature : toInstall) { -Pattern pattern = Pattern.compile(feature.getName()); -boolean matched = false; -for (String fKey : allFeatures.keySet()) { -Matcher matcher = pattern.matcher(fKey); -if (matcher.matches()) { -Feature f = getFeatureMatching(fKey, feature.getVersionRange()); -if (f != null) { -toAdd.add(new FeatureReq(f)); -for (Feature installedFeature : installedFeatures) { -if (installedFeature.getName().equals(f.getName()) && installedFeature.getVersion().equals(f.getVersion())) { -LOGGER.info("The specified feature: '{}' version '{}' {}",f.getName(),f.getVersion(),f.getVersion().endsWith("SNAPSHOT") ? "has been upgraded": "is already installed"); -} -} -matched = true; +for (FeatureReq featureReq : toInstall) { +Collection matching = getFeatures(featureReq); +for (Feature f: matching) { +toAdd.add(new FeatureReq(f)); +for (Feature installedFeature : installedFeatures) { +if (isSameFeature(f, installedFeature)) { +logInstalledOrUpdated(f); } } } -if (!matched && !options.contains(Option.NoFailOnFeatureNotFound)) { -throw new IllegalArgumentException("No matching features for " + feature); +if (matching.isEmpty() && !options.contains(Option.NoFailOnFeatureNotFound)) { +throw new IllegalArgumentException("No matching features for " +
[13/27] karaf git commit: Refactor test
Refactor test Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/01d0aae9 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/01d0aae9 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/01d0aae9 Branch: refs/heads/model_features Commit: 01d0aae9b62531919f00d96eb22119bf59d0209b Parents: 713d25d Author: Christian SchneiderAuthored: Wed Aug 16 11:12:46 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 11:12:46 2017 +0200 -- jaas/modules/pom.xml| 6 + .../karaf/jaas/modules/PrincipalAssert.java | 40 +++ .../properties/PropertiesBackingEngineTest.java | 266 +++ .../properties/PropertiesLoginModuleTest.java | 42 +-- 4 files changed, 146 insertions(+), 208 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/01d0aae9/jaas/modules/pom.xml -- diff --git a/jaas/modules/pom.xml b/jaas/modules/pom.xml index 8313005..b6be3d8 100644 --- a/jaas/modules/pom.xml +++ b/jaas/modules/pom.xml @@ -120,6 +120,12 @@ ${derby-version} test + +org.hamcrest +hamcrest-all +1.3 +test + http://git-wip-us.apache.org/repos/asf/karaf/blob/01d0aae9/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java new file mode 100644 index 000..c19fd2b --- /dev/null +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java @@ -0,0 +1,40 @@ +/* + * Licensed 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. + * under the License. + */ +package org.apache.karaf.jaas.modules; + +import static java.util.stream.Collectors.toList; + +import java.security.Principal; +import java.util.List; +import java.util.stream.Collectors; + +import javax.security.auth.Subject; + +import org.junit.Assert; + +public class PrincipalAssert { + +public static List names(List principals) { +return principals.stream().map(r->r.getName()).collect(toList()); +} + +public static void assertPrincipalNamed(Subject subject, Class clazz, String expectedName) { +Long numMatching = subject.getPrincipals(clazz).stream() +.filter(pr -> expectedName.equals(pr.getName())) +.collect(Collectors.counting()); +Assert.assertEquals("Expected " + clazz.getSimpleName() + " principal in subject with name=" + expectedName, +1l, numMatching.intValue()); +} +} http://git-wip-us.apache.org/repos/asf/karaf/blob/01d0aae9/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/properties/PropertiesBackingEngineTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/properties/PropertiesBackingEngineTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/properties/PropertiesBackingEngineTest.java index b781cd1..0c811da 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/properties/PropertiesBackingEngineTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/properties/PropertiesBackingEngineTest.java @@ -16,188 +16,104 @@ */ package org.apache.karaf.jaas.modules.properties; -import junit.framework.TestCase; +import static org.apache.karaf.jaas.modules.PrincipalAssert.names; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.stream.Collectors; + import org.apache.felix.utils.properties.Properties; import org.apache.karaf.jaas.boot.principal.GroupPrincipal; -import org.apache.karaf.jaas.boot.principal.RolePrincipal; import org.apache.karaf.jaas.boot.principal.UserPrincipal; +import org.junit.After; +import org.junit.Assert; +import
[12/27] karaf git commit: Fix warnings
Fix warnings Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/713d25d4 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/713d25d4 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/713d25d4 Branch: refs/heads/model_features Commit: 713d25d4ffd40ad669a53b5d1fa9d8b497fc8b57 Parents: 767012d Author: Christian SchneiderAuthored: Tue Aug 15 23:30:07 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 23:30:07 2017 +0200 -- .../apache/karaf/jaas/modules/ldap/LDAPBackingEngine.java| 5 ++--- .../java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java | 8 .../java/org/apache/karaf/jaas/modules/ldap/LDAPOptions.java | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/713d25d4/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPBackingEngine.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPBackingEngine.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPBackingEngine.java index 5bd3072..4ee865e 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPBackingEngine.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPBackingEngine.java @@ -33,7 +33,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.regex.Matcher; import java.util.regex.Pattern; /** @@ -87,10 +86,10 @@ public class LDAPBackingEngine implements BackingEngine { LOGGER.debug(" base DN: " + options.getUserBaseDn()); LOGGER.debug(" filter: " + filter); -NamingEnumeration namingEnumeration = context.search(options.getUserBaseDn(), filter, controls); +NamingEnumeration namingEnumeration = context.search(options.getUserBaseDn(), filter, controls); try { while (namingEnumeration.hasMore()) { -SearchResult result = (SearchResult) namingEnumeration.next(); +SearchResult result = namingEnumeration.next(); // We need to do the following because slashes are handled badly. For example, when searching // for a user with lots of special characters like cn=admin,=+<>#;\ http://git-wip-us.apache.org/repos/asf/karaf/blob/713d25d4/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java index f80af8c..7566165 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java @@ -165,14 +165,14 @@ public class LDAPCache implements Closeable, NamespaceChangeListener, ObjectChan LOGGER.debug(" base DN: " + options.getUserBaseDn()); LOGGER.debug(" filter: " + filter); -NamingEnumeration namingEnumeration = context.search(options.getUserBaseDn(), filter, controls); +NamingEnumeration namingEnumeration = context.search(options.getUserBaseDn(), filter, controls); try { if (!namingEnumeration.hasMore()) { LOGGER.warn("User " + user + " not found in LDAP."); return null; } LOGGER.debug("Found the user DN."); -SearchResult result = (SearchResult) namingEnumeration.next(); +SearchResult result = namingEnumeration.next(); // We need to do the following because slashes are handled badly. For example, when searching // for a user with lots of special characters like cn=admin,=+<>#;\ @@ -250,11 +250,11 @@ public class LDAPCache implements Closeable, NamespaceChangeListener, ObjectChan LOGGER.debug(" base DN: " + options.getRoleBaseDn()); LOGGER.debug(" filter: " + filter); -NamingEnumeration namingEnumeration = context.search(options.getRoleBaseDn(), filter, controls); +NamingEnumeration namingEnumeration = context.search(options.getRoleBaseDn(), filter, controls); try { List rolesList = new ArrayList<>(); while (namingEnumeration.hasMore()) { -SearchResult result = (SearchResult) namingEnumeration.next(); +SearchResult result = namingEnumeration.next(); Attributes attributes =
[09/27] karaf git commit: Refactor GenerateServiceMetadata
Refactor GenerateServiceMetadata Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/011c9b04 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/011c9b04 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/011c9b04 Branch: refs/heads/model_features Commit: 011c9b048f6ae16271be6154e6d547ad288e70fc Parents: fcf9b7c Author: Christian SchneiderAuthored: Tue Aug 15 17:47:32 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 17:47:32 2017 +0200 -- .../tracker/GenerateServiceMetadata.java| 74 +--- 1 file changed, 33 insertions(+), 41 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/011c9b04/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java -- diff --git a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java index ba4fac1..2d44bfd 100644 --- a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java +++ b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java @@ -17,6 +17,7 @@ package org.apache.karaf.tooling.tracker; import java.io.File; +import java.io.IOException; import java.io.OutputStream; import java.net.URL; import java.net.URLClassLoader; @@ -84,8 +85,8 @@ public class GenerateServiceMetadata extends AbstractMojo { try { boolean addSourceDirectory = false; -StringBuilder requirements = new StringBuilder(); -StringBuilder capabilities = new StringBuilder(); +List requirements = new ArrayList<>(); +List capabilities = new ArrayList<>(); ClassFinder finder = createFinder(classLoader); List classes = finder.findAnnotatedClasses(Services.class); @@ -103,28 +104,18 @@ public class GenerateServiceMetadata extends AbstractMojo { activators.add(clazz); } -Properties props = new Properties(); +writeServiceProperties(clazz); + Services services = clazz.getAnnotation(Services.class); if (services != null) { for (RequireService req : services.requires()) { -String fltWithClass = combine(req.filter(), "(objectClass=" + req.value().getName() + ")"); -addServiceReq(requirements, fltWithClass); -props.setProperty(req.value().getName(), req.filter()); +requirements.add(getRequirement(req)); } for (ProvideService cap : services.provides()) { -addServiceCap(capabilities, cap); +capabilities.add(getCapability(cap)); } } -Managed managed = clazz.getAnnotation(Managed.class); -if (managed != null) { -props.setProperty("pid", managed.value()); -} - -File file = new File(outputDirectory, "OSGI-INF/karaf-tracker/" + clazz.getName()); -file.getParentFile().mkdirs(); -try (OutputStream os = buildContext.newFileOutputStream(file)) { -props.store(os, null); -} + addSourceDirectory = true; } @@ -134,8 +125,8 @@ public class GenerateServiceMetadata extends AbstractMojo { project.addResource(resource); } -project.getProperties().setProperty(requirementsProperty, requirements.toString()); -project.getProperties().setProperty(capabilitiesProperty, capabilities.toString()); +project.getProperties().setProperty(requirementsProperty, String.join(",", requirements)); +project.getProperties().setProperty(capabilitiesProperty, String.join(",", capabilities)); if (activators.size() == 1) { project.getProperties().setProperty(activatorProperty, activators.get(0).getName()); } @@ -148,7 +139,7 @@ public class GenerateServiceMetadata extends AbstractMojo { packages.add(clazz.getPackage().getName()); } if (!packages.isEmpty()) { - project.getProperties().setProperty("BNDExtension-Karaf-Commands", join(packages, ",")); +
[02/27] karaf git commit: [KARAF-5308] Use upfront loading for repositories
[KARAF-5308] Use upfront loading for repositories Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/a75fabaf Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/a75fabaf Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/a75fabaf Branch: refs/heads/model_features Commit: a75fabaf071b8274c7f266affa7ce7cdd87a2a22 Parents: eb95bce Author: Christian SchneiderAuthored: Tue Aug 15 15:39:26 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 15:39:26 2017 +0200 -- .../internal/service/FeaturesServiceImpl.java | 15 .../internal/service/RepositoryCache.java | 7 ++-- .../internal/service/RepositoryImpl.java| 25 + .../apache/karaf/features/RepositoryTest.java | 3 +- .../internal/service/BlacklistTest.java | 23 ++-- .../features/internal/service/DeployerTest.java | 5 --- .../service/FeaturesValidationTest.java | 37 +++- 7 files changed, 52 insertions(+), 63 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/a75fabaf/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 90f4969..27ccf97 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 @@ -254,15 +254,14 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall public void registerListener(FeaturesListener listener) { listeners.add(listener); try { -Set repositories = new TreeSet<>(); +Set repositoriesList = new TreeSet<>(); Map installedFeatures = new TreeMap<>(); synchronized (lock) { -repositories.addAll(state.repositories); +repositoriesList.addAll(state.repositories); installedFeatures.putAll(copy(state.installedFeatures)); } -Blacklist blacklist = new Blacklist(cfg.blacklisted); -for (String uri : repositories) { -Repository repository = new RepositoryImpl(URI.create(uri), blacklist); +for (String uri : repositoriesList) { +Repository repository = repositories.create(URI.create(uri), false); listener.repositoryEvent(new RepositoryEvent(repository, RepositoryEvent.EventType.RepositoryAdded, true)); } for (Map.Entry entry : installedFeatures.entrySet()) { @@ -357,7 +356,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall @Override public void addRepository(URI uri, boolean install) throws Exception { -Repository repository = repositories.create(uri, true, true); +Repository repository = repositories.create(uri, true); synchronized (lock) { repositories.addRepository(repository); featureCache = null; @@ -610,7 +609,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall } try { if (repo == null) { -repo = repositories.create(URI.create(uri), true, false); +repo = repositories.create(URI.create(uri), false); synchronized (lock) { repositories.addRepository(repo); } @@ -979,7 +978,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall @Override public Repository createRepository(URI uri) throws Exception { -return repositories.create(uri, true, true); +return repositories.create(uri, true); } @Override http://git-wip-us.apache.org/repos/asf/karaf/blob/a75fabaf/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryCache.java -- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryCache.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryCache.java index 4898566..801ffeb 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryCache.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryCache.java @@ -38,11 +38,8 @@
[03/27] karaf git commit: Suppress logging exception in test
Suppress logging exception in test Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/54974034 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/54974034 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/54974034 Branch: refs/heads/model_features Commit: 549740347157bc15cf62de17018fe2c1818eb601 Parents: a75faba Author: Christian SchneiderAuthored: Tue Aug 15 15:39:48 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 15:39:48 2017 +0200 -- .../apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java | 7 +++ 1 file changed, 7 insertions(+) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/54974034/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java index e2c374a..ea29eef 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java @@ -27,6 +27,7 @@ import org.apache.felix.utils.properties.Properties; import org.apache.karaf.jaas.boot.principal.RolePrincipal; import org.apache.karaf.jaas.boot.principal.UserPrincipal; import org.apache.karaf.jaas.modules.NamePasswordCallbackHandler; +import org.apache.log4j.Level; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -202,12 +203,18 @@ public class LdapLoginModuleTest extends AbstractLdapTestUnit { module.initialize(subject, new NamePasswordCallbackHandler("admin", "blahblah"), null, options); assertEquals("Precondition", 0, subject.getPrincipals().size()); +org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(LDAPLoginModule.class); +Level oldLevel = logger.getLevel(); +logger.setLevel(Level.OFF); try { module.login(); fail("Should have thrown LoginException"); } catch (LoginException e) { assertTrue(e.getMessage().startsWith("Authentication failed")); +} finally { +logger.setLevel(oldLevel); } + } @Test
[01/27] karaf git commit: Change Blacklist into an ordinary class [Forced Update!]
Repository: karaf Updated Branches: refs/heads/model_features a59edf056 -> 6576f4765 (forced update) Change Blacklist into an ordinary class Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/eb95bce7 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/eb95bce7 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/eb95bce7 Branch: refs/heads/model_features Commit: eb95bce7d5a1bcf23a5bda919209394ffcf3c01a Parents: e442a1b Author: Christian SchneiderAuthored: Mon Aug 14 18:46:07 2017 +0200 Committer: Christian Schneider Committed: Mon Aug 14 18:46:07 2017 +0200 -- .../features/internal/service/Blacklist.java| 90 +++- .../internal/service/FeaturesServiceImpl.java | 28 + .../internal/service/RepositoryCache.java | 19 +--- .../internal/service/RepositoryImpl.java| 23 ++-- .../internal/service/BlacklistTest.java | 67 .../profile/assembly/ArtifactInstaller.java | 84 +++ .../assembly/AssemblyDeployCallback.java| 11 +- .../apache/karaf/profile/assembly/Builder.java | 104 +++ 8 files changed, 185 insertions(+), 241 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/eb95bce7/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java -- diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java index 0d804a7..f7f4aab 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java @@ -16,12 +16,18 @@ */ package org.apache.karaf.features.internal.service; +import static java.util.stream.Collectors.toSet; + import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; -import java.util.*; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; import org.apache.felix.utils.manifest.Clause; import org.apache.felix.utils.manifest.Parser; @@ -47,25 +53,38 @@ public class Blacklist { public static final String TYPE_REPOSITORY = "repository"; private static final Logger LOGGER = LoggerFactory.getLogger(Blacklist.class); - -private Blacklist() { +private Clause[] clauses; + +public Blacklist() { +this(Collections.emptyList()); } -public static void blacklist(Features features, String blacklisted) { -Set blacklist = loadBlacklist(blacklisted); -blacklist(features, blacklist); +public Blacklist(List blacklist) { +this.clauses = org.apache.felix.utils.manifest.Parser.parseClauses(blacklist.toArray(new String[blacklist.size()])); } - -public static void blacklist(Features features, Collection blacklist) { -Clause[] clauses = Parser.parseClauses(blacklist.toArray(new String[blacklist.size()])); -blacklist(features, clauses); + +public Blacklist(String blacklistUrl) { +Set blacklist = new HashSet<>(); +if (blacklistUrl != null) { +try (InputStream is = new URL(blacklistUrl).openStream(); +BufferedReader reader = new BufferedReader(new InputStreamReader(is))) { +reader.lines() // +.map(line -> line.trim()) // +.filter(line -> line.isEmpty() || line.startsWith("#")).collect(toSet()); +} catch (FileNotFoundException e) { +LOGGER.debug("Unable to load blacklist bundles list", e.toString()); +} catch (Exception e) { +LOGGER.debug("Unable to load blacklist bundles list", e); +} +} +this.clauses = Parser.parseClauses(blacklist.toArray(new String[blacklist.size()])); } -public static void blacklist(Features features, Clause[] clauses) { -features.getFeature().removeIf(feature -> blacklist(feature, clauses)); +public void blacklist(Features features) { +features.getFeature().removeIf(feature -> blacklist(feature)); } -public static boolean blacklist(Feature feature, Clause[] clauses) { +public boolean blacklist(Feature feature) { for (Clause clause : clauses) { // Check feature name if (clause.getName().equals(feature.getName())) { @@ -83,16 +102,16 @@ public class Blacklist { } } // Check bundles -
[2/3] karaf git commit: Extract common code
Extract common code Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/db2bf32c Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/db2bf32c Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/db2bf32c Branch: refs/heads/master Commit: db2bf32c780aadae38136e6ea6adeb8ed38950c4 Parents: c79e2ba Author: Christian SchneiderAuthored: Wed Aug 16 18:00:43 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 18:00:43 2017 +0200 -- .../apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/db2bf32c/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java index 3d6eb66..1e194b6 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModule.java @@ -101,10 +101,11 @@ public class SyncopeLoginModule extends AbstractKarafLoginModule { LOGGER.debug("Populating principals with user"); principals.add(new UserPrincipal(user)); LOGGER.debug("Retrieving user {} roles", user); +String responseSt = EntityUtils.toString(response.getEntity()); if (version.equals("2.x") || version.equals("2")) { -roles = extractingRolesSyncope2(EntityUtils.toString(response.getEntity())); +roles = extractingRolesSyncope2(responseSt); } else { -roles = extractingRolesSyncope1(EntityUtils.toString(response.getEntity())); +roles = extractingRolesSyncope1(responseSt); } } catch (Exception e) { LOGGER.error("User {} authentication failed", user, e); @@ -162,6 +163,7 @@ public class SyncopeLoginModule extends AbstractKarafLoginModule { * @return the list of user roles. * @throws Exception in case of extractiong failure. */ +@SuppressWarnings("unchecked") protected List extractingRolesSyncope2(String response) throws Exception { List roles = new ArrayList<>(); if (response != null && !response.isEmpty()) {
[1/3] karaf git commit: Cleanup jdbc tests
Repository: karaf Updated Branches: refs/heads/master fd7439664 -> b57bceae1 Cleanup jdbc tests Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/c79e2ba2 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/c79e2ba2 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/c79e2ba2 Branch: refs/heads/master Commit: c79e2ba2b30349f220d2d2affb1d1aed410042fb Parents: fd74396 Author: Christian SchneiderAuthored: Wed Aug 16 15:53:10 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 15:53:10 2017 +0200 -- .../karaf/jaas/modules/jdbc/JDBCUtils.java | 4 +- .../jaas/modules/jdbc/JdbcLoginModuleTest.java | 116 --- 2 files changed, 52 insertions(+), 68 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/c79e2ba2/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/jdbc/JDBCUtils.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/jdbc/JDBCUtils.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/jdbc/JDBCUtils.java index 4e1cda8..5be25b0 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/jdbc/JDBCUtils.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/jdbc/JDBCUtils.java @@ -75,9 +75,9 @@ public final class JDBCUtils { if (tokens.length > 1) { filter = tokens[1]; } -ServiceReference[] references = bc.getServiceReferences(clazz, filter); +ServiceReference[] references = bc.getServiceReferences(clazz, filter); if (references != null) { -ServiceReference ref = references[0]; +ServiceReference ref = references[0]; Object ds = bc.getService(ref); bc.ungetService(ref); return ds; http://git-wip-us.apache.org/repos/asf/karaf/blob/c79e2ba2/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/jdbc/JdbcLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/jdbc/JdbcLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/jdbc/JdbcLoginModuleTest.java index cd960ed..66eebb6 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/jdbc/JdbcLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/jdbc/JdbcLoginModuleTest.java @@ -24,7 +24,7 @@ import java.util.Map; import javax.security.auth.Subject; import javax.sql.DataSource; -import org.apache.derby.jdbc.EmbeddedDataSource40; +import org.apache.derby.jdbc.EmbeddedDataSource; import org.apache.karaf.jaas.boot.principal.GroupPrincipal; import org.apache.karaf.jaas.boot.principal.RolePrincipal; import org.apache.karaf.jaas.boot.principal.UserPrincipal; @@ -42,54 +42,42 @@ import static org.junit.Assert.assertTrue; public class JdbcLoginModuleTest { -private EmbeddedDataSource40 dataSource; +private EmbeddedDataSource dataSource; private Map options; +@SuppressWarnings("unchecked") @Before public void setUp() throws Exception { System.setProperty("derby.stream.error.file", "target/derby.log"); // Create datasource -dataSource = new EmbeddedDataSource40(); +dataSource = new EmbeddedDataSource(); dataSource.setDatabaseName("memory:db"); dataSource.setCreateDatabase("create"); // Delete tables try (Connection connection = dataSource.getConnection()) { connection.setAutoCommit(true); -try { -try (Statement statement = connection.createStatement()) { +try (Statement statement = connection.createStatement()) { statement.execute("drop table USERS"); -} } catch (SQLException e) { // Ignore } -try { -try (Statement statement = connection.createStatement()) { -statement.execute("drop table ROLES"); -} +try (Statement statement = connection.createStatement()) { +statement.execute("drop table ROLES"); } catch (SQLException e) { // Ignore } -connection.commit(); -} - -// Create tables -try (Connection connection = dataSource.getConnection()) { try (Statement statement = connection.createStatement()) { statement.execute("create table USERS (USERNAME VARCHAR(32) PRIMARY KEY, PASSWORD VARCHAR(32))"); -} -try
[3/3] karaf git commit: Extract response data. Improve assertions
Extract response data. Improve assertions Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/b57bceae Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/b57bceae Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/b57bceae Branch: refs/heads/master Commit: b57bceae1855e610e3941c73b1b1260bea264c0d Parents: db2bf32 Author: Christian SchneiderAuthored: Wed Aug 16 18:01:20 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 18:01:20 2017 +0200 -- .../modules/syncope/SyncopeLoginModuleTest.java | 131 +++ .../jaas/modules/syncope/syncope1Response.xml | 70 ++ .../jaas/modules/syncope/syncope2Response.json | 55 3 files changed, 146 insertions(+), 110 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/b57bceae/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModuleTest.java index 560879a..1156585 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/syncope/SyncopeLoginModuleTest.java @@ -16,131 +16,42 @@ */ package org.apache.karaf.jaas.modules.syncope; -import org.junit.Test; -import org.junit.Assert; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.junit.Assert.assertThat; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.List; +import java.util.stream.Collectors; + +import org.junit.Test; public class SyncopeLoginModuleTest { @Test public void testRolesExtractionSyncope1() throws Exception { -String syncopeResponse = "\n" + -"\n" + -"\n" + -"\n" + -"false\n" + -"cool\n" + -"false\n" + -"\n" + -"\n" + -"false\n" + -"email\n" + -"ka...@example.net\n" + -"\n" + -"\n" + -"false\n" + -"fullname\n" + -"karaf\n" + -"\n" + -"\n" + -"false\n" + -"gender\n" + -"M\n" + -"\n" + -"\n" + -"false\n" + -"surname\n" + -"karaf\n" + -"\n" + -"\n" + -"false\n" + -"userId\n" + -"ka...@example.net\n" + -"\n" + -"\n" + -"\n" + -"100\n" + -"\n" + -"\n" + -"\n" + -" 2014-08-12T18:37:09.202+02:00\n" + -"0\n" + -" 2014-08-13T09:38:02.204+02:00\n" + -"\n" + -"\n" + -"\n" + -"\n" + -"100\n" + -"\n" + -"\n" + -"\n" + -"\n" + -"100\n" + -"admin\n" + -"\n" + -"\n" + -"\n" + -"\n" + -"101\n" + -"\n" + -"\n" + -"\n" + -"\n" + -"101\n" + -"another\n" + -"\n" + -"\n" + -" 36460D3A3C1E27C0DB2AF23344475EE712DD3C9D\n" + -"active\n" + -"karaf\n" + -"\n"; +String syncopeResponse = read("syncope1Response.xml"); SyncopeLoginModule syncopeLoginModule = new SyncopeLoginModule(); List roles =
karaf git commit: Avoid using commons io. Allow to specify replacement function
Repository: karaf Updated Branches: refs/heads/master 0853a353a -> fd7439664 Avoid using commons io. Allow to specify replacement function Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/fd743966 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/fd743966 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/fd743966 Branch: refs/heads/master Commit: fd74396648a0bb42ba2d01c5bed1c6c7bbef1694 Parents: 0853a35 Author: Christian SchneiderAuthored: Wed Aug 16 14:16:53 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 14:16:53 2017 +0200 -- jaas/modules/pom.xml| 5 --- .../modules/ldap/GSSAPILdapLoginModuleTest.java | 35 .../karaf/jaas/modules/ldap/LdapCacheTest.java | 4 ++- .../modules/ldap/LdapCaseInsensitiveDNTest.java | 4 ++- .../jaas/modules/ldap/LdapLoginModuleTest.java | 9 +++-- .../ldap/LdapLoginModuleWithEscapesTest.java| 5 ++- .../jaas/modules/ldap/LdapPropsUpdater.java | 35 .../ldap/LdapSpecialCharsInPasswordTest.java| 5 ++- 8 files changed, 40 insertions(+), 62 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/fd743966/jaas/modules/pom.xml -- diff --git a/jaas/modules/pom.xml b/jaas/modules/pom.xml index b6be3d8..8038102 100644 --- a/jaas/modules/pom.xml +++ b/jaas/modules/pom.xml @@ -91,11 +91,6 @@ test -commons-io -commons-io -test - - org.apache.directory.server apacheds-core-integ ${directory-version} http://git-wip-us.apache.org/repos/asf/karaf/blob/fd743966/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java index b664bc3..9d049d8 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java @@ -14,13 +14,12 @@ */ package org.apache.karaf.jaas.modules.ldap; +import static org.apache.karaf.jaas.modules.ldap.LdapPropsUpdater.ldapProps; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.security.Principal; import java.util.Collections; @@ -30,7 +29,6 @@ import javax.security.auth.kerberos.KerberosPrincipal; import javax.security.auth.kerberos.KerberosTicket; import javax.security.auth.login.LoginException; -import org.apache.commons.io.IOUtils; import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms; import org.apache.directory.api.ldap.model.entry.DefaultEntry; import org.apache.directory.api.ldap.model.entry.Entry; @@ -131,8 +129,6 @@ import org.junit.runner.RunWith; }) public class GSSAPILdapLoginModuleTest extends KarafKerberosITest { -private static boolean loginConfigUpdated; - @Before public void setUp() throws Exception { super.setUp(); @@ -153,32 +149,13 @@ public class GSSAPILdapLoginModuleTest extends KarafKerberosITest { System.setProperty("java.security.auth.login.config", config.toString()); -updatePort(); +ldapProps("org/apache/karaf/jaas/modules/ldap/gssapi.ldap.properties", + GSSAPILdapLoginModuleTest::replacePortAndAddress); } -public void updatePort() throws Exception { -if (!loginConfigUpdated) { -String basedir = System.getProperty("basedir"); -if (basedir == null) { -basedir = new File(".").getCanonicalPath(); -} - -// Read in ldap.properties and substitute in the correct port -File f = new File(basedir + "/src/test/resources/org/apache/karaf/jaas/modules/ldap/gssapi.ldap.properties"); - -FileInputStream inputStream = new FileInputStream(f); -String content = IOUtils.toString(inputStream, "UTF-8"); -inputStream.close(); -content = content.replaceAll("portno", "" + getLdapServer().getPort()); -content = content.replaceAll("address", KerberosTestUtils.getHostName()); - -File f2 = new File(basedir +
[3/5] karaf git commit: Use simple PrintStream
Use simple PrintStream Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/e973e3c7 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/e973e3c7 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/e973e3c7 Branch: refs/heads/master Commit: e973e3c73cd431492bfc6ed6f1fb336f4f71ceaa Parents: 71b136e Author: Christian SchneiderAuthored: Wed Aug 16 11:50:58 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 11:50:58 2017 +0200 -- .../modules/ldap/GSSAPILdapLoginModuleTest.java | 77 +--- 1 file changed, 33 insertions(+), 44 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/e973e3c7/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java index b0152f1..11daa72 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java @@ -14,9 +14,24 @@ */ package org.apache.karaf.jaas.modules.ldap; -import org.apache.commons.io.FileUtils; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.security.Principal; +import java.util.Collections; + +import javax.security.auth.Subject; +import javax.security.auth.kerberos.KerberosPrincipal; +import javax.security.auth.kerberos.KerberosTicket; +import javax.security.auth.login.LoginException; + import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.SystemUtils; import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms; import org.apache.directory.api.ldap.model.entry.DefaultEntry; import org.apache.directory.api.ldap.model.entry.Entry; @@ -53,22 +68,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import javax.security.auth.Subject; -import javax.security.auth.kerberos.KerberosPrincipal; -import javax.security.auth.kerberos.KerberosTicket; -import javax.security.auth.login.LoginException; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.charset.Charset; -import java.security.Principal; -import java.util.Collections; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - @RunWith(FrameworkRunner.class) @CreateDS(name = "GSSAPILdapLoginModuleTest-class", partitions = @@ -317,34 +316,24 @@ public class GSSAPILdapLoginModuleTest extends AbstractKerberosITest { private String createKrb5Conf(ChecksumType checksumType, EncryptionType encryptionType, boolean isTcp) throws IOException { File file = folder.newFile("krb5.conf"); - -String data = ""; - -data += "[libdefaults]" + SystemUtils.LINE_SEPARATOR; -data += "default_realm = " + REALM + SystemUtils.LINE_SEPARATOR; -data += "default_tkt_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR; -data += "default_tgs_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR; -data += "permitted_enctypes = " + encryptionType.getName() + SystemUtils.LINE_SEPARATOR; -//data += "default_checksum = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR; -//data += "ap_req_checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR; -data += "default-checksum_type = " + checksumType.getName() + SystemUtils.LINE_SEPARATOR; - +PrintStream out = new PrintStream(file); +out.println("[libdefaults]"); +out.println("default_realm = " + REALM); +out.println("default_tkt_enctypes = " + encryptionType.getName()); +out.println("default_tgs_enctypes = " + encryptionType.getName()); +out.println("permitted_enctypes = " + encryptionType.getName()); +out.println("default-checksum_type = " + checksumType.getName()); if (isTcp) { -data += "udp_preference_limit = 1" + SystemUtils.LINE_SEPARATOR; +out.println("udp_preference_limit = 1"); } - - -data += "[realms]" + SystemUtils.LINE_SEPARATOR; -data += REALM + " = {" + SystemUtils.LINE_SEPARATOR; -
[2/5] karaf git commit: Replace deprecated call
Replace deprecated call Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/71b136ed Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/71b136ed Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/71b136ed Branch: refs/heads/master Commit: 71b136ed8307f6470e32874dfed627844c9fc666 Parents: 6aa806d Author: Christian SchneiderAuthored: Wed Aug 16 11:44:38 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 11:44:38 2017 +0200 -- .../apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/71b136ed/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java index 47ea240..b0152f1 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/GSSAPILdapLoginModuleTest.java @@ -61,6 +61,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.charset.Charset; import java.security.Principal; import java.util.Collections; @@ -342,7 +343,7 @@ public class GSSAPILdapLoginModuleTest extends AbstractKerberosITest { data += "." + Strings.lowerCaseAscii(REALM) + " = " + REALM + SystemUtils.LINE_SEPARATOR; data += Strings.lowerCaseAscii(REALM) + " = " + REALM + SystemUtils.LINE_SEPARATOR; -FileUtils.writeStringToFile(file, data); +FileUtils.writeStringToFile(file, data, Charset.defaultCharset()); return file.getAbsolutePath(); }
[1/5] karaf git commit: Use matcher in tests
Repository: karaf Updated Branches: refs/heads/master 01d0aae9b -> 0853a353a Use matcher in tests Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/6aa806d2 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/6aa806d2 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/6aa806d2 Branch: refs/heads/master Commit: 6aa806d2ad0df30d162693f8daa013dc6b0f110f Parents: 01d0aae Author: Christian SchneiderAuthored: Wed Aug 16 11:34:37 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 11:34:37 2017 +0200 -- .../karaf/jaas/modules/PrincipalAssert.java | 40 .../karaf/jaas/modules/PrincipalHelper.java | 29 + .../karaf/jaas/modules/ldap/LdapCacheTest.java | 67 +--- .../properties/PropertiesBackingEngineTest.java | 2 +- .../properties/PropertiesLoginModuleTest.java | 14 ++-- 5 files changed, 67 insertions(+), 85 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/6aa806d2/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java deleted file mode 100644 index c19fd2b..000 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed 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. - * under the License. - */ -package org.apache.karaf.jaas.modules; - -import static java.util.stream.Collectors.toList; - -import java.security.Principal; -import java.util.List; -import java.util.stream.Collectors; - -import javax.security.auth.Subject; - -import org.junit.Assert; - -public class PrincipalAssert { - -public static List names(List principals) { -return principals.stream().map(r->r.getName()).collect(toList()); -} - -public static void assertPrincipalNamed(Subject subject, Class clazz, String expectedName) { -Long numMatching = subject.getPrincipals(clazz).stream() -.filter(pr -> expectedName.equals(pr.getName())) -.collect(Collectors.counting()); -Assert.assertEquals("Expected " + clazz.getSimpleName() + " principal in subject with name=" + expectedName, -1l, numMatching.intValue()); -} -} http://git-wip-us.apache.org/repos/asf/karaf/blob/6aa806d2/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalHelper.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalHelper.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalHelper.java new file mode 100644 index 000..9893193 --- /dev/null +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalHelper.java @@ -0,0 +1,29 @@ +/* + * Licensed 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. + * under the License. + */ +package org.apache.karaf.jaas.modules; + +import static java.util.stream.Collectors.toList; + +import java.security.Principal; +import java.util.Collection; +import java.util.List; + +public class PrincipalHelper { + +public static List names(Collection principals) { +return principals.stream().map(r->r.getName()).collect(toList()); +} + +} http://git-wip-us.apache.org/repos/asf/karaf/blob/6aa806d2/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapCacheTest.java -- diff --git
karaf git commit: Refactor test
Repository: karaf Updated Branches: refs/heads/master 713d25d4f -> 01d0aae9b Refactor test Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/01d0aae9 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/01d0aae9 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/01d0aae9 Branch: refs/heads/master Commit: 01d0aae9b62531919f00d96eb22119bf59d0209b Parents: 713d25d Author: Christian SchneiderAuthored: Wed Aug 16 11:12:46 2017 +0200 Committer: Christian Schneider Committed: Wed Aug 16 11:12:46 2017 +0200 -- jaas/modules/pom.xml| 6 + .../karaf/jaas/modules/PrincipalAssert.java | 40 +++ .../properties/PropertiesBackingEngineTest.java | 266 +++ .../properties/PropertiesLoginModuleTest.java | 42 +-- 4 files changed, 146 insertions(+), 208 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/01d0aae9/jaas/modules/pom.xml -- diff --git a/jaas/modules/pom.xml b/jaas/modules/pom.xml index 8313005..b6be3d8 100644 --- a/jaas/modules/pom.xml +++ b/jaas/modules/pom.xml @@ -120,6 +120,12 @@ ${derby-version} test + +org.hamcrest +hamcrest-all +1.3 +test + http://git-wip-us.apache.org/repos/asf/karaf/blob/01d0aae9/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java new file mode 100644 index 000..c19fd2b --- /dev/null +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/PrincipalAssert.java @@ -0,0 +1,40 @@ +/* + * Licensed 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. + * under the License. + */ +package org.apache.karaf.jaas.modules; + +import static java.util.stream.Collectors.toList; + +import java.security.Principal; +import java.util.List; +import java.util.stream.Collectors; + +import javax.security.auth.Subject; + +import org.junit.Assert; + +public class PrincipalAssert { + +public static List names(List principals) { +return principals.stream().map(r->r.getName()).collect(toList()); +} + +public static void assertPrincipalNamed(Subject subject, Class clazz, String expectedName) { +Long numMatching = subject.getPrincipals(clazz).stream() +.filter(pr -> expectedName.equals(pr.getName())) +.collect(Collectors.counting()); +Assert.assertEquals("Expected " + clazz.getSimpleName() + " principal in subject with name=" + expectedName, +1l, numMatching.intValue()); +} +} http://git-wip-us.apache.org/repos/asf/karaf/blob/01d0aae9/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/properties/PropertiesBackingEngineTest.java -- diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/properties/PropertiesBackingEngineTest.java b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/properties/PropertiesBackingEngineTest.java index b781cd1..0c811da 100644 --- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/properties/PropertiesBackingEngineTest.java +++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/properties/PropertiesBackingEngineTest.java @@ -16,188 +16,104 @@ */ package org.apache.karaf.jaas.modules.properties; -import junit.framework.TestCase; +import static org.apache.karaf.jaas.modules.PrincipalAssert.names; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.stream.Collectors; + import org.apache.felix.utils.properties.Properties; import org.apache.karaf.jaas.boot.principal.GroupPrincipal; -import org.apache.karaf.jaas.boot.principal.RolePrincipal; import org.apache.karaf.jaas.boot.principal.UserPrincipal;
karaf git commit: Fix warnings
Repository: karaf Updated Branches: refs/heads/master 767012d25 -> 713d25d4f Fix warnings Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/713d25d4 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/713d25d4 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/713d25d4 Branch: refs/heads/master Commit: 713d25d4ffd40ad669a53b5d1fa9d8b497fc8b57 Parents: 767012d Author: Christian SchneiderAuthored: Tue Aug 15 23:30:07 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 23:30:07 2017 +0200 -- .../apache/karaf/jaas/modules/ldap/LDAPBackingEngine.java| 5 ++--- .../java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java | 8 .../java/org/apache/karaf/jaas/modules/ldap/LDAPOptions.java | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/713d25d4/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPBackingEngine.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPBackingEngine.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPBackingEngine.java index 5bd3072..4ee865e 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPBackingEngine.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPBackingEngine.java @@ -33,7 +33,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.regex.Matcher; import java.util.regex.Pattern; /** @@ -87,10 +86,10 @@ public class LDAPBackingEngine implements BackingEngine { LOGGER.debug(" base DN: " + options.getUserBaseDn()); LOGGER.debug(" filter: " + filter); -NamingEnumeration namingEnumeration = context.search(options.getUserBaseDn(), filter, controls); +NamingEnumeration namingEnumeration = context.search(options.getUserBaseDn(), filter, controls); try { while (namingEnumeration.hasMore()) { -SearchResult result = (SearchResult) namingEnumeration.next(); +SearchResult result = namingEnumeration.next(); // We need to do the following because slashes are handled badly. For example, when searching // for a user with lots of special characters like cn=admin,=+<>#;\ http://git-wip-us.apache.org/repos/asf/karaf/blob/713d25d4/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java -- diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java index f80af8c..7566165 100644 --- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java +++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPCache.java @@ -165,14 +165,14 @@ public class LDAPCache implements Closeable, NamespaceChangeListener, ObjectChan LOGGER.debug(" base DN: " + options.getUserBaseDn()); LOGGER.debug(" filter: " + filter); -NamingEnumeration namingEnumeration = context.search(options.getUserBaseDn(), filter, controls); +NamingEnumeration namingEnumeration = context.search(options.getUserBaseDn(), filter, controls); try { if (!namingEnumeration.hasMore()) { LOGGER.warn("User " + user + " not found in LDAP."); return null; } LOGGER.debug("Found the user DN."); -SearchResult result = (SearchResult) namingEnumeration.next(); +SearchResult result = namingEnumeration.next(); // We need to do the following because slashes are handled badly. For example, when searching // for a user with lots of special characters like cn=admin,=+<>#;\ @@ -250,11 +250,11 @@ public class LDAPCache implements Closeable, NamespaceChangeListener, ObjectChan LOGGER.debug(" base DN: " + options.getRoleBaseDn()); LOGGER.debug(" filter: " + filter); -NamingEnumeration namingEnumeration = context.search(options.getRoleBaseDn(), filter, controls); +NamingEnumeration namingEnumeration = context.search(options.getRoleBaseDn(), filter, controls); try { List rolesList = new ArrayList<>(); while (namingEnumeration.hasMore()) { -SearchResult result = (SearchResult) namingEnumeration.next(); +SearchResult result =
[2/5] karaf git commit: Avoid excessive logging
Avoid excessive logging Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/fcf9b7c1 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/fcf9b7c1 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/fcf9b7c1 Branch: refs/heads/master Commit: fcf9b7c19b9c9edf56aa75ab29675a30c237e741 Parents: b496914 Author: Christian SchneiderAuthored: Tue Aug 15 17:47:03 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 17:47:03 2017 +0200 -- jaas/jasypt/src/test/resources/log4j.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/fcf9b7c1/jaas/jasypt/src/test/resources/log4j.properties -- diff --git a/jaas/jasypt/src/test/resources/log4j.properties b/jaas/jasypt/src/test/resources/log4j.properties index e1cbdd1..3822bad 100644 --- a/jaas/jasypt/src/test/resources/log4j.properties +++ b/jaas/jasypt/src/test/resources/log4j.properties @@ -18,7 +18,7 @@ # # The logging properties used during tests.. # -log4j.rootLogger=DEBUG, console, file +log4j.rootLogger=INFO, console, file # Console will only display warnnings log4j.appender.console=org.apache.log4j.ConsoleAppender
[3/5] karaf git commit: Refactor GenerateServiceMetadata
Refactor GenerateServiceMetadata Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/011c9b04 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/011c9b04 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/011c9b04 Branch: refs/heads/master Commit: 011c9b048f6ae16271be6154e6d547ad288e70fc Parents: fcf9b7c Author: Christian SchneiderAuthored: Tue Aug 15 17:47:32 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 17:47:32 2017 +0200 -- .../tracker/GenerateServiceMetadata.java| 74 +--- 1 file changed, 33 insertions(+), 41 deletions(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/011c9b04/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java -- diff --git a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java index ba4fac1..2d44bfd 100644 --- a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java +++ b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java @@ -17,6 +17,7 @@ package org.apache.karaf.tooling.tracker; import java.io.File; +import java.io.IOException; import java.io.OutputStream; import java.net.URL; import java.net.URLClassLoader; @@ -84,8 +85,8 @@ public class GenerateServiceMetadata extends AbstractMojo { try { boolean addSourceDirectory = false; -StringBuilder requirements = new StringBuilder(); -StringBuilder capabilities = new StringBuilder(); +List requirements = new ArrayList<>(); +List capabilities = new ArrayList<>(); ClassFinder finder = createFinder(classLoader); List classes = finder.findAnnotatedClasses(Services.class); @@ -103,28 +104,18 @@ public class GenerateServiceMetadata extends AbstractMojo { activators.add(clazz); } -Properties props = new Properties(); +writeServiceProperties(clazz); + Services services = clazz.getAnnotation(Services.class); if (services != null) { for (RequireService req : services.requires()) { -String fltWithClass = combine(req.filter(), "(objectClass=" + req.value().getName() + ")"); -addServiceReq(requirements, fltWithClass); -props.setProperty(req.value().getName(), req.filter()); +requirements.add(getRequirement(req)); } for (ProvideService cap : services.provides()) { -addServiceCap(capabilities, cap); +capabilities.add(getCapability(cap)); } } -Managed managed = clazz.getAnnotation(Managed.class); -if (managed != null) { -props.setProperty("pid", managed.value()); -} - -File file = new File(outputDirectory, "OSGI-INF/karaf-tracker/" + clazz.getName()); -file.getParentFile().mkdirs(); -try (OutputStream os = buildContext.newFileOutputStream(file)) { -props.store(os, null); -} + addSourceDirectory = true; } @@ -134,8 +125,8 @@ public class GenerateServiceMetadata extends AbstractMojo { project.addResource(resource); } -project.getProperties().setProperty(requirementsProperty, requirements.toString()); -project.getProperties().setProperty(capabilitiesProperty, capabilities.toString()); +project.getProperties().setProperty(requirementsProperty, String.join(",", requirements)); +project.getProperties().setProperty(capabilitiesProperty, String.join(",", capabilities)); if (activators.size() == 1) { project.getProperties().setProperty(activatorProperty, activators.get(0).getName()); } @@ -148,7 +139,7 @@ public class GenerateServiceMetadata extends AbstractMojo { packages.add(clazz.getPackage().getName()); } if (!packages.isEmpty()) { - project.getProperties().setProperty("BNDExtension-Karaf-Commands", join(packages, ",")); +
[5/5] karaf git commit: Avoid excessive logging
Avoid excessive logging Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/767012d2 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/767012d2 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/767012d2 Branch: refs/heads/master Commit: 767012d2544be03ab5818f3288912f1578d0e0c2 Parents: 1bf544b Author: Christian SchneiderAuthored: Tue Aug 15 17:57:24 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 17:57:24 2017 +0200 -- jaas/blueprint/jasypt/src/test/resources/log4j.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/767012d2/jaas/blueprint/jasypt/src/test/resources/log4j.properties -- diff --git a/jaas/blueprint/jasypt/src/test/resources/log4j.properties b/jaas/blueprint/jasypt/src/test/resources/log4j.properties index e1cbdd1..3822bad 100644 --- a/jaas/blueprint/jasypt/src/test/resources/log4j.properties +++ b/jaas/blueprint/jasypt/src/test/resources/log4j.properties @@ -18,7 +18,7 @@ # # The logging properties used during tests.. # -log4j.rootLogger=DEBUG, console, file +log4j.rootLogger=INFO, console, file # Console will only display warnnings log4j.appender.console=org.apache.log4j.ConsoleAppender
[1/5] karaf git commit: Suppress logging of WriteToClosedSessionException
Repository: karaf Updated Branches: refs/heads/master ecf6a8dc7 -> 767012d25 Suppress logging of WriteToClosedSessionException Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/b4969149 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/b4969149 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/b4969149 Branch: refs/heads/master Commit: b4969149ff1dc52890f0a4c204258e904e84 Parents: ecf6a8d Author: Christian SchneiderAuthored: Tue Aug 15 17:13:07 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 17:13:07 2017 +0200 -- jaas/modules/src/test/resources/log4j.properties | 3 +++ 1 file changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/b4969149/jaas/modules/src/test/resources/log4j.properties -- diff --git a/jaas/modules/src/test/resources/log4j.properties b/jaas/modules/src/test/resources/log4j.properties index a75bae2..485e43b 100644 --- a/jaas/modules/src/test/resources/log4j.properties +++ b/jaas/modules/src/test/resources/log4j.properties @@ -20,6 +20,9 @@ # log4j.rootLogger=INFO, console, file +# Suppress logging of WriteToClosedSessionException +log4j.logger.org.apache.directory.server.ldap.LdapProtocolHandler=OFF + # Console will only display warnings log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console.layout=org.apache.log4j.PatternLayout
[4/5] karaf git commit: Do not print each classpath Element
Do not print each classpath Element Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/1bf544b9 Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/1bf544b9 Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/1bf544b9 Branch: refs/heads/master Commit: 1bf544b95aa03ad6f4c4ec6a9060b047430615a5 Parents: 011c9b0 Author: Christian SchneiderAuthored: Tue Aug 15 17:48:10 2017 +0200 Committer: Christian Schneider Committed: Tue Aug 15 17:48:10 2017 +0200 -- .../org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java | 1 - 1 file changed, 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/karaf/blob/1bf544b9/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java -- diff --git a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java index 2d44bfd..7b0fd37 100644 --- a/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java +++ b/tooling/karaf-services-maven-plugin/src/main/java/org/apache/karaf/tooling/tracker/GenerateServiceMetadata.java @@ -194,7 +194,6 @@ public class GenerateServiceMetadata extends AbstractMojo { File file = artifact.getFile(); if ( file != null ) { urls.add( file.toURI().toURL() ); -System.out.println("classpath: " + file); } } ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());