Changeset 2598


Ignore:
Timestamp:
02/20/13 11:36:52 (11 years ago)
Author:
keeloo
Message:

Changed WebAppConfig?.xml to VloConfig? to allow for the importerparameters to be included. Made the configuration sensitive to the web application context.

Location:
vlo/branches/vlo-2.13-param/vlo_webapp/src
Files:
3 edited
1 moved

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/VloApplication.java

    r2597 r2598  
    66import javax.servlet.ServletContext;
    77import org.apache.wicket.protocol.http.WebApplication;
    8 import org.springframework.beans.factory.BeanFactory;
    9 import org.springframework.context.support.ClassPathXmlApplicationContext;
    108
    119/**
    12  * Application object for your web application. If you want to run this
    13  * application without deploying, run the Start class.
     10 * {@literal VLO} web application.<br><br>
     11 *
     12 * Because the class extends the WebApplication class, the VLO application
     13 * will normally be deployed on a web server. However, by running the Start
     14 * class, the application outside of a server container.
    1415 *
    1516 */
     
    1819    private final SearchResultsDao searchResults;
    1920   
    20     static VloConfig config; 
     21    // application configuration object
    2122   
     23    static VloConfig config;
     24   
     25    // flag indicating whether or not the application object lives in a context
     26   
     27    boolean inContext;
     28
    2229    /**
    23      *
     30     * Method that will be invoked when the application starts
     31     */
     32    @Override
     33    public void init() {
     34
     35        if (inContext) {
     36           
     37            // add the context parameters to the configuration
     38
     39            ServletContext servletContext;
     40            servletContext = this.getServletContext();
     41            config = VloConfig.addServletContext(config, servletContext);
     42        }
     43    }
     44
     45    /**
     46     * Web application constructor<br><br>
     47     *
     48     * Create the application by invoking this constructor, whenever you want it
     49     * to be an application deployed in a web server container, that is: as an
     50     * application living in a web server context.
    2451     */
    2552    public VloApplication() {
    2653
    2754        /**
    28          *
     55         * Read the application's configuration. Because on instantiation a web
     56         * application cannot said to be living in a context, context parameters
     57         * can only be added to the configuration later, in this case: when the
     58         * {@literal init()} method will be invoked.
    2959         */
    30         ServletContext servletContext;
    31         servletContext = this.getServletContext();
    32         config = VloConfig.setWebApp(servletContext);
    33        
    34         String test;
    35         test = VloConfig.get().getSolrUrl();
    36        
    37         searchResults = new SearchResultsDao();       
     60        config = VloConfig.webApp();
     61
     62        // let the {@literal init()} method know that there will be a context
     63
     64        inContext = true;
     65
     66        // start the application
     67
     68        searchResults = new SearchResultsDao();
    3869    }
    39    
     70
    4071    /**
    41      * Invoke the application in test mode
     72     * Web application constructor<br><br>
     73     *
     74     * Introduce the idea of a channel: the environment in which a test
     75     * configuration object is created is in a way connected to this method.
     76     *
    4277     */
    4378    public VloApplication(VloConfig testConfig) {
     79
     80        // let the application use the configuration created outside of it
     81
     82        inContext = false;
     83
    4484        config = testConfig;
    4585
     
    5898        return searchResults;
    5999    }
    60 
    61100}
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/config/VloConfig.java

    r2597 r2598  
    33import java.io.UnsupportedEncodingException;
    44import java.net.URLEncoder;
    5 import javax.servlet.GenericServlet;
    65import javax.servlet.ServletContext;
    76import org.simpleframework.xml.Element;
     
    8988    public VloConfig() {
    9089        // let the superclass know about the logger defined here
    91         // ConfigFileParam.logger = webAppConfigLogger;
    9290
    9391        logger = new WebAppConfigLogger();
     
    10098     */
    10199    public static final String CONFIG_FILE =
    102             VloConfig.class.getResource("/WebAppConfig.xml").getFile();
     100            VloConfig.class.getResource("/VloConfig.xml").getFile();
    103101
    104102    /**
     
    131129    /**
    132130     * kj: change the annotation. Instead of opening a context, it is now a
    133      * matter of initialising it. Make a new method for referencing.
     131     * matter of initializing it. Make a new method for referencing.
    134132     *
    135133     * Open a static context of WebAppConfig members, and assign values to
     
    151149     * @return the web application configuration in a new static context
    152150     */
    153     public static VloConfig setWebApp(ServletContext context) {
     151    public static VloConfig webApp() {
    154152        if (config == null) {
    155153            // the configuration is not there yet; create it now
     
    157155        }
    158156
    159         /**
    160          * get the XML file configuration from the file by invoking the
    161          * superclass method
    162          */
     157        // get the XML file configuration from the file by invoking the
     158
    163159        config = (VloConfig) read(config);
    164 
    165         /* Contrary to Simple, the servlet context parameters are not retrieved
    166          * by annotation. Get them by invoking a local method.
    167          *
    168          * Here also invoke a superclass method
    169          */
    170         config = addServletContext(config, context);
    171160
    172161        return config;
     
    177166     * method.
    178167     *
     168     * In this method, exceptions to the normal web application context can
     169     * be made.
     170     *
    179171     * @return
    180172     */
    181     public static VloConfig WebAppTest() {
     173    public static VloConfig testWebApp() {
    182174        if (config == null) {
    183175            // the configuration is not there yet; create it now
     
    185177        }
    186178
    187         /**
    188          * get the XML file configuration from the file by invoking the
    189          * superclass method
    190          */
     179        // get the XML file configuration from the file by invoking the
     180
    191181        config = (VloConfig) read(config);
    192182
     
    607597           
    608598    /**
     599     *
     600     * kj: repair annotation
     601     *
     602     * Contrary to Simple, the web application's context parameters are not
     603     * retrieved by annotation. Get them by invoking a local method.
     604     *
    609605     * Add properties of the {@literal servlet's} context<br><br>
    610      *
     606     *  
    611607     * Keep the properties in the static context of the WebAppConfig class, next
    612608     * to the members representing the values in WebAppConfig.xml file.<br><br>
     
    616612     * @return the static WebAppConfig member
    617613     */
    618     static VloConfig addServletContext(VloConfig config, ServletContext context) {
     614    public static VloConfig addServletContext(VloConfig config, ServletContext context) {
    619615
    620616        // retrieve parameter valies from the servlet context
  • vlo/branches/vlo-2.13-param/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/pages/FacetBoxPanelTest.java

    r2597 r2598  
    2121    public void setUp() {
    2222        WicketTester wicketTester;
    23         testConfig = VloConfig.WebAppTest();
     23        testConfig = VloConfig.testWebApp();
    2424        wicketTester = new WicketTester(new VloApplication(testConfig));
    2525    }
Note: See TracChangeset for help on using the changeset viewer.