use of io.quarkus.undertow.deployment.ServletBuildItem.Builder in project camel-quarkus by apache.
the class ServletProcessor method newServlet.
static ServletBuildItem newServlet(String key, ServletConfig servletConfig, BuildProducer<AdditionalBeanBuildItem> additionalBean) {
final String servletName = servletConfig.getEffectiveServletName(key);
final Optional<List<String>> urlPatterns = servletConfig.urlPatterns;
if (!urlPatterns.isPresent() || urlPatterns.get().isEmpty()) {
throw new IllegalStateException(String.format("Missing quarkus.camel.servlet%s.url-patterns", ServletConfig.DEFAULT_SERVLET_NAME.equals(servletName) ? "" : "." + servletName));
}
final Builder builder = ServletBuildItem.builder(servletName, servletConfig.servletClass);
additionalBean.produce(new AdditionalBeanBuildItem(servletConfig.servletClass));
for (String pattern : urlPatterns.get()) {
builder.addMapping(pattern);
}
return builder.build();
}
Aggregations