Ignore:
Timestamp:
03/07/13 08:48:58 (11 years ago)
Author:
keeloo
Message:

Removed VloConfig?.get() and made the member variables static themselves. Cleaned up the VloConfig? class.

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  
    1717 * the VLO web application.
    1818 *
    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
    3326 * declaration, like this:
    3427 *
    3528 * {@literal @element}<br> {@literal parameterMember}<br><br>
    3629 *
    37  * The xml file used should in this case contain a definition like
     30 * The XML should in this case contain a definition like
    3831 *
    3932 * {@literal<parameterMember>} "the value of the
     
    4134 *
    4235 * 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>
    5051 *
    51  * WebAppConfig.get().getSomeParameter();<br><br>
     52 * in any scope, also the scope from which the read message was send.
    5253 *
    53  * will return the configuration, and getSomeParameter() will return a
    54  * specific parameter in it.
    55  *
    5654 * Through the get and set methods, the application is indifferent to the origin
    5755 * of a parameter: you can get and set the value of a parameter without having
    5856 * to worry about how the parameter was defined originally.
    5957 *
    60  * By invoking the read method, and by querying the context, the web
    61  * application, on initialization, determines which definition to use.
    62  *
    6358 * Also, the get and set methods allow for a modification of the original value
    6459 * of the parameter. For example, if the format of a parameter changes, this
     
    128123
    129124    /**
     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    /**
    130142     * Read the configuration from an XML file.
    131143     *
     
    138150     */
    139151    public static VloConfig readConfig(String fileName) {
     152       
     153        // may it is safe to first expand the name a litte bit more
     154
    140155        if (config == null) {
    141156            // the configuration is not there yet; create it now
     
    152167     * Read the configuration from an XML file.
    153168     *
    154      * Invole this method instead of readConfig() if you want to change
     169     * Invoke this method instead of readConfig() if you want to change
    155170     * the parameters because the application is run in a context different
    156171     * from the usual one. Here, modifications of the parameters inspired on
    157172     * the difference in context can be made.
    158173     *
    159      * A web application can serve as a tipical example of a difference in
     174     * A web application can serve as a typical example of a difference in
    160175     * context: the application itself runs in a web server container, while the
    161176     * tests associated with the web application will be run outside this
     
    167182     */
    168183    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);
    176186       
    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
    188189        return config;
    189190    }
     
    200201   
    201202    @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;
    206207   
    207208    @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() {
    211212        return dataRoots;
    212213    }
    213214   
    214215    @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 = "";
    231232   
    232233    /**
     
    235236     */
    236237    @Element
    237     private String nationalProjectMapping = "";
     238    private static String nationalProjectMapping = "";
    238239   
    239240    /**
     
    261262     */
    262263    @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 = " ";
    279280
    280281    /**
     
    294295     * @param dataRoots the value
    295296     */
    296     public void setDataRoots(List<DataRoot> dataRoots) {
    297         this.dataRoots = dataRoots;
     297    public static void setDataRoots(List<DataRoot> param) {
     298        dataRoots = param;
    298299    }
    299300
     
    306307     * @return the value
    307308     */
    308     public void setDeleteAllFirst(boolean deleteAllFirst) {
    309         this.deleteAllFirst = deleteAllFirst;
     309    public static void setDeleteAllFirst(boolean param) {
     310        deleteAllFirst = param;
    310311    }
    311312
     
    318319     * @return the value
    319320     */
    320     public boolean isDeleteAllFirst() {
     321    public static boolean isDeleteAllFirst() {
    321322        return deleteAllFirst;
    322323    }
     
    330331     * @param printMapping the value
    331332     */
    332     public void setPrintMapping(boolean printMapping) {
    333         this.printMapping = printMapping;
     333    public static void setPrintMapping(boolean param) {
     334        printMapping = param;
    334335    }
    335336
     
    342343     * @return the value
    343344     */
    344     public boolean isPrintMapping() {
     345    public static boolean isPrintMapping() {
    345346        return printMapping;
    346347    }
     
    354355     * @return the value
    355356     */
    356     public String getVloHomeLink() {
     357    public static String getVloHomeLink() {
    357358        return vloHomeLink;
    358359    }
     
    366367     * @param vloHomeLink the value
    367368     */
    368     public void setVloHomeLink(String link) {
    369         this.vloHomeLink = link;
     369    public static void setVloHomeLink(String param) {
     370        vloHomeLink = param;
    370371    }
    371372
     
    378379     * @return the value
    379380     */
    380     public String getSolrUrl() {
     381    static public String getSolrUrl() {
    381382        return solrUrl;
    382383    }
     
    390391     * @param url the parameter
    391392     */
    392     public void setSolrUrl(String url) {
    393         this.solrUrl = url;
     393    public static void setSolrUrl(String param) {
     394        solrUrl = param;
    394395    }
    395396
     
    402403     * @return the value
    403404     */
    404     public String getComponentRegistryProfileSchema(String id) {
     405    public static String getComponentRegistryProfileSchema(String id) {
    405406        return profileSchemaUrl.replace("{PROFILE_ID}", id);
    406407    }
     
    414415     * @param profileId the value
    415416     */
    416     public void setProfileSchemaUrl(String url) {
    417         this.profileSchemaUrl = url;
     417    public static void setProfileSchemaUrl(String param) {
     418        profileSchemaUrl = param;
    418419    }
    419420
     
    426427     * @return the value
    427428     */
    428     public String getComponentRegistryRESTURL() {
     429    public static String getComponentRegistryRESTURL() {
    429430        return componentRegistryRESTURL;
    430431    }
     
    438439     * @param componentRegistryRESTURL the value
    439440     */
    440     public void setComponentRegistryRESTURL(String url) {
    441         this.componentRegistryRESTURL = url;
     441    public static void setComponentRegistryRESTURL(String param) {
     442        componentRegistryRESTURL = param;
    442443    }
    443444
     
    450451     * @return the value
    451452     */
    452     public String getHandleServerUrl() {
     453    public static String getHandleServerUrl() {
    453454        return handleServerUrl;
    454455    }
     
    462463     * @param handleServerUrl the value
    463464     */
    464     public void setHandleServerUrl(String url) {
    465         this.handleServerUrl = url;
     465    public static void setHandleServerUrl(String param) {
     466        handleServerUrl = param;
    466467    }
    467468
     
    474475     * @param imdiBrowserUrl the value
    475476     */
    476     public void setIMDIBrowserUrl(String url) {
    477         this.imdiBrowserUrl = url;
     477    public static void setIMDIBrowserUrl(String param) {
     478        imdiBrowserUrl = param;
    478479    }
    479480
     
    485486     * @return the value
    486487     */
    487     public String getIMDIBrowserUrl(String handle) {
     488    public static String getIMDIBrowserUrl(String handle) {
    488489        String result;
    489490        try {
     
    503504     * @return the value
    504505     */
    505     public void setFederatedContentSearchUrl(String url) {
    506         this.FederatedContentSearchUrl = url;
     506    public static void setFederatedContentSearchUrl(String param) {
     507        FederatedContentSearchUrl = param;
    507508    }
    508509
     
    515516     * @param FederatedContentSearchUrl the value
    516517     */
    517     public String getFederatedContentSearchUrl() {
     518    public static String getFederatedContentSearchUrl() {
    518519        return FederatedContentSearchUrl;
    519520    }
     
    527528     * @param nationalProjectMapping the value
    528529     */
    529     public void setNationalProjectMapping(String mapping) {
    530         this.nationalProjectMapping = mapping;
    531     }
     530    public static void setNationalProjectMapping(String param) {
     531        nationalProjectMapping = param;
     532    }
     533   
    532534
    533535    /**
     
    539541     * @return the value
    540542     */
    541     public String getNationalProjectMapping() {
     543    public static String getNationalProjectMapping() {
    542544        return nationalProjectMapping;
    543545    }
     
    551553     * @return the value
    552554     */
    553     public String[] getFacetFields() {
     555    public static String[] getFacetFields() {
    554556        return facetFields;
    555557    }
     
    563565     * @param facetFields the value, a list of facet fields
    564566     */
    565     public void setFacetFields(String[] fields) {
    566         this.facetFields = fields;
     567    public static void setFacetFields(String[] param) {
     568        facetFields = param;
    567569    }
    568570
     
    575577     * @return the value
    576578     */
    577     public String getCountryComponentUrl() {
     579    public static String getCountryComponentUrl() {
    578580        return countryComponentUrl;
    579581    }
     
    587589     * @param countryComponentUrl the value
    588590     */
    589     public void setCountryComponentUrl(String url) {
    590         this.countryComponentUrl = url;
     591    public static void setCountryComponentUrl(String param) {
     592        countryComponentUrl = param;
    591593    }
    592594
     
    599601     * @return the value
    600602     */
    601     public String getLanguage2LetterCodeComponentUrl() {
     603    public static String getLanguage2LetterCodeComponentUrl() {
    602604        return language2LetterCodeComponentUrl;
    603605    }
     
    611613     * @param language2LetterCodeComponentUrl the value
    612614     */
    613     public void setLanguage2LetterCodeComponentUrl(String url) {
    614         this.language2LetterCodeComponentUrl = url;
     615    public static void setLanguage2LetterCodeComponentUrl(String param) {
     616        language2LetterCodeComponentUrl = param;
    615617    }
    616618
     
    623625     * @return the value
    624626     */
    625     public String getLanguage3LetterCodeComponentUrl() {
     627    public static String getLanguage3LetterCodeComponentUrl() {
    626628        return language3LetterCodeComponentUrl;
    627629    }
     
    635637     * @param language3LetterCodeComponentUrl the value
    636638     */
    637     public void setLanguage3LetterCodeComponentUrl(String url) {
    638         this.language3LetterCodeComponentUrl = url;
     639    public static void setLanguage3LetterCodeComponentUrl(String param) {
     640        language3LetterCodeComponentUrl = param;
    639641    }
    640642
     
    647649     * @return the value
    648650     */
    649     public String getSilToISO639CodesUrl() {
     651    public static String getSilToISO639CodesUrl() {
    650652        return silToISO639CodesUrl;
    651653    }
     
    659661     * @param silToISO639CodesUrl the value
    660662     */
    661     public void setSilToISO639CodesUrl(String url) {
    662         this.silToISO639CodesUrl = url;
     663    public static void setSilToISO639CodesUrl(String param) {
     664        silToISO639CodesUrl = param;
    663665    }
    664666}
Note: See TracChangeset for help on using the changeset viewer.