1 15 package org.apache.tapestry.portlet; 16 17 import java.util.ArrayList ; 18 import java.util.Collections ; 19 import java.util.Iterator ; 20 import java.util.List ; 21 22 import javax.portlet.PortletRequest; 23 24 import org.apache.tapestry.IRequestCycle; 25 import org.apache.tapestry.PageNotFoundException; 26 27 33 public class MatchingPortletPageResolver implements PortletPageResolver 34 { 35 private List _contributions; 36 37 private List _sortedContributions; 38 39 private PortletRequest _request; 40 41 public void initializeService() 42 { 43 _sortedContributions = new ArrayList (_contributions); 44 Collections.sort(_sortedContributions); 45 } 46 47 public String getPageNameForRequest(IRequestCycle cycle) 48 { 49 Iterator i = _sortedContributions.iterator(); 50 while (i.hasNext()) 51 { 52 PageResolverContribution c = (PageResolverContribution) i.next(); 53 54 if (c.match(_request)) 55 { 56 String pageName = c.getPageName(); 57 58 try 59 { 60 cycle.getPage(pageName); 61 62 return pageName; 63 } 64 catch (PageNotFoundException ex) 65 { 66 } 68 } 69 } 70 71 73 return null; 74 } 75 76 public void setContributions(List contributions) 77 { 78 _contributions = contributions; 79 } 80 81 public void setRequest(PortletRequest request) 82 { 83 _request = request; 84 } 85 86 } 87 | Popular Tags |