Java Reference
In-Depth Information
Because our bean is a singleton with a startup annotation, the whole process will be in-
voked during the deployment of our application. Feel free to try it out now!
Of course, the database task requires some data in the seats table or it will yield empty
results (that's not a big issue for us). If you want the application to automatically seed
some data to the database, you can create another singleton bean, for instance:
public class DatabaseInitializer {
private EntityManager em;
public void setup() {
SeatType seatType = new SeatType();
seatType.setDescription("Test Data");
Seat seat = new Seat();
Be sure to add a @DependsOn("DatabaseInitializer") annotation on the
PendingSeats bean, so that the initializer runs before our database collector.
If everything goes well, you should see something like this on your console:
23:42:48,455 INFO [TaskListener] (ServerService Thread
Pool -- 54) Submitted
23:42:48,456 INFO [GenerateSeatRequestsFromDatabase]
(EE-ManagedExecutorService-default-Thread-1) Sleeping... (1)
Search WWH ::

Custom Search