Package org.swisspush.gateleen.hook
Class LocalListenerRepository
- java.lang.Object
-
- org.swisspush.gateleen.hook.ListenerRepositoryBase<Map<String,Set<Listener>>>
-
- org.swisspush.gateleen.hook.LocalListenerRepository
-
- All Implemented Interfaces:
ListenerRepository
public class LocalListenerRepository extends ListenerRepositoryBase<Map<String,Set<Listener>>> implements ListenerRepository
Local in-memory implementation of a LocalListenerRepository.- Author:
- https://github.com/ljucam [Mario Ljuca]
-
-
Constructor Summary
Constructors Constructor Description LocalListenerRepository()Creates a new instance of the local in-memory LocalHookListenerRepository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(Listener listener)Adds a listener to the repository.List<Listener>findListeners(String url)Searches for listeners corresponding to the given url.List<Listener>findListeners(String url, String method, io.vertx.core.MultiMap headers)Searches for listeners corresponding to the given url, used http method and request headers.Set<Listener>get(Map<String,Set<Listener>> container, String key)Returns a set with listeners monitoring the given url.List<Listener>getListeners()Returns a copy of all registered listeners.booleanisEmpty()Returns whether the repository is empty or not.voidremoveListener(String listenerId)Removes the listener for the given listenerId.intsize()Returns the size of the repository.
-
-
-
Method Detail
-
addListener
public void addListener(Listener listener)
Description copied from interface:ListenerRepositoryAdds a listener to the repository.- Specified by:
addListenerin interfaceListenerRepository- Parameters:
listener- - the listener
-
findListeners
public List<Listener> findListeners(String url)
Description copied from interface:ListenerRepositorySearches for listeners corresponding to the given url. This is a hierarchical search, starting from top (/url/foo/bar) to bottom (/url).- Specified by:
findListenersin interfaceListenerRepository- Parameters:
url- url- Returns:
- List with listeners for the url, can be empty if no listeners are found.
-
removeListener
public void removeListener(String listenerId)
Description copied from interface:ListenerRepositoryRemoves the listener for the given listenerId.- Specified by:
removeListenerin interfaceListenerRepository- Parameters:
listenerId- listenerId
-
size
public int size()
Description copied from interface:ListenerRepositoryReturns the size of the repository. If the repository is empty, it will return 0.- Specified by:
sizein interfaceListenerRepository- Returns:
- size
-
isEmpty
public boolean isEmpty()
Description copied from interface:ListenerRepositoryReturns whether the repository is empty or not.- Specified by:
isEmptyin interfaceListenerRepository- Returns:
- true if repository is empty.
-
get
public Set<Listener> get(Map<String,Set<Listener>> container, String key)
Description copied from class:ListenerRepositoryBaseReturns a set with listeners monitoring the given url. Please implement this method according to your needs.
-
getListeners
public List<Listener> getListeners()
Description copied from interface:ListenerRepositoryReturns a copy of all registered listeners.- Specified by:
getListenersin interfaceListenerRepository- Returns:
- a copy of all registered listeners
-
findListeners
public List<Listener> findListeners(String url, String method, io.vertx.core.MultiMap headers)
Description copied from interface:ListenerRepositorySearches for listeners corresponding to the given url, used http method and request headers. This is a hierarchical search, starting from top (/url/foo/bar) to bottom (/url).- Specified by:
findListenersin interfaceListenerRepository- Parameters:
url- urlmethod- http methodheaders- http headers- Returns:
- List with listeners for the url, can be empty if no listeners are found.
-
-