org.apache.wicket.guice
Class GuiceComponentInjector

java.lang.Object
  extended by org.apache.wicket.injection.Injector
      extended by org.apache.wicket.injection.ConfigurableInjector
          extended by org.apache.wicket.guice.GuiceComponentInjector
All Implemented Interfaces:
IComponentInstantiationListener
Direct Known Subclasses:
InjectionFlagCachingGuiceComponentInjector

public class GuiceComponentInjector
extends ConfigurableInjector
implements IComponentInstantiationListener

Injects fields/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

Nested Class Summary
static class GuiceComponentInjector.MoreThanOneBindingException
           
 
Constructor Summary
GuiceComponentInjector(Application app)
          Creates a new Wicket GuiceComponentInjector instance.
GuiceComponentInjector(Application app, com.google.inject.Injector injector)
          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
static Annotation findBindingAnnotation(Annotation[] annotations)
           
protected  IFieldValueFactory getFieldValueFactory()
           
 Object inject(Object object)
           
 void onInstantiation(Component component)
           
 
Methods inherited from class org.apache.wicket.injection.Injector
getInstance, inject, isBoundaryClass
 
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)
Creates a new Wicket GuiceComponentInjector instance, using the provided Guice Injector instance.

Parameters:
app -
injector -
Method Detail

inject

public Object inject(Object object)
Overrides:
inject in class ConfigurableInjector
Parameters:
object - object to be injected
Returns:
Object that was injected - used for chaining

onInstantiation

public void onInstantiation(Component component)
Specified by:
onInstantiation in interface IComponentInstantiationListener

findBindingAnnotation

public static Annotation findBindingAnnotation(Annotation[] annotations)
                                        throws GuiceComponentInjector.MoreThanOneBindingException
Parameters:
annotations -
Returns:
Throws:
GuiceComponentInjector.MoreThanOneBindingException

getFieldValueFactory

protected IFieldValueFactory getFieldValueFactory()
Specified by:
getFieldValueFactory in class ConfigurableInjector
See Also:
ConfigurableInjector.getFieldValueFactory()


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