Designing and implementing the backend

For the backend, we will use a WebSocket endpoint mapped to the URL /booking/{movieId}, as follows:

@ServerEndpoint(value = "/booking/{movieId}", 
                            encoders = {SeatsEncoder.class}) 
public class BookingEndpoint { 
     ... 
} 

Inside the endpoint class, we will define an in-memory database to simulate a database for all available movies. In a real-world implementation, the database would be too complex to maintain movies, available dates and cinemas, and seats for each combination in persistent storage. However, for the sake of simplicity, we will create a HashMap of Integer to boolean[][], where the key will be the movie ID, and the value a two-dimensional array of Boolean values, denoting whether the seat is ...

Get Developing Middleware in Java EE 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.