You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ad...@apache.org on 2008/11/07 20:47:05 UTC
svn commit: r712237 - in /ofbiz/trunk/framework:
base/src/org/ofbiz/base/util/UtilProperties.java
base/src/org/ofbiz/base/util/collections/FlexibleProperties.java
webapp/src/org/ofbiz/webapp/view/VelocityViewHandler.java
Author: adrianc
Date: Fri Nov 7 11:47:04 2008
New Revision: 712237
URL: http://svn.apache.org/viewvc?rev=712237&view=rev
Log:
Deprecated one more unnecessary class.
Modified:
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java
ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleProperties.java
ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/VelocityViewHandler.java
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java?rev=712237&r1=712236&r2=712237&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java Fri Nov 7 11:47:04 2008
@@ -41,7 +41,6 @@
import org.ofbiz.base.location.FlexibleLocation;
import org.ofbiz.base.util.cache.UtilCache;
-import org.ofbiz.base.util.collections.FlexibleProperties;
import org.ofbiz.base.util.collections.ResourceBundleMapWrapper;
import org.ofbiz.base.util.string.FlexibleStringExpander;
import org.w3c.dom.Document;
@@ -66,12 +65,12 @@
/** An instance of the generic cache for storing the non-locale-specific properties.
* Each FlexibleProperties instance is keyed by the resource String.
*/
- protected static UtilCache<String, FlexibleProperties> resourceCache = new UtilCache<String, FlexibleProperties>("properties.UtilPropertiesResourceCache");
+ protected static UtilCache<String, Properties> resourceCache = new UtilCache<String, Properties>("properties.UtilPropertiesResourceCache");
/** An instance of the generic cache for storing the non-locale-specific properties.
* Each FlexibleProperties instance is keyed by the file's URL.
*/
- protected static UtilCache<String, FlexibleProperties> urlCache = new UtilCache<String, FlexibleProperties>("properties.UtilPropertiesUrlCache");
+ protected static UtilCache<String, Properties> urlCache = new UtilCache<String, Properties>("properties.UtilPropertiesUrlCache");
public static final Locale LOCALE_ROOT = new Locale("", "", "");
@@ -164,14 +163,14 @@
return null;
}
String cacheKey = resource.replace(".properties", "");
- FlexibleProperties properties = resourceCache.get(cacheKey);
+ Properties properties = resourceCache.get(cacheKey);
if (properties == null) {
try {
URL url = UtilURL.fromResource(resource);
if (url == null)
return null;
- properties = FlexibleProperties.makeFlexibleProperties(url);
+ properties = getProperties(url);
resourceCache.put(cacheKey, properties);
} catch (MissingResourceException e) {
Debug.log(e.getMessage(), module);
@@ -189,15 +188,16 @@
* @return The properties file
*/
public static Properties getProperties(URL url) {
- if (url == null)
+ if (url == null) {
return null;
- FlexibleProperties properties = urlCache.get(url.toString());
-
+ }
+ Properties properties = urlCache.get(url.toString());
if (properties == null) {
try {
- properties = FlexibleProperties.makeFlexibleProperties(url);
+ properties = new Properties();
+ properties.load(url.openStream());
urlCache.put(url.toString(), properties);
- } catch (MissingResourceException e) {
+ } catch (Exception e) {
Debug.log(e.getMessage(), module);
}
}
Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleProperties.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleProperties.java?rev=712237&r1=712236&r2=712237&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleProperties.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/collections/FlexibleProperties.java Fri Nov 7 11:47:04 2008
@@ -32,7 +32,7 @@
/**
* Simple Class for flexibly working with properties files
- *
+ * @deprecated Use java.util.Properties
*/
public class FlexibleProperties extends Properties implements Serializable {
Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/VelocityViewHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/VelocityViewHandler.java?rev=712237&r1=712236&r2=712237&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/VelocityViewHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/VelocityViewHandler.java Fri Nov 7 11:47:04 2008
@@ -29,7 +29,7 @@
import javax.servlet.http.HttpServletResponse;
import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.collections.FlexibleProperties;
+import org.ofbiz.base.util.UtilProperties;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
@@ -65,18 +65,13 @@
ve.setProperty("runtime.log.logsystem.log4j.category", module);
Properties props = null;
- URL propsURL = null;
-
try {
- propsURL = context.getResource("/WEB-INF/velocity.properties");
+ props = UtilProperties.getProperties(context.getResource("/WEB-INF/velocity.properties"));
+ Debug.logInfo("[VelocityViewHandler.init] : Loaded /WEB-INF/velocity.properties", module);
} catch (MalformedURLException e) {
Debug.logError(e, module);
}
-
- if (propsURL != null) {
- props = new FlexibleProperties(propsURL);
- Debug.logWarning("[VelocityViewHandler.init] : Loaded /WEB-INF/velocity.properties", module);
- } else {
+ if (props == null) {
props = new Properties();
Debug.logWarning("[VelocityViewHandler.init] : Cannot load /WEB-INF/velocity.properties. " +
"Using default properties.", module);