myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r377849 - in /incubator/tobago/trunk/tobago-core/src/main: java/org/apache/myfaces/tobago/config/ java/org/apache/myfaces/tobago/context/ resources/org/apache/myfaces/tobago/config/
Date Tue, 14 Feb 2006 21:57:24 GMT
Author: lofwyr
Date: Tue Feb 14 13:57:22 2006
New Revision: 377849

URL: http://svn.apache.org/viewcvs?rev=377849&view=rev
Log:
make the new theme loading mechanism configurable via the tobago-config.xml

Modified:
    incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
    incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java
    incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceLocator.java
    incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerFactory.java
    incubator/tobago/trunk/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config_1_0.dtd

Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java?rev=377849&r1=377848&r2=377849&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
(original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
Tue Feb 14 13:57:22 2006
@@ -34,13 +34,16 @@
 
   private List<Theme> supportedThemes;
   private Theme defaultTheme;
+  private List<Theme> availableThemes;
   private List<String> resourceDirs;
+  private boolean loadThemesFromClasspath;
   private List<MappingRule> mappingRules;
   private boolean ajaxEnabled;
 
 
   public TobagoConfig() {
     supportedThemes = new ArrayList<Theme>();
+    availableThemes = new ArrayList<Theme>();
     resourceDirs = new ArrayList<String>();
   }
 
@@ -129,6 +132,10 @@
     return Collections.unmodifiableList(supportedThemes);
   }
 
+  public List<Theme> getAvailableThemes() {
+    return availableThemes;
+  }
+
   public void addResourceDir(String resourceDir) {
     LOG.info("resourceDir = '" + resourceDir + "'");
     resourceDirs.add(resourceDir);
@@ -144,6 +151,14 @@
 
   public void setAjaxEnabled(String value) {
     this.ajaxEnabled = Boolean.valueOf(value);
+  }
+
+  public boolean isLoadThemesFromClasspath() {
+    return loadThemesFromClasspath;
+  }
+
+  public void setLoadThemesFromClasspath(String loadThemesFromClasspath) {
+    this.loadThemesFromClasspath = Boolean.valueOf(loadThemesFromClasspath);
   }
 
   public Theme getDefaultTheme() {

Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java?rev=377849&r1=377848&r2=377849&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java
(original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfigParser.java
Tue Feb 14 13:57:22 2006
@@ -18,7 +18,7 @@
 
 /*
  * Created 24.06.2003 08:53:35.
- * Id: $
+ * $Id$
  */
 
 import org.apache.commons.digester.Digester;
@@ -70,6 +70,9 @@
         "tobago-config/mapping-rule/attribute/key", "setKey", 0);
     digester.addCallMethod(
         "tobago-config/mapping-rule/attribute/value", "setValue", 0);
+
+    // enable loading theme from classpath
+    digester.addCallMethod("tobago-config/load-themes-from-classpath", "setLoadThemesFromClasspath",
0);
 
     // resource dirs
     digester.addCallMethod("tobago-config/resource-dir", "addResourceDir", 0);

Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceLocator.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceLocator.java?rev=377849&r1=377848&r2=377849&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceLocator.java
(original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceLocator.java
Tue Feb 14 13:57:22 2006
@@ -3,6 +3,7 @@
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.config.TobagoConfig;
 
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
@@ -30,28 +31,28 @@
 // todo: Test for new theme build mechanism still under development
 // http://issues.apache.org/jira/browse/MYFACES-1106
 // to activate you have to do:
-// 1. set USE_JAR_THEME_RESOURCE = true, of course
+// 1. set load-themes-from-classpath = true in the tobago-config.xml
 // 2. add resource-path in tobago-config.xml
 // 3. add ResourceServlet in web.xml
-  public static final boolean USE_JAR_THEME_RESOURCE = false;
 
   private ServletContext servletContext;
   private ResourceManagerImpl resourceManager;
   private List<String> resourceDirs;
-
+  private TobagoConfig tobagoConfig;
 
   public ResourceLocator(
       ServletContext servletContext, ResourceManagerImpl resourceManager,
-      List<String> resourceDirs) {
+      List<String> resourceDirs, TobagoConfig tobagoConfig) {
     this.servletContext = servletContext;
     this.resourceManager = resourceManager;
     this.resourceDirs = resourceDirs;
+    this.tobagoConfig = tobagoConfig;
   }
 
   public void init()
       throws ServletException {
     locateResourcesInWar(servletContext, resourceManager, "/");
-    if (USE_JAR_THEME_RESOURCE) {
+    if (tobagoConfig.isLoadThemesFromClasspath()) {
       locateResourcesInLib(resourceManager);
     }
     for (String dir : resourceDirs) {
@@ -106,6 +107,7 @@
   private void locateResourcesInLib(ResourceManagerImpl resources)
       throws ServletException {
 
+//    ThemeParser parser = new ThemeParser(tobagoConfig);
     InputStream stream = null;
     try {
       LOG.error("Loading tobago-theme.xml");
@@ -113,6 +115,9 @@
 
       while (urls.hasMoreElements()) {
         URL themeUrl = urls.nextElement();
+
+//        parser.parse(themeUrl.openStream());
+
         // TODO other protocols
         if ("jar".equals(themeUrl.getProtocol())) {
           String fileName = themeUrl.toString().substring(4, themeUrl.toString().indexOf("!"));
@@ -153,7 +158,7 @@
           LOG.error("Unknown protocol "+themeUrl);
         }
       }
-    } catch (IOException e) {
+    } catch (Exception e) {
       String msg = "while loading ";
       if (LOG.isErrorEnabled()) {
         LOG.error(msg, e);

Modified: incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerFactory.java?rev=377849&r1=377848&r2=377849&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerFactory.java
(original)
+++ incubator/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/context/ResourceManagerFactory.java
Tue Feb 14 13:57:22 2006
@@ -49,7 +49,7 @@
     ResourceManagerImpl resourceManager = new ResourceManagerImpl();
 
     ResourceLocator resourceLocator = new ResourceLocator(
-        servletContext, resourceManager, tobagoConfig.getResourceDirs());
+        servletContext, resourceManager, tobagoConfig.getResourceDirs(), tobagoConfig);
     resourceLocator.init();
 
     servletContext.setAttribute(RESOURCE_MANAGER, resourceManager);

Modified: incubator/tobago/trunk/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config_1_0.dtd
URL: http://svn.apache.org/viewcvs/incubator/tobago/trunk/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config_1_0.dtd?rev=377849&r1=377848&r2=377849&view=diff
==============================================================================
--- incubator/tobago/trunk/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config_1_0.dtd
(original)
+++ incubator/tobago/trunk/tobago-core/src/main/resources/org/apache/myfaces/tobago/config/tobago-config_1_0.dtd
Tue Feb 14 13:57:22 2006
@@ -18,7 +18,7 @@
 
 <!ENTITY % Boolean "(true|false|yes|no)">
 
-<!ELEMENT tobago-config (theme-config, resource-dir+, mapping-rule*, ajax-enabled?)>
+<!ELEMENT tobago-config (theme-config, resource-dir+, load-themes-from-classpath?, mapping-rule*,
ajax-enabled?)>
 
 <!ELEMENT theme-config (default-theme, supported-theme*)>
 <!ELEMENT default-theme (#PCDATA)>
@@ -29,6 +29,8 @@
 <!ELEMENT fallback (#PCDATA)>
 
 <!ELEMENT resource-dir (#PCDATA)>
+
+<!ELEMENT load-themes-from-classpath (#PCDATA)>
 
 <!ELEMENT mapping-rule (request-uri, forward-uri, attribute*)>
 <!ELEMENT request-uri (#PCDATA)>



Mime
View raw message