As an example of implementing an asynchronous REST service, we will use the same scenario used in the example of the event in the CDI and the asynchronous EJB method. Here, we will create an application that makes it possible to upload three types (or extensions) of files—ZIP, JPG, and PDF extensions. Depending on the extension received, we want the file received to be kept in its respective directory on the filesystem. To develop this example, we have the following classes:
FileUploadResource
: This is a class that represents the resource that works with asynchronous processes to receive all requests to upload, and calls the respective EJB according to the file extension.JpgHandler
: This is an EJB with an available method for saving a JPG file on a disk.PdfHandler
: This is an EJB with an available method for saving a PDF file on a disk.ZipHandler
: This is an EJB with an available method for saving a ZIP file on a disk.FileSystemUtils
: This is a utility...