You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/07/12 07:36:21 UTC
svn commit: r421135 - in /directory/branches/apacheds/optimization:
protocol-ldap/src/main/java/org/apache/directory/server/ldap/
protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/
protocol-ldap/src/test/java/org/apache/directory/ser...
Author: akarasulu
Date: Tue Jul 11 22:36:20 2006
New Revision: 421135
URL: http://svn.apache.org/viewvc?rev=421135&view=rev
Log:
added new interface for pp handlers which has initialization phase to hand off configuration information
Added:
directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/LdapMessageHandler.java
Modified:
directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java
directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java
directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java
directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java
directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java
directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java
directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java
directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java
directory/branches/apacheds/optimization/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java
directory/branches/apacheds/optimization/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java
Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java (original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java Tue Jul 11 22:36:20 2006
@@ -29,12 +29,14 @@
import org.apache.mina.filter.codec.asn1.Asn1CodecDecoder;
import org.apache.mina.filter.codec.asn1.Asn1CodecEncoder;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.support.AbandonHandler;
import org.apache.directory.server.ldap.support.AddHandler;
import org.apache.directory.server.ldap.support.BindHandler;
import org.apache.directory.server.ldap.support.CompareHandler;
import org.apache.directory.server.ldap.support.DeleteHandler;
import org.apache.directory.server.ldap.support.ExtendedHandler;
+import org.apache.directory.server.ldap.support.LdapMessageHandler;
import org.apache.directory.server.ldap.support.ModifyDnHandler;
import org.apache.directory.server.ldap.support.ModifyHandler;
import org.apache.directory.server.ldap.support.SearchHandler;
@@ -80,7 +82,6 @@
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;
import org.apache.mina.handler.demux.DemuxingIoHandler;
-import org.apache.mina.handler.demux.MessageHandler;
import org.apache.mina.util.SessionLog;
@@ -99,6 +100,7 @@
private static final Map DEFAULT_HANDLERS;
/** a set of supported controls */
private static final Set SUPPORTED_CONTROLS;
+
static
{
@@ -170,7 +172,7 @@
* @param env environment properties used to configure the provider and
* underlying codec providers if any
*/
- public LdapProtocolProvider(Hashtable env) throws LdapNamingException
+ public LdapProtocolProvider( StartupConfiguration cfg, Hashtable env) throws LdapNamingException
{
Hashtable copy = ( Hashtable ) env.clone();
copy.put( Context.PROVIDER_URL, "" );
@@ -180,7 +182,7 @@
Iterator requestTypes = DEFAULT_HANDLERS.keySet().iterator();
while ( requestTypes.hasNext() )
{
- MessageHandler handler = null;
+ LdapMessageHandler handler = null;
String type = ( String ) requestTypes.next();
Class clazz = null;
@@ -208,7 +210,8 @@
try
{
Class typeClass = Class.forName( type );
- handler = ( MessageHandler ) clazz.newInstance();
+ handler = ( LdapMessageHandler ) clazz.newInstance();
+ handler.init( cfg );
this.handler.addMessageHandler( typeClass, handler );
}
catch ( Exception e )
@@ -223,44 +226,6 @@
}
this.codecFactory = new ProtocolCodecFactoryImpl( copy );
- }
-
-
- /**
- * Creates a MINA LDAP protocol provider.
- */
- public LdapProtocolProvider() throws LdapNamingException
- {
- SessionRegistry.releaseSingleton();
- new SessionRegistry( null );
-
- Iterator requestTypes = DEFAULT_HANDLERS.keySet().iterator();
- while ( requestTypes.hasNext() )
- {
- MessageHandler handler = null;
- String type = ( String ) requestTypes.next();
- Class clazz = null;
-
- clazz = ( Class ) DEFAULT_HANDLERS.get( type );
-
- try
- {
- Class typeClass = Class.forName( type );
- handler = ( MessageHandler ) clazz.newInstance();
- this.handler.addMessageHandler( typeClass, handler );
- }
- catch ( Exception e )
- {
- LdapNamingException lne;
- String msg = "failed to create handler instance of " + clazz;
- msg += " for processing " + type + " objects.";
- lne = new LdapNamingException( msg, ResultCodeEnum.OTHER );
- lne.setRootCause( e );
- throw lne;
- }
- }
-
- this.codecFactory = new ProtocolCodecFactoryImpl();
}
Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java (original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java Tue Jul 11 22:36:20 2006
@@ -17,12 +17,13 @@
package org.apache.directory.server.ldap.support;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.message.AbandonRequest;
import org.apache.directory.shared.ldap.message.AbandonableRequest;
import org.apache.directory.shared.ldap.message.Request;
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -33,7 +34,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class AbandonHandler implements MessageHandler
+public class AbandonHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( AbandonHandler.class );
@@ -82,5 +83,10 @@
log.debug( "Abandoned request: " + req );
}
}
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java (original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java Tue Jul 11 22:36:20 2006
@@ -22,6 +22,7 @@
import javax.naming.ReferralException;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.AddRequest;
@@ -32,8 +33,8 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,7 +46,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class AddHandler implements MessageHandler
+public class AddHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( AddHandler.class );
private static Control[] EMPTY_CONTROLS = new Control[0];
@@ -127,5 +128,10 @@
result.setResultCode( ResultCodeEnum.SUCCESS );
session.write( req.getResultResponse() );
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java (original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java Tue Jul 11 22:36:20 2006
@@ -25,6 +25,7 @@
import javax.naming.ldap.LdapContext;
import javax.naming.spi.InitialContextFactory;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.BindRequest;
@@ -34,8 +35,8 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,7 +47,7 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class BindHandler implements MessageHandler
+public class BindHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( BindHandler.class );
private static final Control[] EMPTY = new Control[0];
@@ -142,5 +143,10 @@
SessionRegistry.getSingleton().setLdapContext( session, ctx );
result.setResultCode( ResultCodeEnum.SUCCESS );
session.write( req.getResultResponse() );
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java (original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java Tue Jul 11 22:36:20 2006
@@ -22,6 +22,7 @@
import javax.naming.ReferralException;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.core.jndi.ServerLdapContext;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
@@ -33,8 +34,8 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,7 +47,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class CompareHandler implements MessageHandler
+public class CompareHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( CompareHandler.class );
private static Control[] EMPTY_CONTROLS = new Control[0];
@@ -140,5 +141,10 @@
result.setMatchedDn( req.getName() );
session.write( req.getResultResponse() );
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java (original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java Tue Jul 11 22:36:20 2006
@@ -22,6 +22,7 @@
import javax.naming.ReferralException;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.Control;
@@ -32,8 +33,8 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,7 +46,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class DeleteHandler implements MessageHandler
+public class DeleteHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( DeleteHandler.class );
private static Control[] EMPTY_CONTROLS = new Control[0];
@@ -120,5 +121,10 @@
result.setResultCode( ResultCodeEnum.SUCCESS );
session.write( req.getResultResponse() );
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java (original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java Tue Jul 11 22:36:20 2006
@@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.ExtendedOperationHandler;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.message.ExtendedRequest;
@@ -28,8 +29,8 @@
import org.apache.directory.shared.ldap.message.LdapResult;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
/**
@@ -38,7 +39,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ExtendedHandler implements MessageHandler
+public class ExtendedHandler implements LdapMessageHandler
{
private Map handlers = new HashMap();
@@ -104,5 +105,10 @@
session.write( req.getResultResponse() );
}
}
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Added: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/LdapMessageHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/LdapMessageHandler.java?rev=421135&view=auto
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/LdapMessageHandler.java (added)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/LdapMessageHandler.java Tue Jul 11 22:36:20 2006
@@ -0,0 +1,32 @@
+/*
+ * @(#) $Id$
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.support;
+
+import org.apache.directory.server.core.configuration.StartupConfiguration;
+import org.apache.mina.handler.demux.MessageHandler;
+
+/**
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface LdapMessageHandler extends MessageHandler
+{
+ void init( StartupConfiguration cfg );
+}
Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java (original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java Tue Jul 11 22:36:20 2006
@@ -16,12 +16,13 @@
*/
package org.apache.directory.server.ldap.support;
-
+
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.ReferralException;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.Control;
@@ -32,8 +33,8 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,7 +46,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ModifyDnHandler implements MessageHandler
+public class ModifyDnHandler implements LdapMessageHandler
{
private static final Logger LOG = LoggerFactory.getLogger( ModifyDnHandler.class );
private static Control[] EMPTY_CONTROLS = new Control[0];
@@ -183,5 +184,10 @@
result.setResultCode( ResultCodeEnum.SUCCESS );
session.write( req.getResultResponse() );
}
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java (original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java Tue Jul 11 22:36:20 2006
@@ -23,6 +23,7 @@
import javax.naming.directory.ModificationItem;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.Control;
@@ -33,8 +34,8 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,7 +47,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class ModifyHandler implements MessageHandler
+public class ModifyHandler implements LdapMessageHandler
{
private static final Logger LOG = LoggerFactory.getLogger( ModifyHandler.class );
private static final ModificationItem[] EMPTY = new ModificationItem[0];
@@ -124,5 +125,10 @@
result.setResultCode( ResultCodeEnum.SUCCESS );
session.write( req.getResultResponse() );
return;
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java (original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java Tue Jul 11 22:36:20 2006
@@ -28,9 +28,9 @@
import javax.naming.directory.SearchControls;
import javax.naming.ldap.LdapContext;
-import org.apache.directory.server.core.configuration.Configuration;
import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.core.jndi.ServerLdapContext;
+import org.apache.directory.server.core.partition.DirectoryPartitionNexus;
import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.codec.util.LdapResultEnum;
import org.apache.directory.shared.ldap.exception.LdapException;
@@ -49,8 +49,8 @@
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.util.ArrayUtils;
import org.apache.directory.shared.ldap.util.ExceptionUtils;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,10 +62,11 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class SearchHandler implements MessageHandler
+public class SearchHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( SearchHandler.class );
private static final String DEREFALIASES_KEY = "java.naming.ldap.derefAliases";
+ private StartupConfiguration cfg;
/**
@@ -75,12 +76,23 @@
* @param ids the ids to return
* @return the SearchControls to use with the ApacheDS server side JNDI provider
*/
- private static SearchControls getSearchControls( SearchRequest req, String[] ids )
+ private SearchControls getSearchControls( SearchRequest req, String[] ids, boolean isAdmin )
{
// prepare all the search controls
SearchControls controls = new SearchControls();
- controls.setCountLimit( req.getSizeLimit() );
- controls.setTimeLimit( req.getTimeLimit() );
+
+ // take the minimum of system limit with request specified value
+ if ( isAdmin )
+ {
+ controls.setCountLimit( req.getSizeLimit() );
+ controls.setTimeLimit( req.getTimeLimit() );
+ }
+ else
+ {
+ controls.setCountLimit( Math.min( req.getSizeLimit(), cfg.getMaxSizeLimit() ) );
+ controls.setTimeLimit( ( int ) Math.min( req.getTimeLimit(), cfg.getMaxTimeLimit() ) );
+ }
+
controls.setSearchScope( req.getScope().getValue() );
controls.setReturningObjFlag( req.getTypesOnly() );
controls.setReturningAttributes( ids );
@@ -138,7 +150,6 @@
{
ids = ( String[] ) retAttrs.toArray( ArrayUtils.EMPTY_STRING_ARRAY );
}
- SearchControls controls = getSearchControls( req, ids );
try
{
@@ -187,7 +198,6 @@
// Handle annonymous binds
// ===============================================================
- StartupConfiguration cfg = ( StartupConfiguration ) Configuration.toConfiguration( ctx.getEnvironment() );
boolean allowAnonymousBinds = cfg.isAllowAnonymousAccess();
boolean isAnonymousUser = ( ( ServerLdapContext ) ctx ).getPrincipal().getName().trim().equals( "" );
@@ -201,6 +211,27 @@
return;
}
+
+ // ===============================================================
+ // Set search limits differently based on user's identity
+ // ===============================================================
+
+ SearchControls controls = null;
+ if ( isAnonymousUser )
+ {
+ controls = getSearchControls( req, ids, false );
+ }
+ else if ( ( ( ServerLdapContext ) ctx ).getPrincipal().getName()
+ .trim().equals( DirectoryPartitionNexus.ADMIN_PRINCIPAL ) )
+ {
+ controls = getSearchControls( req, ids, true );
+ }
+ else
+ {
+ controls = getSearchControls( req, ids, false );
+ }
+
+
// ===============================================================
// Handle psearch differently
// ===============================================================
@@ -380,5 +411,11 @@
}
}
}
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
+ this.cfg = cfg;
}
}
Modified: directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java (original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java Tue Jul 11 22:36:20 2006
@@ -20,10 +20,11 @@
import javax.naming.NamingException;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.core.jndi.ServerLdapContext;
import org.apache.directory.server.ldap.SessionRegistry;
+
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,7 +37,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public class UnbindHandler implements MessageHandler
+public class UnbindHandler implements LdapMessageHandler
{
private static final Logger log = LoggerFactory.getLogger( UnbindHandler.class );
@@ -64,5 +65,10 @@
{
log.error( "failed to unbind session properly", e );
}
+ }
+
+
+ public void init( StartupConfiguration cfg )
+ {
}
}
Modified: directory/branches/apacheds/optimization/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java (original)
+++ directory/branches/apacheds/optimization/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java Tue Jul 11 22:36:20 2006
@@ -21,6 +21,7 @@
import junit.framework.TestCase;
+import org.apache.directory.server.core.configuration.StartupConfiguration;
import org.apache.directory.server.ldap.LdapProtocolProvider;
import org.apache.directory.server.ldap.support.ExtendedHandler;
import org.apache.directory.shared.ldap.NotImplementedException;
@@ -45,6 +46,7 @@
import org.apache.directory.shared.ldap.message.SearchRequestImpl;
import org.apache.directory.shared.ldap.message.UnbindRequest;
import org.apache.directory.shared.ldap.message.UnbindRequestImpl;
+
import org.apache.mina.common.IoSession;
import org.apache.mina.handler.demux.MessageHandler;
@@ -67,7 +69,7 @@
*/
public void testDefaultOperation() throws LdapNamingException
{
- LdapProtocolProvider provider = new LdapProtocolProvider();
+ LdapProtocolProvider provider = new LdapProtocolProvider( new StartupConfiguration(), new Properties() );
assertNotNull( provider.getCodecFactory() );
assertTrue( provider.getName() == LdapProtocolProvider.SERVICE_NAME );
}
@@ -114,7 +116,7 @@
props.setProperty( UnbindRequest.class.getName(), BogusUnbindHandler.class.getName() );
props.setProperty( UnbindRequestImpl.class.getName(), BogusUnbindHandler.class.getName() );
- LdapProtocolProvider provider = new LdapProtocolProvider( props );
+ LdapProtocolProvider provider = new LdapProtocolProvider( new StartupConfiguration(), props );
assertNotNull( provider.getCodecFactory() );
assertTrue( provider.getName() == LdapProtocolProvider.SERVICE_NAME );
}
Modified: directory/branches/apacheds/optimization/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java?rev=421135&r1=421134&r2=421135&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java (original)
+++ directory/branches/apacheds/optimization/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java Tue Jul 11 22:36:20 2006
@@ -55,7 +55,6 @@
import org.apache.directory.shared.ldap.message.extended.NoticeOfDisconnect;
import org.apache.mina.common.DefaultIoFilterChainBuilder;
import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.IoFilter;
import org.apache.mina.common.IoFilterChainBuilder;
import org.apache.mina.common.IoSession;
import org.apache.mina.common.WriteFuture;
@@ -64,6 +63,7 @@
import org.apache.mina.transport.socket.nio.SocketAcceptor;
import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
import org.apache.mina.transport.socket.nio.SocketSessionConfig;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -83,10 +83,11 @@
protected static final IoAcceptor tcpAcceptor = new SocketAcceptor();
protected static final IoAcceptor udpAcceptor = new DatagramAcceptor();
-
+ protected static final ThreadPoolFilter threadPool;
+
static
{
- IoFilter threadPool = new ThreadPoolFilter();
+ threadPool = new ThreadPoolFilter();
tcpAcceptor.getFilterChain().addFirst( "threadPool", threadPool );
udpAcceptor.getFilterChain().addFirst( "threadPool", threadPool );
}
@@ -104,6 +105,7 @@
public void beforeStartup( DirectoryService service )
{
+ threadPool.setMaximumPoolSize( service.getConfiguration().getStartupConfiguration().getMaxThreads() );
this.directoryService = service;
}
@@ -438,7 +440,7 @@
IoFilterChainBuilder chainBuilder ) throws LdapNamingException, LdapConfigurationException
{
// Register all extended operation handlers.
- LdapProtocolProvider protocolProvider = new LdapProtocolProvider( ( Hashtable ) env.clone() );
+ LdapProtocolProvider protocolProvider = new LdapProtocolProvider( cfg, ( Hashtable ) env.clone() );
for ( Iterator i = cfg.getExtendedOperationHandlers().iterator(); i.hasNext(); )
{