use of io.quarkus.undertow.deployment.ServletBuildItem in project quarkus by vaadin.
the class VaadinQuarkusProcessor method registerUserServlets.
private void registerUserServlets(BuildProducer<ServletBuildItem> servletProducer, Collection<ClassInfo> vaadinServlets) {
// TODO: check that we don't register 2 of the same mapping
for (ClassInfo info : vaadinServlets) {
final AnnotationInstance webServletInstance = info.classAnnotation(DotName.createSimple(WebServlet.class.getName()));
String servletName = Optional.ofNullable(webServletInstance.value("name")).map(AnnotationValue::asString).orElse(info.name().toString());
final ServletBuildItem.Builder servletBuildItem = ServletBuildItem.builder(servletName, info.name().toString());
Stream.of(webServletInstance.value("value"), webServletInstance.value("urlPatterns")).filter(Objects::nonNull).flatMap(value -> Stream.of(value.asStringArray())).forEach(servletBuildItem::addMapping);
addWebInitParameters(webServletInstance, servletBuildItem);
setAsyncSupportedIfDefined(webServletInstance, servletBuildItem);
servletProducer.produce(servletBuildItem.build());
}
}
use of io.quarkus.undertow.deployment.ServletBuildItem in project myfaces by apache.
the class MyFacesProcessor method buildServlet.
@BuildStep
void buildServlet(WebMetadataBuildItem webMetaDataBuildItem, BuildProducer<FeatureBuildItem> feature, BuildProducer<ServletBuildItem> servlet, BuildProducer<ListenerBuildItem> listener) throws IOException {
WebMetaData webMetaData = webMetaDataBuildItem.getWebMetaData();
ServletMetaData facesServlet = null;
if (webMetaData.getServlets() != null) {
facesServlet = webMetaData.getServlets().stream().filter(servletMeta -> FacesServlet.class.getName().equals(servletMeta.getServletClass())).findFirst().orElse(null);
}
if (facesServlet == null) {
// Only define here if not explictly defined in web.xml
servlet.produce(ServletBuildItem.builder("Faces Servlet", FacesServlet.class.getName()).setMultipartConfig(new MultipartConfigElement("")).addMapping("*.xhtml").build());
}
// sometimes Quarkus doesn't scan web-fragments?! lets add it manually
listener.produce(new ListenerBuildItem(StartupServletContextListener.class.getName()));
}
use of io.quarkus.undertow.deployment.ServletBuildItem in project quarkus by vaadin.
the class VaadinQuarkusProcessor method mapVaadinServletPaths.
@BuildStep
void mapVaadinServletPaths(final BeanArchiveIndexBuildItem beanArchiveIndex, final BuildProducer<ServletBuildItem> servletProducer) {
final IndexView indexView = beanArchiveIndex.getIndex();
// Collect all VaadinServlet instances and remove QuarkusVaadinServlet
// and VaadinServlet from the list.
final Collection<ClassInfo> vaadinServlets = indexView.getAllKnownSubclasses(DotName.createSimple(VaadinServlet.class.getName())).stream().filter(servlet -> !servlet.name().toString().equals(QuarkusVaadinServlet.class.getName()) && !servlet.name().toString().equals(VaadinServlet.class.getName())).collect(Collectors.toList());
// If no VaadinServlet instances found register QuarkusVaadinServlet
if (vaadinServlets.isEmpty()) {
servletProducer.produce(ServletBuildItem.builder(QuarkusVaadinServlet.class.getName(), QuarkusVaadinServlet.class.getName()).addMapping("/*").setAsyncSupported(true).build());
} else {
registerUserServlets(servletProducer, vaadinServlets);
}
}
Aggregations