|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectto.etc.iocular.container.BasicContainer
public class BasicContainer
This is a default implementation of an IOC container. While it exists it caches all instance objects. This object is threadsafe.
If an object really needs to be created we do this in two phases. The first phase creates a "build plan" for the object. The build plan considers all possible ways to create the given object, and will select the most optimal plan. The second phase will then execute the plan to actually create the object.
The separation into plan and create phase is needed because an object can be created across many ways (for instance because it has multiple constructors). We cannot try each method in turn because trying would force us to create objects that might not be needed after all when a given way to instantiate is not possible. We prevent this by first determining a plan which is guaranteed to work.
Constructor Summary | |
---|---|
BasicContainer(ContainerDefinition def,
Container parent)
|
Method Summary | ||
---|---|---|
void |
destroy()
|
|
void |
dump(java.lang.Class<?> theClass)
|
|
|
findObject(java.lang.Class<T> theClass)
Return the 'unnamed' object with the specified class from this container. |
|
|
findObject(java.lang.String name,
java.lang.Class<T> theClass)
|
|
java.lang.String |
getIdent()
|
|
|
getObject(java.lang.Class<T> theClass)
Return the 'unnamed' object with the specified class from this container. |
|
|
getObject(java.lang.String name,
java.lang.Class<T> theClass)
|
|
java.lang.Object |
retrieve(ComponentRef ref)
Actually get the required thingy. |
|
void |
setParameter(java.lang.Class<?> theClass,
java.lang.Object instance)
Set the parameter as identified by it's target class to the specified instance. |
|
void |
setParameter(java.lang.Object instance)
Set a container parameter object. |
|
void |
setParameter(java.lang.String name,
java.lang.Object instance)
Sets the parameter with the specified name to the instance passed. |
|
void |
start()
|
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public BasicContainer(ContainerDefinition def, Container parent)
Method Detail |
---|
public void start()
start
in interface Container
public void destroy()
destroy
in interface Container
public java.lang.String getIdent()
public <T> T findObject(java.lang.Class<T> theClass)
Container
findObject
in interface Container
public <T> T findObject(java.lang.String name, java.lang.Class<T> theClass)
findObject
in interface Container
public <T> T getObject(java.lang.Class<T> theClass) throws java.lang.Exception
Container
getObject
in interface Container
java.lang.Exception
public <T> T getObject(java.lang.String name, java.lang.Class<T> theClass) throws java.lang.Exception
getObject
in interface Container
java.lang.Exception
public void setParameter(java.lang.Object instance)
setParameter
in interface Container
instance
- public void setParameter(java.lang.Class<?> theClass, java.lang.Object instance)
setParameter
in interface Container
clz
- instance
- public void setParameter(java.lang.String name, java.lang.Object instance)
setParameter
in interface Container
name
- instance
- public java.lang.Object retrieve(ComponentRef ref) throws java.lang.Exception
T
- theClass
- ref
-
java.lang.Exception
public void dump(java.lang.Class<?> theClass)
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |