Class SpringComponentInjector

  • All Implemented Interfaces:
    org.apache.wicket.application.IComponentInstantiationListener, org.apache.wicket.IBehaviorInstantiationListener

    public class SpringComponentInjector
    extends org.apache.wicket.injection.Injector
    implements org.apache.wicket.application.IComponentInstantiationListener, org.apache.wicket.IBehaviorInstantiationListener
    IComponentInstantiationListener that injects component and behavior properties annotated with SpringBean annotations. To install in yourapplication.init() call getComponentInstantiationListeners().add(new SpringComponentInjector(this));

    Only Wicket Components and Behaviors are automatically injected, other classes such as Session, Model, and any other POJO can be injected by calling Injector.get().inject(this) in their constructor.

    Author:
    Igor Vaynberg (ivaynberg), Justin Lee
    • Constructor Summary

      Constructors 
      Constructor Description
      SpringComponentInjector​(org.apache.wicket.protocol.http.WebApplication webapp)
      Constructor used when spring application context is declared in the spring standard way and can be located through WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContext).
      SpringComponentInjector​(org.apache.wicket.protocol.http.WebApplication webapp, org.springframework.context.ApplicationContext ctx)
      Constructor
      SpringComponentInjector​(org.apache.wicket.protocol.http.WebApplication webapp, org.springframework.context.ApplicationContext ctx, boolean wrapInProxies)
      Constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void inject​(java.lang.Object object)  
      void onInstantiation​(org.apache.wicket.behavior.Behavior behavior)  
      void onInstantiation​(org.apache.wicket.Component component)  
      static void setDefaultContext​(org.apache.wicket.protocol.http.WebApplication webapp, org.springframework.context.ApplicationContext context)
      Set the default context for the given webapp.
      • Methods inherited from class org.apache.wicket.injection.Injector

        bind, get, inject
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SpringComponentInjector

        public SpringComponentInjector​(org.apache.wicket.protocol.http.WebApplication webapp)
        Constructor used when spring application context is declared in the spring standard way and can be located through WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContext).
        Parameters:
        webapp - wicket web application
      • SpringComponentInjector

        public SpringComponentInjector​(org.apache.wicket.protocol.http.WebApplication webapp,
                                       org.springframework.context.ApplicationContext ctx)
        Constructor
        Parameters:
        webapp - wicket web application
        ctx - spring's application context
      • SpringComponentInjector

        public SpringComponentInjector​(org.apache.wicket.protocol.http.WebApplication webapp,
                                       org.springframework.context.ApplicationContext ctx,
                                       boolean wrapInProxies)
        Constructor
        Parameters:
        webapp - wicket web application
        ctx - spring's application context
        wrapInProxies - whether or not wicket should wrap dependencies with specialized proxies that can be safely serialized. in most cases this should be set to true.
    • Method Detail

      • inject

        public void inject​(java.lang.Object object)
        Specified by:
        inject in class org.apache.wicket.injection.Injector
      • onInstantiation

        public void onInstantiation​(org.apache.wicket.Component component)
        Specified by:
        onInstantiation in interface org.apache.wicket.application.IComponentInstantiationListener
      • onInstantiation

        public void onInstantiation​(org.apache.wicket.behavior.Behavior behavior)
        Specified by:
        onInstantiation in interface org.apache.wicket.IBehaviorInstantiationListener
      • setDefaultContext

        public static void setDefaultContext​(org.apache.wicket.protocol.http.WebApplication webapp,
                                             org.springframework.context.ApplicationContext context)
        Set the default context for the given webapp.
        Parameters:
        webapp - web application
        context - context to use as default if non is explicitely specified for the injector