Event Handling

In this application New releases uses event handling,

Let us see how it works here,

In our application /apps/dvdrental/dvdrental/src/main/java/com/dvdrental/impl/NewMovieObserver.java is listening to changes in movie Node.

It is done through,

public class NewMovieObserver implements EventListener{

if (repository.getDescriptor(Repository.OPTION_OBSERVATION_SUPPORTED).equals("true")) {
            observationManager = session.getWorkspace().getObservationManager();
            final String[] types = { "nt:unstructured","sling:Folder" };
            final String path = DVDRentalConstant.MOVIE_PATH;
            observationManager.addEventListener(this, Event.NODE_ADDED, path, true, null, null, false);
       }

Once movie is created they are added in /content/dvdrental/recent Node.

1. Repo before movie is created


Before_Movie_Create


2. Create Movie


Movie_Create



3. Movie Confirmation page



4. Repo After Movie is created

Before_Movie_created



Comments