August 2018
Intermediate to advanced
314 pages
8h 9m
English
In the following code block, we have the JFileUploadResource class, which uses JAX-RS and is a REST service:
import javax.enterprise.event.Event;import javax.enterprise.util.AnnotationLiteral;import javax.inject.Inject;import javax.ws.rs.Consumes;import javax.ws.rs.POST;import javax.ws.rs.Path;import javax.ws.rs.core.Response;import java.io.File;import java.util.Objects;@Path("upload")public class FileUploadResource { @Inject Event<FileEvent> fileEvent; @Consumes("application/pdf") @POST public Response uploadPdf(File file){ FileEvent fileEvent = new FileEvent(file, "pdf"); Event<FileEvent> pdfEvent = this.fileEvent.select(new AnnotationLiteral<Pdf>() {}); pdfEvent.fireAsync(fileEvent) .whenCompleteAsync((event ...
Read now
Unlock full access