Last active
January 1, 2016 10:48
-
-
Save os890/8133398 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ViewConfigValidator implements ServletContextListener | |
{ | |
@Override | |
public void contextInitialized(ServletContextEvent sce) | |
{ | |
ViewConfigResolver viewConfigResolver = | |
BeanProvider.getContextualReference(ViewConfigResolver.class); | |
for (ConfigDescriptor configDescriptor : | |
viewConfigResolver.getConfigDescriptors()) | |
{ | |
try | |
{ | |
if (!isInternal(configDescriptor.getConfigClass()) && | |
sce.getServletContext() | |
.getResource(configDescriptor.getPath()) == null) | |
{ | |
throw new IllegalStateException("path " + | |
configDescriptor.getPath() + | |
" doesn't exist, but it's mapped by " + | |
configDescriptor.getConfigClass().getName()); | |
} | |
} | |
catch (MalformedURLException e) | |
{ | |
throw ExceptionUtils.throwAsRuntimeException(e); | |
} | |
} | |
} | |
//needed with deltaspike 0.5 | |
private boolean isInternal(Class configClass) | |
{ | |
return ViewConfig.class.equals(configClass) || | |
DefaultErrorView.class.equals(configClass) || | |
ViewRef.class.equals(configClass) || | |
ViewRef.Manual.class.equals(configClass); | |
} | |
@Override | |
public void contextDestroyed(ServletContextEvent sce) | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment