use of org.jboss.shrinkwrap.api.ArchivePath in project keycloak by keycloak.
the class UndertowDeployerHelper method addAnnotatedServlets.
private void addAnnotatedServlets(DeploymentInfo di, Archive<?> archive) {
Map<ArchivePath, Node> classNodes = archive.getContent((ArchivePath path) -> {
String stringPath = path.get();
return (stringPath.startsWith("/WEB-INF/classes") && stringPath.endsWith("class"));
});
for (Map.Entry<ArchivePath, Node> entry : classNodes.entrySet()) {
Node n = entry.getValue();
if (n.getAsset() instanceof ClassAsset) {
ClassAsset classAsset = (ClassAsset) n.getAsset();
Class<?> clazz = classAsset.getSource();
WebServlet annotation = clazz.getAnnotation(WebServlet.class);
if (annotation != null) {
ServletInfo undertowServlet = new ServletInfo(clazz.getSimpleName(), (Class<? extends Servlet>) clazz);
String[] mappings = annotation.value();
if (mappings != null) {
for (String urlPattern : mappings) {
undertowServlet.addMapping(urlPattern);
}
}
di.addServlet(undertowServlet);
}
}
}
}
Aggregations