public abstract class AbstractContext extends Object implements Context
Context
implementations.Constructor and Description |
---|
AbstractContext() |
Modifier and Type | Method and Description |
---|---|
<T> void |
addContextListener(Class<T> type,
ContextListener<T> listener)
Registers a
ContextListener for a specified type. |
protected <T> void |
fireContextEvent(Class<T> type)
|
protected Map<Class<?>,List<ContextListener<?>>> |
getListeners()
Gets all registered
ContextListener . |
<T> void |
removeContextListener(Class<T> type,
ContextListener<T> listener)
Unregisters a
ContextListener for a specified type. |
public <T> void addContextListener(Class<T> type, ContextListener<T> listener)
ContextListener
for a specified type.
The listener will be notified when instances of the specified type get added or removed.addContextListener
in interface Context
T
- the specified typetype
- the type to listen forlistener
- the ContextListenerpublic <T> void removeContextListener(Class<T> type, ContextListener<T> listener)
ContextListener
for a specified type.removeContextListener
in interface Context
T
- the specified typetype
- the type to listen forlistener
- the ContextListenerprotected <T> void fireContextEvent(Class<T> type)
T
- the specified typetype
- the type that changedprotected final Map<Class<?>,List<ContextListener<?>>> getListeners()
ContextListener
.
Note: the type parameters of entries match.Map
grouping all registered ContextListener
by the type of instances they are listening
for.Copyright © 2012–2018 Drombler. All rights reserved.