Repository: wicket-site Updated Branches: refs/heads/asf-site 26fcaca36 -> 3708504ee
Servlet 3.x with Spring Framework example - Moved context init into static method Project: http://git-wip-us.apache.org/repos/asf/wicket-site/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket-site/commit/3708504e Tree: http://git-wip-us.apache.org/repos/asf/wicket-site/tree/3708504e Diff: http://git-wip-us.apache.org/repos/asf/wicket-site/diff/3708504e Branch: refs/heads/asf-site Commit: 3708504eef1757c828e8a0019a6eb47d9ec75682 Parents: 26fcaca Author: Tobias Soloschenko <[email protected]> Authored: Mon Feb 27 06:28:18 2017 +0100 Committer: Tobias Soloschenko <[email protected]> Committed: Mon Feb 27 06:28:18 2017 +0100 ---------------------------------------------------------------------- learn/examples/servlet3x.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket-site/blob/3708504e/learn/examples/servlet3x.md ---------------------------------------------------------------------- diff --git a/learn/examples/servlet3x.md b/learn/examples/servlet3x.md index 3cd3daf..b34f5e8 100644 --- a/learn/examples/servlet3x.md +++ b/learn/examples/servlet3x.md @@ -38,21 +38,22 @@ example. You have to place them into the scanned package or in sub packages. (co {% highlight java %} import javax.servlet.annotation.WebListener; import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; @WebListener public class MyContextLoaderListener extends ContextLoaderListener { - private static AnnotationConfigWebApplicationContext context; + public MyContextLoaderListener() { + super(getWebApplicationContext()); + } - static { - context = new AnnotationConfigWebApplicationContext(); + private static WebApplicationContext getWebApplicationContext() { + AnnotationConfigWebApplicationContext context + = new AnnotationConfigWebApplicationContext(); context.scan("com.my.package"); context.refresh(); - } - - public MyContextLoaderListener() { - super(context); + return context; } } {% endhighlight %}
