PersistentSearchListener persistentSearchListener = new PersistentSearchListener( session, req );
// compose notification criteria and add the listener to the event
// service using that notification criteria to determine which events
// are to be delivered to the persistent search issuing client
NotificationCriteria criteria = new NotificationCriteria();
criteria.setAliasDerefMode( req.getDerefAliases() );
criteria.setBase( req.getBase() );
criteria.setFilter( req.getFilter() );
criteria.setScope( req.getScope() );
criteria.setEventMask( EventType.getEventTypes( psearch.getChangeTypes() ) );
getLdapServer().getDirectoryService().getEventService().addListener( persistentSearchListener, criteria );
req.addAbandonListener( new SearchAbandonListener( ldapServer, persistentSearchListener ) );
}