As going through Infinispan API I am wondering why there is package for commands and events both? for example there is an event which is InvalidateCommand and CacheEntryInvalidatedEvent. Does former has to do something with clustered and later(CacheEntryInvalidatedEvent) is just for the local node. It sounds like it should be when ever an invalidatecommand is visited the CacheEntryInvalidatedEvent should be triggered. But I can not see this relationship in the packages. Also why there are both interceptors and listeners?
Commands are used by Infinispan internally to perform operations on remote nodes, as well as some local operations. Events are fired by Infinispan so that user code can react to cache events. So one is an impl detail (commands) and one is a user api (events).
Interceptors are also used for internal purposes and to extend infinispan, whilst listeners are a user api.