public class SpringComponentInjector extends Injector implements IComponentInstantiationListener, 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 Component
s and Behavior
s 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.
Constructor and Description |
---|
SpringComponentInjector(WebApplication webapp)
Constructor used when spring application context is declared in the spring standard way and
can be located through
WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContext) . |
SpringComponentInjector(WebApplication webapp,
org.springframework.context.ApplicationContext ctx)
Constructor
|
SpringComponentInjector(WebApplication webapp,
org.springframework.context.ApplicationContext ctx,
boolean wrapInProxies)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
inject(Object object)
Injects the specified object.
|
void |
onInstantiation(Behavior behavior)
Called when a behavior instance is created
|
void |
onInstantiation(Component component)
Called for every component that is instantiated.
|
static void |
setDefaultContext(WebApplication webapp,
org.springframework.context.ApplicationContext context)
Set the default context for the given webapp.
|
public SpringComponentInjector(WebApplication webapp)
WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContext)
.webapp
- wicket web applicationpublic SpringComponentInjector(WebApplication webapp, org.springframework.context.ApplicationContext ctx)
webapp
- wicket web applicationctx
- spring's application contextpublic SpringComponentInjector(WebApplication webapp, org.springframework.context.ApplicationContext ctx, boolean wrapInProxies)
webapp
- wicket web applicationctx
- spring's application contextwrapInProxies
- whether or not wicket should wrap dependencies with specialized proxies that can
be safely serialized. in most cases this should be set to true.public void inject(Object object)
Injector
Injector.inject(Object, IFieldValueFactory)
with some IFieldValueFactory
inject
in class Injector
Injector.inject(Object, IFieldValueFactory)
public void onInstantiation(Component component)
IComponentInstantiationListener
onInstantiation
in interface IComponentInstantiationListener
component
- the component that is being instantiated.public void onInstantiation(Behavior behavior)
IBehaviorInstantiationListener
onInstantiation
in interface IBehaviorInstantiationListener
public static void setDefaultContext(WebApplication webapp, org.springframework.context.ApplicationContext context)
webapp
- web applicationcontext
- context to use as default if non is explicitely specified for the injectorCopyright © 2006–2022 Apache Software Foundation. All rights reserved.