You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2010/05/12 14:29:17 UTC
svn commit: r943468 - in
/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap:
LdapServer.java handlers/SearchHandler.java
replication/ReplicationProvider.java
Author: kayyagari
Date: Wed May 12 12:29:17 2010
New Revision: 943468
URL: http://svn.apache.org/viewvc?rev=943468&view=rev
Log:
o added a interface for configuring replication provider from within LdapServer
o updated SearchHandler and LdapServer classes
Added:
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicationProvider.java
Modified:
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java?rev=943468&r1=943467&r2=943468&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapServer.java Wed May 12 12:29:17 2010
@@ -55,6 +55,7 @@ import org.apache.directory.server.ldap.
import org.apache.directory.server.ldap.handlers.bind.MechanismHandler;
import org.apache.directory.server.ldap.handlers.extended.StartTlsHandler;
import org.apache.directory.server.ldap.handlers.ssl.LdapsInitializer;
+import org.apache.directory.server.ldap.replication.ReplicationProvider;
import org.apache.directory.server.ldap.replication.ReplicationSystem;
import org.apache.directory.server.protocol.shared.DirectoryBackedService;
import org.apache.directory.server.protocol.shared.transport.TcpTransport;
@@ -222,6 +223,8 @@ public class LdapServer extends Director
private IoFilterChainBuilder chainBuilder;
+ private ReplicationProvider replicationProvider;
+
/**
* Creates an LDAP protocol provider.
*/
@@ -443,6 +446,12 @@ public class LdapServer extends Director
*/
installDefaultHandlers();
+ if( replicationProvider != null )
+ {
+ replicationProvider.init( this );
+ ( ( SearchHandler ) getSearchHandler() ).setReplicationProvider( replicationProvider );
+ }
+
startNetwork( transport, chain );
}
@@ -512,6 +521,11 @@ public class LdapServer extends Director
future.await( 1000L );
sessionIt.next().close( true );
}
+
+ if( replicationProvider != null )
+ {
+ replicationProvider.stop();
+ }
}
}
catch ( Exception e )
@@ -1278,8 +1292,14 @@ public class LdapServer extends Director
{
return replicationSystem;
}
+
-
+ public void setReplicationProvider( ReplicationProvider replicationProvider )
+ {
+ this.replicationProvider = replicationProvider;
+ }
+
+
/**
* @see Object#toString()
*/
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java?rev=943468&r1=943467&r2=943468&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java Wed May 12 12:29:17 2010
@@ -36,14 +36,16 @@ import org.apache.directory.server.core.
import org.apache.directory.server.i18n.I18n;
import org.apache.directory.server.ldap.LdapSession;
import org.apache.directory.server.ldap.handlers.controls.PagedSearchContext;
+import org.apache.directory.server.ldap.replication.ReplicationProvider;
import org.apache.directory.shared.ldap.codec.controls.ManageDsaITControl;
+import org.apache.directory.shared.ldap.codec.controls.replication.syncRequestValue.SyncRequestValueControl;
import org.apache.directory.shared.ldap.codec.search.controls.pagedSearch.PagedResultsControl;
import org.apache.directory.shared.ldap.codec.search.controls.persistentSearch.PersistentSearchControl;
import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.Entry;
-import org.apache.directory.shared.ldap.entry.StringValue;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.StringValue;
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
@@ -90,6 +92,7 @@ public class SearchHandler extends LdapR
/** cached to save redundant lookups into registries */
private AttributeType objectClassAttributeType;
+ protected ReplicationProvider replicationProvider;
/**
* Constructs a new filter EqualityNode asserting that a candidate
@@ -173,6 +176,11 @@ public class SearchHandler extends LdapR
{
LOG.debug( "Handling single reply request: {}", req );
+ // check firt for the syncrepl search request control
+ if ( req.getControls().containsKey( SyncRequestValueControl.CONTROL_OID ) )
+ {
+ handleSyncreplSearch( session, req );
+ }
// First, if we have the ManageDSAIt control, go directly
// to the handling without pre-processing the request
if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
@@ -1625,4 +1633,25 @@ public class SearchHandler extends LdapR
return farthestReferralAncestor;
}
-}
\ No newline at end of file
+
+
+ public void setReplicationProvider( ReplicationProvider prov )
+ {
+ this.replicationProvider = prov;
+ }
+
+
+ /**
+ *
+ * handles the syncrepl search
+ *
+ * @param session the LDAP session under which processing occurs
+ * @param req the request to be handled
+ * @throws LdapException
+ */
+ public void handleSyncreplSearch( LdapSession session, InternalSearchRequest req ) throws LdapException
+ {
+ replicationProvider.handleSyncRequest( session, req );
+ }
+
+}
Added: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicationProvider.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicationProvider.java?rev=943468&view=auto
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicationProvider.java (added)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/ReplicationProvider.java Wed May 12 12:29:17 2010
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.directory.server.ldap.replication;
+
+import org.apache.directory.server.ldap.LdapServer;
+import org.apache.directory.server.ldap.LdapSession;
+import org.apache.directory.shared.ldap.exception.LdapException;
+import org.apache.directory.shared.ldap.message.internal.InternalSearchRequest;
+
+/**
+ * Interface for a replication provider.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ReplicationProvider
+{
+ /**
+ * initializes the replication provider
+ *
+ * @param server the LdapServer instance
+ */
+ void init( LdapServer server );
+
+
+ /**
+ * stops the replication provider
+ */
+ void stop();
+
+
+ /**
+ * A method to be used by any RFC 4533 compatible provider implementation
+ *
+ * @param session the LdapSession instance
+ * @param req the SearchRequest with the SyncRequest control
+ * @throws LdapException
+ */
+ void handleSyncRequest( LdapSession session, InternalSearchRequest req ) throws LdapException;
+}