Struts uses an internal Dependency Injection framework, named Guice, to load key framework beans. This allows Internally, the framework uses its own dependency injection container. The container loads key framework objects, so that any piece of the framework to can be replaced, extended, or removed in a standard, consistent way. Plugins, in particular, leverage this capability to extend the framework to provide support for third-party libraries like Spring or Sitemesh. Therefore, the common Struts application most likely
Most applications won't need to interact with this particular configuration elementextend the Bean Configuration.
Beans
The bean element has one required attribute, class
, which specifies the Java class to be created or manipulated. A bean can either
- be
...
- created by
...
- the framework's container and injected into internal
...
- framework objects, or
...
- have values injected to its static methods
. The former first use, object injection, is generally accompanied by the type
attribute, which tells Guice the container which interface this object implements.
The latter second use, value injection, is good for allowing objects not created by Guice the container to receive framework constants. Objects using value inject must define the the static
attribute.
Attribute | Required | Description |
---|---|---|
class | yes | the name of the bean class |
type | no | the primary Java interface this class implements |
name | no | the unique name of this bean; must be unique among other beans that specify the same |
scope | no | the scope of the bean; must be either |
static | no | whether to inject static methods or not; shouldn't be |
optional | no | whether the bean is optional or not |
...