|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.beanfabrics.context.DefaultContext
public class DefaultContext
The DefaultContext
is the default implementation of the
Context
interface.
Constructor Summary | |
---|---|
DefaultContext()
Constructs a DefaultContext . |
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. |
|
protected void |
fireParentAdded(Context parent)
Fires a parentAdded-event to each registered listener. |
|
protected void |
fireParentRemoved(Context parent)
Fires a parentRemoved-event to each registered listener. |
|
protected void |
fireServiceAdded(ServiceEntry entry)
Fires a service-added-event to each registered listener. |
|
protected void |
fireServiceRemoved(ServiceEntry entry)
Fires a service-removed-event to each registered listener. |
|
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. |
|
protected ServiceEntry |
removeServiceEntry(Context origin,
java.lang.Class<?> type)
Removes the first service entry from this context that matches the given type and origially was placed into the given "origin" context. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultContext()
DefaultContext
.
Method Detail |
---|
public java.util.List<Context> getParents()
getParents
in interface Context
public void addParent(Context parent)
Context
as a parent to the this context.
addParent
in interface Context
public void removeParent(Context parent)
Context
from this context.
removeParent
in interface Context
public void addContextListener(ContextListener l)
ContextListener
.
addContextListener
in interface Context
public void removeContextListener(ContextListener l)
ContextListener
.
removeContextListener
in interface Context
protected void fireParentAdded(Context parent)
parent
- the parent this context has been added toprotected void fireParentRemoved(Context parent)
parent
- the parent this context has been removed from.protected void fireServiceAdded(ServiceEntry entry)
entry
- the service entry that has been added to this contextprotected void fireServiceRemoved(ServiceEntry entry)
entry
- the service entry that has been removed from this contextpublic <T> boolean addService(java.lang.Class<? super T> type, T service)
Context
and make it available
for clients.
addService
in interface Context
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 sucessfullyprotected ServiceEntry removeServiceEntry(Context origin, java.lang.Class<?> type)
origin
- type
-
public <T> T removeService(java.lang.Class<? extends T> type)
removeService
in interface Context
null
otherwise.public java.util.List<ServiceEntry> getServiceEntries()
getServiceEntries
in interface Context
public ServiceEntry findService(java.lang.Class<?> type)
findService
in interface Context
public <T> T getService(java.lang.Class<? extends T> type)
Context.findService(Class)
. It returns the same result as
ctx.findService(aType).getService()
.
getService
in interface Context
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |