org.wicketstuff.springreference
Class SpringReferenceSupporter

java.lang.Object
  extended by org.wicketstuff.springreference.AbstractSpringReferenceSupporter
      extended by org.wicketstuff.springreference.SpringReferenceSupporter

public class SpringReferenceSupporter
extends AbstractSpringReferenceSupporter

Used by SpringReference and AbstractSpringDependencies to do the actual spring bean lookups. This must be registered in the init() method of your wicket Application or WebApplication otherwise SpringReference and AbstractSpringDependencies will not work.

Example:

 
  public class App extends WebApplication {
        @Override
        public Class getHomePage() {
                return HomePage.class;
        }
 
        @Override
        protected void init() {
                super.init();
 
                getMarkupSettings().setDefaultMarkupEncoding(CharEncoding.UTF_8);
 
                SpringReferenceSupporter.register(this); // <--
        }
 }
 
 

Author:
akiraly

Constructor Summary
SpringReferenceSupporter(ApplicationContext applicationContext)
          Constructor.
 
Method Summary
protected static SpringReferenceSupporter get()
           
protected  ApplicationContext getApplicationContext()
           
static void register(Application application, SpringReferenceSupporter supporter)
          Registers the passed in supporter with the wicket application.
static void register(WebApplication application)
          Creates and registers an instance of this class with the wicket web application.
 
Methods inherited from class org.wicketstuff.springreference.AbstractSpringReferenceSupporter
clearCache, findAndSetInstance, findBeanName, getBeanDefinition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpringReferenceSupporter

public SpringReferenceSupporter(ApplicationContext applicationContext)
Constructor.

Parameters:
applicationContext - where the spring bean will be searched for, not null
Method Detail

register

public static void register(WebApplication application)
Creates and registers an instance of this class with the wicket web application. Uses WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContext) to get spring web application context. If more fine grained registration is needed use register(Application, SpringReferenceSupporter). If you want to use SpringReference you have to use one of the register methods in your wicket applications init().

Parameters:
application - wicket web application, not null

register

public static void register(Application application,
                            SpringReferenceSupporter supporter)
Registers the passed in supporter with the wicket application. This is the more sophisticated variant of registration. Most users could go with register(WebApplication).

Parameters:
application - wicket application, not null
supporter - spring reference supporter. Null value means removal.

get

protected static SpringReferenceSupporter get()
Returns:
instance registered with the current threads wicket application

getApplicationContext

protected ApplicationContext getApplicationContext()
Specified by:
getApplicationContext in class AbstractSpringReferenceSupporter
Returns:
context where the spring bean is searched for, not null


Copyright © 2012. All Rights Reserved.