Changeset 2659 for vlo/branches/vlo-2.13-param/vlo_importer/src/main/java/eu/clarin/cmdi/vlo/config/VloConfig.java
- Timestamp:
- 03/07/13 08:48:58 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-2.13-param/vlo_importer/src/main/java/eu/clarin/cmdi/vlo/config/VloConfig.java
r2657 r2659 17 17 * the VLO web application. 18 18 * 19 * A member is annotated by prepending @element. When the VloConfig class is 20 * reflected into the Simple framework, the framework will assign the values 21 * it finds in the VloConfig.xml file to the members in the VloConfig class. 22 * 23 * By invoking the get method defined in the VloConfig class, a VLO application 24 * can query the value of a parameter. If you just instantiate an instance of 25 * the VloConfig class, the members will be assigned values from the packaged 26 * the VloConfig.xml file. 27 * 28 * Alternatively, the readConfig methods will let you specify an xml file of 29 * your choice. 30 * 31 * Whenever you like to add a parameter the VLO configuration, add a member 32 * with the appropriate name and type, and prepend an at aign to the 19 * A member is annotated by prepending {@literal @element}. When the VloConfig 20 * class is reflected into the Simple framework, the framework will assign the 21 * values it finds in the VloConfig.xml file to the members in the VloConfig 22 * class. 23 * 24 * Whenever you need to add a parameter the VLO configuration, add a member 25 * with the appropriate name and type, and prepend an at sign to the 33 26 * declaration, like this: 34 27 * 35 28 * {@literal @element}<br> {@literal parameterMember}<br><br> 36 29 * 37 * The xml file usedshould in this case contain a definition like30 * The XML should in this case contain a definition like 38 31 * 39 32 * {@literal<parameterMember>} "the value of the … … 41 34 * 42 35 * If you want to add a type of member that is not included in VloConfig class 43 * yet, or if you are looking for more information on the framework, please refer 44 * to <url> <br><br> 45 * 46 * The parameters are stored statically. This means that after you have create 47 * a VloConfig object, you can reference a parameter outside the scope in which 48 * the object was originally created. So after a VloConfig object has been 49 * created, get() in 36 * yet, or if you are looking for more information on the framework, please 37 * refer to <url> <br><br> 38 * 39 * In the VloConfig class, the parameters are stored statically. This means that 40 * after 41 * 42 * {@literal VloConfig.read();}<br><br> 43 * 44 * or 45 * 46 * {@literal VloConfig.read();}<br><br> 47 * 48 * has been issued from a certain context, you can reference a parameter by 49 * 50 * {@literal WebAppConfig.getSomeParameter();}<br><br> 50 51 * 51 * WebAppConfig.get().getSomeParameter();<br><br>52 * in any scope, also the scope from which the read message was send. 52 53 * 53 * will return the configuration, and getSomeParameter() will return a54 * specific parameter in it.55 *56 54 * Through the get and set methods, the application is indifferent to the origin 57 55 * of a parameter: you can get and set the value of a parameter without having 58 56 * to worry about how the parameter was defined originally. 59 57 * 60 * By invoking the read method, and by querying the context, the web61 * application, on initialization, determines which definition to use.62 *63 58 * Also, the get and set methods allow for a modification of the original value 64 59 * of the parameter. For example, if the format of a parameter changes, this … … 128 123 129 124 /** 125 * Read the configuration from the packaged XML configuration file. 126 * 127 * @param fileName the name of the file to read the configuration from 128 * 129 * @return the configuration 130 */ 131 public static VloConfig readPackagedConfig() { 132 133 // set the name of the packaged configuration file 134 String fileName = "/VloConfig"; 135 136 config = VloConfig.readConfig (fileName); 137 138 return config; 139 } 140 141 /** 130 142 * Read the configuration from an XML file. 131 143 * … … 138 150 */ 139 151 public static VloConfig readConfig(String fileName) { 152 153 // may it is safe to first expand the name a litte bit more 154 140 155 if (config == null) { 141 156 // the configuration is not there yet; create it now … … 152 167 * Read the configuration from an XML file. 153 168 * 154 * Invo le this method instead of readConfig() if you want to change169 * Invoke this method instead of readConfig() if you want to change 155 170 * the parameters because the application is run in a context different 156 171 * from the usual one. Here, modifications of the parameters inspired on 157 172 * the difference in context can be made. 158 173 * 159 * A web application can serve as a t ipical example of a difference in174 * A web application can serve as a typical example of a difference in 160 175 * context: the application itself runs in a web server container, while the 161 176 * tests associated with the web application will be run outside this … … 167 182 */ 168 183 public static VloConfig readTestConfig(String fileName) { 169 if (config == null) { 170 // the configuration is not there yet; create it now 171 config = new VloConfig(); 172 } 173 174 // get the XML file configuration from the file by invoking ... 175 config = (VloConfig) read(fileName, config); 184 185 config = VloConfig.readConfig (fileName); 176 186 177 // modify the parameters here 178 179 return config; 180 } 181 182 /** 183 * Return the reference to the configuration 184 * 185 * @return the configuration 186 */ 187 public static VloConfig get (){ 187 // modify the configuration here 188 188 189 return config; 189 190 } … … 200 201 201 202 @Element // directive for Simple 202 private boolean deleteAllFirst = false;203 204 @Element 205 private boolean printMapping = false;203 private static boolean deleteAllFirst = false; 204 205 @Element 206 private static boolean printMapping = false; 206 207 207 208 @ElementList // directive for Simple 208 private List<DataRoot> dataRoots;209 210 public List<DataRoot> getDataRoots() {209 private static List<DataRoot> dataRoots; 210 211 public static List<DataRoot> getDataRoots() { 211 212 return dataRoots; 212 213 } 213 214 214 215 @Element 215 private String vloHomeLink = "";216 217 @Element 218 private String solrUrl = "";219 220 @Element 221 private String profileSchemaUrl = "";222 223 @Element 224 private String componentRegistryRESTURL = "";225 226 @Element 227 private String handleServerUrl = "";228 229 @Element 230 private String imdiBrowserUrl = "";216 private static String vloHomeLink = ""; 217 218 @Element 219 private static String solrUrl = ""; 220 221 @Element 222 private static String profileSchemaUrl = ""; 223 224 @Element 225 private static String componentRegistryRESTURL = ""; 226 227 @Element 228 private static String handleServerUrl = ""; 229 230 @Element 231 private static String imdiBrowserUrl = ""; 231 232 232 233 /** … … 235 236 */ 236 237 @Element 237 private String nationalProjectMapping = "";238 private static String nationalProjectMapping = ""; 238 239 239 240 /** … … 261 262 */ 262 263 @ElementArray(entry = "facetField") 263 private String[] facetFields = {"", "", ""};264 265 @Element 266 private String countryComponentUrl = "";267 268 @Element 269 private String language2LetterCodeComponentUrl = "";270 271 @Element 272 private String language3LetterCodeComponentUrl = "";273 274 @Element 275 private String silToISO639CodesUrl = "";276 277 @Element 278 private String FederatedContentSearchUrl = " ";264 private static String[] facetFields = {"", "", ""}; 265 266 @Element 267 private static String countryComponentUrl = ""; 268 269 @Element 270 private static String language2LetterCodeComponentUrl = ""; 271 272 @Element 273 private static String language3LetterCodeComponentUrl = ""; 274 275 @Element 276 private static String silToISO639CodesUrl = ""; 277 278 @Element 279 private static String FederatedContentSearchUrl = " "; 279 280 280 281 /** … … 294 295 * @param dataRoots the value 295 296 */ 296 public void setDataRoots(List<DataRoot> dataRoots) {297 this.dataRoots = dataRoots;297 public static void setDataRoots(List<DataRoot> param) { 298 dataRoots = param; 298 299 } 299 300 … … 306 307 * @return the value 307 308 */ 308 public void setDeleteAllFirst(boolean deleteAllFirst) {309 this.deleteAllFirst = deleteAllFirst;309 public static void setDeleteAllFirst(boolean param) { 310 deleteAllFirst = param; 310 311 } 311 312 … … 318 319 * @return the value 319 320 */ 320 public boolean isDeleteAllFirst() {321 public static boolean isDeleteAllFirst() { 321 322 return deleteAllFirst; 322 323 } … … 330 331 * @param printMapping the value 331 332 */ 332 public void setPrintMapping(boolean printMapping) {333 this.printMapping = printMapping;333 public static void setPrintMapping(boolean param) { 334 printMapping = param; 334 335 } 335 336 … … 342 343 * @return the value 343 344 */ 344 public boolean isPrintMapping() {345 public static boolean isPrintMapping() { 345 346 return printMapping; 346 347 } … … 354 355 * @return the value 355 356 */ 356 public String getVloHomeLink() {357 public static String getVloHomeLink() { 357 358 return vloHomeLink; 358 359 } … … 366 367 * @param vloHomeLink the value 367 368 */ 368 public void setVloHomeLink(String link) {369 this.vloHomeLink = link;369 public static void setVloHomeLink(String param) { 370 vloHomeLink = param; 370 371 } 371 372 … … 378 379 * @return the value 379 380 */ 380 public String getSolrUrl() {381 static public String getSolrUrl() { 381 382 return solrUrl; 382 383 } … … 390 391 * @param url the parameter 391 392 */ 392 public void setSolrUrl(String url) {393 this.solrUrl = url;393 public static void setSolrUrl(String param) { 394 solrUrl = param; 394 395 } 395 396 … … 402 403 * @return the value 403 404 */ 404 public String getComponentRegistryProfileSchema(String id) {405 public static String getComponentRegistryProfileSchema(String id) { 405 406 return profileSchemaUrl.replace("{PROFILE_ID}", id); 406 407 } … … 414 415 * @param profileId the value 415 416 */ 416 public void setProfileSchemaUrl(String url) {417 this.profileSchemaUrl = url;417 public static void setProfileSchemaUrl(String param) { 418 profileSchemaUrl = param; 418 419 } 419 420 … … 426 427 * @return the value 427 428 */ 428 public String getComponentRegistryRESTURL() {429 public static String getComponentRegistryRESTURL() { 429 430 return componentRegistryRESTURL; 430 431 } … … 438 439 * @param componentRegistryRESTURL the value 439 440 */ 440 public void setComponentRegistryRESTURL(String url) {441 this.componentRegistryRESTURL = url;441 public static void setComponentRegistryRESTURL(String param) { 442 componentRegistryRESTURL = param; 442 443 } 443 444 … … 450 451 * @return the value 451 452 */ 452 public String getHandleServerUrl() {453 public static String getHandleServerUrl() { 453 454 return handleServerUrl; 454 455 } … … 462 463 * @param handleServerUrl the value 463 464 */ 464 public void setHandleServerUrl(String url) {465 this.handleServerUrl = url;465 public static void setHandleServerUrl(String param) { 466 handleServerUrl = param; 466 467 } 467 468 … … 474 475 * @param imdiBrowserUrl the value 475 476 */ 476 public void setIMDIBrowserUrl(String url) {477 this.imdiBrowserUrl = url;477 public static void setIMDIBrowserUrl(String param) { 478 imdiBrowserUrl = param; 478 479 } 479 480 … … 485 486 * @return the value 486 487 */ 487 public String getIMDIBrowserUrl(String handle) {488 public static String getIMDIBrowserUrl(String handle) { 488 489 String result; 489 490 try { … … 503 504 * @return the value 504 505 */ 505 public void setFederatedContentSearchUrl(String url) {506 this.FederatedContentSearchUrl = url;506 public static void setFederatedContentSearchUrl(String param) { 507 FederatedContentSearchUrl = param; 507 508 } 508 509 … … 515 516 * @param FederatedContentSearchUrl the value 516 517 */ 517 public String getFederatedContentSearchUrl() {518 public static String getFederatedContentSearchUrl() { 518 519 return FederatedContentSearchUrl; 519 520 } … … 527 528 * @param nationalProjectMapping the value 528 529 */ 529 public void setNationalProjectMapping(String mapping) { 530 this.nationalProjectMapping = mapping; 531 } 530 public static void setNationalProjectMapping(String param) { 531 nationalProjectMapping = param; 532 } 533 532 534 533 535 /** … … 539 541 * @return the value 540 542 */ 541 public String getNationalProjectMapping() {543 public static String getNationalProjectMapping() { 542 544 return nationalProjectMapping; 543 545 } … … 551 553 * @return the value 552 554 */ 553 public String[] getFacetFields() {555 public static String[] getFacetFields() { 554 556 return facetFields; 555 557 } … … 563 565 * @param facetFields the value, a list of facet fields 564 566 */ 565 public void setFacetFields(String[] fields) {566 this.facetFields = fields;567 public static void setFacetFields(String[] param) { 568 facetFields = param; 567 569 } 568 570 … … 575 577 * @return the value 576 578 */ 577 public String getCountryComponentUrl() {579 public static String getCountryComponentUrl() { 578 580 return countryComponentUrl; 579 581 } … … 587 589 * @param countryComponentUrl the value 588 590 */ 589 public void setCountryComponentUrl(String url) {590 this.countryComponentUrl = url;591 public static void setCountryComponentUrl(String param) { 592 countryComponentUrl = param; 591 593 } 592 594 … … 599 601 * @return the value 600 602 */ 601 public String getLanguage2LetterCodeComponentUrl() {603 public static String getLanguage2LetterCodeComponentUrl() { 602 604 return language2LetterCodeComponentUrl; 603 605 } … … 611 613 * @param language2LetterCodeComponentUrl the value 612 614 */ 613 public void setLanguage2LetterCodeComponentUrl(String url) {614 this.language2LetterCodeComponentUrl = url;615 public static void setLanguage2LetterCodeComponentUrl(String param) { 616 language2LetterCodeComponentUrl = param; 615 617 } 616 618 … … 623 625 * @return the value 624 626 */ 625 public String getLanguage3LetterCodeComponentUrl() {627 public static String getLanguage3LetterCodeComponentUrl() { 626 628 return language3LetterCodeComponentUrl; 627 629 } … … 635 637 * @param language3LetterCodeComponentUrl the value 636 638 */ 637 public void setLanguage3LetterCodeComponentUrl(String url) {638 this.language3LetterCodeComponentUrl = url;639 public static void setLanguage3LetterCodeComponentUrl(String param) { 640 language3LetterCodeComponentUrl = param; 639 641 } 640 642 … … 647 649 * @return the value 648 650 */ 649 public String getSilToISO639CodesUrl() {651 public static String getSilToISO639CodesUrl() { 650 652 return silToISO639CodesUrl; 651 653 } … … 659 661 * @param silToISO639CodesUrl the value 660 662 */ 661 public void setSilToISO639CodesUrl(String url) {662 this.silToISO639CodesUrl = url;663 public static void setSilToISO639CodesUrl(String param) { 664 silToISO639CodesUrl = param; 663 665 } 664 666 }
Note: See TracChangeset
for help on using the changeset viewer.