[seam-commits] Seam SVN: r8713 - in trunk/src/main/org/jboss/seam: navigation and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sun Aug 17 00:14:41 EDT 2008


Author: norman.richards at jboss.com
Date: 2008-08-17 00:14:41 -0400 (Sun, 17 Aug 2008)
New Revision: 8713

Modified:
   trunk/src/main/org/jboss/seam/deployment/URLScanner.java
   trunk/src/main/org/jboss/seam/navigation/Pages.java
   trunk/src/main/org/jboss/seam/web/RewriteFilter.java
   trunk/src/main/org/jboss/seam/web/RewritingResponse.java
Log:
JBSEAM-274

Modified: trunk/src/main/org/jboss/seam/deployment/URLScanner.java
===================================================================
--- trunk/src/main/org/jboss/seam/deployment/URLScanner.java	2008-08-16 23:44:37 UTC (rev 8712)
+++ trunk/src/main/org/jboss/seam/deployment/URLScanner.java	2008-08-17 04:14:41 UTC (rev 8713)
@@ -82,7 +82,7 @@
       handle(paths);
    }
    
-   private void handle(Set<String> paths)
+   protected void handle(Set<String> paths)
    {
       for ( String urlPath: paths )
       {

Modified: trunk/src/main/org/jboss/seam/navigation/Pages.java
===================================================================
--- trunk/src/main/org/jboss/seam/navigation/Pages.java	2008-08-16 23:44:37 UTC (rev 8712)
+++ trunk/src/main/org/jboss/seam/navigation/Pages.java	2008-08-17 04:14:41 UTC (rev 8713)
@@ -10,6 +10,7 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.ResourceBundle;
@@ -25,6 +26,7 @@
 import javax.faces.convert.ConverterException;
 import javax.faces.model.DataModel;
 import javax.faces.validator.ValidatorException;
+import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 
 import org.dom4j.DocumentException;
@@ -39,6 +41,7 @@
 import org.jboss.seam.annotations.Startup;
 import org.jboss.seam.annotations.intercept.BypassInterceptors;
 import org.jboss.seam.contexts.Contexts;
+import org.jboss.seam.contexts.ServletLifecycle;
 import org.jboss.seam.core.Events;
 import org.jboss.seam.core.Expressions;
 import org.jboss.seam.core.Init;
@@ -47,6 +50,8 @@
 import org.jboss.seam.core.ResourceLoader;
 import org.jboss.seam.core.Expressions.MethodExpression;
 import org.jboss.seam.core.Expressions.ValueExpression;
+import org.jboss.seam.deployment.DeploymentStrategy;
+import org.jboss.seam.deployment.URLScanner;
 import org.jboss.seam.faces.FacesMessages;
 import org.jboss.seam.faces.Validation;
 import org.jboss.seam.international.StatusMessage;
@@ -114,7 +119,23 @@
                parse(stream);
            }
        }
+       
+       PagesDeploymentStrategy pagesDeployer = new PagesDeploymentStrategy();
+       pagesDeployer.scan();
+       
+       for (String fileName: pagesDeployer.scannedFiles())  {
+           String viewId = "/" + fileName.substring(0,fileName.length()-".page.xml".length()) + ".xhtml"; // needs more here
+           
+           InputStream stream = ResourceLoader.instance().getResourceAsStream(fileName);      
+           if (stream==null) {
+               log.info("no pages.xml file found: " + fileName);
+           } else {
+               log.debug("reading pages.xml file: " + fileName);
+               parse(stream,viewId);
+           } 
+       }
    }
+   
    /**
     * Run any navigation rule defined in pages.xml
     * 
@@ -1599,4 +1620,62 @@
    public Collection<String> getKnownViewIds() {
        return pagesByViewId.keySet();
    }
+   
+   public class PagesScanner 
+       extends URLScanner 
+   {
+
+       public PagesScanner(DeploymentStrategy strategy) {
+           super(strategy);
+       }
+
+       public void scanForPages(ServletContext context) {
+           HashSet<String> paths = new HashSet<String>();
+           paths.add(context.getRealPath("/"));
+           handle(paths);
+       }
+   }
+   
+   public class PagesDeploymentStrategy
+       extends DeploymentStrategy
+   {
+       PagesScanner scanner;
+       
+       List<String> files;
+       
+       public PagesDeploymentStrategy() {
+           scanner = new PagesScanner(this);
+           files = new ArrayList<String>();
+       }
+
+       public List<String> scannedFiles() {
+           return files;
+       }
+       
+       @Override
+       public void handle(String name) {
+           if (name.endsWith(".page.xml")) {
+               files.add(name);
+           }
+       }
+
+       @Override
+       public ClassLoader getClassLoader() {
+           return null;
+       }
+
+       @Override
+       protected String getDeploymentHandlersKey() {
+           return null;
+       }
+
+
+       @Override
+       public void scan()
+       {
+           scanner.scanForPages(ServletLifecycle.getServletContext());
+       }
+
+       
+   }
 }

Modified: trunk/src/main/org/jboss/seam/web/RewriteFilter.java
===================================================================
--- trunk/src/main/org/jboss/seam/web/RewriteFilter.java	2008-08-16 23:44:37 UTC (rev 8712)
+++ trunk/src/main/org/jboss/seam/web/RewriteFilter.java	2008-08-17 04:14:41 UTC (rev 8713)
@@ -30,7 +30,7 @@
 @Name("org.jboss.seam.web.rewriteFilter")
 @Install(precedence=Install.BUILT_IN,value=false)
 @BypassInterceptors
- at Filter(within="org.jboss.seam.debug.hotDeployFilter")
+ at Filter(within={"org.jboss.seam.web.multipartFilter","org.jboss.seam.web.authenticationFilter","org.jboss.seam.web.loggingFilter","org.jboss.seam.web.exceptionFilter","org.jboss.seam.web.identityFilter"})
 public class RewriteFilter 
     extends AbstractFilter
 {
@@ -44,24 +44,26 @@
     {
         List<Pattern> allPatterns = getAllPatterns();
         
+        boolean done = false;
+        
         if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
             response = new RewritingResponse((HttpServletRequest) request,
                     (HttpServletResponse)response,
                     allPatterns);
-            process((HttpServletRequest) request, 
-                    (HttpServletResponse) response,
-                    allPatterns);
+            
+            done = process((HttpServletRequest) request, 
+                           (HttpServletResponse) response,
+                            allPatterns);
         }
-        
-        
-        if (!response.isCommitted()) {
+                
+       if (!done) {
             chain.doFilter(request, response);
-        }
+       }
     }
     
     
     @SuppressWarnings("unchecked")
-    public void process(HttpServletRequest request, 
+    public boolean process(HttpServletRequest request, 
                         HttpServletResponse response, List<Pattern> patterns)
         throws IOException, 
                ServletException 
@@ -76,13 +78,26 @@
         if (rewrite!=null) {
             String newPath = rewrite.rewrite();
             
-            log.info("rewritten incoming path is " + localPath);
+            log.info("rewritten incoming path is " + newPath);
             
             if (!fullPath.equals(request.getContextPath() + newPath)) {
                 RequestDispatcher dispatcher = request.getRequestDispatcher(newPath);
+                
+//                final String wrappedPath = newPath;
+//                HttpServletRequest wrapped = new HttpServletRequestWrapper(request) {
+//                    @Override
+//                    public String getServletPath() {
+//                        return wrappedPath;
+//
+//                    }
+//                };
+//                dispatcher.forward(wrapped, response);
                 dispatcher.forward(request, response);
+                return true;
             }
         }
+        
+        return false;
     }
 
 

Modified: trunk/src/main/org/jboss/seam/web/RewritingResponse.java
===================================================================
--- trunk/src/main/org/jboss/seam/web/RewritingResponse.java	2008-08-16 23:44:37 UTC (rev 8712)
+++ trunk/src/main/org/jboss/seam/web/RewritingResponse.java	2008-08-17 04:14:41 UTC (rev 8713)
@@ -30,7 +30,7 @@
     
     @Override
     public String encodeUrl(String url) {
-        return super.encodeURL(url);
+        return encodeURL(url);
     }
     
     @Override
@@ -49,7 +49,7 @@
     @Override
     public String encodeRedirectURL(String url) {
         log.info("encode redirectURL called with " + url);
-        return super.encodeRedirectURL(url);
+        return encodeURL(url);
     }
     
     




More information about the seam-commits mailing list