Search in sources :

Example 1 with Builder

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();
}
Also used : AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) Builder(io.quarkus.undertow.deployment.ServletBuildItem.Builder) List(java.util.List)

Aggregations

AdditionalBeanBuildItem (io.quarkus.arc.deployment.AdditionalBeanBuildItem)1 Builder (io.quarkus.undertow.deployment.ServletBuildItem.Builder)1 List (java.util.List)1