struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeromy Evans <>
Subject Re: xwork and DI
Date Tue, 22 Apr 2008 02:57:27 GMT
Musachy Barroso wrote:
> If I want to add a constant that can be injected in one of xwork
> classes (like "devMode" for example), what do I need to do? Just
> adding @Inject and defining the constant in in core
> doesn't work. I don't know much about this whole guice black magic
> thing :)
> musachy
Here's some simple examples:

Setup some beans and constants in the Container with unique names:

eg. 1. Inject constant into a bean
Line 333
    public void setMappingConfigurationName(String 
mappingConfigurationName) {
        this.mappingConfigurationName = mappingConfigurationName;

eg. 2. Inject Container into a bean to enable run-time lookup by name 
and class:
    public void setContainer(Container container) {
        this.container = container;
  Line 116
   mappingConfiguration = 

eg. 3. Inject Bean into another bean directly: exactly as per the 
container injection.  If there's only one instance it will bind, 
otherwise specify the name, otherwise it will fail.
public void setActionMapper(ActionMapper actionMapper) {...

It only gets complicated when you need to mix injection with beans 
created outside the container, as described by Wes.

 Jeromy Evans

PS. this is far inferior to the current functionality of Guice.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message