Yeah... Why would someone put hundreds of getters for beans inside Application? This would be a big dummy access way to Spring's Beans, since we can use Annotations in a clever way.
:-) On Mon, Apr 28, 2008 at 6:56 AM, lars vonk <[EMAIL PROTECTED]> wrote: > > > > The @SpringBean approach > > is very useful, but its magic about a transient attribute that is not > > transient make us fell uncomfortable. > > > What do you mean by transient and magic? The attributes are not transient. > A > proxy is generated that is serialized. At runtime the real dependency is > retrieved from the spring container. > > I wouldn't use the approach you suggest for the following reasons: > > - Scatters your Application class all over your code. Any Component > (Pages, > Components) that need a Spring dependency need to the make the verbose > method call ((MyApplication)Application).get().getService(). > - All your dependencies need to be in the Application class which can lead > to a gigantic Application class if you use a lot of spring beans in your > application. > - Risk of serializing your spring beans: Since the Annotaion Based > approach > generates proxies for your spring beans they can be safely serialized. The > approach you suggest just returns the spring beans. This increases the > change of accidentally serializing a spring bean if you do for instance: > > public class MyPage { > private Service service; > public MyPage() { > this.service = Application.get().getService(); > } > } > > So I would stick with the current approach since it is IMHO a cleaner way > of > integrating with Spring. > > Cheers, Lars > > > On Mon, Apr 28, 2008 at 10:39 AM, Sergio García <[EMAIL PROTECTED]> > wrote: > > > > > This posts is about the vision that my colleague Daniel Fernández and me > > have > > about how should be the integration between Wicket and Spring, using the > > new > > annotation functionalities provided by Spring 2.5. The @SpringBean > > approach > > is very useful, but its magic about a transient attribute that is not > > transient make us fell uncomfortable. > > > > Four main steps are needed in this approach: > > > > 1) Change applicationClassname web.xml parameter to: > > > > <init-param> > > <param-name>applicationFactoryClassName</param-name> > > <param-value> > > org.apache.wicket.spring.SpringWebApplicationFactory > > </param-value> > > </init-param> > > > > 2) Declare the application class as a Spring bean (Spring 2.5 way) > > > > @Component > > public class MyApplication extends WebApplication > > > > 3) Declare into the application class the services with the correct > Spring > > 2.5 annotations > > > > @Autowired > > private AaaService aaaService; > > > > 4) Add getters for the services > > public AaaService getAaaService(){ > > return this.aaaService; > > } > > > > For convenience, you can add a static get() method to retrieve the > casted > > application class > > > > public static MyApplication get() { > > return (MyApplication) Application.get(); > > } > > > > So you can retrieve the service from any page with a simple > > MyApplication.get().getAaaService() > > > > > > > > > > As the applications class is not serializable, there are no need to make > > transient magic. > > > > What do you think about this approach? > > > > > > > > > > -- > > View this message in context: > > > http://www.nabble.com/Spring-2.5-and-Wicket%2C-our-vision-about-integration-tp16930960p16930960.html > > Sent from the Wicket - User mailing list archive at Nabble.com. > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > -- Bruno Borges blog.brunoborges.com.br +55 1185657739 "The glory of great men should always be measured by the means they have used to acquire it." - Francois de La Rochefoucauld