Changeset 2598
- Timestamp:
- 02/20/13 11:36:52 (11 years ago)
- 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 6 6 import javax.servlet.ServletContext; 7 7 import org.apache.wicket.protocol.http.WebApplication; 8 import org.springframework.beans.factory.BeanFactory;9 import org.springframework.context.support.ClassPathXmlApplicationContext;10 8 11 9 /** 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. 14 15 * 15 16 */ … … 18 19 private final SearchResultsDao searchResults; 19 20 20 static VloConfig config;21 // application configuration object 21 22 23 static VloConfig config; 24 25 // flag indicating whether or not the application object lives in a context 26 27 boolean inContext; 28 22 29 /** 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. 24 51 */ 25 52 public VloApplication() { 26 53 27 54 /** 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. 29 59 */ 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(); 38 69 } 39 70 40 71 /** 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 * 42 77 */ 43 78 public VloApplication(VloConfig testConfig) { 79 80 // let the application use the configuration created outside of it 81 82 inContext = false; 83 44 84 config = testConfig; 45 85 … … 58 98 return searchResults; 59 99 } 60 61 100 } -
vlo/branches/vlo-2.13-param/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/config/VloConfig.java
r2597 r2598 3 3 import java.io.UnsupportedEncodingException; 4 4 import java.net.URLEncoder; 5 import javax.servlet.GenericServlet;6 5 import javax.servlet.ServletContext; 7 6 import org.simpleframework.xml.Element; … … 89 88 public VloConfig() { 90 89 // let the superclass know about the logger defined here 91 // ConfigFileParam.logger = webAppConfigLogger;92 90 93 91 logger = new WebAppConfigLogger(); … … 100 98 */ 101 99 public static final String CONFIG_FILE = 102 VloConfig.class.getResource("/ WebAppConfig.xml").getFile();100 VloConfig.class.getResource("/VloConfig.xml").getFile(); 103 101 104 102 /** … … 131 129 /** 132 130 * kj: change the annotation. Instead of opening a context, it is now a 133 * matter of initiali sing it. Make a new method for referencing.131 * matter of initializing it. Make a new method for referencing. 134 132 * 135 133 * Open a static context of WebAppConfig members, and assign values to … … 151 149 * @return the web application configuration in a new static context 152 150 */ 153 public static VloConfig setWebApp(ServletContext context) {151 public static VloConfig webApp() { 154 152 if (config == null) { 155 153 // the configuration is not there yet; create it now … … 157 155 } 158 156 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 163 159 config = (VloConfig) read(config); 164 165 /* Contrary to Simple, the servlet context parameters are not retrieved166 * by annotation. Get them by invoking a local method.167 *168 * Here also invoke a superclass method169 */170 config = addServletContext(config, context);171 160 172 161 return config; … … 177 166 * method. 178 167 * 168 * In this method, exceptions to the normal web application context can 169 * be made. 170 * 179 171 * @return 180 172 */ 181 public static VloConfig WebAppTest() {173 public static VloConfig testWebApp() { 182 174 if (config == null) { 183 175 // the configuration is not there yet; create it now … … 185 177 } 186 178 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 191 181 config = (VloConfig) read(config); 192 182 … … 607 597 608 598 /** 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 * 609 605 * Add properties of the {@literal servlet's} context<br><br> 610 * 606 * 611 607 * Keep the properties in the static context of the WebAppConfig class, next 612 608 * to the members representing the values in WebAppConfig.xml file.<br><br> … … 616 612 * @return the static WebAppConfig member 617 613 */ 618 static VloConfig addServletContext(VloConfig config, ServletContext context) {614 public static VloConfig addServletContext(VloConfig config, ServletContext context) { 619 615 620 616 // 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 21 21 public void setUp() { 22 22 WicketTester wicketTester; 23 testConfig = VloConfig. WebAppTest();23 testConfig = VloConfig.testWebApp(); 24 24 wicketTester = new WicketTester(new VloApplication(testConfig)); 25 25 }
Note: See TracChangeset
for help on using the changeset viewer.