You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by am...@apache.org on 2026/05/29 16:30:09 UTC
(aries-rsa) 03/09: ARIES-2225 Fix FastBinProvider intents handling to comply with spec
This is an automated email from the ASF dual-hosted git repository.
amichair pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit 60cf02978822adc64ff763f860eaeb9f3a7c44d3
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Thu May 21 09:04:05 2026 +0300
ARIES-2225 Fix FastBinProvider intents handling to comply with spec
---
.../aries/rsa/provider/fastbin/Activator.java | 2 +-
.../rsa/provider/fastbin/FastBinProvider.java | 65 +++++++++++-----------
2 files changed, 33 insertions(+), 34 deletions(-)
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/Activator.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/Activator.java
index 17db549a..d1855340 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/Activator.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/Activator.java
@@ -67,7 +67,7 @@ public class Activator extends BaseActivator implements ManagedService {
client = provider.getClient();
server = provider.getServer();
Dictionary<String, Object> props = new Hashtable<>();
- props.put(RemoteConstants.REMOTE_INTENTS_SUPPORTED, new String[]{});
+ props.put(RemoteConstants.REMOTE_INTENTS_SUPPORTED, FastBinProvider.SUPPORTED_INTENTS);
props.put(RemoteConstants.REMOTE_CONFIGS_SUPPORTED, provider.getSupportedTypes());
register(DistributionProvider.class, provider, props);
}
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/FastBinProvider.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/FastBinProvider.java
index 200a8e35..a707a894 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/FastBinProvider.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/FastBinProvider.java
@@ -22,7 +22,11 @@ import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import java.net.URI;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
@@ -37,6 +41,7 @@ import org.apache.aries.rsa.spi.DistributionProvider;
import org.apache.aries.rsa.spi.Endpoint;
import org.apache.aries.rsa.spi.ImportedService;
import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
+import org.apache.aries.rsa.util.StringPlus;
import org.fusesource.hawtdispatch.Dispatch;
import org.fusesource.hawtdispatch.DispatchQueue;
import org.osgi.framework.BundleContext;
@@ -50,6 +55,14 @@ public class FastBinProvider implements DistributionProvider {
private static final Logger LOG = LoggerFactory.getLogger(FastBinProvider.class);
+ /**
+ * All intents supported by this provider.
+ * <p>
+ * We currently don't support any intents, but the TCK requires at least
+ * one to exist, so we add a placeholder default one that does nothing.
+ */
+ static final String[] SUPPORTED_INTENTS = { "aries.rsa.default" };
+
public static final String FASTBIN_CONFIG_TYPE = "aries.fastbin";
public static final String FASTBIN_ADDRESS = FASTBIN_CONFIG_TYPE + ".address";
@@ -101,56 +114,42 @@ public class FastBinProvider implements DistributionProvider {
return new String[] {FASTBIN_CONFIG_TYPE};
}
+ @SafeVarargs
+ private static <T> Set<T> union(Collection<T>... collections) {
+ Set<T> union = new HashSet<>();
+ for (Collection<T> c : collections)
+ if (c != null)
+ union.addAll(c);
+ return union;
+ }
+
@Override
public Endpoint exportService(final Object serviceO,
BundleContext serviceContext,
Map<String, Object> effectiveProperties,
Class[] exportedInterfaces) {
- // Compute properties
- /*
- Map<String, Object> properties = new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
- for (String k : reference.getPropertyKeys()) {
- properties.put(k, reference.getProperty(k));
- }
- // Bail out if there is any intents specified, we don't support any
- Set<String> intents = Utils.normalize(properties.get(SERVICE_EXPORTED_INTENTS));
- Set<String> extraIntents = Utils.normalize(properties.get(SERVICE_EXPORTED_INTENTS_EXTRA));
- if (!intents.isEmpty() || !extraIntents.isEmpty()) {
- throw new UnsupportedOperationException();
- }
- // Bail out if there are any configurations specified, we don't support any
- Set<String> configs = Utils.normalize(properties.get(SERVICE_EXPORTED_CONFIGS));
- if (configs.isEmpty()) {
- configs.add(CONFIG);
- } else if (!configs.contains(CONFIG)) {
- throw new UnsupportedOperationException();
+ effectiveProperties.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, getSupportedTypes());
+ Set<String> intents = union(
+ StringPlus.normalize(effectiveProperties.get(RemoteConstants.SERVICE_EXPORTED_INTENTS)),
+ StringPlus.normalize(effectiveProperties.get(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA)));
+ intents.removeAll(Arrays.asList(SUPPORTED_INTENTS));
+ if (!intents.isEmpty()) {
+ LOG.warn("Unsupported intents found: {}. Not exporting service", intents);
+ return null;
}
- URI connectUri = new URI(this.server.getConnectAddress());
- String fabricAddress = connectUri.getScheme() + "://" + exportedAddress + ":" + connectUri.getPort();
-
- properties.remove(SERVICE_EXPORTED_CONFIGS);
- properties.put(SERVICE_IMPORTED_CONFIGS, new String[] { CONFIG });
- properties.put(ENDPOINT_FRAMEWORK_UUID, this.uuid);
- properties.put(FABRIC_ADDRESS, fabricAddress);
-
- String uuid = UuidGenerator.getUUID();
- properties.put(ENDPOINT_ID, uuid);
- */
-
String endpointId = UuidGenerator.getUUID();
effectiveProperties.put(RemoteConstants.ENDPOINT_ID, endpointId);
URI connectUri = URI.create(this.server.getConnectAddress());
String fastbinAddress = connectUri.getScheme() + "://" + exportedAddress + ":" + connectUri.getPort();
effectiveProperties.put(FASTBIN_ADDRESS, fastbinAddress);
- effectiveProperties.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, getSupportedTypes());
+ effectiveProperties.put(RemoteConstants.SERVICE_INTENTS, Arrays.asList(SUPPORTED_INTENTS));
- // Now, export the service
final EndpointDescription description = new EndpointDescription(effectiveProperties);
- // Export it
+ // export it
server.registerService(description.getId(), new ServerInvoker.ServiceFactory() {
public Object get() {
return serviceO;