source: vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/VloWicketApplication.java @ 4651

Last change on this file since 4651 was 4651, checked in by Twan Goosen, 10 years ago

VLO version property gets set build time and is included in footer of page

File size: 2.8 KB
Line 
1package eu.clarin.cmdi.vlo;
2
3import eu.clarin.cmdi.vlo.service.SolrDocumentService;
4import eu.clarin.cmdi.vlo.wicket.pages.FacetedSearchPage;
5import eu.clarin.cmdi.vlo.wicket.pages.RecordPage;
6import org.apache.wicket.Application;
7import org.apache.wicket.markup.html.WebPage;
8import org.apache.wicket.protocol.http.WebApplication;
9import org.apache.wicket.resource.loader.BundleStringResourceLoader;
10import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
11import org.springframework.beans.BeansException;
12import org.springframework.beans.factory.annotation.Autowired;
13import org.springframework.context.ApplicationContext;
14import 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 */
22public 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}
Note: See TracBrowser for help on using the repository browser.