|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Context
A Context
is an hierarchical environment for service objects.
Call addService(Class, Object)
to put a service object into this
context. Call getService(Class)
or findService(Class)
to
receive a reference to a service.
A context can be part of Zero-to-Many parents, and can itself be parent of Zero-to-Many children. Any service made available for a parent is also available for all children but not vice-versa.
Method Summary | ||
---|---|---|
void |
addContextListener(ContextListener l)
Add the given ContextListener . |
|
void |
addParent(Context parent)
Adds the given Context as a parent to the this context. |
|
|
addService(java.lang.Class<? super T> type,
T service)
Place the given service into this Context and make it available
for clients. |
|
ServiceEntry |
findService(java.lang.Class<?> type)
Finds and returns the first service entry in this context that matches the given type. |
|
java.util.List<Context> |
getParents()
Returns a list of all parents. |
|
|
getService(java.lang.Class<? extends T> type)
Finds and returns the first service implementation in this context that matches the given type. |
|
java.util.List<ServiceEntry> |
getServiceEntries()
Returns a list of all service entries that are available in this context. |
|
void |
removeContextListener(ContextListener l)
Remove the given ContextListener . |
|
void |
removeParent(Context parent)
Removes the given parent Context from this context. |
|
|
removeService(java.lang.Class<? extends T> type)
Removes the first service of the given type. |
Method Detail |
---|
void addParent(Context parent)
Context
as a parent to the this context.
parent
- void removeParent(Context parent)
Context
from this context.
parent
- java.util.List<Context> getParents()
void addContextListener(ContextListener l)
ContextListener
.
l
- void removeContextListener(ContextListener l)
ContextListener
.
l
- <T> boolean addService(java.lang.Class<? super T> type, T service)
Context
and make it available
for clients.
T
- the generic type of the servicetype
- the type of the service. Clients will find the service by
using this type.service
- the service implementation
true
, if the service has been added sucessfully<T> T removeService(java.lang.Class<? extends T> type)
type
-
null
otherwise.java.util.List<ServiceEntry> getServiceEntries()
ServiceEntry findService(java.lang.Class<?> type)
type
-
<T> T getService(java.lang.Class<? extends T> type)
findService(Class)
. It returns the same result as
ctx.findService(aType).getService()
.
T
- type
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |