Difference between revisions of "Code Discussion 2008-11-03"

From MPDLMediaWiki
Jump to navigation Jump to search
(Creation)
 
 
(10 intermediate revisions by 2 users not shown)
Line 4: Line 4:
=PropertyReader=
=PropertyReader=


[[Java_Exception_Handling|see here]]
== Current situation ==
* [https://subversion.mpdl.mpg.de/repos/common/trunk/common_services/framework_access/src/main/java/de/mpg/escidoc/services/framework/PropertyReader.java PropertyReader]
<code>
    public static String getProperty(String key) throws IOException, URISyntaxException
    {
        // First check system properties
        String value = System.getProperty(key);
        if (value != null)
        {
            return value;
        }
        // Check properties file
        if (properties == null)
        {
            loadProperties();
        }
        // Get the property
        value = properties.getProperty(key);
        return value;
    }
</code>
 
* Static helper class
* loads properties from solution-specific properties file (e.g. pubman.properties, faces.properties)
 
== Problem ==
 
If more than one solution is deployed on the same JBoss instance, the following happens:
* When the first solution reads a property, the appropriate properties file is loaded.
* When another solution reads a property that was already defined by the first solution, that property is given back (although it may have a wrong value), i.e. that solution does not work correctly.
* When another solution reads a property that wasn't already defined by the first solution, the according properties file is also read in overwriting the properties that exist in both files. I.e. the first solution doesn't work correctly.
 
* Similar issue with [https://subversion.mpdl.mpg.de/repos/common/trunk/common_services/framework_access/src/main/java/de/mpg/escidoc/services/framework/ServiceLocator.java ServiceLocator].
 
== Ideas ==
* Only use unambiguous properties
** But: e.g. framework url
* Define properties set per solution (How?)
 
== Solution ==


==Next topic==
==Next topic==
Line 10: Line 49:
[[Code_Discussion_2008-11-10 | Next topic 2008-11-10]]
[[Code_Discussion_2008-11-10 | Next topic 2008-11-10]]


[[Category:ESciDoc-Team|Code 2008-11-03]]
[[Category:Code_Discussion|Code 2008-11-03]]

Latest revision as of 14:40, 25 April 2012

Previous topic[edit]

Previous topic 2008-10-20

PropertyReader[edit]

Current situation[edit]

   public static String getProperty(String key) throws IOException, URISyntaxException
   {
       // First check system properties
       String value = System.getProperty(key);
       if (value != null)
       {
           return value;
       }
       // Check properties file
       if (properties == null)
       {
           loadProperties();
       }
       // Get the property
       value = properties.getProperty(key);
       return value;
   }

  • Static helper class
  • loads properties from solution-specific properties file (e.g. pubman.properties, faces.properties)

Problem[edit]

If more than one solution is deployed on the same JBoss instance, the following happens:

  • When the first solution reads a property, the appropriate properties file is loaded.
  • When another solution reads a property that was already defined by the first solution, that property is given back (although it may have a wrong value), i.e. that solution does not work correctly.
  • When another solution reads a property that wasn't already defined by the first solution, the according properties file is also read in overwriting the properties that exist in both files. I.e. the first solution doesn't work correctly.

Ideas[edit]

  • Only use unambiguous properties
    • But: e.g. framework url
  • Define properties set per solution (How?)

Solution[edit]

Next topic[edit]

Next topic 2008-11-10