You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Anton Nikitin <te...@gmail.com> on 2006/08/03 05:32:54 UTC

Q: tapestry-spring

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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org