amichair commented on code in PR #98:
URL: https://github.com/apache/aries-rsa/pull/98#discussion_r3199333964
##########
rsa/src/main/java/org/apache/aries/rsa/core/ExportRegistrationImpl.java:
##########
@@ -35,167 +38,214 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Implements an ExportRegistration. Since there is a 1:1 relationship between
+ * an ExportRegistration and its ExportReference (they are basically two views
+ * of the same underlying data - one is the modifiable part and one the
read-only
+ * part), this class implements both interfaces together.
+ */
@SuppressWarnings("rawtypes")
-public class ExportRegistrationImpl implements ExportRegistration {
+public class ExportRegistrationImpl implements ExportRegistration,
ExportReference {
private static final Logger LOG =
LoggerFactory.getLogger(ExportRegistrationImpl.class);
- private final CloseHandler closeHandler;
- private ExportReferenceImpl exportReference;
- private final Closeable server;
- private final Throwable exception;
+ /**
+ * According to the specs, multiple ExportRegistration can be linked
together,
+ * i.e. they have a shared state - this is implemented via this inner
class,
+ * where every group of linked export registrations reference a single
Shared instance.
+ */
+ private static class Shared {
- private final ExportRegistrationImpl parent;
- private int instanceCount;
- private volatile boolean closed;
+ private Set<CloseHandler> closeHandlers =
Collections.newSetFromMap(new ConcurrentHashMap<>());
+ private EventProducer eventProducer;
+ private ServiceReference serviceReference;
+ private volatile EndpointDescription endpoint;
+ private Closeable server;
+ private Throwable exception;
- private final EventProducer sender;
-
- private ExportRegistrationImpl(ExportRegistrationImpl parent,
- CloseHandler rsaCore,
- EventProducer sender,
- ExportReferenceImpl exportReference,
- Closeable server,
- Throwable exception) {
- this.sender = sender;
- this.parent = parent != null ? parent.parent : this; // a parent
points to itself
- this.parent.addInstance();
- this.closeHandler = rsaCore;
- this.exportReference = exportReference;
- this.server = server;
- this.exception = exception;
- }
+ private int instanceCount;
+
+ void add(CloseHandler closeHandler) {
+ if (closeHandler != null) {
+ closeHandlers.add(closeHandler);
+ }
+ }
+
+ void add() {
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]