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 67cce1359fe6cf07f8575e85c52e6952990f79f7 Author: Amichai Rothman <[email protected]> AuthorDate: Thu Jun 4 17:22:44 2026 +0300 ARIES-2233 Extract common discovery Interest class --- .../aries/rsa/discovery/tcp/InterestManager.java | 1 + .../aries/rsa/discovery/zookeeper/Interest.java | 57 ---------------------- .../rsa/discovery/zookeeper/InterestManager.java | 1 + .../apache/aries/rsa/spi/discovery}/Interest.java | 2 +- .../aries/rsa/spi/discovery/package-info.java | 22 +++++++++ 5 files changed, 25 insertions(+), 58 deletions(-) diff --git a/discovery/tcp/src/main/java/org/apache/aries/rsa/discovery/tcp/InterestManager.java b/discovery/tcp/src/main/java/org/apache/aries/rsa/discovery/tcp/InterestManager.java index 5abdfc75..4929fcf9 100644 --- a/discovery/tcp/src/main/java/org/apache/aries/rsa/discovery/tcp/InterestManager.java +++ b/discovery/tcp/src/main/java/org/apache/aries/rsa/discovery/tcp/InterestManager.java @@ -18,6 +18,7 @@ */ package org.apache.aries.rsa.discovery.tcp; +import org.apache.aries.rsa.spi.discovery.Interest; import org.osgi.framework.ServiceReference; import org.osgi.service.remoteserviceadmin.EndpointDescription; import org.osgi.service.remoteserviceadmin.EndpointEvent; diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/Interest.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/Interest.java deleted file mode 100644 index da659d59..00000000 --- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/Interest.java +++ /dev/null @@ -1,57 +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.aries.rsa.discovery.zookeeper; - -import static org.osgi.service.remoteserviceadmin.EndpointEventListener.ENDPOINT_LISTENER_SCOPE; - -import java.util.List; - -import org.apache.aries.rsa.util.StringPlus; -import org.osgi.framework.ServiceReference; -import org.osgi.service.remoteserviceadmin.EndpointDescription; -import org.osgi.service.remoteserviceadmin.EndpointEvent; -import org.osgi.service.remoteserviceadmin.EndpointEventListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Interest { - private static final Logger LOG = LoggerFactory.getLogger(Interest.class); - - private final List<String> scopes; - private final EndpointEventListener listener; - - public Interest(ServiceReference<?> sref, EndpointEventListener listener) { - this.scopes = StringPlus.normalize(sref.getProperty(ENDPOINT_LISTENER_SCOPE)); - this.listener = listener; - } - - public void notifyListener(EndpointEvent event) { - EndpointDescription endpoint = event.getEndpoint(); - scopes.stream().filter(endpoint::matches).findFirst().ifPresent(scope -> { // notify with first scope - LOG.info("Calling endpointChanged on {} for filter {}, type {}, endpoint {}", - listener, scope, event.getType(), endpoint); - listener.endpointChanged(event, scope); - }); - } - - @Override - public String toString() { - return "Interest [scopes=" + scopes + ", listener=" + listener.getClass() + "]"; - } -} diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/InterestManager.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/InterestManager.java index f8812612..0dba15e5 100644 --- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/InterestManager.java +++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/InterestManager.java @@ -21,6 +21,7 @@ package org.apache.aries.rsa.discovery.zookeeper; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.apache.aries.rsa.spi.discovery.Interest; import org.apache.aries.rsa.discovery.zookeeper.client.ClientManager; import org.apache.aries.rsa.discovery.zookeeper.client.ZookeeperEndpointListener; import org.apache.aries.rsa.discovery.zookeeper.client.ZookeeperEndpointRepository; diff --git a/discovery/tcp/src/main/java/org/apache/aries/rsa/discovery/tcp/Interest.java b/spi/src/main/java/org/apache/aries/rsa/spi/discovery/Interest.java similarity index 98% rename from discovery/tcp/src/main/java/org/apache/aries/rsa/discovery/tcp/Interest.java rename to spi/src/main/java/org/apache/aries/rsa/spi/discovery/Interest.java index e96fa09e..6900dab2 100644 --- a/discovery/tcp/src/main/java/org/apache/aries/rsa/discovery/tcp/Interest.java +++ b/spi/src/main/java/org/apache/aries/rsa/spi/discovery/Interest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.aries.rsa.discovery.tcp; +package org.apache.aries.rsa.spi.discovery; import org.apache.aries.rsa.util.StringPlus; import org.osgi.framework.ServiceReference; diff --git a/spi/src/main/java/org/apache/aries/rsa/spi/discovery/package-info.java b/spi/src/main/java/org/apache/aries/rsa/spi/discovery/package-info.java new file mode 100644 index 00000000..e6410a6b --- /dev/null +++ b/spi/src/main/java/org/apache/aries/rsa/spi/discovery/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + */ + [email protected] [email protected]("2.0.0") +package org.apache.aries.rsa.spi.discovery; \ No newline at end of file
