• New Feature
  • Status: Open
  • 2 Major
  • Resolution:
  • SpringRuntime
  • gbevin
  • Reporter: gbevin
  • August 08, 2008
  • 1
  • Watchers: 2
  • March 10, 2010

Description

A typical way of working with DSO is to split the tree of shared objects through transient fields and to populate them with local instances through an on-load specification. but, when clustering objects that use Spring beans in fields, they can be set to transient in the usual fashion, however there’s no way to easily populate them with the local instance of a non-clustered bean.

I think this should ideally be handled automatically but not sure if it’s possible. Whenever a transient field in Terracotta is initialized that corresponds to a Spring bean instance, the corresponding local instance of the Spring bean could be injected as normal. This would need some investigation for each possibly method of injection (constructor, setter, autowired, explicitly bound, …).

Maybe this needs the introduction of a more general concept of reference containers. While the new keyword and class fields are authoritative for working with the lifecycle of objects without IoC, with IoC in the picture one or many containers are responsible for the lifecycle and identity of object references. Maybe we need a generic API or config tag to tap into that during on-load.

Comments

Tim Eck 2008-08-08

This sounds like what is for in tc-config.xml. I don't have experience with it really, but if you didn't know that exists, you should check it out :-)

Eugene Kuleshov 2008-08-14

Like Tim said, scenario described in the bug report is taken care of. More over it is exactly what makes spring integration superior to the raw on-load scripting. If I am not mistaken, Spring architecture overview on the wiki describe how it is implemented.

Fiona OShea 2008-12-09

Geert Is this resolved to your satisfaction?

Geert Bevin 2008-12-09

I’ll look in detail tomorrow, didn’t get the comment about .

Petri Hakala 2009-10-16

Terracotta 3.1 doesn’t have non-distributed-field anymore. First that was really stupid way to do it anyway if you have a lot of spring objects on your session. It just make you specify spring beans twice. I would like to see autowiring happening automatically and use annotations like Geert described it. Spring Roo is using @Configurable annotation a lot and I see this is coming major pain if this is not fixed. Below example shows how this can be done with Terracotta right now:

tc-config.xml:

<![CDATA[ ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(attrs.getRequest().getSession().getServletContext()); context.getAutowireCapableBeanFactory().autowireBean(self); ]]>