Package de.caluga.morphium.cache
Class MessagingCacheSynchronizer
- java.lang.Object
-
- de.caluga.morphium.cache.AbstractCacheSynchronizer<MessagingCacheSyncListener>
-
- de.caluga.morphium.cache.MessagingCacheSynchronizer
-
- All Implemented Interfaces:
MessageListener,MorphiumStorageListener<Object>
public class MessagingCacheSynchronizer extends AbstractCacheSynchronizer<MessagingCacheSyncListener> implements MessageListener, MorphiumStorageListener<Object>
User: Stephan Bösebeck Date: 27.05.12 Time: 14:14 Connects to the Messaging system and to morphium. As soon as there is a message coming with name "cacheSync", this is responsible for clearing the local cache for this entity. Messaging used:- Msg.name == Always cacheSync
- Msg.type == Always multi - more than one node may listen to those messages
- Msg.msg == The messag is the Reason for clearing (remove, store, user interaction...)
- Msg.value == String, name of the class whose cache should be cleared
- Msg.additional == always null
- Msg.ttl == 30 sec - shoule be enought time for the message to be processed by all nodes
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.caluga.morphium.MorphiumStorageListener
MorphiumStorageListener.UpdateTypes
-
-
Field Summary
Fields Modifier and Type Field Description static StringCACHE_SYNC_RECORDstatic StringCACHE_SYNC_TYPE-
Fields inherited from class de.caluga.morphium.cache.AbstractCacheSynchronizer
listenerForType, listeners, log, morphium
-
-
Constructor Summary
Constructors Constructor Description MessagingCacheSynchronizer(Messaging msg, Morphium morphium)
-
Method Summary
-
Methods inherited from class de.caluga.morphium.cache.AbstractCacheSynchronizer
addSyncListener, addSyncListener, firePostClearEvent, firePreClearEvent, removeSyncListener, removeSyncListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.caluga.morphium.messaging.MessageListener
markAsProcessedBeforeExec
-
-
-
-
Field Detail
-
CACHE_SYNC_TYPE
public static final String CACHE_SYNC_TYPE
- See Also:
- Constant Field Values
-
CACHE_SYNC_RECORD
public static final String CACHE_SYNC_RECORD
- See Also:
- Constant Field Values
-
-
Method Detail
-
sendClearMessage
public void sendClearMessage(Class type, String reason, boolean force)
sends message if necessary- Parameters:
type- - typereason- - reason
-
detach
public void detach()
-
isAttached
public boolean isAttached()
-
sendClearAllMessage
public void sendClearAllMessage(String reason)
-
preStore
public void preStore(Morphium m, Object r, boolean isNew) throws MorphiumAccessVetoException
- Specified by:
preStorein interfaceMorphiumStorageListener<Object>- Throws:
MorphiumAccessVetoException
-
preStore
public void preStore(Morphium m, Map<Object,Boolean> isNew) throws MorphiumAccessVetoException
- Specified by:
preStorein interfaceMorphiumStorageListener<Object>- Throws:
MorphiumAccessVetoException
-
postStore
public void postStore(Morphium m, Object r, boolean isNew)
- Specified by:
postStorein interfaceMorphiumStorageListener<Object>
-
postStore
public void postStore(Morphium m, Map<Object,Boolean> isNew) throws MorphiumAccessVetoException
- Specified by:
postStorein interfaceMorphiumStorageListener<Object>- Throws:
MorphiumAccessVetoException
-
postDrop
public void postDrop(Morphium m, Class cls)
- Specified by:
postDropin interfaceMorphiumStorageListener<Object>
-
preDrop
public void preDrop(Morphium m, Class cls)
- Specified by:
preDropin interfaceMorphiumStorageListener<Object>
-
postRemove
public void postRemove(Morphium m, Object r)
- Specified by:
postRemovein interfaceMorphiumStorageListener<Object>
-
postRemove
public void postRemove(Morphium m, List<Object> lst)
- Specified by:
postRemovein interfaceMorphiumStorageListener<Object>
-
firePreSendEvent
public void firePreSendEvent(Class type, Msg m) throws CacheSyncVetoException
- Throws:
CacheSyncVetoException
-
preRemove
public void preRemove(Morphium m, Query<Object> q) throws MorphiumAccessVetoException
- Specified by:
preRemovein interfaceMorphiumStorageListener<Object>- Throws:
MorphiumAccessVetoException
-
preRemove
public void preRemove(Morphium m, Object r) throws MorphiumAccessVetoException
- Specified by:
preRemovein interfaceMorphiumStorageListener<Object>- Throws:
MorphiumAccessVetoException
-
postLoad
public void postLoad(Morphium m, Object o) throws MorphiumAccessVetoException
- Specified by:
postLoadin interfaceMorphiumStorageListener<Object>- Throws:
MorphiumAccessVetoException
-
postLoad
public void postLoad(Morphium m, List<Object> o) throws MorphiumAccessVetoException
- Specified by:
postLoadin interfaceMorphiumStorageListener<Object>- Throws:
MorphiumAccessVetoException
-
preUpdate
public void preUpdate(Morphium m, Class<?> cls, Enum updateType) throws MorphiumAccessVetoException
- Specified by:
preUpdatein interfaceMorphiumStorageListener<Object>- Throws:
MorphiumAccessVetoException
-
postRemove
public void postRemove(Morphium m, Query q)
- Specified by:
postRemovein interfaceMorphiumStorageListener<Object>
-
postUpdate
public void postUpdate(Morphium m, Class cls, Enum updateType)
- Specified by:
postUpdatein interfaceMorphiumStorageListener<Object>
-
onMessage
public Msg onMessage(Messaging msg, Msg m)
Description copied from interface:MessageListenerprocess message, send answer if null is returned, no answer is sent- Specified by:
onMessagein interfaceMessageListener
-
disableCommitMessages
public void disableCommitMessages()
-
enableCommitMessages
public void enableCommitMessages()
-
setCommitMessage
public void setCommitMessage(boolean msg)
-
isCommitMessages
public boolean isCommitMessages()
-
-