|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.wicketstuff.springreference.AbstractSpringDependencies
public abstract class AbstractSpringDependencies
This class together with SpringReferenceSupporter makes it possible to use spring
annotation driven injection with wicket (for example @Autowired and
@Qualifier annotated fields). It has most of the benefits of
SpringReference (except lazy lookup) so this can be used too where
@SpringBean from wicket-spring fails (no dynamic proxies used, serialization
supported).
Instances of this class use the SpringReferenceSupporter for bean lookup, so it must
be registered in your wicket WebApplication init() method (
SpringReferenceSupporter.register(this);). Otherwise you will get
NullPointerException during instantiation. See SpringReferenceSupporter for more
information.
Probably this is the most ugly looking in code from the spring-wicket integration alternatives,
however this is the closest to the vanilla spring injection.
The base idea is that the spring dependencies are encapsulated into a subclass of this class.
Dependencies are (re)injected during instantiation, deserialization and cloning.
Usage:
public class MySession extends AuthenticatedWebSession
{
private static final long serialVersionUID = 1L;
// This nested class holds all our spring dependencies. Annotated in spring style.
static class Deps extends AbstractSpringDependencies
{
private static final long serialVersionUID = 1L;
@Autowired
@Qualifier("authenticationManager")
transient AuthenticationManager authenticationManager;
@Autowired
transient AbstractRememberMeServices abstractRememberMeServices;
}
private final Deps deps = new Deps();
// ...
public boolean authenticate(String username, String password)
{
// ...
deps.authenticationManager.authenticate(token);
AbstractRememberMeServices rememberMeServices = deps.abstractRememberMeServices;
// ...
}
}
| Constructor Summary | |
|---|---|
protected |
AbstractSpringDependencies()
Constructor. |
| Method Summary | |
|---|---|
AbstractSpringDependencies |
clone()
|
protected void |
init()
Injects dependencies. |
protected Object |
readResolve()
Called during deserialization by the JVM. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractSpringDependencies()
init().
| Method Detail |
|---|
protected void init()
protected Object readResolve()
init().
public AbstractSpringDependencies clone()
clone in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||