Skip to content

Commit

Permalink
refs #583410 - coma bean factory missed to call listeners at least once
Browse files Browse the repository at this point in the history
  • Loading branch information
mgoellnitz committed Mar 3, 2017
1 parent e420aac commit 6bae00b
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions coma/src/org/tangram/coma/ComaBeanFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand All @@ -37,6 +38,8 @@ public class ComaBeanFactory extends AbstractComaBeanFactory {

private static final Logger LOG = LoggerFactory.getLogger(ComaBeanFactory.class);

private final Map<Class<? extends Content>, List<BeanListener>> attachedListeners = new HashMap<>();

@Inject
private Set<ComaBeanPopulator> populators;

Expand Down Expand Up @@ -134,14 +137,24 @@ public Set<Content> getChildren(String startFolderId, String pattern) {


/**
* Empty implementation.
* Coma is read only and does not even deal with external changes.
* Attach a listener for any changes dealing with classes of the given type.
* Coma is read only and does not even deal with external changes so far.
*
* @see org.tangram.content.BeanFactory#addListener(java.lang.Class, org.tangram.content.BeanListener)
* @param cls class to be notified when instances of that class have been changed
* @param listener listener to be notified about changes
*/
@Override
public void addListener(Class<? extends Content> cls, BeanListener listener) {
// Since we don't have any changes, we don't need to register listeners
synchronized (attachedListeners) {
List<BeanListener> listeners = attachedListeners.get(cls);
if (listeners==null) {
listeners = new ArrayList<>();
attachedListeners.put(cls, listeners);
} // if
listeners.add(listener);
} // synchronized
listener.reset();
LOG.info("addListener() {}: {}", cls.getSimpleName(), attachedListeners.get(cls).size());
} // addListener()

} // ComaBeanFactory

0 comments on commit 6bae00b

Please sign in to comment.