myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1660708 - in /myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago: internal/util/MimeTypeUtils.java webapp/TobagoServletContextListener.java
Date Wed, 18 Feb 2015 19:46:35 GMT
Author: lofwyr
Date: Wed Feb 18 19:46:35 2015
New Revision: 1660708

URL: http://svn.apache.org/r1660708
Log:
TOBAGO-1433: Supported resource types should be configurable
init

Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/MimeTypeUtils.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoServletContextListener.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/MimeTypeUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/MimeTypeUtils.java?rev=1660708&r1=1660707&r2=1660708&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/MimeTypeUtils.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/MimeTypeUtils.java
Wed Feb 18 19:46:35 2015
@@ -21,7 +21,7 @@ package org.apache.myfaces.tobago.intern
 
 import org.apache.myfaces.tobago.config.TobagoConfig;
 
-import javax.faces.context.FacesContext;
+import javax.servlet.ServletContext;
 import java.util.Map;
 
 public final class MimeTypeUtils {
@@ -79,11 +79,6 @@ public final class MimeTypeUtils {
       }
     }
 
-    if (ADDITIONAL_MIME_TYPES == null) {
-      final TobagoConfig tobagoConfig = TobagoConfig.getInstance(FacesContext.getCurrentInstance());
-      ADDITIONAL_MIME_TYPES = tobagoConfig.getMimeTypes();
-    }
-
     final int index = file.lastIndexOf('.');
     if (index > -1) {
       String extension = file.substring(index + 1);
@@ -92,4 +87,13 @@ public final class MimeTypeUtils {
 
     return null;
   }
+
+  public static void init(ServletContext servletContext) {
+    if (ADDITIONAL_MIME_TYPES == null) {
+      final TobagoConfig tobagoConfig = TobagoConfig.getInstance(servletContext);
+      ADDITIONAL_MIME_TYPES = tobagoConfig.getMimeTypes();
+    } else {
+      throw new IllegalStateException(MimeTypeUtils.class.getSimpleName() + " is already
initialized!");
+    }
+  }
 }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoServletContextListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoServletContextListener.java?rev=1660708&r1=1660707&r2=1660708&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoServletContextListener.java
(original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoServletContextListener.java
Wed Feb 18 19:46:35 2015
@@ -23,6 +23,7 @@ import org.apache.myfaces.tobago.config.
 import org.apache.myfaces.tobago.internal.config.ContentSecurityPolicy;
 import org.apache.myfaces.tobago.internal.config.TobagoConfigBuilder;
 import org.apache.myfaces.tobago.internal.context.ResourceManagerFactory;
+import org.apache.myfaces.tobago.internal.util.MimeTypeUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -51,6 +52,9 @@ public class TobagoServletContextListene
     if (LOG.isInfoEnabled()) {
       final TobagoConfig tobagoConfig = TobagoConfig.getInstance(servletContext);
       LOG.info("TobagoConfig: " + tobagoConfig);
+
+      MimeTypeUtils.init(servletContext);
+
       final ContentSecurityPolicy.Mode mode = tobagoConfig.getContentSecurityPolicy().getMode();
       final StringBuilder builder = new StringBuilder();
       builder.append("\n*************************************************************************************");



Mime
View raw message