public static void startConsumer() throws Exception
{
DirectoryService provDirService = DSAnnotationProcessor.getDirectoryService();
consumerServer = ServerAnnotationProcessor.getLdapServer( provDirService );
final SyncReplConsumer consumer = (SyncReplConsumer)ServerAnnotationProcessor.createConsumer();
List<ReplicationConsumer> replConsumers = new ArrayList<ReplicationConsumer>();
replConsumers.add( consumer );
consumerServer.setReplConsumers( replConsumers );
consumerServer.startReplicationConsumers();
Runnable r = new Runnable()
{
public void run()
{
try
{
DirectoryService ds = consumerServer.getDirectoryService();
Dn configDn = new Dn( ds.getSchemaManager(), "ads-replConsumerId=localhost,ou=system" );
consumer.getConfig().setConfigEntryDn( configDn );
Entry provConfigEntry = new DefaultEntry( ds.getSchemaManager(), configDn,
"objectClass: ads-replConsumer",
"ads-replConsumerId: localhost",
"ads-searchBaseDN", consumer.getConfig().getBaseDn(),
"ads-replProvHostName", consumer.getConfig().getRemoteHost(),
"ads-replProvPort", String.valueOf( consumer.getConfig().getRemotePort() ),
"ads-replRefreshInterval", String.valueOf( consumer.getConfig().getRefreshInterval() ),
"ads-replRefreshNPersist", String.valueOf( consumer.getConfig().isRefreshNPersist() ),
"ads-replSearchScope", consumer.getConfig().getSearchScope().getLdapUrlValue(),
"ads-replSearchFilter", consumer.getConfig().getFilter(),
"ads-replSearchSizeLimit", String.valueOf( consumer.getConfig().getSearchSizeLimit() ),
"ads-replSearchTimeOut", String.valueOf( consumer.getConfig().getSearchTimeout() ),
"ads-replUserDn", consumer.getConfig().getReplUserDn(),
"ads-replUserPassword", consumer.getConfig().getReplUserPassword() );
provConfigEntry.put( "ads-replAliasDerefMode", consumer.getConfig().getAliasDerefMode().getJndiValue() );
provConfigEntry.put( "ads-replAttributes", consumer.getConfig().getAttributes() );
consumerSession = consumerServer.getDirectoryService().getAdminSession();
consumerSession.add( provConfigEntry );
}