public class BasicContainer extends Object implements Container
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 and Description |
|---|
BasicContainer(ContainerDefinition def,
Container parent) |
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
void |
dump(Class<?> theClass) |
<T> T |
findObject(Class<T> theClass)
Return the 'unnamed' object with the specified class from this container.
|
<T> T |
findObject(String name,
Class<T> theClass) |
String |
getIdent() |
<T> T |
getObject(Class<T> theClass)
Return the 'unnamed' object with the specified class from this container.
|
<T> T |
getObject(String name,
Class<T> theClass) |
Object |
retrieve(ComponentRef ref)
Actually get the required thingy.
|
void |
setParameter(Class<?> theClass,
Object instance)
Set the parameter as identified by it's target class to the specified instance.
|
void |
setParameter(Object instance)
Set a container parameter object.
|
void |
setParameter(String name,
Object instance)
Sets the parameter with the specified name to the instance passed.
|
void |
start() |
String |
toString() |
public BasicContainer(ContainerDefinition def, Container parent)
public String getIdent()
public <T> T findObject(Class<T> theClass)
ContainerfindObject in interface Containerpublic <T> T findObject(String name, Class<T> theClass)
findObject in interface Containerpublic <T> T getObject(Class<T> theClass) throws Exception
Containerpublic void setParameter(Object instance)
setParameter in interface Containerinstance - public void setParameter(Class<?> theClass, Object instance)
setParameter in interface Containerclz - instance - public void setParameter(String name, Object instance)
setParameter in interface Containername - instance - public Object retrieve(ComponentRef ref) throws Exception
T - theClass - ref - Exceptionpublic void dump(Class<?> theClass)
Copyright © 2017 etc.to. All rights reserved.