All Implemented Interfaces:
Serializable
All Known Implementing Classes:
ContainerImpl
When injecting a method or constructor, you can additionally annotate its parameters with Inject and specify a dependency name. When a parameter has no annotation, the container uses the name from the method or constructor's Inject annotation respectively.
For example:
class Foo {
// Inject the int constant named "i".
@Inject("i") int i;
// Inject the default implementation of Bar and the String constant
// named "s".
@Inject Foo(Bar bar, @Inject("s") String s) {
...
}
// Inject the default implementation of Baz and the Bob implementation
// named "foo".
@Inject void initialize(Baz baz, @Inject("foo") Bob bob) {
...
}
// Inject the default implementation of Tee.
@Inject void setTee(Tee tee) {
...
}
}
To create and inject an instance of {@code Foo}:
Container c = ...; Foo foo = c.inject(Foo.class);
crazybob - @google.com (Bob Lee)| Field Summary | ||
|---|---|---|
| String | DEFAULT_NAME | Default dependency name. |
| Method from com.opensymphony.xwork2.inject.Container Summary: |
|---|
| getInstance, getInstance, getInstanceNames, inject, inject, removeScopeStrategy, setScopeStrategy |
| Method from com.opensymphony.xwork2.inject.Container Detail: |
|---|
|
|
|
|
|
|
|