Having just written several pages that use @SpringBean, I agree that this new
implementation seems quite awkward.  Today, all I do is declare the services
in the classes that need them and access that member directly.  What if I
want to share those pages across multiple applications?  Then I need to add
an accessor to each application that uses those pages?  Creating a common
ancestor Application and subclassing may or may not be an option.

As an end-user, I don't care about non-transient fields that are transient. 
I liked the fact that integrating with spring was so easy and painless. 
Adding this step of indirection through the Application class seems like
more work.

Just my thoughts.

-Doug


Sergio García 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-tp16930960p16943155.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]

Reply via email to