|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Implementation container.
The container is responsible for creating and maintaining instances of implementations of specifications. It is driven by a model defining the relationships between specifications and implementations. Its main use is to decouple compiletime classpaths from runtime classpaths. Implementations need not be visible during compiletime. Applications can be written against a stable API with no implementation dependent knowledge. The implementations building the runtime can then be exchanged independently during application assembly.
Example: Getting an instance of an implementation of a specification
Specification spec = (Specification) ContainerFactory.getContainer().
getImplementation(Specification.class, "jDTAUS Implementation");
Example: Getting an instance of an implementation of a dependency
public class Implementation {
private transient Specification _dependency0;
private Specification getSpecification() {
Specification ret = null;
if(this._dependency0 != null) {
ret = this._dependency0;
} else {
ret = (Specification) ContainerFactory.getContainer().
getDependency(Implementation.class, "Specification");
if(ModelFactory.getModel().getModules().
getImplementation(Implementation.class.getName()).
getDependencies().getDependency("Specification").isBound()) {
this._dependency0 = ret;
}
}
return ret;
}
}
ContainerFactory| Method Summary | |
Object |
getDependency(Class implementation,
String dependencyName)
Gets an instance of an implementation of some dependency. |
Object |
getImplementation(Class specification,
String implementationName)
Gets an instance of an implementation of some specification. |
| Method Detail |
public Object getDependency(Class implementation,
String dependencyName)
implementation - the class of the implementation to return an
instance of a dependency for.dependencyName - the logical name of the dependency to return.
NullPointerException - if either or
is .
InstantiationException - if creating
an instance of the dependency fails.
public Object getImplementation(Class specification,
String implementationName)
specification - the class of the specification to return an
instance of an implementation for.implementationName - the name of the implementation to return.
NullPointerException - if either or
is .
InstantiationException - if creating
an instance of the implementation fails.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||