1 | package eu.clarin.cmdi.vlo; |
---|
2 | |
---|
3 | import eu.clarin.cmdi.vlo.service.SolrDocumentService; |
---|
4 | import eu.clarin.cmdi.vlo.wicket.pages.FacetedSearchPage; |
---|
5 | import eu.clarin.cmdi.vlo.wicket.pages.RecordPage; |
---|
6 | import org.apache.wicket.Application; |
---|
7 | import org.apache.wicket.markup.html.WebPage; |
---|
8 | import org.apache.wicket.protocol.http.WebApplication; |
---|
9 | import org.apache.wicket.resource.loader.BundleStringResourceLoader; |
---|
10 | import org.apache.wicket.spring.injection.annot.SpringComponentInjector; |
---|
11 | import org.springframework.beans.BeansException; |
---|
12 | import org.springframework.beans.factory.annotation.Autowired; |
---|
13 | import org.springframework.context.ApplicationContext; |
---|
14 | import org.springframework.context.ApplicationContextAware; |
---|
15 | |
---|
16 | /** |
---|
17 | * Application object for your web application. If you want to run this |
---|
18 | * application without deploying, run the Start class. |
---|
19 | * |
---|
20 | * @see eu.clarin.cmdi.Start#main(String[]) |
---|
21 | */ |
---|
22 | public class VloWicketApplication extends WebApplication implements ApplicationContextAware { |
---|
23 | |
---|
24 | @Autowired |
---|
25 | private SolrDocumentService documentService; |
---|
26 | |
---|
27 | private ApplicationContext applicationContext; |
---|
28 | |
---|
29 | /** |
---|
30 | * @return the home page of this application |
---|
31 | * @see org.apache.wicket.Application#getHomePage() |
---|
32 | */ |
---|
33 | @Override |
---|
34 | public Class<? extends WebPage> getHomePage() { |
---|
35 | return FacetedSearchPage.class; |
---|
36 | } |
---|
37 | |
---|
38 | /** |
---|
39 | * @see org.apache.wicket.Application#init() |
---|
40 | */ |
---|
41 | @Override |
---|
42 | public void init() { |
---|
43 | super.init(); |
---|
44 | // this listener will inject any spring beans that need to be autowired |
---|
45 | getComponentInstantiationListeners().add(new SpringComponentInjector(this, applicationContext)); |
---|
46 | // register the resource of field names (used by eu.clarin.cmdi.vlo.wicket.componentsSolrFieldNameLabel) |
---|
47 | getResourceSettings().getStringResourceLoaders().add(new BundleStringResourceLoader("fieldNames")); |
---|
48 | // register the resource of application properties (version information filtered at build time) |
---|
49 | getResourceSettings().getStringResourceLoaders().add(new BundleStringResourceLoader("application")); |
---|
50 | |
---|
51 | // Record (query result) page. E.g. /vlo/record?docId=abc123 |
---|
52 | // (cannot encode docId in path because it contains a slash) |
---|
53 | mountPage("/record", RecordPage.class); |
---|
54 | } |
---|
55 | |
---|
56 | /** |
---|
57 | * |
---|
58 | * @return the active VLO wicket application |
---|
59 | */ |
---|
60 | public static VloWicketApplication get() { |
---|
61 | return (VloWicketApplication) Application.get(); |
---|
62 | } |
---|
63 | |
---|
64 | /** |
---|
65 | * Method needed for dynamic injection of application context (as happens in |
---|
66 | * unit tests) |
---|
67 | * |
---|
68 | * @param applicationContext |
---|
69 | * @throws BeansException |
---|
70 | */ |
---|
71 | @Override |
---|
72 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
---|
73 | this.applicationContext = applicationContext; |
---|
74 | } |
---|
75 | |
---|
76 | public SolrDocumentService getDocumentService() { |
---|
77 | return documentService; |
---|
78 | } |
---|
79 | |
---|
80 | } |
---|