org.apache.wicket.guice
Class GuiceComponentInjector

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

public class GuiceComponentInjector
extends Injector
implements IComponentInstantiationListener

Injects field members of components using Guice.

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

 addComponentInstantiationListener(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.

Author:
Alastair Maw

Constructor Summary
GuiceComponentInjector(Application app)
          Creates a new Wicket GuiceComponentInjector instance.
GuiceComponentInjector(Application app, com.google.inject.Injector injector)
          Constructor
GuiceComponentInjector(Application app, com.google.inject.Injector injector, boolean wrapInProxies)
          Creates a new Wicket GuiceComponentInjector instance, using the provided Guice Injector instance.
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.
 
Method Summary
 void inject(java.lang.Object object)
          Injects the specified object.
 void onInstantiation(Component component)
          Called for every component that is instantiated.
 
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

GuiceComponentInjector

public GuiceComponentInjector(Application app)
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 Detail

inject

public void inject(java.lang.Object object)
Injects the specified object. This method is usually implemented by delegating to Injector.inject(Object, IFieldValueFactory) with some IFieldValueFactory

Specified by:
inject in class Injector
See Also:
Injector.inject(Object, IFieldValueFactory)

onInstantiation

public void onInstantiation(Component component)
Called for every component that is instantiated. This method is called during construction, so do not depend on the construction being completed yet. The id is guaranteed to be set before this call.

Specified by:
onInstantiation in interface IComponentInstantiationListener
Parameters:
component - the component that is being instantiated.


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.