Provide access to Spring from Application

by kinabalu on July 20, 2009

When developing with Apache Wicket, there are times when you won’t be able to use wicket-spring to access your bean implementations. Here is a simple example that you can add to your Wicket Application class to make accessing the context easier

 
    protected void init() {
        ...
        ServletContext servletContext = super.getServletContext();
        applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
        ...
    }
 
    private ApplicationContext applicationContext;
 
 
    public Object getBean(String name) {
        if (name == null) return null;
 
        return applicationContext.getBean(name);
    }

Similar Posts:

Share this:
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • Slashdot
  • Technorati

Leave a Comment

Previous post:

Next post: