Hi all,

On his tapestry-spring contribution
[http://howardlewisship.com/tapestry-javaforge/tapestry-spring/], Howard
mentioned that "...injecting Spring beans that are not singletons doesn't
work properly..."

How exactly is this manifested?

I tried a very quick example, using a bean mapped like so:
<bean singleton="false" class="beans.NonSingletonBean" id="myHello"/>

Source:
public class NonSingletonBean {
        private Date date;

        public NonSingletonBean() {
                this.date = new Date(); 
        }
        public String currentDate() {
                return date.toString();
        }
}

In Home.java:
[...]
        @InjectObject("spring:myHello")
        public abstract NonSingletonBean getHello();
[...]
        public IPage onSubmit() {
                System.out.println(getHello().currentDate());
        }

The injected bean would behave as expected - i.e. when bean configured as
singleton="false", the onSubmit handler would produce a new date string on
every call; when using bean default (singleton), the date was fixed to
whenever value when it was first created.

What lifecycle model is compromised when injecting beans this way? Is it
still a problem if I inject application context through a
ApplicationContextAware bean, and then call ac.getBean("someBean") in my
page class?


Many thanks,
- Anton


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to