use of org.apache.myfaces.spi.ServletMapping in project tomee by apache.
the class TomEEWebConfigProvider method getFacesServletMappings.
@Override
public List<ServletMapping> getFacesServletMappings(final ExternalContext externalContext) {
final List<ServletMapping> facesServletMappings = super.getFacesServletMappings(externalContext);
try {
// getContext() is a runtime object where getServletRegistrations() is forbidden so unwrap
final ServletContext sc = ServletContext.class.cast(Reflections.get(externalContext.getContext(), "sc"));
if (sc != null && sc.getServletRegistrations() != null) {
for (final Map.Entry<String, ? extends ServletRegistration> reg : sc.getServletRegistrations().entrySet()) {
final ServletRegistration value = reg.getValue();
if ("javax.faces.webapp.FacesServlet".equals(value.getClassName())) {
for (final String mapping : value.getMappings()) {
final Class<?> clazz = sc.getClassLoader().loadClass(value.getClassName());
final org.apache.myfaces.shared_impl.webapp.webxml.ServletMapping mappingImpl = new org.apache.myfaces.shared_impl.webapp.webxml.ServletMapping(value.getName(), clazz, mapping);
facesServletMappings.add(new ServletMappingImpl(mappingImpl));
}
}
}
} else {
facesServletMappings.addAll(super.getFacesServletMappings(externalContext));
}
} catch (final Exception e) {
// don't fail cause our cast failed
facesServletMappings.clear();
facesServletMappings.addAll(super.getFacesServletMappings(externalContext));
}
return facesServletMappings;
}
Aggregations