O'Reilly logo

Developing Middleware in Java EE 8 by Abdalla Mahmoud

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required