public class RewriteConfiguration implements ConfigurationProvider {
public static final String PRETTYFACES_CONFIG_SERVLETCONTEXT_KEY = "org.jboss.seam.faces.com.ocpsoft.pretty.faces.spi.ConfigurationProvider";
@Override
public PrettyConfig loadConfiguration(ServletContext sc) {
WebXmlParser webXmlParser = new WebXmlParser();
try {
webXmlParser.parse(sc);
} catch (IOException ex) {
throw new RuntimeException(ex);
} catch (SAXException ex) {
throw new RuntimeException(ex);
}
BeanManager beanManager = (BeanManager) sc.getAttribute(BeanManagerServletContextListener.BEANMANAGER_SERVLETCONTEXT_KEY);
if(beanManager == null)
beanManager = new BeanManagerLocator().getBeanManager();
ViewConfigStore store = BeanManagerUtils.getContextualInstance(beanManager, ViewConfigStore.class);
List<UrlMapping> mappings = loadUrlMappings(store, webXmlParser.getFacesMapping());
PrettyConfig prettyConfig = new PrettyConfig();
prettyConfig.setMappings(mappings);
return prettyConfig;
}