svn commit: r963612 - /struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java

2010-07-13 Thread lukaszlenart
Author: lukaszlenart
Date: Tue Jul 13 07:10:06 2010
New Revision: 963612

URL: http://svn.apache.org/viewvc?rev=963612&view=rev
Log:
Code clean up and refactoring

Modified:

struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java?rev=963612&r1=963611&r2=963612&view=diff
==
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/template/BaseTemplateEngine.java
 Tue Jul 13 07:10:06 2010
@@ -21,6 +21,10 @@
 
 package org.apache.struts2.components.template;
 
+import com.opensymphony.xwork2.util.ClassLoaderUtil;
+import com.opensymphony.xwork2.util.logging.Logger;
+import com.opensymphony.xwork2.util.logging.LoggerFactory;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -30,10 +34,6 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
-import com.opensymphony.xwork2.util.ClassLoaderUtil;
-import com.opensymphony.xwork2.util.logging.Logger;
-import com.opensymphony.xwork2.util.logging.LoggerFactory;
-
 /**
  * Base class for template engines.
  */
@@ -41,64 +41,105 @@ public abstract class BaseTemplateEngine
 
 private static final Logger LOG = 
LoggerFactory.getLogger(BaseTemplateEngine.class);
 
-/** The default theme properties file name. Default is 'theme.properties' 
*/
+/**
+ * The default theme properties file name. Default is 'theme.properties'
+ */
 public static final String DEFAULT_THEME_PROPERTIES_FILE_NAME = 
"theme.properties";
 
 final Map themeProps = new HashMap();
 
 public Map getThemeProps(Template template) {
 synchronized (themeProps) {
-Properties props = (Properties) 
themeProps.get(template.getTheme());
+Properties props = themeProps.get(template.getTheme());
 if (props == null) {
-String propName = template.getDir() + "/" + 
template.getTheme() + "/"+getThemePropertiesFileName();
-
-// WW-1292
-// let's try getting it from the filesystem
-File propFile = new File(propName);
-InputStream is = null;
-try {
-if (propFile.exists()) {
-is = new FileInputStream(propFile);
-}
-}
-catch(FileNotFoundException e) {
-LOG.warn("Unable to find file in filesystem 
["+propFile.getAbsolutePath()+"]");
-}
-
-if (is == null) {
-// if its not in filesystem. let's try the classpath
-is = ClassLoaderUtil.getResourceAsStream(propName, 
getClass());
-}
-
-props = new Properties();
-
-if (is != null) {
-try {
-props.load(is);
-} catch (IOException e) {
-LOG.error("Could not load " + propName, e);
-} finally {
-try {
-is.close();
-} catch(IOException io) {
-LOG.warn("Unable to close input stream", io);
-}
-}
-}
-
+props = readNewProperties(template);
 themeProps.put(template.getTheme(), props);
 }
-
 return props;
 }
 }
 
+private Properties readNewProperties(Template template) {
+String propName = buildPropertyFilename(template);
+return loadProperties(propName);
+}
+
+private Properties loadProperties(String propName) {
+InputStream is = readProperty(propName);
+Properties props = new Properties();
+if (is != null) {
+tryToLoadPropertiesFromStream(props, propName, is);
+}
+return props;
+}
+
+private InputStream readProperty(String propName) {
+InputStream is = tryReadingPropertyFileFromFileSystem(propName);
+if (is == null) {
+is = readPropertyFromClasspath(propName);
+}
+return is;
+}
+
+/**
+ * if its not in filesystem. let's try the classpath
+ */
+private InputStream readPropertyFromClasspath(String propName) {
+return ClassLoaderUtil.getResourceAsStream(propName, getClass());
+}
+
+private void tryToLoadPropertiesFromStream(Properties props, String 
propName, InputStream is) {
+try {
+props.lo

[CONF] Confluence Changes in the last 24 hours

2010-07-13 Thread confluence
This is a daily summary of all recent changes in Confluence.

-
Updated Spaces:
-


Apache ACE (https://cwiki.apache.org/confluence/display/ACE)

Pages
-
Board Report (2010-07) created by marrs (03:23 AM)
https://cwiki.apache.org/confluence/display/ACE/Board+Report+%282010-07%29



Apache ActiveMQ (https://cwiki.apache.org/confluence/display/ACTIVEMQ)

Pages
-
Apache ActiveMQ Board Report - July 2010 created by chirino (09:31 AM)
https://cwiki.apache.org/confluence/display/ACTIVEMQ/Apache+ActiveMQ+Board+Report+-+July+2010



Apache Avro (https://cwiki.apache.org/confluence/display/AVRO)

Pages
-
How To Contribute edited by  plinehan  (08:48 PM)
https://cwiki.apache.org/confluence/display/AVRO/How+To+Contribute



Apache Camel (https://cwiki.apache.org/confluence/display/CAMEL)

Pages
-
DataSet edited by  cmoulliard  (04:02 AM)
https://cwiki.apache.org/confluence/display/CAMEL/DataSet

Simple edited by  davsclaus  (03:17 AM)
https://cwiki.apache.org/confluence/display/CAMEL/Simple



Apache Geronimo v2.2 (https://cwiki.apache.org/confluence/display/GMOxDOC22)

Pages
-
EJB failover edited by  chirun...@gmail.com  (02:08 AM)
https://cwiki.apache.org/confluence/display/GMOxDOC22/EJB+failover

JMS clustering in Geronimo edited by  chirun...@gmail.com  (02:04 AM)
https://cwiki.apache.org/confluence/display/GMOxDOC22/JMS+clustering+in+Geronimo



Apache Geronimo v3.0 (https://cwiki.apache.org/confluence/display/GMOxDOC30)

Pages
-
Apache Geronimo v3.0 documentation development status edited by  
chirun...@gmail.com  (01:24 AM)
https://cwiki.apache.org/confluence/display/GMOxDOC30/Apache+Geronimo+v3.0+documentation+development+status



Apache Karaf (https://cwiki.apache.org/confluence/display/KARAF)

Pages
-
Release Guide edited by  jgoodyear  (09:24 AM)
https://cwiki.apache.org/confluence/display/KARAF/Release+Guide

6.1. Extending the console edited by  gnodet  (08:21 AM)
https://cwiki.apache.org/confluence/display/KARAF/6.1.+Extending+the+console

5.1. Troubleshooting, Debugging and Profiling edited by  gnodet  (08:18 AM)
https://cwiki.apache.org/confluence/display/KARAF/5.1.+Troubleshooting%2C+Debugging+and+Profiling

4.7. Administration edited by  gnodet  (08:16 AM)
https://cwiki.apache.org/confluence/display/KARAF/4.7.+Administration

4.5. Security framework edited by  gnodet  (08:11 AM)
https://cwiki.apache.org/confluence/display/KARAF/4.5.+Security+framework

Articles created by jgoodyear (07:37 AM)
https://cwiki.apache.org/confluence/display/KARAF/Articles

4.4. Deployer edited by  gnodet  (06:52 AM)
https://cwiki.apache.org/confluence/display/KARAF/4.4.+Deployer

4.2. Remote Console edited by  gnodet  (05:45 AM)
https://cwiki.apache.org/confluence/display/KARAF/4.2.+Remote+Console

4.1. Console and Commands edited by  gnodet  (05:43 AM)
https://cwiki.apache.org/confluence/display/KARAF/4.1.+Console+and+Commands

3. Installation edited by  gnodet  (05:42 AM)
https://cwiki.apache.org/confluence/display/KARAF/3.+Installation

2.1. Quick Start (Source) edited by  gnodet  (05:36 AM)
https://cwiki.apache.org/confluence/display/KARAF/2.1.+Quick+Start+%28Source%29

2. Quick Start edited by  gnodet  (05:32 AM)
https://cwiki.apache.org/confluence/display/KARAF/2.+Quick+Start

Karaf welcome screen edited by  gnodet  (05:28 AM)
https://cwiki.apache.org/confluence/display/KARAF/Karaf+welcome+screen

Karaf Features edited by  gnodet  (05:25 AM)
https://cwiki.apache.org/confluence/display/KARAF/Karaf+Features

Karaf Users' Guide edited by  gnodet  (05:24 AM)
https://cwiki.apache.org/confluence/display/KARAF/Karaf+Users%27+Guide



Apache Struts 2 Plugin Registry 
(https://cwiki.apache.org/confluence/display/S2PLUGINS)

Pages
-
Struts2 jQuery plugin - Version 2.3.0 created by jogep (02:26 AM)
https://cwiki.apache.org/confluence/display/S2PLUGINS/2010/07/13/Struts2+jQuery+plugin+-+Version+2.3.0

jQuery plugin - Easy AJAX and Widget Integration edited by  jogep  (02:25 AM)
https://cwiki.apache.org/confluence/display/S2PLUGINS/jQuery+plugin+-+Easy+AJAX+and+Widget+Integration



Apache Tapestry (https://cwiki.apache.org/confluence/display/TAPESTRY)

Pages
-
Key Features edited by  uli  (05:20 AM)
https://cwiki.apache.org/confluence/display/TAPESTRY/Key+Features

Banner edited by  uli  (05: