click-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bob Schellink <sab...@gmail.com>
Subject Re: svn commit: r782672 - in /incubator/click/trunk/click/examples/src/org/apache/click/examples/page/table: SearchTablePage.java TableStyles.java
Date Tue, 09 Jun 2009 20:07:33 GMT
Malcolm Edgar wrote:
> I suppose the service should be made serializable, this should not be
> any problem as it is stateless


This is certainly one option but as far as best practice goes it could 
be problematic as Spring services tend to reference each other.
I can imagine a situation where serialization can pull in lots of 
referenced Spring services, which could lead to problems.

Playing around with the various options it seems that stateful Pages 
might be better off using the ApplicationContext injection approach:

public class StatefulPage extends Page implements 
ApplicationContextAware {

   ...

   public CustomerService getCustomerService() {
     return (CustomerService) ctx.getBean("customerService");
   }

  public void setApplicationContext(ApplicationContext 
applicationContext) throws BeansException {
         this.ctx = applicationContext;
     }
}

The ApplicationContext is re-injected by Click, even for stateful 
pages, meaning the service can be looked up instead of injected.

Another option might be to change the way "injected Spring beans" work 
(option 3 from the javadoc). Currently the beans are injected when a 
new instance of Page is created. However we could change this so that 
injections occurs in the "activatePageInstance" method, much like 
ApplicationContext is re-injected.

Anyway just throwing around some ideas.

bob


Mime
View raw message