Class GuiceComponentInjector

java.lang.Object
org.apache.wicket.injection.Injector
org.apache.wicket.guice.GuiceComponentInjector
All Implemented Interfaces:
IComponentInstantiationListener, IBehaviorInstantiationListener

Injects field members of components and behaviors using Guice.

Add this to your application in its Application.init() method like so:

 getComponentInstantiationListeners().add(new GuiceComponentInjector(this));
 

There are different constructors for this object depending on how you want to wire things. See the javadoc for the constructors for more information.

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:
Alastair Maw
  • Constructor Details

    • GuiceComponentInjector

      Creates a new Wicket GuiceComponentInjector instance.

      Internally this will create a new Guice Injector instance, with no Module instances. This is only useful if your beans have appropriate ImplementedBy annotations on them so that they can be automatically picked up with no extra configuration code.

      Parameters:
      app -
    • GuiceComponentInjector

      public GuiceComponentInjector(Application app, com.google.inject.Module... modules)
      Creates a new Wicket GuiceComponentInjector instance, using the supplied Guice Module instances to create a new Guice Injector instance internally.
      Parameters:
      app -
      modules -
    • GuiceComponentInjector

      public GuiceComponentInjector(Application app, com.google.inject.Injector injector)
      Constructor
      Parameters:
      app -
      injector -
    • GuiceComponentInjector

      public GuiceComponentInjector(Application app, com.google.inject.Injector injector, boolean wrapInProxies)
      Creates a new Wicket GuiceComponentInjector instance, using the provided Guice Injector instance.
      Parameters:
      app -
      injector -
      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 Details