1 24 package org.riotfamily.common.web.view; 25 26 import java.util.ArrayList ; 27 import java.util.Collections ; 28 import java.util.List ; 29 30 import javax.servlet.http.HttpServletRequest ; 31 import javax.servlet.http.HttpServletResponse ; 32 33 import org.riotfamily.common.web.filter.ResourceStamper; 34 import org.riotfamily.common.web.mapping.ReverseHandlerMapping; 35 import org.springframework.beans.BeansException; 36 import org.springframework.context.ApplicationContext; 37 import org.springframework.context.ApplicationContextAware; 38 import org.springframework.core.OrderComparator; 39 40 44 public class CommonMacroHelperFactory implements MacroHelperFactory, 45 ApplicationContextAware { 46 47 private ApplicationContext ctx; 48 49 private ResourceStamper stamper; 50 51 private List mappings; 52 53 public void setStamper(ResourceStamper stamper) { 54 this.stamper = stamper; 55 } 56 57 public void setApplicationContext(ApplicationContext applicationContext) 58 throws BeansException { 59 60 this.ctx = applicationContext; 61 mappings = new ArrayList (applicationContext.getBeansOfType( 62 ReverseHandlerMapping.class).values()); 63 64 if (!mappings.isEmpty()) { 65 Collections.sort(mappings, new OrderComparator()); 66 } 67 } 68 69 public Object createMacroHelper(HttpServletRequest request, 70 HttpServletResponse response) { 71 72 return new CommonMacroHelper(ctx, request, response, stamper, mappings); 73 } 74 75 } 76 | Popular Tags |