You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by da...@apache.org on 2019/12/17 08:24:34 UTC
[sling-whiteboard] branch master updated: Javadoc for MergeContext
This is an automated email from the ASF dual-hosted git repository.
davidb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git
The following commit(s) were added to refs/heads/master by this push:
new 7950119 Javadoc for MergeContext
7950119 is described below
commit 795011920535689dda6539336c09b48caf2f8fce
Author: David Bosschaert <da...@gmail.com>
AuthorDate: Tue Dec 17 08:24:20 2019 +0000
Javadoc for MergeContext
---
.../main/java/org/osgi/feature/MergeContext.java | 24 ++++++++++++++++++++--
.../osgi/feature/builder/MergeContextBuilder.java | 22 +++++++++++++++++---
.../org/osgi/feature/impl/FeatureServiceImpl.java | 2 +-
.../osgi/feature/impl/FeatureServiceImplTest.java | 2 +-
4 files changed, 43 insertions(+), 7 deletions(-)
diff --git a/osgi-featuremodel/src/main/java/org/osgi/feature/MergeContext.java b/osgi-featuremodel/src/main/java/org/osgi/feature/MergeContext.java
index f45fbb5..61e221d 100644
--- a/osgi-featuremodel/src/main/java/org/osgi/feature/MergeContext.java
+++ b/osgi-featuremodel/src/main/java/org/osgi/feature/MergeContext.java
@@ -18,8 +18,28 @@ package org.osgi.feature;
import java.util.List;
+/**
+ * Context provided by the caller for the merge operation.
+ * @ConsumerType
+ */
public interface MergeContext {
- List<Bundle> resolveBundles(Bundle b1, Bundle b2);
+ /**
+ * If two merged features both contain the same bundle, same group ID and
+ * artifact ID but different version, this method is called to resolve what to
+ * do.
+ * @param b1 The first bundle.
+ * @param b2 The second bundle.
+ * @return Return a list of bundles that should be used in this case. This could
+ * be one or both of the provided bundles, or a different bundle altogether.
+ */
+ List<Bundle> resolveBundleConflict(Bundle b1, Bundle b2);
- Configuration resolveConfigurations(Configuration c1, Configuration c2);
+ /**
+ * If two merged features both contain the same configuration PID, this method
+ * is called to perform the merge operation.
+ * @param c1 The first configuration.
+ * @param c2 The second configuration.
+ * @return The configuration to use.
+ */
+ Configuration resolveConfigurationConflict(Configuration c1, Configuration c2);
}
diff --git a/osgi-featuremodel/src/main/java/org/osgi/feature/builder/MergeContextBuilder.java b/osgi-featuremodel/src/main/java/org/osgi/feature/builder/MergeContextBuilder.java
index b0b2472..f558230 100644
--- a/osgi-featuremodel/src/main/java/org/osgi/feature/builder/MergeContextBuilder.java
+++ b/osgi-featuremodel/src/main/java/org/osgi/feature/builder/MergeContextBuilder.java
@@ -1,3 +1,19 @@
+/*
+ * 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.osgi.feature.builder;
import org.osgi.feature.Bundle;
@@ -10,7 +26,7 @@ import java.util.function.BiFunction;
public class MergeContextBuilder {
private BiFunction<Bundle, Bundle, List<Bundle>> bundleResolver;
- public MergeContextBuilder setBundleResolver(BiFunction<Bundle, Bundle, List<Bundle>> bf) {
+ public MergeContextBuilder setBundleConflictResolver(BiFunction<Bundle, Bundle, List<Bundle>> bf) {
bundleResolver = bf;
return this;
}
@@ -27,12 +43,12 @@ public class MergeContextBuilder {
}
@Override
- public List<Bundle> resolveBundles(Bundle b1, Bundle b2) {
+ public List<Bundle> resolveBundleConflict(Bundle b1, Bundle b2) {
return bundleResolver.apply(b1, b2);
}
@Override
- public Configuration resolveConfigurations(Configuration c1, Configuration c2) {
+ public Configuration resolveConfigurationConflict(Configuration c1, Configuration c2) {
// TODO Auto-generated method stub
return null;
}
diff --git a/osgi-featuremodel/src/main/java/org/osgi/feature/impl/FeatureServiceImpl.java b/osgi-featuremodel/src/main/java/org/osgi/feature/impl/FeatureServiceImpl.java
index 2c3e551..e33bd0d 100644
--- a/osgi-featuremodel/src/main/java/org/osgi/feature/impl/FeatureServiceImpl.java
+++ b/osgi-featuremodel/src/main/java/org/osgi/feature/impl/FeatureServiceImpl.java
@@ -129,7 +129,7 @@ public class FeatureServiceImpl implements FeatureService {
if (bID.getGroupId().equals(orgID.getGroupId()) &&
bID.getArtifactId().equals(orgID.getArtifactId())) {
- List<Bundle> res = new ArrayList<>(ctx.resolveBundles(b, orgb));
+ List<Bundle> res = new ArrayList<>(ctx.resolveBundleConflict(b, orgb));
if (res.contains(orgb)) {
res.remove(orgb);
} else {
diff --git a/osgi-featuremodel/src/test/java/org/osgi/feature/impl/FeatureServiceImplTest.java b/osgi-featuremodel/src/test/java/org/osgi/feature/impl/FeatureServiceImplTest.java
index ef024c3..4b7ed7e 100644
--- a/osgi-featuremodel/src/test/java/org/osgi/feature/impl/FeatureServiceImplTest.java
+++ b/osgi-featuremodel/src/test/java/org/osgi/feature/impl/FeatureServiceImplTest.java
@@ -81,7 +81,7 @@ public class FeatureServiceImplTest {
}
MergeContext ctx = new MergeContextBuilder()
- .setBundleResolver((b1, b2) -> Arrays.asList(b1, b2))
+ .setBundleConflictResolver((b1, b2) -> Arrays.asList(b1, b2))
.build();
ArtifactID tid = new ArtifactID("foo", "bar", "1.2.3");
Feature f3 = fs.mergeFeatures(tid, f1, f2, ctx);