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 2024/06/03 13:51:02 UTC
(aries-rsa) branch master updated (09cf7aa5 -> 0b94606e)
This is an automated email from the ASF dual-hosted git repository.
amichai pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
from 09cf7aa5 ARIES-2033 Fix Zookeeper discovery missing service capability
new d922bb38 Fix JUnit assertThat deprecation warnings
new bc5cee51 Fix string concatenation in log messages
new 55e66ce3 Replace deprecated karaf ShellTable class
new 8c4037ed ARIES-2156 Remove support for deprecated EventListener interface
new 6d3d2cda ARIES-2157 Replace deprecated PackageAdmin usage with BundleWiring
new cc1740bc Fix typos in comments
new 5821905f Simplify tests
new 20fa9508 Refactor and simplify statements and methods
new 7a13d299 Fix potential NPE when updating MDNS discovery interest
new 0b94606e Convert tabs to spaces
The 10 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:
LICENSE | 36 +-
discovery/command/pom.xml | 2 +-
.../rsa/discovery/command/EndpointsCommand.java | 7 +-
.../discovery/config/PropertyValidatorTest.java | 4 +-
discovery/local/bnd.bnd | 2 +-
.../rsa/discovery/endpoint/PropertiesMapper.java | 6 +-
.../local/EndpointDescriptionBundleParser.java | 2 +-
.../aries/rsa/discovery/local/LocalDiscovery.java | 10 +-
.../local/EndpointDescriptionBundleParserTest.java | 13 +-
.../apache/aries/rsa/discovery/mdns/Interest.java | 164 ++++------
.../aries/rsa/discovery/mdns/InterestManager.java | 179 +++++-----
.../aries/rsa/discovery/mdns/MdnsDiscovery.java | 362 ++++++++++-----------
.../discovery/mdns/PublishingEndpointListener.java | 215 ++++++------
.../aries/rsa/discovery/zookeeper/Interest.java | 54 +--
.../rsa/discovery/zookeeper/InterestManager.java | 16 +-
.../zookeeper/PublishingEndpointListener.java | 18 +-
.../discovery/zookeeper/client/ClientManager.java | 2 +-
.../client/ZookeeperEndpointListener.java | 1 -
.../client/ZookeeperEndpointRepository.java | 2 +-
.../zookeeper/server/ZookeeperStarter.java | 4 +-
.../zookeeper/ZookeeperDiscoveryTest.java | 2 +-
.../apache/aries/rsa/eapub/EventAdminHelper.java | 2 +-
.../aries/rsa/eapub/EventAdminHelperTest.java | 8 +-
itests/tck/tck.bndrun | 34 +-
provider/fastbin/Readme.md | 4 +-
provider/fastbin/pom.xml | 4 +-
.../fastbin/api/ProtobufSerializationStrategy.java | 2 +-
.../rsa/provider/fastbin/io/ProtocolCodec.java | 4 +-
.../aries/rsa/provider/fastbin/io/Service.java | 4 +-
.../aries/rsa/provider/fastbin/io/Transport.java | 2 +-
.../rsa/provider/fastbin/io/TransportServer.java | 2 +-
.../fastbin/tcp/AbstractInvocationStrategy.java | 13 +-
.../fastbin/tcp/BlockingInvocationStrategy.java | 6 +-
.../provider/fastbin/tcp/ClientInvokerImpl.java | 4 +-
.../rsa/provider/fastbin/tcp/InvocationType.java | 16 +-
.../provider/fastbin/tcp/LengthPrefixedCodec.java | 10 +-
.../provider/fastbin/tcp/ServerInvokerImpl.java | 2 +-
.../rsa/provider/fastbin/tcp/TcpTransport.java | 16 +-
.../provider/fastbin/tcp/TcpTransportServer.java | 4 +-
.../fastbin/util/IntrospectionSupport.java | 6 +-
.../rsa/provider/fastbin/util/UuidGenerator.java | 2 +-
.../aries/rsa/provider/fastbin/InvocationTest.java | 12 +-
.../rsa/provider/fastbin/StreamInvocationTest.java | 2 +-
.../fastbin/streams/OutputStreamProxyTest.java | 6 +-
.../fastbin/tcp/LengthPrefixedCodecTest.java | 22 +-
provider/tcp/bnd.bnd | 4 +-
.../apache/aries/rsa/provider/tcp/TcpProvider.java | 1 +
.../apache/aries/rsa/provider/tcp/TcpServer.java | 2 +-
.../rsa/provider/tcp/TcpProviderIntentTest.java | 8 +-
.../rsa/provider/tcp/TcpProviderPrimitiveTest.java | 6 +-
.../aries/rsa/provider/tcp/TcpProviderTest.java | 4 +-
.../rsa/core/DistributionProviderTracker.java | 6 +-
.../apache/aries/rsa/core/ExportReferenceImpl.java | 8 +-
.../org/apache/aries/rsa/core/PackageUtil.java | 73 ++---
.../aries/rsa/core/RemoteServiceAdminCore.java | 27 +-
.../aries/rsa/core/ClientServiceFactoryTest.java | 9 +-
.../aries/rsa/core/ImportRegistrationImplTest.java | 8 +-
.../aries/rsa/core/OverlayPropertiesTest.java | 11 +-
.../aries/rsa/core/RemoteServiceAdminCoreTest.java | 39 ++-
.../org/apache/aries/rsa/spi/ExportPolicy.java | 2 +-
topology-manager/Readme.md | 2 +-
.../EndpointEventListenerTracker.java | 33 +-
.../exporter/EndpointListenerAdapter.java | 70 ----
.../exporter/EndpointListenerNotifier.java | 6 -
.../exporter/TopologyManagerExport.java | 7 +-
.../importer/TopologyManagerImport.java | 2 +-
.../importer/local/EndpointListenerManager.java | 30 +-
.../rsa/topologymanager/importer/local/Readme.md | 2 +-
.../exporter/EndpointListenerNotifierTest.java | 10 +-
.../exporter/RecordingEndpointEventListener.java | 2 +-
.../importer/TopologyManagerImportTest.java | 3 +-
.../importer/local/EndpointListenerImplTest.java | 14 +-
.../importer/local/FilterHelperTest.java | 2 +-
73 files changed, 706 insertions(+), 973 deletions(-)
delete mode 100644 topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerAdapter.java
(aries-rsa) 08/10: Refactor and simplify statements and methods
Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit 20fa9508b609ad751ee63806ce3733b9720bd030
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Mon Jun 3 16:16:16 2024 +0300
Refactor and simplify statements and methods
---
.../aries/rsa/discovery/command/EndpointsCommand.java | 5 +----
.../rsa/discovery/config/PropertyValidatorTest.java | 2 +-
.../org/apache/aries/rsa/discovery/mdns/Interest.java | 2 +-
.../apache/aries/rsa/discovery/zookeeper/Interest.java | 8 ++------
.../zookeeper/client/ZookeeperEndpointListener.java | 1 -
.../rsa/discovery/zookeeper/server/ZookeeperStarter.java | 2 +-
.../provider/fastbin/tcp/AbstractInvocationStrategy.java | 3 +--
.../aries/rsa/provider/fastbin/tcp/InvocationType.java | 16 +++-------------
.../rsa/provider/fastbin/util/IntrospectionSupport.java | 4 ++--
.../aries/rsa/provider/fastbin/InvocationTest.java | 8 ++++----
.../aries/rsa/provider/fastbin/StreamInvocationTest.java | 2 +-
.../provider/fastbin/streams/OutputStreamProxyTest.java | 6 +++---
.../org/apache/aries/rsa/provider/tcp/TcpProvider.java | 1 +
.../org/apache/aries/rsa/core/ExportReferenceImpl.java | 8 ++++----
.../apache/aries/rsa/core/RemoteServiceAdminCore.java | 6 ++----
.../org/apache/aries/rsa/core/OverlayPropertiesTest.java | 1 -
.../topologymanager/exporter/TopologyManagerExport.java | 5 +----
.../importer/TopologyManagerImportTest.java | 3 +--
.../importer/local/EndpointListenerImplTest.java | 2 +-
19 files changed, 30 insertions(+), 55 deletions(-)
diff --git a/discovery/command/src/main/java/org/apache/aries/rsa/discovery/command/EndpointsCommand.java b/discovery/command/src/main/java/org/apache/aries/rsa/discovery/command/EndpointsCommand.java
index 031d0e84..ab5c8c47 100644
--- a/discovery/command/src/main/java/org/apache/aries/rsa/discovery/command/EndpointsCommand.java
+++ b/discovery/command/src/main/java/org/apache/aries/rsa/discovery/command/EndpointsCommand.java
@@ -111,6 +111,7 @@ public class EndpointsCommand implements EndpointEventListener {
break;
case EndpointEvent.REMOVED:
+ case EndpointEvent.MODIFIED_ENDMATCH:
endpoints.remove(endpoint);
break;
@@ -118,10 +119,6 @@ public class EndpointsCommand implements EndpointEventListener {
endpoints.remove(endpoint);
endpoints.add(endpoint);
break;
-
- case EndpointEvent.MODIFIED_ENDMATCH:
- endpoints.remove(endpoint);
- break;
}
}
diff --git a/discovery/config/src/test/java/org/apache/aries/rsa/discovery/config/PropertyValidatorTest.java b/discovery/config/src/test/java/org/apache/aries/rsa/discovery/config/PropertyValidatorTest.java
index 590f8e06..60f60af6 100644
--- a/discovery/config/src/test/java/org/apache/aries/rsa/discovery/config/PropertyValidatorTest.java
+++ b/discovery/config/src/test/java/org/apache/aries/rsa/discovery/config/PropertyValidatorTest.java
@@ -45,7 +45,7 @@ public class PropertyValidatorTest {
dic.put("key", "value");
assertThat(toMap(dic).size(), is(1));
- assertThat(toMap(dic).keySet().contains("key"), is(true));
+ assertThat(toMap(dic).containsKey("key"), is(true));
assertThat(toMap(dic).get("key"), Is.is("value"));
assertThat(toMap(null), notNullValue());
diff --git a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java
index 1bc64d3b..712a8dcc 100644
--- a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java
+++ b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java
@@ -104,7 +104,7 @@ public class Interest {
filter = currentScope.get();
} else if(alreadyAdded) {
if(LOG.isDebugEnabled()) {
- LOG.debug("Listener {} is no longer interested in endpoint {}. It will be {}", id, ed, alreadyAdded ? "MODIFIED" : "ADDED");
+ LOG.debug("Listener {} is no longer interested in endpoint {}. It will be {}", id, ed, "MODIFIED");
}
EndpointDescription previous = added.remove(ed.getId());
event = new EndpointEvent(MODIFIED_ENDMATCH, ed);
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
index aa61087a..4f539f9d 100644
--- 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
@@ -21,6 +21,7 @@ package org.apache.aries.rsa.discovery.zookeeper;
import static org.osgi.service.remoteserviceadmin.EndpointEventListener.ENDPOINT_LISTENER_SCOPE;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
import org.apache.aries.rsa.util.StringPlus;
@@ -86,12 +87,7 @@ public class Interest {
if (getClass() != obj.getClass())
return false;
Interest other = (Interest) obj;
- if (sref == null) {
- if (other.sref != null)
- return false;
- } else if (!sref.equals(other.sref))
- return false;
- return true;
+ return Objects.equals(sref, other.sref);
}
@Override
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ZookeeperEndpointListener.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ZookeeperEndpointListener.java
index ba82e3a6..a2ce6e6b 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ZookeeperEndpointListener.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ZookeeperEndpointListener.java
@@ -25,7 +25,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
-import java.util.stream.Stream;
import org.apache.aries.rsa.spi.EndpointDescriptionParser;
import org.apache.zookeeper.KeeperException;
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/server/ZookeeperStarter.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/server/ZookeeperStarter.java
index cdbd8bdf..57d0d2e5 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/server/ZookeeperStarter.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/server/ZookeeperStarter.java
@@ -115,7 +115,7 @@ public class ZookeeperStarter {
Properties props = new Properties();
for (String key : dict.keySet()) {
Object value = dict.get(key);
- if (!(value instanceof String && "".equals(value))) {
+ if (!"".equals(value)) {
props.put(key, value);
}
}
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java
index a1924c29..f6c3267e 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java
@@ -113,9 +113,8 @@ public abstract class AbstractInvocationStrategy implements InvocationStrategy {
int pos = responseStream.position();
try {
- Object value = null;
Throwable error = (Throwable)target;
- serializationStrategy.encodeResponse(loader, null, value, error, responseStream);
+ serializationStrategy.encodeResponse(loader, null, null, error, responseStream);
} catch(Exception e) {
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/InvocationType.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/InvocationType.java
index ccec3b4c..1012a0fe 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/InvocationType.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/InvocationType.java
@@ -29,11 +29,7 @@ public enum InvocationType {
@Override
protected boolean applies(Method method) {
- Class<?> returnType = method.getReturnType();
- if(returnType != null) {
- return Future.class.isAssignableFrom(returnType);
- }
- return false;
+ return Future.class.isAssignableFrom(method.getReturnType());
}
}, ASYNC_CALLBACK(new AsyncInvocationStrategy()){
@@ -48,13 +44,7 @@ public enum InvocationType {
@Override
protected boolean applies(Method method) {
- if(!promiseAvailable)
- return false;
- Class<?> returnType = method.getReturnType();
- if(returnType != null) {
- return Promise.class.isAssignableFrom(returnType);
- }
- return false;
+ return promiseAvailable && Promise.class.isAssignableFrom(method.getReturnType());
}
}, BLOCKING(new BlockingInvocationStrategy()){
@@ -65,7 +55,7 @@ public enum InvocationType {
}
};
- private InvocationStrategy strategy;
+ private final InvocationStrategy strategy;
/**
* the dependency to OSGi promise is optional. This flag
* tracks if the class is visible or not
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/IntrospectionSupport.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/IntrospectionSupport.java
index f29e0c3e..087ae386 100755
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/IntrospectionSupport.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/IntrospectionSupport.java
@@ -57,7 +57,7 @@ public final class IntrospectionSupport {
String name = method.getName();
Class<?> type = method.getReturnType();
Class<?>[] params = method.getParameterTypes();
- if ((name.startsWith("is") || name.startsWith("get")) && params.length == 0 && type != null && isSettableType(type)) {
+ if ((name.startsWith("is") || name.startsWith("get")) && params.length == 0 && isSettableType(type)) {
try {
@@ -311,7 +311,7 @@ public final class IntrospectionSupport {
return buffer.toString();
} catch (Throwable e) {
e.printStackTrace();
- return "Could not toString: "+e.toString();
+ return "Could not toString: " + e;
}
}
diff --git a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
index 6b35f314..db9eae12 100644
--- a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
+++ b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
@@ -426,8 +426,8 @@ public class InvocationTest {
double latency_avg = ((latency_sum * 1.0d) / requests.get()) / MILLIS_IN_A_NANO;
double request_rate = ((requests.get() * 1.0d) / (end - start)) * SECONDS_IN_A_NANO;
- System.err.println(String.format("Requests/Second: %,.2f", request_rate));
- System.err.println(String.format("Average request latency: %,.2f ms", latency_avg));
+ System.err.printf("Requests/Second: %,.2f%n", request_rate);
+ System.err.printf("Average request latency: %,.2f ms%n", latency_avg);
System.err.println("Error Ratio: " + failures.get() + " / " + requests.get());
}
finally {
@@ -552,8 +552,8 @@ public class InvocationTest {
double latency_avg = ((latency_sum * 1.0d) / requests.get()) / MILLIS_IN_A_NANO;
double request_rate = ((requests.get() * 1.0d) / (end - start)) * SECONDS_IN_A_NANO;
- System.err.println(String.format("Requests/Second: %,.2f", request_rate));
- System.err.println(String.format("Average request latency: %,.2f ms", latency_avg));
+ System.err.printf("Requests/Second: %,.2f%n", request_rate);
+ System.err.printf("Average request latency: %,.2f ms%n", latency_avg);
System.err.println("Error Ratio: " + failures.get() + " / " + requests.get());
}
finally {
diff --git a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/StreamInvocationTest.java b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/StreamInvocationTest.java
index 807a0483..836bb33a 100644
--- a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/StreamInvocationTest.java
+++ b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/StreamInvocationTest.java
@@ -130,7 +130,7 @@ public class StreamInvocationTest {
ByteArrayOutputStream result = new ByteArrayOutputStream();
testService.intoStream(result, "Test");
Thread.sleep(100);
- assertEquals("Test", new String(result.toByteArray()));
+ assertEquals("Test", result.toString());
}
diff --git a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/streams/OutputStreamProxyTest.java b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/streams/OutputStreamProxyTest.java
index 4c8eaa81..efdf5619 100644
--- a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/streams/OutputStreamProxyTest.java
+++ b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/streams/OutputStreamProxyTest.java
@@ -48,7 +48,7 @@ public class OutputStreamProxyTest {
assertEquals(0, out.size());
fixture.close();
assertEquals(10, out.size());
- assertEquals("xxxxxxxxxx", new String(out.toByteArray()));
+ assertEquals("xxxxxxxxxx", out.toString());
}
@Test
@@ -70,8 +70,8 @@ public class OutputStreamProxyTest {
fixture.close();
assertEquals(10 + charSize, out.size());
byte[] byteArray = out.toByteArray();
- for (int i = 0; i < byteArray.length; i++) {
- assertEquals('x', byteArray[i]);
+ for (byte b : byteArray) {
+ assertEquals('x', b);
}
}
diff --git a/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpProvider.java b/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpProvider.java
index 348c82bc..6ec64414 100644
--- a/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpProvider.java
+++ b/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpProvider.java
@@ -68,6 +68,7 @@ public class TcpProvider implements DistributionProvider {
return new String[] {TCP_CONFIG_TYPE};
}
+ @SafeVarargs
private static <T> Set<T> union(Collection<T>... collections) {
Set<T> union = new HashSet<>();
for (Collection<T> c : collections)
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/ExportReferenceImpl.java b/rsa/src/main/java/org/apache/aries/rsa/core/ExportReferenceImpl.java
index a72988e5..11e4f289 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/ExportReferenceImpl.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/ExportReferenceImpl.java
@@ -22,6 +22,8 @@ import org.osgi.framework.ServiceReference;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.osgi.service.remoteserviceadmin.ExportReference;
+import java.util.Objects;
+
@SuppressWarnings("rawtypes")
public class ExportReferenceImpl implements ExportReference {
@@ -63,10 +65,8 @@ public class ExportReferenceImpl implements ExportReference {
return false;
}
ExportReferenceImpl other = (ExportReferenceImpl) obj;
- boolean ed = endpoint == null ? other.endpoint == null
- : endpoint.equals(other.endpoint);
- boolean sr = serviceReference == null ? other.serviceReference == null
- : serviceReference.equals(other.serviceReference);
+ boolean ed = Objects.equals(endpoint, other.endpoint);
+ boolean sr = Objects.equals(serviceReference, other.serviceReference);
return ed && sr;
}
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
index bb72ee03..2c7489e0 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
@@ -312,12 +312,10 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
// non-interface classes (which are valid OBJECTCLASS values, even if discouraged)
interfaces.addAll(providedInterfaces);
} else {
- List<String> providedList = providedInterfaces;
- List<String> allowedList = exportedInterfaces;
- if (!providedList.containsAll(allowedList)) {
+ if (!providedInterfaces.containsAll(exportedInterfaces)) {
throw new IllegalArgumentException(String.format(
"exported interfaces %s must be a subset of the service's registered types %s",
- allowedList, providedList));
+ exportedInterfaces, providedInterfaces));
}
interfaces.addAll(exportedInterfaces);
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java
index 6bfb7f87..3730856c 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java
@@ -18,7 +18,6 @@
*/
package org.apache.aries.rsa.core;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExport.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExport.java
index 2ae744d0..d2176588 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExport.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExport.java
@@ -99,11 +99,8 @@ public class TopologyManagerExport implements ServiceListener {
modified(sref);
break;
- case ServiceEvent.MODIFIED_ENDMATCH:
- remove(sref);
- break;
-
case ServiceEvent.UNREGISTERING:
+ case ServiceEvent.MODIFIED_ENDMATCH:
remove(sref);
break;
}
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImportTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImportTest.java
index 240298a8..ea600e62 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImportTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImportTest.java
@@ -20,7 +20,6 @@ package org.apache.aries.rsa.topologymanager.importer;
import static org.junit.Assert.assertTrue;
-import java.util.Dictionary;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
@@ -86,7 +85,7 @@ public class TopologyManagerImportTest {
BundleContext bc = c.createMock(BundleContext.class);
EasyMock.expect(bc.registerService(EasyMock.eq(RemoteServiceAdminListener.class),
EasyMock.anyObject(RemoteServiceAdminListener.class),
- (Dictionary)EasyMock.anyObject())).andReturn(sreg).anyTimes();
+ EasyMock.anyObject())).andReturn(sreg).anyTimes();
return bc;
}
}
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
index 3290285b..0f894f44 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
@@ -48,7 +48,7 @@ public class EndpointListenerImplTest extends Assert {
// expect Listener registration
EasyMock.expect(bc.registerService(EasyMock.aryEq(ifAr),
EasyMock.anyObject(),
- (Dictionary)EasyMock.anyObject())).andReturn(sr).atLeastOnce();
+ EasyMock.anyObject())).andReturn(sr).atLeastOnce();
sr.setProperties(EasyMock.anyObject());
(aries-rsa) 07/10: Simplify tests
Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit 5821905f6aa0abb454816581ee389aa1bf2553cb
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Mon Jun 3 16:02:51 2024 +0300
Simplify tests
---
.../local/EndpointDescriptionBundleParserTest.java | 13 +++++++------
.../aries/rsa/eapub/EventAdminHelperTest.java | 8 ++++----
.../aries/rsa/provider/fastbin/InvocationTest.java | 2 +-
.../fastbin/tcp/LengthPrefixedCodecTest.java | 22 +++++++++++-----------
.../rsa/provider/tcp/TcpProviderPrimitiveTest.java | 2 +-
.../aries/rsa/core/ClientServiceFactoryTest.java | 9 +++++----
.../aries/rsa/core/ImportRegistrationImplTest.java | 8 +++-----
.../aries/rsa/core/OverlayPropertiesTest.java | 10 ++++------
.../importer/local/EndpointListenerImplTest.java | 6 +++---
9 files changed, 39 insertions(+), 41 deletions(-)
diff --git a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
index a6d81e19..f83f437a 100644
--- a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
+++ b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
@@ -36,14 +36,13 @@ import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.easymock.EasyMock;
-import org.junit.Assert;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
-public class EndpointDescriptionBundleParserTest extends TestCase {
+public class EndpointDescriptionBundleParserTest {
private Bundle createBundleContaining(URL ed1URL) {
Bundle b = EasyMock.createNiceMock(Bundle.class);
@@ -61,9 +60,10 @@ public class EndpointDescriptionBundleParserTest extends TestCase {
EasyMock.replay(b);
List<EndpointDescription> rsElements = new EndpointDescriptionBundleParser().getAllEndpointDescriptions(b);
- Assert.assertEquals(0, rsElements.size());
+ assertEquals(0, rsElements.size());
}
+ @Test
public void testAllEndpoints1() {
URL ed1URL = getClass().getResource("/ed1.xml");
@@ -91,6 +91,7 @@ public class EndpointDescriptionBundleParserTest extends TestCase {
assertEquals(Arrays.asList("SomeOtherService", "WithSomeSecondInterface"), endpoint3.getInterfaces());
}
+ @Test
public void testAllEndpoints2() throws Exception {
URL ed2URL = getClass().getResource("/ed2.xml");
@@ -134,10 +135,10 @@ public class EndpointDescriptionBundleParserTest extends TestCase {
assertEquals('X', props.get("Character2"));
int[] intArray = (int[]) props.get("int-array");
- assertTrue(Arrays.equals(new int[] {1, 2}, intArray));
+ assertArrayEquals(new int[]{1, 2}, intArray);
Integer[] integerArray = (Integer[]) props.get("Integer-array");
- assertTrue(Arrays.equals(new Integer[] {2, 1}, integerArray));
+ assertArrayEquals(new Integer[]{2, 1}, integerArray);
assertEquals(Arrays.asList(true, false), props.get("bool-list"));
assertEquals(new HashSet<>(), props.get("long-set"));
diff --git a/eapub/src/test/java/org/apache/aries/rsa/eapub/EventAdminHelperTest.java b/eapub/src/test/java/org/apache/aries/rsa/eapub/EventAdminHelperTest.java
index 2590dd1d..0965b164 100644
--- a/eapub/src/test/java/org/apache/aries/rsa/eapub/EventAdminHelperTest.java
+++ b/eapub/src/test/java/org/apache/aries/rsa/eapub/EventAdminHelperTest.java
@@ -85,8 +85,8 @@ public class EventAdminHelperTest {
Assert.assertEquals(Long.MAX_VALUE, event.getProperty("service.remote.id"));
Assert.assertEquals(uuid, event.getProperty("service.remote.uuid"));
Assert.assertEquals("foo://bar", event.getProperty("service.remote.uri"));
- Assert.assertTrue(Arrays.equals(interfaces.toArray(new String[] {}),
- (String[]) event.getProperty("objectClass")));
+ Assert.assertArrayEquals(interfaces.toArray(new String[]{}),
+ (String[]) event.getProperty("objectClass"));
Assert.assertNotNull(event.getProperty("timestamp"));
@@ -157,8 +157,8 @@ public class EventAdminHelperTest {
Assert.assertEquals(new Version("0"), event.getProperty("bundle.version"));
Assert.assertSame(exportException, event.getProperty("cause"));
Assert.assertEquals(epd, event.getProperty("export.registration"));
- Assert.assertTrue(Arrays.equals(new String[] {"org.foo.Bar"},
- (String[]) event.getProperty("objectClass")));
+ Assert.assertArrayEquals(new String[]{"org.foo.Bar"},
+ (String[]) event.getProperty("objectClass"));
RemoteServiceAdminEvent rsae = (RemoteServiceAdminEvent) event.getProperty("event");
Assert.assertSame(exportException, rsae.getException());
diff --git a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
index 3a62c620..6b35f314 100644
--- a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
+++ b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
@@ -299,7 +299,7 @@ public class InvocationTest {
threads[t].join(10000);
System.err.format("REQUEST: %d of %d%n", requests.get(), BENCHMARK_CLIENTS);
System.err.format("RESPONSES: %d of %d%n", responses.get(), BENCHMARK_CLIENTS);
- assertEquals(threads[t].isAlive(), false);
+ assertFalse(threads[t].isAlive());
}
assertEquals(BENCHMARK_CLIENTS, requests.get());
diff --git a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodecTest.java b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodecTest.java
index 58e4e9d8..7a5ceddb 100644
--- a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodecTest.java
+++ b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodecTest.java
@@ -37,7 +37,7 @@ import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.getCurrentArguments;
import static org.easymock.EasyMock.replay;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
public class LengthPrefixedCodecTest {
private ReadableByteChannel readableByteChannel = createMock(ReadableByteChannel.class);
@@ -62,12 +62,12 @@ public class LengthPrefixedCodecTest {
@Test
public void testFull() throws Exception {
- assertEquals(false, codec.full());
+ assertFalse(codec.full());
}
@Test
public void testEmpty() throws Exception {
- assertEquals(true, codec.empty());
+ assertTrue(codec.empty());
}
@Test
@@ -87,8 +87,8 @@ public class LengthPrefixedCodecTest {
final BufferState state = codec.write(value);
assertEquals(BufferState.WAS_EMPTY, state);
- assertEquals(false, codec.full());
- assertEquals(false, codec.empty());
+ assertFalse(codec.full());
+ assertFalse(codec.empty());
assertEquals(0L, codec.getWriteCounter());
}
@@ -101,8 +101,8 @@ public class LengthPrefixedCodecTest {
final BufferState state = codec.write(value2);
assertEquals(BufferState.NOT_EMPTY, state);
- assertEquals(false, codec.full());
- assertEquals(false, codec.empty());
+ assertFalse(codec.full());
+ assertFalse(codec.empty());
assertEquals(0L, codec.getWriteCounter());
}
@@ -117,8 +117,8 @@ public class LengthPrefixedCodecTest {
final BufferState state = codec.flush();
assertEquals(BufferState.EMPTY, state);
- assertEquals(false, codec.full());
- assertEquals(true, codec.empty());
+ assertFalse(codec.full());
+ assertTrue(codec.empty());
assertEquals(bytesThatWillBeWritten, codec.getWriteCounter());
assertEquals(BufferState.WAS_EMPTY, codec.flush());
@@ -135,8 +135,8 @@ public class LengthPrefixedCodecTest {
final BufferState state = codec.flush();
assertEquals(BufferState.NOT_EMPTY, state);
- assertEquals(false, codec.full());
- assertEquals(false, codec.empty());
+ assertFalse(codec.full());
+ assertFalse(codec.empty());
assertEquals(bytesThatWillBeWritten, codec.getWriteCounter());
}
diff --git a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
index 6528e8b9..5ddd77d4 100644
--- a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
+++ b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
@@ -104,7 +104,7 @@ public class TcpProviderPrimitiveTest {
@Test
public void testBoolean() {
- Assert.assertEquals(true, myServiceProxy.callBoolean(true));
+ Assert.assertTrue(myServiceProxy.callBoolean(true));
}
@Test
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java
index f0c321a0..2f45d13f 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java
@@ -20,6 +20,7 @@ package org.apache.aries.rsa.core;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.isA;
+import static org.junit.Assert.assertSame;
import java.util.HashMap;
import java.util.Map;
@@ -27,6 +28,7 @@ import java.util.Map;
import org.apache.aries.rsa.spi.DistributionProvider;
import org.easymock.EasyMock;
import org.easymock.IMocksControl;
+import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
@@ -35,10 +37,9 @@ import org.osgi.framework.wiring.BundleWiring;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import junit.framework.TestCase;
-
-public class ClientServiceFactoryTest extends TestCase {
+public class ClientServiceFactoryTest {
+ @Test
@SuppressWarnings("rawtypes")
public void testGetService() throws ClassNotFoundException {
final Object myTestProxyObject = new Object();
@@ -64,7 +65,7 @@ public class ClientServiceFactoryTest extends TestCase {
/**
* Creating dummy class as I was not able to really mock it
- * @param myTestProxyObject
+ * @param proxy
* @return
*/
private DistributionProvider mockDistributionProvider(final Object proxy) {
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/ImportRegistrationImplTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/ImportRegistrationImplTest.java
index 077a0196..dd398a12 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/ImportRegistrationImplTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/ImportRegistrationImplTest.java
@@ -18,10 +18,6 @@
*/
package org.apache.aries.rsa.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import org.easymock.EasyMock;
import org.easymock.IMocksControl;
import org.junit.Test;
@@ -29,6 +25,8 @@ import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import static org.junit.Assert.*;
+
public class ImportRegistrationImplTest {
@Test
@@ -81,7 +79,7 @@ public class ImportRegistrationImplTest {
try {
i2.setImportedServiceRegistration(sr);
- assertTrue("An exception should be thrown here !", false);
+ fail("An exception should be thrown here !");
} catch (IllegalStateException e) {
// must be thrown here
}
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java
index d48bd0a0..6bfb7f87 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java
@@ -18,10 +18,6 @@
*/
package org.apache.aries.rsa.core;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -29,6 +25,8 @@ import java.util.Map;
import org.junit.Test;
import org.osgi.framework.Constants;
+import static org.junit.Assert.*;
+
public class OverlayPropertiesTest {
@Test
@@ -57,8 +55,8 @@ public class OverlayPropertiesTest {
assertEquals("achanged", sProps.get("aaa"));
assertEquals("bval", sProps.get("bbb"));
assertEquals("CVAL", sProps.get("CCC"));
- assertTrue("Should not be possible to override the objectClass property",
- Arrays.equals(new String[] {"X"}, (Object[]) sProps.get(Constants.OBJECTCLASS)));
+ assertArrayEquals("Should not be possible to override the objectClass property",
+ new String[]{"X"}, (Object[]) sProps.get(Constants.OBJECTCLASS));
assertEquals("Should not be possible to override the service.id property",
17L, sProps.get(Constants.SERVICE_ID));
}
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
index 7864ce44..3290285b 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
@@ -73,15 +73,15 @@ public class EndpointListenerImplTest extends Assert {
break;
case 4:
assertEquals("adding second entry failed", 2, scope.size());
- assertNotNull(scope.contains("(a=b)"));
- assertNotNull(scope.contains("(c=d)"));
+ assertTrue(scope.contains("(a=b)"));
+ assertTrue(scope.contains("(c=d)"));
break;
case 5:
assertEquals("remove failed", 1, scope.size());
assertEquals("(c=d)", scope.get(0));
break;
default:
- assertTrue("This should not happen!", false);
+ fail("This should not happen!");
}
return null;
}
(aries-rsa) 01/10: Fix JUnit assertThat deprecation warnings
Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit d922bb38034d2fc9f8073a66f2aa362b90943f6f
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Mon Jun 3 07:43:15 2024 +0300
Fix JUnit assertThat deprecation warnings
---
.../apache/aries/rsa/discovery/config/PropertyValidatorTest.java | 2 +-
.../aries/rsa/discovery/zookeeper/ZookeeperDiscoveryTest.java | 2 +-
.../org/apache/aries/rsa/provider/tcp/TcpProviderIntentTest.java | 8 ++++----
.../apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java | 4 ++--
.../java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java | 4 ++--
.../org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java | 2 +-
.../topologymanager/exporter/EndpointListenerNotifierTest.java | 4 ++--
.../topologymanager/exporter/RecordingEndpointEventListener.java | 2 +-
.../rsa/topologymanager/importer/local/FilterHelperTest.java | 2 +-
9 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/discovery/config/src/test/java/org/apache/aries/rsa/discovery/config/PropertyValidatorTest.java b/discovery/config/src/test/java/org/apache/aries/rsa/discovery/config/PropertyValidatorTest.java
index 414090f4..590f8e06 100644
--- a/discovery/config/src/test/java/org/apache/aries/rsa/discovery/config/PropertyValidatorTest.java
+++ b/discovery/config/src/test/java/org/apache/aries/rsa/discovery/config/PropertyValidatorTest.java
@@ -31,9 +31,9 @@ import java.util.Vector;
import static java.util.Collections.singletonList;
import static org.apache.aries.rsa.discovery.config.PropertyValidator.*;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
/**
* @author dpishchukhin
diff --git a/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/ZookeeperDiscoveryTest.java b/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/ZookeeperDiscoveryTest.java
index 1bd0050d..ddac35a3 100644
--- a/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/ZookeeperDiscoveryTest.java
+++ b/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/ZookeeperDiscoveryTest.java
@@ -19,9 +19,9 @@
package org.apache.aries.rsa.discovery.zookeeper;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
import java.io.ByteArrayInputStream;
import java.io.File;
diff --git a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderIntentTest.java b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderIntentTest.java
index 672b77a9..0b9565db 100644
--- a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderIntentTest.java
+++ b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderIntentTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.aries.rsa.provider.tcp;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
@@ -30,7 +31,6 @@ import org.apache.aries.rsa.provider.tcp.myservice.MyServiceImpl;
import org.apache.aries.rsa.spi.Endpoint;
import org.apache.aries.rsa.util.EndpointHelper;
import org.easymock.EasyMock;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.BundleContext;
@@ -57,7 +57,7 @@ public class TcpProviderIntentTest {
String[] standardIntents = {"osgi.basic", "osgi.async"};
props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS, standardIntents);
Endpoint ep = provider.exportService(myService, bc, props, exportedInterfaces);
- Assert.assertThat("Service should be exported as the intents: " + Arrays.toString(standardIntents) + " must be supported", ep, notNullValue());
+ assertThat("Service should be exported as the intents: " + Arrays.toString(standardIntents) + " must be supported", ep, notNullValue());
}
@Test
@@ -66,7 +66,7 @@ public class TcpProviderIntentTest {
EndpointHelper.addObjectClass(props, exportedInterfaces);
props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS, "unknown");
Endpoint ep = provider.exportService(myService, bc, props, exportedInterfaces);
- Assert.assertThat("Service should not be exported as intent is not supported", ep, nullValue());
+ assertThat("Service should not be exported as intent is not supported", ep, nullValue());
}
@Test
@@ -75,7 +75,7 @@ public class TcpProviderIntentTest {
EndpointHelper.addObjectClass(props, exportedInterfaces);
props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA, "unknown");
Endpoint ep = provider.exportService(myService, bc, props, exportedInterfaces);
- Assert.assertThat("Service should not be exported as intent is not supported", ep, nullValue());
+ assertThat("Service should not be exported as intent is not supported", ep, nullValue());
}
}
diff --git a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
index b1442c5e..6528e8b9 100644
--- a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
+++ b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
@@ -19,12 +19,12 @@
package org.apache.aries.rsa.provider.tcp;
import static java.util.Arrays.asList;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.everyItem;
import static org.hamcrest.Matchers.isIn;
import static org.hamcrest.Matchers.samePropertyValuesAs;
import static org.hamcrest.core.StringStartsWith.startsWith;
-import static org.junit.Assert.assertThat;
import static org.osgi.framework.Version.parseVersion;
import java.io.IOException;
@@ -64,7 +64,7 @@ public class TcpProviderPrimitiveTest {
PrimitiveServiceImpl myService = new PrimitiveServiceImpl();
BundleContext bc = EasyMock.mock(BundleContext.class);
ep = provider.exportService(myService, bc, props, exportedInterfaces);
- Assert.assertThat(ep.description().getId(), startsWith("tcp://localhost:"));
+ assertThat(ep.description().getId(), startsWith("tcp://localhost:"));
System.out.println(ep.description());
myServiceProxy = (PrimitiveService)provider.importEndpoint(PrimitiveService.class.getClassLoader(),
bc,
diff --git a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
index 2fe59eae..7a920fd5 100644
--- a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
+++ b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
@@ -18,11 +18,11 @@
*/
package org.apache.aries.rsa.provider.tcp;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.core.StringStartsWith.startsWith;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -92,7 +92,7 @@ public class TcpProviderTest {
ep = provider.exportService(new MyServiceImpl("service1"), bc, props, exportedInterfaces);
props.put("aries.rsa.id", "service2");
ep2 = provider.exportService(new MyServiceImpl("service2"), bc, props, exportedInterfaces);
- Assert.assertThat(ep.description().getId(), startsWith("tcp://localhost:"));
+ assertThat(ep.description().getId(), startsWith("tcp://localhost:"));
myServiceProxy = (MyService)provider.importEndpoint(
MyService.class.getClassLoader(),
bc,
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
index 039e48d0..45fe9a0b 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
@@ -21,6 +21,7 @@ package org.apache.aries.rsa.core;
import static org.easymock.EasyMock.anyObject;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.array;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.equalTo;
@@ -28,7 +29,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifierTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifierTest.java
index 2ca301a8..54feb5ac 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifierTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifierTest.java
@@ -23,8 +23,8 @@ import static org.easymock.EasyMock.capture;
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.newCapture;
import static org.hamcrest.core.Is.is;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import java.util.Arrays;
import java.util.Collection;
@@ -136,7 +136,7 @@ public class EndpointListenerNotifierTest {
Filter filter2 = it.next();
Dictionary<String, String> props = new Hashtable();
props.put("myProp", "A");
- Assert.assertThat(filter1.match(props) || filter2.match(props), is(true));
+ assertThat(filter1.match(props) || filter2.match(props), is(true));
}
private void filterMatches(Filter filter) {
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/RecordingEndpointEventListener.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/RecordingEndpointEventListener.java
index c26ff099..5190b5a8 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/RecordingEndpointEventListener.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/RecordingEndpointEventListener.java
@@ -18,9 +18,9 @@
*/
package org.apache.aries.rsa.topologymanager.exporter;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.samePropertyValuesAs;
-import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.Iterator;
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/FilterHelperTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/FilterHelperTest.java
index ba0aa288..a6b2d890 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/FilterHelperTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/FilterHelperTest.java
@@ -19,8 +19,8 @@
package org.apache.aries.rsa.topologymanager.importer.local;
import static org.apache.aries.rsa.topologymanager.importer.local.FilterHelper.isClassExcluded;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertThat;
import org.junit.Assert;
import org.junit.Test;
(aries-rsa) 02/10: Fix string concatenation in log messages
Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit bc5cee5184240342745ff2e45ba2263f3a1bae9d
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Mon Jun 3 07:52:05 2024 +0300
Fix string concatenation in log messages
---
.../apache/aries/rsa/discovery/endpoint/PropertiesMapper.java | 4 ++--
.../rsa/discovery/local/EndpointDescriptionBundleParser.java | 2 +-
.../aries/rsa/discovery/zookeeper/client/ClientManager.java | 2 +-
.../rsa/discovery/zookeeper/server/ZookeeperStarter.java | 2 +-
.../java/org/apache/aries/rsa/eapub/EventAdminHelper.java | 2 +-
.../rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java | 6 +++---
.../rsa/provider/fastbin/tcp/BlockingInvocationStrategy.java | 4 ++--
.../apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java | 6 +++---
.../apache/aries/rsa/core/DistributionProviderTracker.java | 2 +-
rsa/src/main/java/org/apache/aries/rsa/core/PackageUtil.java | 7 +++----
.../org/apache/aries/rsa/core/RemoteServiceAdminCore.java | 11 ++++++-----
.../rsa/topologymanager/importer/TopologyManagerImport.java | 2 +-
12 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
index cee5d2b9..1d5d9f33 100644
--- a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
+++ b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
@@ -165,7 +165,7 @@ class PropertiesMapper {
return null;
}
if (!"String".equals(type)) {
- LOG.warn("Embedded XML must be of type String, found: " + type);
+ LOG.warn("Embedded XML must be of type String, found: {}", type);
return null;
}
Node xmlContent = (Node)el.getAny();
@@ -225,7 +225,7 @@ class PropertiesMapper {
return ctor.newInstance(value);
}
} catch (Exception e) {
- LOG.warn("Could not create Endpoint Property of type " + type + " and value " + value);
+ LOG.warn("Could not create Endpoint Property of type {} and value {}", type, value);
return null;
}
}
diff --git a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParser.java b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParser.java
index e45af33f..339e215b 100644
--- a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParser.java
+++ b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParser.java
@@ -51,7 +51,7 @@ public final class EndpointDescriptionBundleParser {
try {
elements.addAll(parser.readEndpoints(resourceURL.openStream()));
} catch (Exception ex) {
- LOG.warn("Problem parsing: " + resourceURL, ex);
+ LOG.warn("Problem parsing: {}", resourceURL, ex);
}
}
return elements;
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ClientManager.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ClientManager.java
index ec5cc16e..388e7633 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ClientManager.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ClientManager.java
@@ -105,7 +105,7 @@ public class ClientManager implements Watcher {
/* Callback for ZooKeeper */
public void process(WatchedEvent event) {
- LOG.debug("Got ZooKeeper event " + event);
+ LOG.debug("Got ZooKeeper event {}", event);
if (event.getState() == KeeperState.SyncConnected) {
LOG.info("Connection to ZooKeeper established. Publishing Zookeeper service");
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/server/ZookeeperStarter.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/server/ZookeeperStarter.java
index 7c7fb20c..cdbd8bdf 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/server/ZookeeperStarter.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/server/ZookeeperStarter.java
@@ -52,7 +52,7 @@ public class ZookeeperStarter {
QuorumPeerConfig peerConfig = parseConfig(config, context);
startFromConfig(peerConfig);
} catch (Exception th) {
- LOG.warn("Problem applying configuration update: " + config, th);
+ LOG.warn("Problem applying configuration update: {}", config, th);
}
}
diff --git a/eapub/src/main/java/org/apache/aries/rsa/eapub/EventAdminHelper.java b/eapub/src/main/java/org/apache/aries/rsa/eapub/EventAdminHelper.java
index 9c2392dd..88c19be6 100644
--- a/eapub/src/main/java/org/apache/aries/rsa/eapub/EventAdminHelper.java
+++ b/eapub/src/main/java/org/apache/aries/rsa/eapub/EventAdminHelper.java
@@ -92,7 +92,7 @@ public class EventAdminHelper implements RemoteServiceAdminListener {
try {
refs = bctx.getAllServiceReferences(EventAdmin.class.getName(), null);
} catch (InvalidSyntaxException e) {
- LOG.error("Failed to get EventAdmin: " + e.getMessage(), e);
+ LOG.error("Failed to get EventAdmin: {}", e.getMessage(), e);
}
if (refs != null) {
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java
index 2e6b1493..f943431e 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java
@@ -119,13 +119,13 @@ public abstract class AbstractInvocationStrategy implements InvocationStrategy {
} catch(Exception e) {
- LOGGER.warn("Initial Encoding response for method "+method+" failed. Retrying", e);
+ LOGGER.warn("Initial Encoding response for method {} failed. Retrying", method, e);
// we failed to encode the response.. reposition and write that error.
try {
responseStream.position(pos);
serializationStrategy.encodeResponse(loader, null, null, new ServiceException(e.toString()), responseStream);
} catch (Exception unexpected) {
- LOGGER.error("Error while servicing "+method, unexpected);
+ LOGGER.error("Error while servicing {}", method, unexpected);
}
} finally {
@@ -180,7 +180,7 @@ public abstract class AbstractInvocationStrategy implements InvocationStrategy {
responseStream.position(pos);
serializationStrategy.encodeResponse(loader, resultType, value, new ServiceException(e.toString()), responseStream);
} catch (Exception unexpected) {
- LOGGER.error("Error while servicing "+method, unexpected);
+ LOGGER.error("Error while servicing {}", method, unexpected);
}
} finally {
onComplete.run();
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/BlockingInvocationStrategy.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/BlockingInvocationStrategy.java
index 7844b380..32d27901 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/BlockingInvocationStrategy.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/BlockingInvocationStrategy.java
@@ -115,13 +115,13 @@ public class BlockingInvocationStrategy extends AbstractInvocationStrategy {
} catch(Exception e) {
- LOGGER.warn("Initial Encoding response for method "+method+" failed. Retrying", e);
+ LOGGER.warn("Initial Encoding response for method {} failed. Retrying", method, e);
// we failed to encode the response.. reposition and write that error.
try {
responseStream.position(pos);
serializationStrategy.encodeResponse(loader, method.getReturnType(), null, new RemoteException(e.toString()), responseStream);
} catch (Exception unexpected) {
- LOGGER.error("Error while servicing "+method, unexpected);
+ LOGGER.error("Error while servicing {}", method, unexpected);
}
} finally {
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java
index a3f52cac..32f69ab3 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java
@@ -108,7 +108,7 @@ public class TcpTransport implements Transport {
if (onCompleted != null) {
onCompleted.run();
}
- LOG.error("start should not be called from state: " + _serviceState);
+ LOG.error("start should not be called from state: {}", _serviceState);
}
}
});
@@ -137,7 +137,7 @@ public class TcpTransport implements Transport {
if (onCompleted != null) {
onCompleted.run();
}
- LOG.error("stop should not be called from state: " + _serviceState);
+ LOG.error("stop should not be called from state: {}", _serviceState);
}
}
});
@@ -497,7 +497,7 @@ public class TcpTransport implements Transport {
if( LOG.isTraceEnabled() ) {
final String label = dispatchQueue.getLabel();
if( label !=null ) {
- LOG.trace(label +" | "+message);
+ LOG.trace("{} | {}", label, message);
} else {
LOG.trace(message);
}
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java b/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
index 71589872..e1c948e5 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
@@ -65,7 +65,7 @@ public class DistributionProviderTracker extends ServiceTracker<DistributionProv
Dictionary<String, Object> props = new Hashtable<>();
props.put(REMOTE_INTENTS_SUPPORTED, getPropertyNullSafe(reference, REMOTE_INTENTS_SUPPORTED));
props.put(REMOTE_CONFIGS_SUPPORTED, getPropertyNullSafe(reference, REMOTE_CONFIGS_SUPPORTED));
- LOG.info("Registering RemoteServiceAdmin for provider " + provider.getClass().getName());
+ LOG.info("Registering RemoteServiceAdmin for provider {}", provider.getClass().getName());
return context.registerService(RemoteServiceAdmin.class.getName(), rsaf, props);
}
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/PackageUtil.java b/rsa/src/main/java/org/apache/aries/rsa/core/PackageUtil.java
index d4de961b..1b03825a 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/PackageUtil.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/PackageUtil.java
@@ -50,8 +50,8 @@ public class PackageUtil {
try {
Bundle b = pa.getBundle(iClass);
if (b == null) {
- LOG.info("Unable to find interface version for interface " + iClass.getName()
- + ". Falling back to 0.0.0");
+ LOG.info("Unable to find interface version for interface {}. Falling back to 0.0.0",
+ iClass.getName());
return "0.0.0";
}
LOG.debug("Interface source bundle: {}", b.getSymbolicName());
@@ -79,8 +79,7 @@ public class PackageUtil {
LOG.error("Was unable to obtain the package admin service -> can't resolve interface versions");
}
- LOG.info("Unable to find interface version for interface " + iClass.getName()
- + ". Falling back to 0.0.0");
+ LOG.info("Unable to find interface version for interface {}. Falling back to 0.0.0", iClass.getName());
return "0.0.0";
}
}
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
index 2d7dcc8e..de1953c4 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
@@ -228,7 +228,7 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
final List<String> interfaceNames,
final ServiceReference<?> serviceReference,
final Map<String, Object> serviceProperties) {
- LOG.info("interfaces selected for export: " + interfaceNames);
+ LOG.info("interfaces selected for export: {}", interfaceNames);
try {
checkPermission(new EndpointPermission("*", EndpointPermission.EXPORT));
@@ -497,7 +497,8 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
imReg.setImportedServiceRegistration(csfReg);
} catch (Exception ex) {
// Only logging at debug level as this might be written to the log at the TopologyManager
- LOG.debug("Can not proxy service with interfaces " + Arrays.toString(interfaceNames) + ": " + ex.getMessage(), ex);
+ LOG.debug("Can not proxy service with interfaces {}: {}",
+ Arrays.toString(interfaceNames), ex.getMessage(), ex);
imReg.setException(ex);
}
return imReg;
@@ -619,7 +620,7 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
}
public void close() {
- LOG.info("Closing " + this.getClass().getSimpleName());
+ LOG.info("Closing {}", this.getClass().getSimpleName());
closeImportRegistrations();
if (exportedServiceListener != null) {
bctx.removeServiceListener(exportedServiceListener);
@@ -639,8 +640,8 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
if (org.osgi.framework.Constants.SERVICE_ID.toLowerCase().equals(lowerKey)
|| org.osgi.framework.Constants.OBJECTCLASS.toLowerCase().equals(lowerKey)) {
// objectClass and service.id must not be overwritten
- LOG.info("exportService called with additional properties map that contained illegal key: "
- + key + ", the key is ignored");
+ LOG.info("exportService called with additional properties map that contained illegal key: {}," +
+ " the key is ignored", key);
} else {
String origKey = keysLowerCase.get(lowerKey);
if (origKey != null) {
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImport.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImport.java
index 896f1e0b..fe53007d 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImport.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImport.java
@@ -152,7 +152,7 @@ public class TopologyManagerImport implements EndpointEventListener, RemoteServi
LOG.debug("Service import was successful {}", ir);
return Stream.of(ir);
} else {
- LOG.info("Error importing service " + endpoint, ir.getException());
+ LOG.info("Error importing service {}", endpoint, ir.getException());
}
}
}
(aries-rsa) 09/10: Fix potential NPE when updating MDNS discovery interest
Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit 7a13d2998b076425db802105260170c190613b12
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Mon Jun 3 16:22:19 2024 +0300
Fix potential NPE when updating MDNS discovery interest
---
.../src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java
index 712a8dcc..530751d9 100644
--- a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java
+++ b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java
@@ -78,8 +78,9 @@ public class Interest {
event = new EndpointEvent(REMOVED, ed);
filter = oldScope.orElse(null);
}
-
- notifyListener(event, filter);
+
+ if (event != null)
+ notifyListener(event, filter);
return remove;
});
(aries-rsa) 04/10: ARIES-2156 Remove support for deprecated EventListener interface
Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit 8c4037ed1404879c98e36a461830704dbe2bb664
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Mon Jun 3 11:10:48 2024 +0300
ARIES-2156 Remove support for deprecated EventListener interface
---
.../apache/aries/rsa/discovery/mdns/Interest.java | 43 +++----------
.../aries/rsa/discovery/mdns/InterestManager.java | 15 +----
.../aries/rsa/discovery/mdns/MdnsDiscovery.java | 14 -----
.../discovery/mdns/PublishingEndpointListener.java | 17 +-----
.../aries/rsa/discovery/zookeeper/Interest.java | 46 ++------------
.../rsa/discovery/zookeeper/InterestManager.java | 16 +----
.../zookeeper/PublishingEndpointListener.java | 18 +-----
.../EndpointEventListenerTracker.java | 33 ++++------
.../exporter/EndpointListenerAdapter.java | 70 ----------------------
.../exporter/EndpointListenerNotifier.java | 6 --
.../importer/local/EndpointListenerManager.java | 30 +---------
.../exporter/EndpointListenerNotifierTest.java | 6 +-
.../importer/local/EndpointListenerImplTest.java | 6 +-
13 files changed, 40 insertions(+), 280 deletions(-)
diff --git a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java
index 4dd4fe6f..1bc64d3b 100644
--- a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java
+++ b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java
@@ -35,7 +35,6 @@ import org.apache.aries.rsa.util.StringPlus;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.osgi.service.remoteserviceadmin.EndpointEvent;
import org.osgi.service.remoteserviceadmin.EndpointEventListener;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,10 +45,10 @@ public class Interest {
private final Long id;
private final ConcurrentMap<String, EndpointDescription> added = new ConcurrentHashMap<>();
private final AtomicReference<List<String>> scopes = new AtomicReference<>();
- private final Object epListener;
+ private final EndpointEventListener epListener;
- public Interest(Long id, Object epListener, Map<String, Object> props) {
+ public Interest(Long id, EndpointEventListener epListener, Map<String, Object> props) {
this.id = id;
this.scopes.set(StringPlus.normalize(props.get(ENDPOINT_LISTENER_SCOPE)));
this.epListener = epListener;
@@ -131,45 +130,17 @@ public class Interest {
}
private void notifyListener(EndpointEvent event, String filter) {
- if (epListener instanceof EndpointEventListener) {
- notifyEEListener(event, filter, (EndpointEventListener)epListener);
- } else if (epListener instanceof EndpointListener) {
- notifyEListener(event, filter, (EndpointListener)epListener);
- }
+ EndpointDescription endpoint = event.getEndpoint();
+ LOG.info("Calling endpointChanged on class {} for filter {}, type {}, endpoint {} ",
+ epListener, filter, event.getType(), endpoint);
+ epListener.endpointChanged(event, filter);
}
private Optional<String> getFirstMatch(EndpointDescription endpoint, List<String> scopes) {
return scopes.stream().filter(endpoint::matches).findFirst();
}
- private void notifyEEListener(EndpointEvent event, String currentScope, EndpointEventListener listener) {
- EndpointDescription endpoint = event.getEndpoint();
- LOG.info("Calling endpointchanged on class {} for filter {}, type {}, endpoint {} ",
- listener, currentScope, event.getType(), endpoint);
- listener.endpointChanged(event, currentScope);
- }
-
- private void notifyEListener(EndpointEvent event, String currentScope, EndpointListener listener) {
- EndpointDescription endpoint = event.getEndpoint();
- LOG.info("Calling old listener on class {} for filter {}, type {}, endpoint {} ",
- listener, currentScope, event.getType(), endpoint);
- switch (event.getType()) {
- case EndpointEvent.ADDED:
- listener.endpointAdded(endpoint, currentScope);
- break;
-
- case EndpointEvent.MODIFIED:
- listener.endpointRemoved(endpoint, currentScope);
- listener.endpointAdded(endpoint, currentScope);
- break;
-
- case EndpointEvent.REMOVED:
- listener.endpointRemoved(endpoint, currentScope);
- break;
- }
- }
-
- @Override
+ @Override
public String toString() {
return "Interest [scopes=" + scopes + ", epListener=" + epListener.getClass() + "]";
}
diff --git a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/InterestManager.java b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/InterestManager.java
index 42f215d7..3ba9bf99 100644
--- a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/InterestManager.java
+++ b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/InterestManager.java
@@ -39,7 +39,6 @@ import org.apache.aries.rsa.spi.EndpointDescriptionParser;
import org.osgi.service.jaxrs.client.SseEventSourceFactory;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.osgi.service.remoteserviceadmin.EndpointEventListener;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -163,23 +162,11 @@ public class InterestManager {
interests.remove(getServiceId(props));
}
- public void bindEndpointListener(EndpointListener epListener, Map<String, Object> props) {
- addInterest(epListener, props);
- }
-
- public void updatedEndpointListener(Map<String, Object> props) {
- updatedInterest(props);
- }
-
- public void unbindEndpointListener(Map<String, Object> props) {
- interests.remove(getServiceId(props));
- }
-
private Long getServiceId(Map<String, Object> props) {
return (Long) props.get("service.id");
}
- private void addInterest(Object epListener, Map<String, Object> props) {
+ private void addInterest(EndpointEventListener epListener, Map<String, Object> props) {
Long id = getServiceId(props);
diff --git a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/MdnsDiscovery.java b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/MdnsDiscovery.java
index a217862d..441fe7b2 100644
--- a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/MdnsDiscovery.java
+++ b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/MdnsDiscovery.java
@@ -51,7 +51,6 @@ import org.osgi.service.jaxrs.client.SseEventSourceFactory;
import org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime;
import org.osgi.service.jaxrs.runtime.dto.RuntimeDTO;
import org.osgi.service.remoteserviceadmin.EndpointEventListener;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -99,19 +98,6 @@ public class MdnsDiscovery {
interestManager.unbindEndpointEventListener(props);
}
- @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
- public void bindEndpointListener(EndpointListener epListener, Map<String, Object> props) {
- interestManager.bindEndpointListener(epListener, props);
- }
-
- public void updatedEndpointListener(Map<String, Object> props) {
- interestManager.updatedEndpointListener(props);
- }
-
- public void unbindEndpointListener(Map<String, Object> props) {
- interestManager.unbindEndpointListener(props);
- }
-
@Reference(policy = ReferencePolicy.DYNAMIC)
public void bindJaxrsServiceRuntime(JaxrsServiceRuntime runtime) {
updateAndRegister(runtime);
diff --git a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/PublishingEndpointListener.java b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/PublishingEndpointListener.java
index d5f4b700..46872fc0 100644
--- a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/PublishingEndpointListener.java
+++ b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/PublishingEndpointListener.java
@@ -50,13 +50,12 @@ import org.osgi.service.jaxrs.whiteboard.annotations.RequireJaxrsWhiteboard;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.osgi.service.remoteserviceadmin.EndpointEvent;
import org.osgi.service.remoteserviceadmin.EndpointEventListener;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Listens for local {@link EndpointEvent}s using {@link EndpointEventListener} and old style {@link EndpointListener}
+ * Listens for local {@link EndpointEvent}s using {@link EndpointEventListener}
* and publishes changes to listeners using Server Sent Events (SSE)
*/
@SuppressWarnings("deprecation")
@@ -80,7 +79,7 @@ public class PublishingEndpointListener {
public PublishingEndpointListener(EndpointDescriptionParser parser, BundleContext bctx, String uuid) {
this.parser = parser;
this.uuid = uuid;
- String[] ifAr = {EndpointEventListener.class.getName(), EndpointListener.class.getName()};
+ String[] ifAr = { EndpointEventListener.class.getName() };
Dictionary<String, Object> props = serviceProperties(uuid);
listenerReg = bctx.registerService(ifAr, new ListenerFactory(), props);
resourceReg = bctx.registerService(PublishingEndpointListener.class, this,
@@ -181,7 +180,7 @@ public class PublishingEndpointListener {
}
- private class PerClientEndpointEventListener implements EndpointEventListener, EndpointListener {
+ private class PerClientEndpointEventListener implements EndpointEventListener {
private final Long bundleId;
@@ -194,16 +193,6 @@ public class PublishingEndpointListener {
public void endpointChanged(EndpointEvent event, String filter) {
endpointUpdate(bundleId, event.getEndpoint(), event.getType());
}
-
- @Override
- public void endpointAdded(EndpointDescription endpoint, String matchedFilter) {
- endpointUpdate(bundleId, endpoint, EndpointEvent.ADDED);
- }
-
- @Override
- public void endpointRemoved(EndpointDescription endpoint, String matchedFilter) {
- endpointUpdate(bundleId, endpoint, EndpointEvent.REMOVED);
- }
}
class Subscription {
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
index 21c2eaf1..aa61087a 100644
--- 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
@@ -28,7 +28,6 @@ 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.osgi.service.remoteserviceadmin.EndpointListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,13 +37,13 @@ public class Interest {
private final ServiceReference<?> sref;
private final List<String> scopes;
- private final Object epListener;
+ private final EndpointEventListener epListener;
public Interest(ServiceReference<?> sref) {
this(sref, null);
}
- public Interest(ServiceReference<?> sref, Object epListener) {
+ public Interest(ServiceReference<?> sref, EndpointEventListener epListener) {
this.sref = sref;
this.scopes = StringPlus.normalize(sref.getProperty(ENDPOINT_LISTENER_SCOPE));
this.epListener = epListener;
@@ -54,21 +53,15 @@ public class Interest {
return scopes;
}
- public Object getEpListener() {
- return epListener;
- }
-
public void notifyListener(EndpointEvent event) {
EndpointDescription endpoint = event.getEndpoint();
Optional<String> currentScope = getFirstMatch(endpoint);
if (currentScope.isPresent()) {
LOG.debug("Matched {} against {}", endpoint, currentScope);
- Object service = getEpListener();
- if (service instanceof EndpointEventListener) {
- notifyEEListener(event, currentScope.get(), (EndpointEventListener)service);
- } else if (service instanceof EndpointListener) {
- notifyEListener(event, currentScope.get(), (EndpointListener)service);
- }
+ String scope = currentScope.get();
+ LOG.info("Calling endpointchanged on class {} for filter {}, type {}, endpoint {} ",
+ epListener, scope, event.getType(), endpoint);
+ epListener.endpointChanged(event, scope);
}
}
@@ -76,33 +69,6 @@ public class Interest {
return scopes.stream().filter(endpoint::matches).findFirst();
}
- private void notifyEEListener(EndpointEvent event, String currentScope, EndpointEventListener listener) {
- EndpointDescription endpoint = event.getEndpoint();
- LOG.info("Calling endpointchanged on class {} for filter {}, type {}, endpoint {} ",
- listener, currentScope, event.getType(), endpoint);
- listener.endpointChanged(event, currentScope);
- }
-
- private void notifyEListener(EndpointEvent event, String currentScope, EndpointListener listener) {
- EndpointDescription endpoint = event.getEndpoint();
- LOG.info("Calling old listener on class {} for filter {}, type {}, endpoint {} ",
- listener, currentScope, event.getType(), endpoint);
- switch (event.getType()) {
- case EndpointEvent.ADDED:
- listener.endpointAdded(endpoint, currentScope);
- break;
-
- case EndpointEvent.MODIFIED:
- listener.endpointRemoved(endpoint, currentScope);
- listener.endpointAdded(endpoint, currentScope);
- break;
-
- case EndpointEvent.REMOVED:
- listener.endpointRemoved(endpoint, currentScope);
- break;
- }
- }
-
@Override
public int hashCode() {
final int prime = 31;
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 0d22a47d..d223782f 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
@@ -32,7 +32,6 @@ import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.remoteserviceadmin.EndpointEvent;
import org.osgi.service.remoteserviceadmin.EndpointEventListener;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -82,20 +81,7 @@ public class InterestManager {
interests.remove(new Interest(sref));
}
- @Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
- public void bindEndpointListener(ServiceReference<EndpointListener> sref, EndpointListener epListener) {
- addInterest(sref, epListener);
- }
-
- public void updatedEndpointListener(ServiceReference<EndpointListener> sref, EndpointListener epListener) {
- addInterest(sref, epListener);
- }
-
- public void unbindEndpointListener(ServiceReference<EndpointListener> sref) {
- interests.remove(new Interest(sref));
- }
-
- private void addInterest(ServiceReference<?> sref, Object epListener) {
+ private void addInterest(ServiceReference<?> sref, EndpointEventListener epListener) {
if (isOurOwnEndpointEventListener(sref)) {
LOG.debug("Skipping our own EndpointEventListener");
return;
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/PublishingEndpointListener.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/PublishingEndpointListener.java
index f43975ee..db6d35a0 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/PublishingEndpointListener.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/PublishingEndpointListener.java
@@ -30,19 +30,17 @@ import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.osgi.service.remoteserviceadmin.EndpointEvent;
import org.osgi.service.remoteserviceadmin.EndpointEventListener;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
/**
- * Listens for local {@link EndpointEvent}s using {@link EndpointEventListener} and old style {@link EndpointListener}
+ * Listens for local {@link EndpointEvent}s using {@link EndpointEventListener}
* and publishes changes to the {@link ZookeeperEndpointRepository}
*/
@SuppressWarnings("deprecation")
@Component(service = {}, immediate = true)
-public class PublishingEndpointListener implements EndpointEventListener, EndpointListener {
+public class PublishingEndpointListener implements EndpointEventListener {
private ServiceRegistration<?> listenerReg;
@@ -52,7 +50,7 @@ public class PublishingEndpointListener implements EndpointEventListener, Endpoi
@Activate
public void start(BundleContext bctx) {
String uuid = bctx.getProperty(Constants.FRAMEWORK_UUID);
- String[] ifAr = {EndpointEventListener.class.getName(), EndpointListener.class.getName()};
+ String[] ifAr = { EndpointEventListener.class.getName() };
Dictionary<String, String> props = serviceProperties(uuid);
listenerReg = bctx.registerService(ifAr, this, props);
}
@@ -67,16 +65,6 @@ public class PublishingEndpointListener implements EndpointEventListener, Endpoi
repository.endpointChanged(event);
}
- @Override
- public void endpointAdded(EndpointDescription endpoint, String matchedFilter) {
- endpointChanged(new EndpointEvent(EndpointEvent.ADDED, endpoint), matchedFilter);
- }
-
- @Override
- public void endpointRemoved(EndpointDescription endpoint, String matchedFilter) {
- endpointChanged(new EndpointEvent(EndpointEvent.REMOVED, endpoint), matchedFilter);
- }
-
private Dictionary<String, String> serviceProperties(String uuid) {
String scope = String.format("(&(%s=*)(%s=%s))", Constants.OBJECTCLASS,
RemoteConstants.ENDPOINT_FRAMEWORK_UUID, uuid);
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/EndpointEventListenerTracker.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/EndpointEventListenerTracker.java
index 1bd8d090..d0d8b8ed 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/EndpointEventListenerTracker.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/EndpointEventListenerTracker.java
@@ -18,7 +18,6 @@
*/
package org.apache.aries.rsa.topologymanager;
-import org.apache.aries.rsa.topologymanager.exporter.EndpointListenerAdapter;
import org.apache.aries.rsa.topologymanager.exporter.EndpointListenerNotifier;
import org.apache.aries.rsa.topologymanager.exporter.TopologyManagerExport;
import org.osgi.framework.BundleContext;
@@ -27,11 +26,10 @@ import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.service.remoteserviceadmin.EndpointEventListener;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
import org.osgi.util.tracker.ServiceTracker;
@SuppressWarnings({ "deprecation", "rawtypes", "unchecked" })
-final class EndpointEventListenerTracker extends ServiceTracker {
+final class EndpointEventListenerTracker extends ServiceTracker<EndpointEventListener, EndpointEventListener> {
private TopologyManagerExport tmExport;
EndpointEventListenerTracker(BundleContext context, TopologyManagerExport tmExport) {
@@ -40,8 +38,7 @@ final class EndpointEventListenerTracker extends ServiceTracker {
}
private static Filter getFilter() {
- String filterSt = String.format("(|(objectClass=%s)(objectClass=%s))", EndpointEventListener.class.getName(),
- EndpointListener.class.getName());
+ String filterSt = String.format("(objectClass=%s)", EndpointEventListener.class.getName());
try {
return FrameworkUtil.createFilter(filterSt);
} catch (InvalidSyntaxException e) {
@@ -50,29 +47,21 @@ final class EndpointEventListenerTracker extends ServiceTracker {
}
@Override
- public Object addingService(ServiceReference reference) {
- Object listener = super.addingService(reference);
- EndpointEventListener actualListener = getListener(listener);
- this.tmExport.addEPListener(actualListener, EndpointListenerNotifier.filtersFromEEL(reference));
- return actualListener;
- }
-
- private EndpointEventListener getListener(Object listener) {
- return (listener instanceof EndpointEventListener)
- ? (EndpointEventListener) listener
- : new EndpointListenerAdapter((EndpointListener) listener);
+ public EndpointEventListener addingService(ServiceReference reference) {
+ EndpointEventListener listener = super.addingService(reference);
+ this.tmExport.addEPListener(listener, EndpointListenerNotifier.filtersFromEEL(reference));
+ return listener;
}
@Override
- public void modifiedService(ServiceReference reference, Object listener) {
- EndpointEventListener actualListener = getListener(listener);
- this.tmExport.addEPListener(actualListener, EndpointListenerNotifier.filtersFromEEL(reference));
- super.modifiedService(reference, actualListener);
+ public void modifiedService(ServiceReference reference, EndpointEventListener listener) {
+ this.tmExport.addEPListener(listener, EndpointListenerNotifier.filtersFromEEL(reference));
+ super.modifiedService(reference, listener);
}
@Override
- public void removedService(ServiceReference reference, Object listener) {
- this.tmExport.removeEPListener((EndpointEventListener) listener);
+ public void removedService(ServiceReference reference, EndpointEventListener listener) {
+ this.tmExport.removeEPListener(listener);
super.removedService(reference, listener);
}
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerAdapter.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerAdapter.java
deleted file mode 100644
index 888be769..00000000
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerAdapter.java
+++ /dev/null
@@ -1,70 +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.topologymanager.exporter;
-
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.EndpointEvent;
-import org.osgi.service.remoteserviceadmin.EndpointEventListener;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
-
-/**
- * Wraps on old style EndpointListener into the new
- * EndpointEventListener interface
- */
-@SuppressWarnings("deprecation")
-public class EndpointListenerAdapter implements EndpointEventListener {
- private EndpointListener epl;
-
- public EndpointListenerAdapter(EndpointListener epl) {
- this.epl = epl;
- }
-
- @Override
- public void endpointChanged(EndpointEvent event, String filter) {
- EndpointDescription endpoint = event.getEndpoint();
- switch (event.getType()) {
- case EndpointEvent.ADDED:
- epl.endpointAdded(endpoint, filter);
- break;
- case EndpointEvent.REMOVED:
- epl.endpointRemoved(endpoint, filter);
- break;
- case EndpointEvent.MODIFIED:
- epl.endpointRemoved(endpoint, filter);
- epl.endpointAdded(endpoint, filter);
- break;
- case EndpointEvent.MODIFIED_ENDMATCH:
- epl.endpointRemoved(endpoint, filter);
- break;
- }
- }
-
- /**
- * Checks for equality of the adapted EndpointListener
- */
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof EndpointListenerAdapter) {
- EndpointListenerAdapter ela = (EndpointListenerAdapter)obj;
- return epl.equals(ela.epl);
- } else {
- return super.equals(obj);
- }
- }
-}
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifier.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifier.java
index 2972f1d8..c9e53f9e 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifier.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifier.java
@@ -35,7 +35,6 @@ 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.osgi.service.remoteserviceadmin.EndpointListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,11 +50,6 @@ public class EndpointListenerNotifier {
this.listeners = new ConcurrentHashMap<>();
}
- public static Set<Filter> filtersFromEL(ServiceReference<EndpointListener> sref) {
- List<String> scopes = StringPlus.normalize(sref.getProperty(EndpointListener.ENDPOINT_LISTENER_SCOPE));
- return getFilterSet(scopes);
- }
-
public static Set<Filter> filtersFromEEL(ServiceReference<EndpointEventListener> sref) {
List<String> scopes = StringPlus.normalize(sref.getProperty(EndpointEventListener.ENDPOINT_LISTENER_SCOPE));
return getFilterSet(scopes);
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerManager.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerManager.java
index a246a03b..03cfcfdf 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerManager.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerManager.java
@@ -27,10 +27,7 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.hooks.service.FindHook;
import org.osgi.framework.hooks.service.ListenerHook;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.EndpointEvent;
import org.osgi.service.remoteserviceadmin.EndpointEventListener;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -43,26 +40,7 @@ import org.slf4j.LoggerFactory;
* the interest in the local system.
*/
@SuppressWarnings("deprecation")
-public class EndpointListenerManager implements ServiceInterestListener{
-
- private final class EndpointListenerAdapter implements EndpointListener, EndpointEventListener {
- @Override
- public void endpointRemoved(EndpointDescription endpoint, String matchedFilter) {
- EndpointEvent event = new EndpointEvent(EndpointEvent.REMOVED, endpoint);
- endpointListener.endpointChanged(event, matchedFilter);
- }
-
- @Override
- public void endpointAdded(EndpointDescription endpoint, String matchedFilter) {
- EndpointEvent event = new EndpointEvent(EndpointEvent.ADDED, endpoint);
- endpointListener.endpointChanged(event, matchedFilter);
- }
-
- @Override
- public void endpointChanged(EndpointEvent event, String filter) {
- endpointListener.endpointChanged(event, filter);
- }
- }
+public class EndpointListenerManager implements ServiceInterestListener {
private static final Logger LOG = LoggerFactory.getLogger(EndpointListenerManager.class);
@@ -87,10 +65,8 @@ public class EndpointListenerManager implements ServiceInterestListener{
}
public void start() {
- EndpointListener endpointListenerAdapter = new EndpointListenerAdapter();
- String[] ifAr = {EndpointListener.class.getName(), EndpointEventListener.class.getName()};
- serviceRegistration = bctx.registerService(ifAr, endpointListenerAdapter, getEELProperties());
-
+ String[] ifAr = { EndpointEventListener.class.getName() };
+ serviceRegistration = bctx.registerService(ifAr, endpointListener, getEELProperties());
bctx.registerService(ListenerHook.class, listenerHook, null);
bctx.registerService(FindHook.class, findHook, null);
}
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifierTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifierTest.java
index 54feb5ac..b045b077 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifierTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifierTest.java
@@ -106,7 +106,7 @@ public class EndpointListenerNotifierTest {
@Test
public void testNormalizeScopeForSingleString() {
ServiceReference sr = createListenerServiceWithFilter("(myProp=A)");
- Set<Filter> res = EndpointListenerNotifier.filtersFromEL(sr);
+ Set<Filter> res = EndpointListenerNotifier.filtersFromEEL(sr);
assertEquals(1, res.size());
Filter filter = res.iterator().next();
filterMatches(filter);
@@ -116,7 +116,7 @@ public class EndpointListenerNotifierTest {
public void testNormalizeScopeForStringArray() {
String[] filters = {"(myProp=A)", "(otherProp=B)"};
ServiceReference sr = createListenerServiceWithFilter(filters);
- Set<Filter> res = EndpointListenerNotifier.filtersFromEL(sr);
+ Set<Filter> res = EndpointListenerNotifier.filtersFromEEL(sr);
assertEquals(filters.length, res.size());
Iterator<Filter> it = res.iterator();
Filter filter1 = it.next();
@@ -130,7 +130,7 @@ public class EndpointListenerNotifierTest {
public void testNormalizeScopeForCollection() {
Collection<String> collection = Arrays.asList("(myProp=A)", "(otherProp=B)");
ServiceReference sr = createListenerServiceWithFilter(collection);
- Set<Filter> res = EndpointListenerNotifier.filtersFromEL(sr);
+ Set<Filter> res = EndpointListenerNotifier.filtersFromEEL(sr);
Iterator<Filter> it = res.iterator();
Filter filter1 = it.next();
Filter filter2 = it.next();
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
index dcdba609..7864ce44 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerImplTest.java
@@ -22,7 +22,6 @@ import java.util.Dictionary;
import java.util.List;
import org.apache.aries.rsa.topologymanager.importer.TopologyManagerImport;
-import org.apache.aries.rsa.topologymanager.importer.local.EndpointListenerManager;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.easymock.IMocksControl;
@@ -31,7 +30,6 @@ import org.junit.Test;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.remoteserviceadmin.EndpointEventListener;
-import org.osgi.service.remoteserviceadmin.EndpointListener;
@SuppressWarnings("deprecation")
public class EndpointListenerImplTest extends Assert {
@@ -46,7 +44,7 @@ public class EndpointListenerImplTest extends Assert {
TopologyManagerImport tm = c.createMock(TopologyManagerImport.class);
ServiceRegistration sr = c.createMock(ServiceRegistration.class);
- String[] ifAr = {EndpointListener.class.getName(), EndpointEventListener.class.getName()};
+ String[] ifAr = { EndpointEventListener.class.getName() };
// expect Listener registration
EasyMock.expect(bc.registerService(EasyMock.aryEq(ifAr),
EasyMock.anyObject(),
@@ -60,7 +58,7 @@ public class EndpointListenerImplTest extends Assert {
public Object answer() throws Throwable {
Object[] args = EasyMock.getCurrentArguments();
Dictionary props = (Dictionary)args[0];
- List<String> scope = (List<String>)props.get(EndpointListener.ENDPOINT_LISTENER_SCOPE);
+ List<String> scope = (List<String>)props.get(EndpointEventListener.ENDPOINT_LISTENER_SCOPE);
switch (testCase) {
case 1:
assertEquals(1, scope.size());
(aries-rsa) 06/10: Fix typos in comments
Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit cc1740bcc8526bea918fe9bb886b9e2e2761ecb1
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Mon Jun 3 14:35:03 2024 +0300
Fix typos in comments
---
.../apache/aries/rsa/discovery/endpoint/PropertiesMapper.java | 2 +-
.../org/apache/aries/rsa/discovery/local/LocalDiscovery.java | 2 +-
.../zookeeper/client/ZookeeperEndpointRepository.java | 2 +-
provider/fastbin/Readme.md | 4 ++--
provider/fastbin/pom.xml | 4 ++--
.../provider/fastbin/api/ProtobufSerializationStrategy.java | 2 +-
.../apache/aries/rsa/provider/fastbin/io/ProtocolCodec.java | 4 ++--
.../java/org/apache/aries/rsa/provider/fastbin/io/Service.java | 4 ++--
.../org/apache/aries/rsa/provider/fastbin/io/Transport.java | 2 +-
.../apache/aries/rsa/provider/fastbin/io/TransportServer.java | 2 +-
.../rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java | 4 ++--
.../rsa/provider/fastbin/tcp/BlockingInvocationStrategy.java | 2 +-
.../aries/rsa/provider/fastbin/tcp/ClientInvokerImpl.java | 4 ++--
.../aries/rsa/provider/fastbin/tcp/LengthPrefixedCodec.java | 10 +++++-----
.../aries/rsa/provider/fastbin/tcp/ServerInvokerImpl.java | 2 +-
.../apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java | 10 +++++-----
.../aries/rsa/provider/fastbin/tcp/TcpTransportServer.java | 4 ++--
.../aries/rsa/provider/fastbin/util/IntrospectionSupport.java | 2 +-
.../apache/aries/rsa/provider/fastbin/util/UuidGenerator.java | 2 +-
.../org/apache/aries/rsa/provider/fastbin/InvocationTest.java | 2 +-
.../main/java/org/apache/aries/rsa/provider/tcp/TcpServer.java | 2 +-
.../java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java | 2 +-
.../org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java | 4 ++--
spi/src/main/java/org/apache/aries/rsa/spi/ExportPolicy.java | 2 +-
topology-manager/Readme.md | 2 +-
.../rsa/topologymanager/exporter/TopologyManagerExport.java | 2 +-
.../apache/aries/rsa/topologymanager/importer/local/Readme.md | 2 +-
27 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
index 1d5d9f33..f3fa57fd 100644
--- a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
+++ b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
@@ -267,7 +267,7 @@ class PropertiesMapper {
|| val instanceof Float
|| val instanceof Integer
|| val instanceof Short) {
- // various numbers.. maybe "val instanceof Number"?
+ // various numbers... maybe "val instanceof Number"?
setValueType(propEl, val);
propEl.setValue(val.toString());
} else {
diff --git a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
index 03350f68..5df81bd8 100644
--- a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
+++ b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
@@ -104,7 +104,7 @@ public class LocalDiscovery implements BundleListener {
/**
* If the tracker was removed or the scope was changed this doesn't require
- * additional callbacks on the tracker. Its the responsibility of the tracker
+ * additional callbacks on the tracker. It's the responsibility of the tracker
* itself to clean up any orphans. See Remote Service Admin spec 122.6.3
* @param endpointListener
*/
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ZookeeperEndpointRepository.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ZookeeperEndpointRepository.java
index 1bba0035..4c01d0ff 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ZookeeperEndpointRepository.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/client/ZookeeperEndpointRepository.java
@@ -156,7 +156,7 @@ public class ZookeeperEndpointRepository {
} catch (NodeExistsException nee) {
// this sometimes happens after a ZooKeeper node dies and the ephemeral node
// that belonged to the old session was not yet deleted. We need to make our
- // session the owner of the node so it won't get deleted automatically -
+ // session the owner of the node, so it won't get deleted automatically -
// we do this by deleting and recreating it ourselves.
LOG.info("node for endpoint already exists, recreating: {}", fullPath);
try {
diff --git a/provider/fastbin/Readme.md b/provider/fastbin/Readme.md
index a47e1849..748772f1 100644
--- a/provider/fastbin/Readme.md
+++ b/provider/fastbin/Readme.md
@@ -2,7 +2,7 @@
Allows transparent remoting using Java Serialization over TCP. The fastbin provider uses a pool of nio tcp channels to transport data.
It can use either java object serialization or protobuf to serialize parameters and return values.
-Sync remote calls have a default timeout of 5 minutes. For long running operations async calls should be used. This is indicated by having either
+Sync remote calls have a default timeout of 5 minutes. For long-running operations async calls should be used. This is indicated by having either
* `Future`
* `CompletableFuture`
@@ -12,7 +12,7 @@ as the return value of the remote method. The client will receive a proxy of tha
## Streaming Data
-When large amount of data (e.g. files) need to be transferred remotely it is not advisable to use large byte arrays as this will allocate a lot of memory. Instead the fastbin transport allows to
+When large amount of data (e.g. files) need to be transferred remotely it is not advisable to use large byte arrays as this will allocate a lot of memory. Instead, the fastbin transport allows to
use `InputStream` and `OutputStream` as parameter or return value. When a remote method contains such a parameter, the stream is replaced with a proxy implementation that pipes data remotely from/to the original stream.
## Transport configuration
diff --git a/provider/fastbin/pom.xml b/provider/fastbin/pom.xml
index 363910ae..588292e4 100644
--- a/provider/fastbin/pom.xml
+++ b/provider/fastbin/pom.xml
@@ -50,13 +50,13 @@
<groupId>org.fusesource.hawtbuf</groupId>
<artifactId>hawtbuf</artifactId>
</dependency>
- <!-- this is only needed you you want to use the ProtobufSerializationStrategy -->
+ <!-- this is only needed if you want to use the ProtobufSerializationStrategy -->
<dependency>
<groupId>org.fusesource.hawtbuf</groupId>
<artifactId>hawtbuf-proto</artifactId>
<optional>true</optional>
</dependency>
- <!-- this is only needed you you want to use the Promise for remote services -->
+ <!-- this is only needed if you want to use the Promise for remote services -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.util.promise</artifactId>
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/api/ProtobufSerializationStrategy.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/api/ProtobufSerializationStrategy.java
index 65d69a66..edb07a5b 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/api/ProtobufSerializationStrategy.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/api/ProtobufSerializationStrategy.java
@@ -115,7 +115,7 @@ public class ProtobufSerializationStrategy implements SerializationStrategy {
Constructor<?> ctr = loader.loadClass(className).getConstructor(String.class);
error = (Throwable) ctr.newInstance(message);
} catch (Throwable e) {
- // fallback to something simple..
+ // fallback to something simple...
error = new RuntimeException(className+": "+message);
}
result.onFailure(error);
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/ProtocolCodec.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/ProtocolCodec.java
index d8a01c1e..4de96c50 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/ProtocolCodec.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/ProtocolCodec.java
@@ -23,7 +23,7 @@ import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel;
/**
- * Interface to encode and decode commands in and out of a a non blocking channel.
+ * Interface to encode and decode commands in and out of a non-blocking channel.
*
*/
public interface ProtocolCodec {
@@ -83,7 +83,7 @@ public interface ProtocolCodec {
BufferState flush() throws IOException;
/**
- * @return true if the codec will no accept any more writes.
+ * @return true if the codec will not accept any more writes.
*/
boolean full();
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/Service.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/Service.java
index caa7e3b8..e20da71e 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/Service.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/Service.java
@@ -34,7 +34,7 @@ public interface Service {
/**
* Starts the service. Executes the onComplete runnable once the service has fully started up.
*
- * @param onComplete my be set to null if not interested in a callback.
+ * @param onComplete may be set to null if not interested in a callback.
*/
void start(Runnable onComplete) throws Exception;
@@ -47,7 +47,7 @@ public interface Service {
/**
* Stops the service. Executes the onComplete runnable once the service has fully stopped.
*
- * @param onComplete my be set to null if not interested in a callback.
+ * @param onComplete may be set to null if not interested in a callback.
*/
void stop(Runnable onComplete);
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/Transport.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/Transport.java
index 2164b0d5..0b33fade 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/Transport.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/Transport.java
@@ -30,7 +30,7 @@ public interface Transport extends Service, Dispatched {
boolean full();
/**
- * A one way asynchronous send of a command. Only sent if the the transport is not full.
+ * A one way asynchronous send of a command. Only sent if the transport is not full.
*
* @param command
* @return true if the command was accepted.
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/TransportServer.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/TransportServer.java
index fa569875..799dd98d 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/TransportServer.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/io/TransportServer.java
@@ -31,7 +31,7 @@ import org.fusesource.hawtdispatch.DispatchQueue;
public interface TransportServer extends Service {
/**
- * Registers an @see TransportAcceptListener which is notified of accepted
+ * Registers a {@link TransportAcceptListener} which is notified of accepted
* channels.
*
* @param acceptListener
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java
index f943431e..a1924c29 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AbstractInvocationStrategy.java
@@ -120,7 +120,7 @@ public abstract class AbstractInvocationStrategy implements InvocationStrategy {
} catch(Exception e) {
LOGGER.warn("Initial Encoding response for method {} failed. Retrying", method, e);
- // we failed to encode the response.. reposition and write that error.
+ // we failed to encode the response... reposition and write that error
try {
responseStream.position(pos);
serializationStrategy.encodeResponse(loader, null, null, new ServiceException(e.toString()), responseStream);
@@ -175,7 +175,7 @@ public abstract class AbstractInvocationStrategy implements InvocationStrategy {
try {
serializationStrategy.encodeResponse(loader, resultType, value, error, responseStream);
} catch (Exception e) {
- // we failed to encode the response.. reposition and write that error.
+ // we failed to encode the response... reposition and write that error
try {
responseStream.position(pos);
serializationStrategy.encodeResponse(loader, resultType, value, new ServiceException(e.toString()), responseStream);
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/BlockingInvocationStrategy.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/BlockingInvocationStrategy.java
index 32d27901..1c049cd9 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/BlockingInvocationStrategy.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/BlockingInvocationStrategy.java
@@ -116,7 +116,7 @@ public class BlockingInvocationStrategy extends AbstractInvocationStrategy {
} catch(Exception e) {
LOGGER.warn("Initial Encoding response for method {} failed. Retrying", method, e);
- // we failed to encode the response.. reposition and write that error.
+ // we failed to encode the response... reposition and write that error.
try {
responseStream.position(pos);
serializationStrategy.encodeResponse(loader, method.getReturnType(), null, new RemoteException(e.toString()), responseStream);
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ClientInvokerImpl.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ClientInvokerImpl.java
index 2d8e67a4..c3b8a890 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ClientInvokerImpl.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ClientInvokerImpl.java
@@ -333,9 +333,9 @@ public class ClientInvokerImpl implements ClientInvoker, Dispatched {
public InvokerTransportPool(String uri, DispatchQueue queue) {
/*
- * the evict time needs to be 0. Otherwise the client will
+ * the evict time needs to be 0. Otherwise, the client will
* evict transport objects which breaks the connection for
- * long running async calls.
+ * long-running async calls.
* Since there is limit of 2 transports per uri it shouldn't be that many objects
*/
super(uri, queue, TransportPool.DEFAULT_POOL_SIZE, 0);
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodec.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodec.java
index 89edf542..c2a2523e 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodec.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodec.java
@@ -132,7 +132,7 @@ public class LengthPrefixedCodec implements ProtocolCodec {
public Object read() throws IOException {
while(true) {
if( read_buffer.remaining()!=0 ) {
- // keep reading from the channel until we fill the read buffer..
+ // keep reading from the channel until we fill the read buffer
int count = read_channel.read(read_buffer);
if (count == -1) {
throw new EOFException("Peer disconnected");
@@ -141,7 +141,7 @@ public class LengthPrefixedCodec implements ProtocolCodec {
}
read_counter += count;
} else {
- //read buffer is full.. interpret it..
+ //read buffer is full... interpret it
read_buffer.flip();
if( read_buffer.capacity() == 4 ) {
@@ -154,18 +154,18 @@ public class LengthPrefixedCodec implements ProtocolCodec {
throw new ProtocolException("Packet length was declared as " + size + " but at most " + MAX_PACKET_SIZE + "is allowed. You can configure this limit with the system property aries.fastbin.max.packet.bytes");
}
if( size == 4 ) {
- // weird.. empty frame.. guess it could happen.
+ // weird... empty frame... guess it could happen.
Buffer rc = new Buffer(read_buffer);
read_buffer = ByteBuffer.allocate(4);
return rc;
} else {
- // Resize to the right size.. this resumes the reads..
+ // Resize to the right size... this resumes the reads
ByteBuffer next = ByteBuffer.allocate(size);
next.putInt(size);
read_buffer = next;
}
} else {
- // finish loading the rest of the buffer..
+ // finish loading the rest of the buffer
Buffer rc = new Buffer(read_buffer);
read_buffer = ByteBuffer.allocate(4);
return rc;
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ServerInvokerImpl.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ServerInvokerImpl.java
index cc7be2bf..d9377e75 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ServerInvokerImpl.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ServerInvokerImpl.java
@@ -348,7 +348,7 @@ public class ServerInvokerImpl implements ServerInvoker, Dispatched {
throw new RuntimeException(e);
}
- // Lets decode the remaining args on the target's executor
+ // Let's decode the remaining args on the target's executor
// to take cpu load off the
ClassLoader loader = holder==null ? getClass().getClassLoader() : holder.loader;
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java
index 32f69ab3..0573a2a9 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java
@@ -196,7 +196,7 @@ public class TcpTransport implements Transport {
try {
if (socketState.isConnecting()) {
trace("connecting...");
- // this allows the connect to complete..
+ // this allows the connect to complete...
readSource = Dispatch.createSource(channel, SelectionKey.OP_CONNECT, dispatchQueue);
readSource.setEventHandler(new Runnable() {
public void run() {
@@ -381,7 +381,7 @@ public class TcpTransport implements Transport {
}
try {
long initial = codec.getReadCounter();
- // Only process up to 64k worth of data at a time so we can give
+ // Only process up to 64k worth of data at a time, so we can give
// other connections a chance to process their requests.
while( codec.getReadCounter() - initial < 1024 * 64 ) {
Object command = codec.read();
@@ -486,7 +486,7 @@ public class TcpTransport implements Transport {
/**
* Sets whether 'localhost' or the actual local host name should be used to
- * make local connections. On some operating systems such as Macs its not
+ * make local connections. On some operating systems such as Macs it's not
* possible to connect as the local host name so localhost is better.
*/
public void setUseLocalHost(boolean useLocalHost) {
@@ -588,7 +588,7 @@ public class TcpTransport implements Transport {
if( reduction!=0 ) {
if( dst.remaining() == 0 ) {
// we need to suspend the read now until we get
- // a new allowance..
+ // a new allowance...
readSource.suspend();
read_suspended = true;
}
@@ -621,7 +621,7 @@ public class TcpTransport implements Transport {
if( reduction!=0 ) {
if( src.remaining() == 0 ) {
// we need to suspend the read now until we get
- // a new allowance..
+ // a new allowance...
write_suspended = true;
suspendWrite();
}
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransportServer.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransportServer.java
index cb8853ee..a95adad1 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransportServer.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransportServer.java
@@ -146,7 +146,7 @@ public class TcpTransportServer implements TransportServer {
protected String resolveHostName() {
String result;
if (bindAddress.getAddress().isAnyLocalAddress()) {
- // make it more human readable and useful, an alternative to 0.0.0.0
+ // make it more human-readable and useful, an alternative to 0.0.0.0
try {
result = InetAddress.getLocalHost().getCanonicalHostName();
} catch (UnknownHostException e) {
@@ -191,7 +191,7 @@ public class TcpTransportServer implements TransportServer {
protected final void handleSocket(SocketChannel socket) throws Exception {
HashMap<String, Object> options = new HashMap<>();
// options.put("maxInactivityDuration", Long.valueOf(maxInactivityDuration));
-// options.put("maxInactivityDurationInitalDelay", Long.valueOf(maxInactivityDurationInitalDelay));
+// options.put("maxInactivityDurationInitialDelay", Long.valueOf(maxInactivityDurationInitialDelay));
// options.put("trace", Boolean.valueOf(trace));
// options.put("soTimeout", Integer.valueOf(soTimeout));
// options.put("socketBufferSize", Integer.valueOf(socketBufferSize));
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/IntrospectionSupport.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/IntrospectionSupport.java
index 5ef8efa9..f29e0c3e 100755
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/IntrospectionSupport.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/IntrospectionSupport.java
@@ -170,7 +170,7 @@ public final class IntrospectionSupport {
return false;
}
- // If the type is null or it matches the needed type, just use the
+ // If the type is null, or it matches the needed type, just use the
// value directly
if (value == null || value.getClass() == setter.getParameterTypes()[0]) {
setter.invoke(target, value);
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/UuidGenerator.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/UuidGenerator.java
index 5ec3a97d..7db7927b 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/UuidGenerator.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/UuidGenerator.java
@@ -90,7 +90,7 @@ public class UuidGenerator {
}
/**
- * As we have to find the hostname as a side-affect of generating a unique
+ * As we have to find the hostname as a side effect of generating a unique
* stub, we allow its easy retrieval here
*
* @return the local host name
diff --git a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
index 7e549b6a..3a62c620 100644
--- a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
+++ b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
@@ -85,7 +85,7 @@ public class InvocationTest {
assertEquals("Hello Fabric!", hello.hello("Fabric"));
assertEquals("Hello World!", hello.helloworld());
- // Verification the we can pick the right overloaded method even if using a mixure
+ // Verification that we can pick the right overloaded method even if using a mix
// of primitives / objects and array dimensions.
assertEquals('a', hello.mix(0));
assertEquals('b', hello.mix(new int[]{0}));
diff --git a/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpServer.java b/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpServer.java
index abce724e..c5657ce5 100644
--- a/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpServer.java
+++ b/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpServer.java
@@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
/**
* A server listening on a single TCP port, which accepts connections
- * and dispatches method invocation requests to one or more MethodInovkers
+ * and dispatches method invocation requests to one or more MethodInvokers
* (according to the target endpoint ID).
*/
public class TcpServer implements Closeable, Runnable {
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
index 9fd7d86d..bb72ee03 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
@@ -99,7 +99,7 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
createServiceListener();
}
- // listen for exported services being unregistered so we can close the export
+ // listen for exported services being unregistered, so we can close the export
protected void createServiceListener() {
this.exportedServiceListener = new ServiceListener() {
public void serviceChanged(ServiceEvent event) {
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
index aff96b8a..22aca0a8 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
@@ -158,7 +158,7 @@ public class RemoteServiceAdminCoreTest {
assertEquals(1, rsaCore.getImportedEndpoints().size());
- // lets import the same endpoint once more -> should get a copy of the ImportRegistration
+ // let's import the same endpoint once more -> should get a copy of the ImportRegistration
ImportRegistration ireg2 = rsaCore.importService(endpoint2);
assertNotNull(ireg2);
assertEquals(2, rsaCore.getImportedEndpoints().size());
@@ -201,7 +201,7 @@ public class RemoteServiceAdminCoreTest {
assertNotNull(ireg);
assertEquals(1, rsaCore.getImportedEndpoints().size());
- // lets import the same endpoint once more -> should get a copy of the ImportRegistration
+ // let's import the same endpoint once more -> should get a copy of the ImportRegistration
ImportRegistration ireg2 = rsaCore.importService(endpoint);
assertNotNull(ireg2);
assertEquals(2, rsaCore.getImportedEndpoints().size());
diff --git a/spi/src/main/java/org/apache/aries/rsa/spi/ExportPolicy.java b/spi/src/main/java/org/apache/aries/rsa/spi/ExportPolicy.java
index 2d070bde..17fd543a 100644
--- a/spi/src/main/java/org/apache/aries/rsa/spi/ExportPolicy.java
+++ b/spi/src/main/java/org/apache/aries/rsa/spi/ExportPolicy.java
@@ -36,7 +36,7 @@ public interface ExportPolicy {
* Allows to supply additional properties for a service that are then
* given to RemoteServiceAdmin. The service will be exported
* if the original service or the additional properties contain the
- * non empty property service.exported.interfaces.
+ * non-empty property service.exported.interfaces.
*
* @param sref service to export
* @return additional properties for exported Service (must not be null)
diff --git a/topology-manager/Readme.md b/topology-manager/Readme.md
index b4fb2c46..0bcb75b1 100644
--- a/topology-manager/Readme.md
+++ b/topology-manager/Readme.md
@@ -11,7 +11,7 @@ with matching remote Endpoints.
## ExportPolicy
This behaviour can be customized by exposing a service implementing the [ExportPolicy interface](https://github.com/apache/aries-rsa/blob/master/spi/src/main/java/org/apache/aries/rsa/spi/ExportPolicy.java).
-It can be used to implement system wide governance rules.
+It can be used to implement system-wide governance rules.
Some examples what could be done:
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExport.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExport.java
index dac5238b..2ae744d0 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExport.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExport.java
@@ -81,7 +81,7 @@ public class TopologyManagerExport implements ServiceListener {
}
}
- // track all service registrations so we can export any services that are configured to be exported
+ // track all service registrations, so we can export any services that are configured to be exported
// ServiceListener events may be delivered out of order, concurrently, re-entrant, etc. (see spec or docs)
public void serviceChanged(ServiceEvent event) {
ServiceReference<?> sref = event.getServiceReference();
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/Readme.md b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/Readme.md
index 0c031020..ba038478 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/Readme.md
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/Readme.md
@@ -17,5 +17,5 @@
under the License.
-->
Takes care of tracking local demand for services by using a ListenerHook and FindHook.
-Manages the scope of the EndpointLister that is used for importing external services so it matches the local service
+Manages the scope of the EndpointLister that is used for importing external services, so it matches the local service
demand.
(aries-rsa) 05/10: ARIES-2157 Replace deprecated PackageAdmin usage with BundleWiring
Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit 6d3d2cda69206e44dec7fa4ca0d1b19bb3400b10
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Mon Jun 3 14:04:11 2024 +0300
ARIES-2157 Replace deprecated PackageAdmin usage with BundleWiring
---
.../rsa/core/DistributionProviderTracker.java | 4 +-
.../org/apache/aries/rsa/core/PackageUtil.java | 70 +++++++++-------------
.../aries/rsa/core/RemoteServiceAdminCore.java | 8 +--
.../aries/rsa/core/RemoteServiceAdminCoreTest.java | 33 +++++++---
4 files changed, 57 insertions(+), 58 deletions(-)
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java b/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
index e1c948e5..12505e02 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
@@ -54,13 +54,11 @@ public class DistributionProviderTracker extends ServiceTracker<DistributionProv
}
LOG.debug("RemoteServiceAdmin Implementation is starting up");
BundleContext apiContext = getAPIContext();
- PackageUtil packageUtil = new PackageUtil(context);
EventProducer eventProducer = new EventProducer(context);
RemoteServiceAdminCore rsaCore = new RemoteServiceAdminCore(context,
apiContext,
eventProducer,
- provider,
- packageUtil);
+ provider);
RemoteServiceAdminFactory rsaf = new RemoteServiceAdminFactory(rsaCore);
Dictionary<String, Object> props = new Hashtable<>();
props.put(REMOTE_INTENTS_SUPPORTED, getPropertyNullSafe(reference, REMOTE_INTENTS_SUPPORTED));
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/PackageUtil.java b/rsa/src/main/java/org/apache/aries/rsa/core/PackageUtil.java
index 1b03825a..f83278e1 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/PackageUtil.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/PackageUtil.java
@@ -18,65 +18,51 @@
*/
package org.apache.aries.rsa.core;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.framework.*;
+import org.osgi.framework.namespace.PackageNamespace;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleWiring;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-@SuppressWarnings("deprecation")
+import java.util.List;
+import java.util.function.Function;
+
+/**
+ * Utility methods for obtaining package metadata.
+ */
public class PackageUtil {
public static final Logger LOG = LoggerFactory.getLogger(PackageUtil.class);
- private BundleContext bc;
- public PackageUtil(BundleContext bc) {
- this.bc = bc;
- }
+ protected static Function<Class<?>, Bundle> BUNDLE_FINDER = FrameworkUtil::getBundle;
/**
- * Tries to retrieve the version of iClass via the PackageAdmin.
+ * Tries to retrieve the version of iClass via its bundle exported packages metadata.
*
* @param iClass tThe interface for which the version should be found
* @return the version of the interface or "0.0.0" if no version information could be found or an error
* occurred during the retrieval
*/
- public String getVersion(Class<?> iClass) {
- ServiceReference<PackageAdmin> paRef = bc.getServiceReference(PackageAdmin.class);
- if (paRef != null) {
- PackageAdmin pa = bc.getService(paRef);
- try {
- Bundle b = pa.getBundle(iClass);
- if (b == null) {
- LOG.info("Unable to find interface version for interface {}. Falling back to 0.0.0",
- iClass.getName());
- return "0.0.0";
- }
- LOG.debug("Interface source bundle: {}", b.getSymbolicName());
-
- ExportedPackage[] ep = pa.getExportedPackages(b);
- LOG.debug("Exported Packages of the source bundle: {}", (Object)ep);
-
- String pack = iClass.getPackage().getName();
- LOG.debug("Looking for Package: {}", pack);
- if (ep != null) {
- for (ExportedPackage p : ep) {
- if (p != null
- && pack.equals(p.getName())) {
- LOG.debug("found package -> Version: {}", p.getVersion());
- return p.getVersion().toString();
- }
+ public static String getVersion(Class<?> iClass) {
+ Bundle bundle = BUNDLE_FINDER.apply(iClass);
+ if (bundle != null) {
+ BundleWiring wiring = bundle.adapt(BundleWiring.class);
+ List<BundleCapability> capabilities = wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE);
+ LOG.debug("Interface {} found in bundle {} with exports {}", iClass.getName(), bundle.getSymbolicName(), capabilities);
+ if (capabilities != null) {
+ String iPackage = iClass.getPackage().getName();
+ LOG.debug("Looking for exported package: {}", iPackage);
+ for (BundleCapability cap : capabilities) {
+ String capPackage = (String)cap.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE);
+ if (iPackage.equals(capPackage)) {
+ Version version = (Version)cap.getAttributes().get(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE);
+ LOG.debug("found package {} version {}", iPackage, version);
+ if (version != null)
+ return version.toString();
}
}
- } finally {
- if (pa != null) {
- bc.ungetService(paRef);
- }
}
- } else {
- LOG.error("Was unable to obtain the package admin service -> can't resolve interface versions");
}
LOG.info("Unable to find interface version for interface {}. Falling back to 0.0.0", iClass.getName());
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
index de1953c4..9fd7d86d 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
@@ -71,19 +71,16 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
private ServiceListener exportedServiceListener;
private DistributionProvider provider;
private BundleContext apictx;
- private PackageUtil packageUtil;
private CloseHandler closeHandler;
public RemoteServiceAdminCore(BundleContext context,
BundleContext apiContext,
EventProducer eventProducer,
- DistributionProvider provider,
- PackageUtil packageUtil) {
+ DistributionProvider provider) {
this.bctx = context;
this.apictx = apiContext;
this.eventProducer = eventProducer;
this.provider = provider;
- this.packageUtil = packageUtil;
this.closeHandler = new CloseHandler() {
public void onClose(ExportRegistration exportReg) {
removeExportRegistration(exportReg);
@@ -682,7 +679,8 @@ public class RemoteServiceAdminCore implements RemoteServiceAdmin {
props.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, frameworkUUID);
for (Class<?> iface : ifaces) {
String pkg = iface.getPackage().getName();
- props.put(RemoteConstants.ENDPOINT_PACKAGE_VERSION_ + pkg, packageUtil.getVersion(iface));
+ String version = PackageUtil.getVersion(iface);
+ props.put(RemoteConstants.ENDPOINT_PACKAGE_VERSION_ + pkg, version);
}
return props;
}
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
index 45fe9a0b..aff96b8a 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
@@ -55,6 +55,9 @@ import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
+import org.osgi.framework.namespace.PackageNamespace;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleWiring;
import org.osgi.service.remoteserviceadmin.EndpointDescription;
import org.osgi.service.remoteserviceadmin.ExportReference;
import org.osgi.service.remoteserviceadmin.ExportRegistration;
@@ -80,24 +83,38 @@ public class RemoteServiceAdminCoreTest {
expect(rsaContext.getProperty(Constants.FRAMEWORK_UUID)).andReturn("some_uuid1").anyTimes();
expect(rsaContext.getBundle()).andReturn(b).anyTimes();
+
+ mockExportingBundle(c, "mybundle", String.class, "1.2.3");
+
apiContext = c.createMock(BundleContext.class);
provider = new DummyProvider();
- PackageUtil packageUtil = new PackageUtil(rsaContext) {
- @Override
- public String getVersion(Class<?> iClass) {
- return "1.0.0";
- }
- };
EventProducer eventProducer = new EventProducer(rsaContext) {
protected void notifyListeners(org.osgi.service.remoteserviceadmin.RemoteServiceAdminEvent rsae) {
// skip
}
};
- rsaCore = new RemoteServiceAdminCore(rsaContext, apiContext, eventProducer, provider, packageUtil) {
+ rsaCore = new RemoteServiceAdminCore(rsaContext, apiContext, eventProducer, provider) {
protected void createServiceListener() {}
};
}
+ private void mockExportingBundle(IMocksControl c, String symbolicName, Class<String> iClass, String version) {
+ Map<String, Object> capAttributes = new HashMap<>();
+ capAttributes.put(PackageNamespace.PACKAGE_NAMESPACE, iClass.getPackage().getName());
+ capAttributes.put(PackageNamespace.CAPABILITY_VERSION_ATTRIBUTE, new Version(version));
+
+ BundleCapability cap = c.createMock(BundleCapability.class);
+ expect(cap.getAttributes()).andStubReturn(capAttributes);
+
+ BundleWiring wiring = c.createMock(BundleWiring.class);
+ expect(wiring.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE)).andStubReturn(Arrays.asList(cap));
+
+ Bundle b = c.createMock(Bundle.class);
+ expect(b.getSymbolicName()).andStubReturn(symbolicName);
+ expect(b.adapt(BundleWiring.class)).andStubReturn(wiring);
+ PackageUtil.BUNDLE_FINDER = cls -> b;
+ }
+
@Test
public void testDontExportOwnServiceProxies() throws InvalidSyntaxException {
Map<String, Object> sProps = new HashMap<>();
@@ -318,7 +335,7 @@ public class RemoteServiceAdminCoreTest {
assertEquals("some_uuid1", props.get(RemoteConstants.ENDPOINT_FRAMEWORK_UUID));
assertEquals(Arrays.asList("java.lang.String"),
Arrays.asList((Object[]) props.get(org.osgi.framework.Constants.OBJECTCLASS)));
- assertEquals("1.0.0", props.get("endpoint.package.version.java.lang"));
+ assertEquals("1.2.3", props.get("endpoint.package.version.java.lang"));
c.verify();
}
(aries-rsa) 03/10: Replace deprecated karaf ShellTable class
Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit 55e66ce38dc949176a23769895674445b82519ec
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Mon Jun 3 08:24:58 2024 +0300
Replace deprecated karaf ShellTable class
---
discovery/command/pom.xml | 2 +-
.../java/org/apache/aries/rsa/discovery/command/EndpointsCommand.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/discovery/command/pom.xml b/discovery/command/pom.xml
index b7cb752e..925583f1 100644
--- a/discovery/command/pom.xml
+++ b/discovery/command/pom.xml
@@ -45,7 +45,7 @@
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.table</artifactId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
<version>4.4.6</version>
<scope>provided</scope>
</dependency>
diff --git a/discovery/command/src/main/java/org/apache/aries/rsa/discovery/command/EndpointsCommand.java b/discovery/command/src/main/java/org/apache/aries/rsa/discovery/command/EndpointsCommand.java
index 8df5aeae..031d0e84 100644
--- a/discovery/command/src/main/java/org/apache/aries/rsa/discovery/command/EndpointsCommand.java
+++ b/discovery/command/src/main/java/org/apache/aries/rsa/discovery/command/EndpointsCommand.java
@@ -22,7 +22,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-import org.apache.karaf.shell.table.ShellTable;
+import org.apache.karaf.shell.support.table.ShellTable;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Activate;
(aries-rsa) 10/10: Convert tabs to spaces
Posted by am...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
amichai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-rsa.git
commit 0b94606ef815d6a8ceea72fe39ef8cc8aa2261a0
Author: Amichai Rothman <am...@apache.org>
AuthorDate: Mon Jun 3 16:26:14 2024 +0300
Convert tabs to spaces
---
LICENSE | 36 +--
discovery/local/bnd.bnd | 2 +-
.../aries/rsa/discovery/local/LocalDiscovery.java | 8 +-
.../apache/aries/rsa/discovery/mdns/Interest.java | 134 ++++----
.../aries/rsa/discovery/mdns/InterestManager.java | 166 +++++-----
.../aries/rsa/discovery/mdns/MdnsDiscovery.java | 350 ++++++++++-----------
.../discovery/mdns/PublishingEndpointListener.java | 206 ++++++------
itests/tck/tck.bndrun | 34 +-
provider/tcp/bnd.bnd | 4 +-
9 files changed, 470 insertions(+), 470 deletions(-)
diff --git a/LICENSE b/LICENSE
index 2654c436..a00e56bb 100644
--- a/LICENSE
+++ b/LICENSE
@@ -202,24 +202,24 @@
limitations under the License.
- ======================================
- LICENSES FOR INCLUDED DEPENDENCIES
- ======================================
-
- All the source code for the Aries JPA project is released under the
- license above. Additionally, the Aries JPA binary distribution
- includes a number of third-party files that are required in
- order to the software to function. Unless noted below, these jars
- and resource files are also released under the ASF license above.
-
- The exceptions are as follows:
-
- ===========================
- persistence-xsd.rsrc - included in the org.apache.aries.jpa.container jar, taken from:
- http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd)
- persistence_2_0-xsd.rsrc - included in the org.apache.aries.jpa.container jar, taken from:
- http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd)
- ===========================
+ ======================================
+ LICENSES FOR INCLUDED DEPENDENCIES
+ ======================================
+
+ All the source code for the Aries JPA project is released under the
+ license above. Additionally, the Aries JPA binary distribution
+ includes a number of third-party files that are required in
+ order to the software to function. Unless noted below, these jars
+ and resource files are also released under the ASF license above.
+
+ The exceptions are as follows:
+
+ ===========================
+ persistence-xsd.rsrc - included in the org.apache.aries.jpa.container jar, taken from:
+ http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd)
+ persistence_2_0-xsd.rsrc - included in the org.apache.aries.jpa.container jar, taken from:
+ http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd)
+ ===========================
COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
diff --git a/discovery/local/bnd.bnd b/discovery/local/bnd.bnd
index 30698353..542135a3 100644
--- a/discovery/local/bnd.bnd
+++ b/discovery/local/bnd.bnd
@@ -16,4 +16,4 @@
# specific language governing permissions and limitations
# under the License.
Export-Package: \
- org.osgi.xmlns.rsa.v1_0;version=1.0.0
+ org.osgi.xmlns.rsa.v1_0;version=1.0.0
diff --git a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
index 5df81bd8..89cae9df 100644
--- a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
+++ b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
@@ -130,10 +130,10 @@ public class LocalDiscovery implements BundleListener {
void updatedListener(ServiceReference<EndpointEventListener> endpointListenerRef, EndpointEventListener endpointListener) {
// if service properties have been updated, the filter (scope)
// might have changed so we remove and re-add the listener
- // TODO fix this so that we don't:
- // 1. remove and add when there is no change
- // 2. remove and add instead of modifying
- // 3. remove instead of modified end match
+ // TODO fix this so that we don't:
+ // 1. remove and add when there is no change
+ // 2. remove and add instead of modifying
+ // 3. remove instead of modified end match
synchronized (listenerToFilters) {
unbindListener(endpointListener);
bindListener(endpointListenerRef, endpointListener);
diff --git a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java
index 530751d9..ef0c7953 100644
--- a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java
+++ b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/Interest.java
@@ -49,41 +49,41 @@ public class Interest {
public Interest(Long id, EndpointEventListener epListener, Map<String, Object> props) {
- this.id = id;
+ this.id = id;
this.scopes.set(StringPlus.normalize(props.get(ENDPOINT_LISTENER_SCOPE)));
this.epListener = epListener;
}
public void update(Map<String, Object> props) {
-
- List<String> newScopes = StringPlus.normalize(props.get(ENDPOINT_LISTENER_SCOPE));
- List<String> oldScopes = this.scopes.getAndSet(newScopes);
-
- added.values().removeIf(ed -> {
- Optional<String> newScope = getFirstMatch(ed, newScopes);
- Optional<String> oldScope = getFirstMatch(ed, oldScopes);
- EndpointEvent event;
- boolean remove;
- String filter;
- if(newScope.isPresent()) {
- remove = false;
- filter = newScope.get();
- if(oldScope.isPresent() && oldScope.get().equals(filter)) {
- event = null;
- } else {
- event = new EndpointEvent(MODIFIED, ed);
- }
- } else {
- remove = true;
- event = new EndpointEvent(REMOVED, ed);
- filter = oldScope.orElse(null);
- }
+
+ List<String> newScopes = StringPlus.normalize(props.get(ENDPOINT_LISTENER_SCOPE));
+ List<String> oldScopes = this.scopes.getAndSet(newScopes);
+
+ added.values().removeIf(ed -> {
+ Optional<String> newScope = getFirstMatch(ed, newScopes);
+ Optional<String> oldScope = getFirstMatch(ed, oldScopes);
+ EndpointEvent event;
+ boolean remove;
+ String filter;
+ if(newScope.isPresent()) {
+ remove = false;
+ filter = newScope.get();
+ if(oldScope.isPresent() && oldScope.get().equals(filter)) {
+ event = null;
+ } else {
+ event = new EndpointEvent(MODIFIED, ed);
+ }
+ } else {
+ remove = true;
+ event = new EndpointEvent(REMOVED, ed);
+ filter = oldScope.orElse(null);
+ }
- if (event != null)
- notifyListener(event, filter);
-
- return remove;
- });
+ if (event != null)
+ notifyListener(event, filter);
+
+ return remove;
+ });
}
public Object getEpListener() {
@@ -91,57 +91,57 @@ public class Interest {
}
public void endpointChanged(EndpointDescription ed) {
- List<String> scopes = this.scopes.get();
- Optional<String> currentScope = getFirstMatch(ed, scopes);
- boolean alreadyAdded = added.containsKey(ed.getId());
- EndpointEvent event;
- String filter;
+ List<String> scopes = this.scopes.get();
+ Optional<String> currentScope = getFirstMatch(ed, scopes);
+ boolean alreadyAdded = added.containsKey(ed.getId());
+ EndpointEvent event;
+ String filter;
if (currentScope.isPresent()) {
- if(LOG.isDebugEnabled()) {
- LOG.debug("Listener {} is interested in endpoint {}. It will be {}", id, ed, alreadyAdded ? "MODIFIED" : "ADDED");
- }
- added.put(ed.getId(), ed);
- event = new EndpointEvent(alreadyAdded ? MODIFIED : ADDED, ed);
- filter = currentScope.get();
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Listener {} is interested in endpoint {}. It will be {}", id, ed, alreadyAdded ? "MODIFIED" : "ADDED");
+ }
+ added.put(ed.getId(), ed);
+ event = new EndpointEvent(alreadyAdded ? MODIFIED : ADDED, ed);
+ filter = currentScope.get();
} else if(alreadyAdded) {
- if(LOG.isDebugEnabled()) {
- LOG.debug("Listener {} is no longer interested in endpoint {}. It will be {}", id, ed, "MODIFIED");
- }
- EndpointDescription previous = added.remove(ed.getId());
- event = new EndpointEvent(MODIFIED_ENDMATCH, ed);
- filter = getFirstMatch(previous, scopes).orElse(null);
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Listener {} is no longer interested in endpoint {}. It will be {}", id, ed, "MODIFIED");
+ }
+ EndpointDescription previous = added.remove(ed.getId());
+ event = new EndpointEvent(MODIFIED_ENDMATCH, ed);
+ filter = getFirstMatch(previous, scopes).orElse(null);
} else {
- if(LOG.isDebugEnabled()) {
- LOG.debug("Listener {} not interested in endpoint {}", id, ed);
- }
- return;
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Listener {} not interested in endpoint {}", id, ed);
+ }
+ return;
}
- notifyListener(event, filter);
+ notifyListener(event, filter);
}
- public void endpointRemoved(String id) {
- EndpointDescription previous = added.remove(id);
- if(previous != null) {
- if(LOG.isDebugEnabled()) {
- LOG.debug("Endpoint {} is no longer available for listener {}", id, this.id);
- }
- notifyListener(new EndpointEvent(REMOVED, previous), getFirstMatch(previous, scopes.get()).orElse(null));
- }
- }
+ public void endpointRemoved(String id) {
+ EndpointDescription previous = added.remove(id);
+ if(previous != null) {
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Endpoint {} is no longer available for listener {}", id, this.id);
+ }
+ notifyListener(new EndpointEvent(REMOVED, previous), getFirstMatch(previous, scopes.get()).orElse(null));
+ }
+ }
- private void notifyListener(EndpointEvent event, String filter) {
- EndpointDescription endpoint = event.getEndpoint();
- LOG.info("Calling endpointChanged on class {} for filter {}, type {}, endpoint {} ",
- epListener, filter, event.getType(), endpoint);
- epListener.endpointChanged(event, filter);
- }
+ private void notifyListener(EndpointEvent event, String filter) {
+ EndpointDescription endpoint = event.getEndpoint();
+ LOG.info("Calling endpointChanged on class {} for filter {}, type {}, endpoint {} ",
+ epListener, filter, event.getType(), endpoint);
+ epListener.endpointChanged(event, filter);
+ }
private Optional<String> getFirstMatch(EndpointDescription endpoint, List<String> scopes) {
return scopes.stream().filter(endpoint::matches).findFirst();
}
- @Override
+ @Override
public String toString() {
return "Interest [scopes=" + scopes + ", epListener=" + epListener.getClass() + "]";
}
diff --git a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/InterestManager.java b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/InterestManager.java
index 3ba9bf99..473416d0 100644
--- a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/InterestManager.java
+++ b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/InterestManager.java
@@ -64,90 +64,90 @@ public class InterestManager {
private final ConcurrentMap<String, SseEventSource> streams = new ConcurrentHashMap<>();
public InterestManager(SseEventSourceFactory factory, EndpointDescriptionParser parser, Client client) {
-
- this.eventSourceFactory = factory;
- this.parser = parser;
- this.client = client;
-
+
+ this.eventSourceFactory = factory;
+ this.parser = parser;
+ this.client = client;
+
}
public void deactivate() {
- streams.values().forEach(SseEventSource::close);
- streams.clear();
-
+ streams.values().forEach(SseEventSource::close);
+ streams.clear();
+
interests.clear();
}
public void remoteAdded(String uri) {
- if(streams.containsKey(uri)) {
- return;
- }
-
- if(LOG.isInfoEnabled()) {
- LOG.info("Discovered a remote at {}", uri);
- }
-
- SseEventSource sse = eventSourceFactory.newBuilder(client.target(uri)).build();
- sse.register(i -> onEndpointEvent(uri, i), t -> lostRemoteStream(uri, t), () -> lostRemoteStream(uri, null));
- streams.put(uri, sse);
- sse.open();
+ if(streams.containsKey(uri)) {
+ return;
+ }
+
+ if(LOG.isInfoEnabled()) {
+ LOG.info("Discovered a remote at {}", uri);
+ }
+
+ SseEventSource sse = eventSourceFactory.newBuilder(client.target(uri)).build();
+ sse.register(i -> onEndpointEvent(uri, i), t -> lostRemoteStream(uri, t), () -> lostRemoteStream(uri, null));
+ streams.put(uri, sse);
+ sse.open();
}
public void remoteRemoved(String uri) {
- if(LOG.isInfoEnabled()) {
- LOG.info("Remote at {} is no longer present", uri);
- }
-
- SseEventSource sseEventSource = streams.remove(uri);
- if(sseEventSource != null) {
- sseEventSource.close();
- }
+ if(LOG.isInfoEnabled()) {
+ LOG.info("Remote at {} is no longer present", uri);
+ }
+
+ SseEventSource sseEventSource = streams.remove(uri);
+ if(sseEventSource != null) {
+ sseEventSource.close();
+ }
}
private void onEndpointEvent(String source, InboundSseEvent event) {
- String name = event.getName();
-
- if(LOG.isDebugEnabled()) {
- LOG.debug("Received a {} notification from {}", name, source);
- }
-
- if(ENDPOINT_UPDATED.equals(name)) {
- EndpointDescription ed = parser.readEndpoint(event.readData(InputStream.class));
- endpointsBySource.compute(source, (a,b) -> {
- return b == null ? singleton(ed) : concat(b.stream(), Stream.of(ed)).collect(toSet());
- });
- interests.values().forEach(i -> i.endpointChanged(ed));
- } else if (ENDPOINT_REVOKED.equals(name)) {
- String id = event.readData();
- endpointsBySource.compute(source, (a,b) -> {
- if(b == null) {
- return null;
- } else {
- Set<EndpointDescription> set = b.stream().filter(ed -> !ed.getId().equals(id)).collect(toSet());
- return set.isEmpty() ? null : set;
- }
- });
- interests.values().forEach(i -> i.endpointRemoved(id));
- }
+ String name = event.getName();
+
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("Received a {} notification from {}", name, source);
+ }
+
+ if(ENDPOINT_UPDATED.equals(name)) {
+ EndpointDescription ed = parser.readEndpoint(event.readData(InputStream.class));
+ endpointsBySource.compute(source, (a,b) -> {
+ return b == null ? singleton(ed) : concat(b.stream(), Stream.of(ed)).collect(toSet());
+ });
+ interests.values().forEach(i -> i.endpointChanged(ed));
+ } else if (ENDPOINT_REVOKED.equals(name)) {
+ String id = event.readData();
+ endpointsBySource.compute(source, (a,b) -> {
+ if(b == null) {
+ return null;
+ } else {
+ Set<EndpointDescription> set = b.stream().filter(ed -> !ed.getId().equals(id)).collect(toSet());
+ return set.isEmpty() ? null : set;
+ }
+ });
+ interests.values().forEach(i -> i.endpointRemoved(id));
+ }
}
private void lostRemoteStream(String source, Throwable t) {
-
- if(t != null) {
- if(LOG.isWarnEnabled()) {
- LOG.warn("The remote {} had a failure", source, t);
- }
- } else {
- if(LOG.isInfoEnabled()) {
- LOG.info("The remote {} has disconnected", source);
- }
- }
-
- Set<EndpointDescription> remove = endpointsBySource.remove(source);
- if(remove != null) {
- remove.forEach(ed -> interests.values().forEach(i -> i.endpointRemoved(ed.getId())));
- }
+
+ if(t != null) {
+ if(LOG.isWarnEnabled()) {
+ LOG.warn("The remote {} had a failure", source, t);
+ }
+ } else {
+ if(LOG.isInfoEnabled()) {
+ LOG.info("The remote {} has disconnected", source);
+ }
+ }
+
+ Set<EndpointDescription> remove = endpointsBySource.remove(source);
+ if(remove != null) {
+ remove.forEach(ed -> interests.values().forEach(i -> i.endpointRemoved(ed.getId())));
+ }
}
public void bindEndpointEventListener(EndpointEventListener epListener, Map<String, Object> props) {
@@ -162,18 +162,18 @@ public class InterestManager {
interests.remove(getServiceId(props));
}
- private Long getServiceId(Map<String, Object> props) {
- return (Long) props.get("service.id");
- }
+ private Long getServiceId(Map<String, Object> props) {
+ return (Long) props.get("service.id");
+ }
private void addInterest(EndpointEventListener epListener, Map<String, Object> props) {
-
- Long id = getServiceId(props);
-
- if(LOG.isInfoEnabled()) {
- LOG.info("Service {} has registered an interest in endpoint events", id);
- }
-
+
+ Long id = getServiceId(props);
+
+ if(LOG.isInfoEnabled()) {
+ LOG.info("Service {} has registered an interest in endpoint events", id);
+ }
+
Interest interest = new Interest(getServiceId(props), epListener, props);
interests.put(getServiceId(props), interest);
@@ -183,13 +183,13 @@ public class InterestManager {
}
private void updatedInterest(Map<String, Object> props) {
-
+
Long id = getServiceId(props);
-
- if(LOG.isInfoEnabled()) {
- LOG.info("Service {} has changed its interest in endpoint events", id);
- }
-
+
+ if(LOG.isInfoEnabled()) {
+ LOG.info("Service {} has changed its interest in endpoint events", id);
+ }
+
interests.get(id).update(props);
}
}
diff --git a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/MdnsDiscovery.java b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/MdnsDiscovery.java
index 441fe7b2..c6034635 100644
--- a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/MdnsDiscovery.java
+++ b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/MdnsDiscovery.java
@@ -59,31 +59,31 @@ import org.slf4j.LoggerFactory;
@Component
public class MdnsDiscovery {
- private static final String _ARIES_DISCOVERY_HTTP_TCP_LOCAL = "_aries-discovery._tcp.local.";
+ private static final String _ARIES_DISCOVERY_HTTP_TCP_LOCAL = "_aries-discovery._tcp.local.";
- private static final Logger LOG = LoggerFactory.getLogger(MdnsDiscovery.class);
-
- private final Client client;
-
- private final String fwUuid;
-
- private final InterestManager interestManager;
-
- private final PublishingEndpointListener publishingListener;
-
- private JaxrsServiceRuntime runtime;
-
- private JmDNS jmdns;
+ private static final Logger LOG = LoggerFactory.getLogger(MdnsDiscovery.class);
+
+ private final Client client;
+
+ private final String fwUuid;
+
+ private final InterestManager interestManager;
+
+ private final PublishingEndpointListener publishingListener;
+
+ private JaxrsServiceRuntime runtime;
+
+ private JmDNS jmdns;
- @Activate
- public MdnsDiscovery(BundleContext ctx, @Reference SseEventSourceFactory eventSourceFactory,
- @Reference ClientBuilder clientBuilder, @Reference EndpointDescriptionParser parser) {
- this.client = clientBuilder.build();
- this.interestManager = new InterestManager(eventSourceFactory, parser, client);
- fwUuid = ctx.getProperty(FRAMEWORK_UUID);
- this.publishingListener = new PublishingEndpointListener(parser, ctx, fwUuid);
- }
+ @Activate
+ public MdnsDiscovery(BundleContext ctx, @Reference SseEventSourceFactory eventSourceFactory,
+ @Reference ClientBuilder clientBuilder, @Reference EndpointDescriptionParser parser) {
+ this.client = clientBuilder.build();
+ this.interestManager = new InterestManager(eventSourceFactory, parser, client);
+ fwUuid = ctx.getProperty(FRAMEWORK_UUID);
+ this.publishingListener = new PublishingEndpointListener(parser, ctx, fwUuid);
+ }
@Reference(cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC)
public void bindEndpointEventListener(EndpointEventListener epListener, Map<String, Object> props) {
@@ -100,174 +100,174 @@ public class MdnsDiscovery {
@Reference(policy = ReferencePolicy.DYNAMIC)
public void bindJaxrsServiceRuntime(JaxrsServiceRuntime runtime) {
- updateAndRegister(runtime);
+ updateAndRegister(runtime);
}
- public void updatedJaxrsServiceRuntime(JaxrsServiceRuntime runtime) {
- updateAndRegister(runtime);
- }
+ public void updatedJaxrsServiceRuntime(JaxrsServiceRuntime runtime) {
+ updateAndRegister(runtime);
+ }
- public void unbindJaxrsServiceRuntime(JaxrsServiceRuntime runtime) {
- JmDNS jmdns = null;
- synchronized (this) {
- if(runtime == this.runtime) {
- jmdns = this.jmdns;
- this.runtime = null;
- }
- }
-
- if(jmdns != null) {
- jmdns.unregisterAllServices();
- }
- }
+ public void unbindJaxrsServiceRuntime(JaxrsServiceRuntime runtime) {
+ JmDNS jmdns = null;
+ synchronized (this) {
+ if(runtime == this.runtime) {
+ jmdns = this.jmdns;
+ this.runtime = null;
+ }
+ }
+
+ if(jmdns != null) {
+ jmdns.unregisterAllServices();
+ }
+ }
- private void updateAndRegister(JaxrsServiceRuntime runtime) {
- JmDNS jmdns;
- synchronized (this) {
- this.runtime = runtime;
- jmdns = this.jmdns;
- }
-
- if(jmdns != null) {
- RuntimeDTO runtimeDTO = runtime.getRuntimeDTO();
- List<String> uris = StringPlus.normalize(runtimeDTO.serviceDTO.properties.get(JAX_RS_SERVICE_ENDPOINT));
-
- if(uris == null || uris.isEmpty()) {
- LOG.warn("Unable to advertise discovery as there are no endpoint URIs");
- return;
- }
-
- String base = runtimeDTO.defaultApplication.base;
- if(base == null) {
- base = "";
- }
-
- base += "/aries/rsa/discovery";
-
- URI uri = uris.stream()
- .filter(s -> s.matches(".*(?:[0-9]{1,3}\\.){3}[0-9]{1,3}.*"))
- .findFirst()
- .map(URI::create)
- .orElseGet(() -> URI.create(uris.get(0)));
-
- Map<String, Object> props = new HashMap<>();
- props.put("scheme", uri.getScheme() == null ? "" : uri.getScheme());
- props.put("path", uri.getPath() == null ? base : uri.getPath() + base);
- props.put("frameworkUuid", fwUuid);
-
- ServiceInfo info = ServiceInfo.create(_ARIES_DISCOVERY_HTTP_TCP_LOCAL, fwUuid, uri.getPort(), 0, 0, props);
-
- try {
- jmdns.registerService(info);
- } catch (IOException ioe) {
- LOG.error("Unable to advertise discovery", ioe);
- }
- }
- }
+ private void updateAndRegister(JaxrsServiceRuntime runtime) {
+ JmDNS jmdns;
+ synchronized (this) {
+ this.runtime = runtime;
+ jmdns = this.jmdns;
+ }
+
+ if(jmdns != null) {
+ RuntimeDTO runtimeDTO = runtime.getRuntimeDTO();
+ List<String> uris = StringPlus.normalize(runtimeDTO.serviceDTO.properties.get(JAX_RS_SERVICE_ENDPOINT));
+
+ if(uris == null || uris.isEmpty()) {
+ LOG.warn("Unable to advertise discovery as there are no endpoint URIs");
+ return;
+ }
+
+ String base = runtimeDTO.defaultApplication.base;
+ if(base == null) {
+ base = "";
+ }
+
+ base += "/aries/rsa/discovery";
+
+ URI uri = uris.stream()
+ .filter(s -> s.matches(".*(?:[0-9]{1,3}\\.){3}[0-9]{1,3}.*"))
+ .findFirst()
+ .map(URI::create)
+ .orElseGet(() -> URI.create(uris.get(0)));
+
+ Map<String, Object> props = new HashMap<>();
+ props.put("scheme", uri.getScheme() == null ? "" : uri.getScheme());
+ props.put("path", uri.getPath() == null ? base : uri.getPath() + base);
+ props.put("frameworkUuid", fwUuid);
+
+ ServiceInfo info = ServiceInfo.create(_ARIES_DISCOVERY_HTTP_TCP_LOCAL, fwUuid, uri.getPort(), 0, 0, props);
+
+ try {
+ jmdns.registerService(info);
+ } catch (IOException ioe) {
+ LOG.error("Unable to advertise discovery", ioe);
+ }
+ }
+ }
public static @interface Config {
- public String bind_address();
+ public String bind_address();
}
@Activate
public void start(Config config) throws UnknownHostException, IOException {
- String bind = config.bind_address();
-
- JmDNS jmdns = JmDNS.create(bind == null ? null : InetAddress.getByName(bind));
-
- JaxrsServiceRuntime runtime;
- synchronized (this) {
- this.jmdns = jmdns;
- runtime = this.runtime;
- }
-
- if(runtime != null) {
- updateAndRegister(runtime);
- }
-
- // Add a service listener
- jmdns.addServiceListener(_ARIES_DISCOVERY_HTTP_TCP_LOCAL, new MdnsListener());
-
+ String bind = config.bind_address();
+
+ JmDNS jmdns = JmDNS.create(bind == null ? null : InetAddress.getByName(bind));
+
+ JaxrsServiceRuntime runtime;
+ synchronized (this) {
+ this.jmdns = jmdns;
+ runtime = this.runtime;
+ }
+
+ if(runtime != null) {
+ updateAndRegister(runtime);
+ }
+
+ // Add a service listener
+ jmdns.addServiceListener(_ARIES_DISCOVERY_HTTP_TCP_LOCAL, new MdnsListener());
+
}
@Deactivate
public void stop () {
- try {
- jmdns.close();
- } catch (IOException e) {
- LOG.warn("An exception occurred closing the mdns discovery");
- }
-
- interestManager.deactivate();
- publishingListener.stop();
+ try {
+ jmdns.close();
+ } catch (IOException e) {
+ LOG.warn("An exception occurred closing the mdns discovery");
+ }
+
+ interestManager.deactivate();
+ publishingListener.stop();
}
- private class MdnsListener implements ServiceListener {
-
- private final ConcurrentMap<String, String> namesToUris = new ConcurrentHashMap<>();
-
- @Override
- public void serviceAdded(ServiceEvent event) {
- }
-
- @Override
- public void serviceRemoved(ServiceEvent event) {
- ServiceInfo info = event.getInfo();
- if(info != null) {
- String removed = namesToUris.remove(info.getKey());
- if(removed != null) {
- interestManager.remoteRemoved(removed);
- }
- }
- }
-
- @Override
- public void serviceResolved(ServiceEvent event) {
- ServiceInfo info = event.getInfo();
-
- String infoUuid = info.getPropertyString("frameworkUuid");
-
- if(infoUuid == null || infoUuid.equals(fwUuid)) {
- // Ignore until we can see if this is for our own endpoint
- return;
- }
-
- String scheme = info.getPropertyString("scheme");
- if(scheme == null) {
- scheme = "http";
- }
-
- String path = info.getPropertyString("path");
- if(path == null) {
- // Not a complete record yet
- return;
- }
-
- int port = info.getPort();
- if(port == -1) {
- switch(scheme) {
- case "http":
- port = 80;
- break;
- case "https":
- port = 443;
- break;
- default:
- LOG.error("Unknown URI scheme advertised {} by framework {} on host {}",
- scheme, info.getName(), info.getDomain());
- }
- }
-
- String address = info.getInetAddresses()[0].getHostAddress();
-
- String uri = String.format("%s://%s:%d/%s", scheme, address, port, path);
-
- LOG.info("Discovered remote at {}", uri);
-
- namesToUris.put(info.getKey(), uri);
-
- interestManager.remoteAdded(uri);
- }
- }
+ private class MdnsListener implements ServiceListener {
+
+ private final ConcurrentMap<String, String> namesToUris = new ConcurrentHashMap<>();
+
+ @Override
+ public void serviceAdded(ServiceEvent event) {
+ }
+
+ @Override
+ public void serviceRemoved(ServiceEvent event) {
+ ServiceInfo info = event.getInfo();
+ if(info != null) {
+ String removed = namesToUris.remove(info.getKey());
+ if(removed != null) {
+ interestManager.remoteRemoved(removed);
+ }
+ }
+ }
+
+ @Override
+ public void serviceResolved(ServiceEvent event) {
+ ServiceInfo info = event.getInfo();
+
+ String infoUuid = info.getPropertyString("frameworkUuid");
+
+ if(infoUuid == null || infoUuid.equals(fwUuid)) {
+ // Ignore until we can see if this is for our own endpoint
+ return;
+ }
+
+ String scheme = info.getPropertyString("scheme");
+ if(scheme == null) {
+ scheme = "http";
+ }
+
+ String path = info.getPropertyString("path");
+ if(path == null) {
+ // Not a complete record yet
+ return;
+ }
+
+ int port = info.getPort();
+ if(port == -1) {
+ switch(scheme) {
+ case "http":
+ port = 80;
+ break;
+ case "https":
+ port = 443;
+ break;
+ default:
+ LOG.error("Unknown URI scheme advertised {} by framework {} on host {}",
+ scheme, info.getName(), info.getDomain());
+ }
+ }
+
+ String address = info.getInetAddresses()[0].getHostAddress();
+
+ String uri = String.format("%s://%s:%d/%s", scheme, address, port, path);
+
+ LOG.info("Discovered remote at {}", uri);
+
+ namesToUris.put(info.getKey(), uri);
+
+ interestManager.remoteAdded(uri);
+ }
+ }
}
diff --git a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/PublishingEndpointListener.java b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/PublishingEndpointListener.java
index 46872fc0..d78a5824 100644
--- a/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/PublishingEndpointListener.java
+++ b/discovery/mdns/src/main/java/org/apache/aries/rsa/discovery/mdns/PublishingEndpointListener.java
@@ -76,14 +76,14 @@ public class PublishingEndpointListener {
private final Set<Subscription> listeners = ConcurrentHashMap.newKeySet();
@SuppressWarnings("serial")
- public PublishingEndpointListener(EndpointDescriptionParser parser, BundleContext bctx, String uuid) {
+ public PublishingEndpointListener(EndpointDescriptionParser parser, BundleContext bctx, String uuid) {
this.parser = parser;
- this.uuid = uuid;
+ this.uuid = uuid;
String[] ifAr = { EndpointEventListener.class.getName() };
Dictionary<String, Object> props = serviceProperties(uuid);
listenerReg = bctx.registerService(ifAr, new ListenerFactory(), props);
resourceReg = bctx.registerService(PublishingEndpointListener.class, this,
- new Hashtable<String, Object>() {{put("osgi.jaxrs.resource", Boolean.TRUE);}});
+ new Hashtable<String, Object>() {{put("osgi.jaxrs.resource", Boolean.TRUE);}});
}
@Deactivate
@@ -94,41 +94,41 @@ public class PublishingEndpointListener {
}
private void endpointUpdate(Long bundleId, EndpointDescription ed, int type) {
- String edFwUuid = ed.getFrameworkUUID();
- if(edFwUuid == null || !edFwUuid.equals(uuid)) {
- LOG.warn("This listener has been called with an endpoint {} for a remote framework {}", ed.getId(), edFwUuid);
- return;
- }
- String id = ed.getId();
- switch(type) {
- case EndpointEvent.ADDED:
- case EndpointEvent.MODIFIED:
- localEndpoints.compute(id, (k,v) -> {
- return v == null ? new SponsoredEndpoint(ed, singleton(bundleId)) :
- new SponsoredEndpoint(ed, concat(v.sponsors.stream(), Stream.of(bundleId)).collect(toSet()));
- });
- String data = toEndpointData(ed);
- listeners.forEach(s -> s.update(data));
- break;
- case EndpointEvent.MODIFIED_ENDMATCH:
- case EndpointEvent.REMOVED:
- boolean act = localEndpoints.compute(id, (k,v) -> {
- if(v == null) {
- return null;
- } else {
- Set<Long> updated = v.sponsors.stream().filter(l -> !bundleId.equals(l)).collect(toSet());
- return updated.isEmpty() ? null : new SponsoredEndpoint(v.ed, updated);
- }
- }) == null;
-
- if(act) {
- listeners.forEach(s -> s.revoke(id));
- }
- break;
- default:
- LOG.error("Unknown event type {} for endpoint {}", type, ed);
- }
- }
+ String edFwUuid = ed.getFrameworkUUID();
+ if(edFwUuid == null || !edFwUuid.equals(uuid)) {
+ LOG.warn("This listener has been called with an endpoint {} for a remote framework {}", ed.getId(), edFwUuid);
+ return;
+ }
+ String id = ed.getId();
+ switch(type) {
+ case EndpointEvent.ADDED:
+ case EndpointEvent.MODIFIED:
+ localEndpoints.compute(id, (k,v) -> {
+ return v == null ? new SponsoredEndpoint(ed, singleton(bundleId)) :
+ new SponsoredEndpoint(ed, concat(v.sponsors.stream(), Stream.of(bundleId)).collect(toSet()));
+ });
+ String data = toEndpointData(ed);
+ listeners.forEach(s -> s.update(data));
+ break;
+ case EndpointEvent.MODIFIED_ENDMATCH:
+ case EndpointEvent.REMOVED:
+ boolean act = localEndpoints.compute(id, (k,v) -> {
+ if(v == null) {
+ return null;
+ } else {
+ Set<Long> updated = v.sponsors.stream().filter(l -> !bundleId.equals(l)).collect(toSet());
+ return updated.isEmpty() ? null : new SponsoredEndpoint(v.ed, updated);
+ }
+ }) == null;
+
+ if(act) {
+ listeners.forEach(s -> s.revoke(id));
+ }
+ break;
+ default:
+ LOG.error("Unknown event type {} for endpoint {}", type, ed);
+ }
+ }
private Dictionary<String, Object> serviceProperties(String uuid) {
String scope = String.format("(&(%s=*)(%s=%s))", Constants.OBJECTCLASS,
@@ -139,60 +139,60 @@ public class PublishingEndpointListener {
}
private String toEndpointData(EndpointDescription ed) {
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- parser.writeEndpoint(ed, baos);
- return new String(baos.toByteArray(), StandardCharsets.UTF_8).replace("\n", "").replace("\r", "");
- } catch (Exception e) {
- LOG.error("Unable to serialize the endpoint {}", ed, e);
- throw new RuntimeException(e);
- }
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ parser.writeEndpoint(ed, baos);
+ return new String(baos.toByteArray(), StandardCharsets.UTF_8).replace("\n", "").replace("\r", "");
+ } catch (Exception e) {
+ LOG.error("Unable to serialize the endpoint {}", ed, e);
+ throw new RuntimeException(e);
+ }
}
@GET
- @Produces(SERVER_SENT_EVENTS)
- @Path("aries/rsa/discovery")
- public void listen(@Context Sse sse, @Context SseEventSink sink) {
- Subscription subscription = new Subscription(sse, sink);
- listeners.add(subscription);
-
- localEndpoints.values().stream()
- .map(s -> toEndpointData(s.ed))
- .forEach(subscription::update);
- }
-
- private class ListenerFactory implements ServiceFactory<PerClientEndpointEventListener> {
-
- @Override
- public PerClientEndpointEventListener getService(Bundle bundle,
- ServiceRegistration<PerClientEndpointEventListener> registration) {
- return new PerClientEndpointEventListener(bundle.getBundleId());
- }
-
- @Override
- public void ungetService(Bundle bundle, ServiceRegistration<PerClientEndpointEventListener> registration,
- PerClientEndpointEventListener service) {
- Long bundleId = service.bundleId;
- localEndpoints.values().stream()
- .filter(s -> s.sponsors.contains(bundleId))
- .forEach(s -> endpointUpdate(bundleId, s.ed, EndpointEvent.REMOVED));
- }
-
+ @Produces(SERVER_SENT_EVENTS)
+ @Path("aries/rsa/discovery")
+ public void listen(@Context Sse sse, @Context SseEventSink sink) {
+ Subscription subscription = new Subscription(sse, sink);
+ listeners.add(subscription);
+
+ localEndpoints.values().stream()
+ .map(s -> toEndpointData(s.ed))
+ .forEach(subscription::update);
+ }
+
+ private class ListenerFactory implements ServiceFactory<PerClientEndpointEventListener> {
+
+ @Override
+ public PerClientEndpointEventListener getService(Bundle bundle,
+ ServiceRegistration<PerClientEndpointEventListener> registration) {
+ return new PerClientEndpointEventListener(bundle.getBundleId());
+ }
+
+ @Override
+ public void ungetService(Bundle bundle, ServiceRegistration<PerClientEndpointEventListener> registration,
+ PerClientEndpointEventListener service) {
+ Long bundleId = service.bundleId;
+ localEndpoints.values().stream()
+ .filter(s -> s.sponsors.contains(bundleId))
+ .forEach(s -> endpointUpdate(bundleId, s.ed, EndpointEvent.REMOVED));
+ }
+
}
private class PerClientEndpointEventListener implements EndpointEventListener {
-
- private final Long bundleId;
-
- public PerClientEndpointEventListener(Long bundleId) {
- super();
- this.bundleId = bundleId;
- }
-
- @Override
- public void endpointChanged(EndpointEvent event, String filter) {
- endpointUpdate(bundleId, event.getEndpoint(), event.getType());
- }
+
+ private final Long bundleId;
+
+ public PerClientEndpointEventListener(Long bundleId) {
+ super();
+ this.bundleId = bundleId;
+ }
+
+ @Override
+ public void endpointChanged(EndpointEvent event, String filter) {
+ endpointUpdate(bundleId, event.getEndpoint(), event.getType());
+ }
}
class Subscription {
@@ -204,11 +204,11 @@ public class PublishingEndpointListener {
SseEventSink eventSink;
public Subscription(Sse sse, SseEventSink eventSink) {
- this.sse = sse;
- this.eventSink = eventSink;
- }
+ this.sse = sse;
+ this.eventSink = eventSink;
+ }
- public void update(String endpointData) {
+ public void update(String endpointData) {
eventSink.send(sse.newEvent(ENDPOINT_UPDATED, endpointData))
.whenComplete(this::sendFailure);
}
@@ -219,27 +219,27 @@ public class PublishingEndpointListener {
}
public void close() {
- eventSink.close();
- listeners.remove(this);
+ eventSink.close();
+ listeners.remove(this);
}
private void sendFailure(Object o, Throwable t) {
if(t != null) {
- LOG.error("Failed to send endpoint message, closing");
- listeners.remove(this);
- eventSink.close();
+ LOG.error("Failed to send endpoint message, closing");
+ listeners.remove(this);
+ eventSink.close();
}
}
}
private static class SponsoredEndpoint {
- private final EndpointDescription ed;
- private final Set<Long> sponsors;
-
- public SponsoredEndpoint(EndpointDescription ed, Set<Long> sponsors) {
- super();
- this.ed = ed;
- this.sponsors = sponsors;
- }
+ private final EndpointDescription ed;
+ private final Set<Long> sponsors;
+
+ public SponsoredEndpoint(EndpointDescription ed, Set<Long> sponsors) {
+ super();
+ this.ed = ed;
+ this.sponsors = sponsors;
+ }
}
}
diff --git a/itests/tck/tck.bndrun b/itests/tck/tck.bndrun
index 31b1e752..a41b4ca7 100644
--- a/itests/tck/tck.bndrun
+++ b/itests/tck/tck.bndrun
@@ -40,22 +40,22 @@
-runfw: org.eclipse.osgi;version='[3.8.0.v20120529-1548,3.8.0.v20120529-1548]'
-runee: JavaSE-1.8
-runrequires: \
- osgi.identity;filter:='(osgi.identity=org.osgi.test.cases.remoteserviceadmin)',\
- osgi.identity;filter:='(osgi.identity=org.apache.aries.rsa.topology-manager)',\
- osgi.identity;filter:='(osgi.identity=org.ops4j.pax.logging.pax-logging-service)'
-
+ osgi.identity;filter:='(osgi.identity=org.osgi.test.cases.remoteserviceadmin)',\
+ osgi.identity;filter:='(osgi.identity=org.apache.aries.rsa.topology-manager)',\
+ osgi.identity;filter:='(osgi.identity=org.ops4j.pax.logging.pax-logging-service)'
+
-runblacklist: \
- osgi.identity;filter:='(osgi.identity=osgi.cmpn)',\
- osgi.identity;filter:='(osgi.identity=slf4j.api)'
+ osgi.identity;filter:='(osgi.identity=osgi.cmpn)',\
+ osgi.identity;filter:='(osgi.identity=slf4j.api)'
-runbundles: \
- org.apache.aries.rsa.core;version='[1.10.0,1.10.1)',\
- org.apache.aries.rsa.discovery.config;version='[1.10.0,1.10.1)',\
- org.apache.aries.rsa.provider.tcp;version='[1.10.0,1.10.1)',\
- org.apache.aries.rsa.spi;version='[1.10.0,1.10.1)',\
- org.apache.aries.rsa.topology-manager;version='[1.10.0,1.10.1)',\
- org.apache.felix.configadmin;version='[1.9.26,1.9.27)',\
- org.apache.felix.eventadmin;version='[1.6.4,1.6.5)',\
- org.apache.servicemix.bundles.junit;version='[3.8.2,3.8.3)',\
- org.osgi.test.cases.remoteserviceadmin;version='[5.0.0,5.0.1)',\
- org.ops4j.pax.logging.pax-logging-api;version='[1.11.2,1.11.3)',\
- org.ops4j.pax.logging.pax-logging-service;version='[1.11.2,1.11.3)'
+ org.apache.aries.rsa.core;version='[1.10.0,1.10.1)',\
+ org.apache.aries.rsa.discovery.config;version='[1.10.0,1.10.1)',\
+ org.apache.aries.rsa.provider.tcp;version='[1.10.0,1.10.1)',\
+ org.apache.aries.rsa.spi;version='[1.10.0,1.10.1)',\
+ org.apache.aries.rsa.topology-manager;version='[1.10.0,1.10.1)',\
+ org.apache.felix.configadmin;version='[1.9.26,1.9.27)',\
+ org.apache.felix.eventadmin;version='[1.6.4,1.6.5)',\
+ org.apache.servicemix.bundles.junit;version='[3.8.2,3.8.3)',\
+ org.osgi.test.cases.remoteserviceadmin;version='[5.0.0,5.0.1)',\
+ org.ops4j.pax.logging.pax-logging-api;version='[1.11.2,1.11.3)',\
+ org.ops4j.pax.logging.pax-logging-service;version='[1.11.2,1.11.3)'
diff --git a/provider/tcp/bnd.bnd b/provider/tcp/bnd.bnd
index d07bc353..5fb3a1c9 100644
--- a/provider/tcp/bnd.bnd
+++ b/provider/tcp/bnd.bnd
@@ -16,5 +16,5 @@
# specific language governing permissions and limitations
# under the License.
Private-Package: \
- org.apache.aries.rsa.util,\
- org.osgi.util.converter
+ org.apache.aries.rsa.util,\
+ org.osgi.util.converter