- if(entityListenerMap.put(entity, listener)) {
- ListenerActorRefEntry listenerEntry = listenerActorMap.get(listener);
- if(listenerEntry == null) {
- listenerActorMap.put(listener, new ListenerActorRefEntry());
- } else {
- listenerEntry.referenceCount++;
+ /**
+ * Set the in-jeopardy flag and indicate its previous state.
+ *
+ * @param inJeopardy new value of the in-jeopardy flag
+ * @return Previous value of the flag.
+ */
+ @SuppressWarnings("checkstyle:hiddenField")
+ boolean setInJeopardy(final boolean inJeopardy) {
+ final boolean wasInJeopardy = this.inJeopardy;
+ this.inJeopardy = inJeopardy;
+ return wasInJeopardy;
+ }
+
+ void addEntityOwnershipListener(final String entityType, final DOMEntityOwnershipListener listener) {
+ LOG.debug("{}: Adding EntityOwnershipListener {} for entity type {}", logId, listener, entityType);
+
+ listenerLock.writeLock().lock();
+ try {
+ if (entityTypeListenerMap.put(entityType, listener)) {
+ ListenerActorRefEntry listenerEntry = listenerActorMap.get(listener);
+ if (listenerEntry == null) {
+ listenerActorMap.put(listener, new ListenerActorRefEntry(listener));
+ } else {
+ listenerEntry.referenceCount++;
+ }