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 2007/10/08 08:52:47 UTC
svn commit: r582729 - in
/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap:
./ gui/ support/ support/bind/ support/extended/
Author: akarasulu
Date: Sun Oct 7 23:52:45 2007
New Revision: 582729
URL: http://svn.apache.org/viewvc?rev=582729&view=rev
Log:
cleaned up some static structure in LDAP protocol provider
Modified:
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsDialog.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbstractLdapHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAbandonHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAddHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultCompareHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultDeleteHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultExtendedHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyDnHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultUnbindHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/BindHandlerChain.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GetLdapContext.java
directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/LaunchDiagnosticUiHandler.java
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java Sun Oct 7 23:52:45 2007
@@ -78,6 +78,7 @@
private SearchHandler searchHandler;
private UnbindHandler unbindHandler;
+ private final SessionRegistry registry;
/** the underlying provider codec factory */
private final ProtocolCodecFactory codecFactory;
@@ -111,8 +112,7 @@
copy.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.directory.server.core.jndi.CoreContextFactory" );
copy.put( DirectoryService.JNDI_KEY, directoryService );
- SessionRegistry.releaseSingleton();
- new SessionRegistry( cfg, copy );
+ this.registry = new SessionRegistry( cfg, copy );
this.supportedControls = new HashSet<String>();
this.supportedControls.add( PersistentSearchControl.CONTROL_OID );
@@ -249,6 +249,7 @@
{
this.handler.removeMessageHandler( AbandonRequest.class );
this.abandonHandler = abandonHandler;
+ this.abandonHandler.setProtocolProvider( this );
//noinspection unchecked
this.handler.addMessageHandler( AbandonRequest.class, this.abandonHandler );
}
@@ -264,6 +265,7 @@
{
this.handler.removeMessageHandler( AddRequest.class );
this.addHandler = addHandler;
+ this.addHandler.setProtocolProvider( this );
//noinspection unchecked
this.handler.addMessageHandler( AddRequest.class, this.addHandler );
}
@@ -279,6 +281,7 @@
{
this.handler.removeMessageHandler( BindRequest.class );
this.bindHandler = bindHandler;
+ this.bindHandler.setProtocolProvider( this );
if ( directoryService != null )
{
this.bindHandler.setDirectoryService( directoryService );
@@ -298,6 +301,7 @@
{
this.handler.removeMessageHandler( CompareRequest.class );
this.compareHandler = compareHandler;
+ this.compareHandler.setProtocolProvider( this );
//noinspection unchecked
this.handler.addMessageHandler( CompareRequest.class, this.compareHandler );
}
@@ -313,6 +317,7 @@
{
this.handler.removeMessageHandler( DeleteRequest.class );
this.deleteHandler = deleteHandler;
+ this.deleteHandler.setProtocolProvider( this );
//noinspection unchecked
this.handler.addMessageHandler( DeleteRequest.class, this.deleteHandler );
}
@@ -328,6 +333,7 @@
{
this.handler.removeMessageHandler( ExtendedRequest.class );
this.extendedHandler = extendedHandler;
+ this.extendedHandler.setProtocolProvider( this );
//noinspection unchecked
this.handler.addMessageHandler( ExtendedRequest.class, this.extendedHandler );
}
@@ -343,6 +349,7 @@
{
this.handler.removeMessageHandler( ModifyRequest.class );
this.modifyHandler = modifyHandler;
+ this.modifyHandler.setProtocolProvider( this );
//noinspection unchecked
this.handler.addMessageHandler( ModifyRequest.class, this.modifyHandler );
}
@@ -358,6 +365,7 @@
{
this.handler.removeMessageHandler( ModifyDnRequest.class );
this.modifyDnHandler = modifyDnHandler;
+ this.modifyDnHandler.setProtocolProvider( this );
//noinspection unchecked
this.handler.addMessageHandler( ModifyDnRequest.class, this.modifyDnHandler );
}
@@ -373,6 +381,7 @@
{
this.handler.removeMessageHandler( SearchRequest.class );
this.searchHandler = searchHandler;
+ this.searchHandler.setProtocolProvider( this );
//noinspection unchecked
this.handler.addMessageHandler( SearchRequest.class, this.searchHandler );
}
@@ -388,11 +397,18 @@
{
this.handler.removeMessageHandler( UnbindRequest.class );
this.unbindHandler = unbindHandler;
+ this.unbindHandler.setProtocolProvider( this );
//noinspection unchecked
this.handler.addMessageHandler( UnbindRequest.class, this.unbindHandler );
}
+ public SessionRegistry getRegistry()
+ {
+ return registry;
+ }
+
+
/**
* A snickers based BER Decoder factory.
*/
@@ -446,7 +462,7 @@
public void sessionClosed( IoSession session )
{
- SessionRegistry.getSingleton().remove( session );
+ registry.remove( session );
}
@@ -511,7 +527,7 @@
SessionLog.warn( session,
"Unexpected exception forcing session to close: sending disconnect notice to client.", cause );
session.write( NoticeOfDisconnect.PROTOCOLERROR );
- SessionRegistry.getSingleton().remove( session );
+ registry.remove( session );
session.close();
}
}
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/SessionRegistry.java Sun Oct 7 23:52:45 2007
@@ -23,7 +23,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.Map;
import javax.naming.Context;
@@ -48,9 +47,6 @@
*/
public class SessionRegistry
{
- /** the singleton for this registry */
- private static SessionRegistry singleton;
-
/** the set of client contexts */
private final Map<IoSession, LdapContext> contexts = new HashMap<IoSession, LdapContext>();
@@ -65,44 +61,13 @@
/**
- * Gets the singleton instance for this SessionRegistry. If the singleton
- * does not exist one is created.
- *
- * @return the singleton SessionRegistry instance
- */
- public static SessionRegistry getSingleton()
- {
- if ( singleton == null )
- {
- singleton = new SessionRegistry( new LdapConfiguration(), new Hashtable<String, Object>() );
- }
-
- return singleton;
- }
-
-
- static void releaseSingleton()
- {
- singleton = null;
- }
-
-
- /**
* Creates a singleton session state object for the system.
*
* @param env the properties associated with this SessionRegistry
+ * @param cfg the ldap configuration
*/
- SessionRegistry( LdapConfiguration cfg, Hashtable<String, Object> env )
+ public SessionRegistry( LdapConfiguration cfg, Hashtable<String, Object> env )
{
- if ( singleton == null )
- {
- singleton = this;
- }
- else
- {
- throw new IllegalStateException( "There can only be one singleton." );
- }
-
if ( env == null )
{
this.env = new Hashtable<String, Object>();
@@ -211,6 +176,7 @@
if ( reqmap == null )
{
+ //noinspection unchecked
return Collections.EMPTY_MAP;
}
@@ -223,7 +189,7 @@
* Overload that does not require boxing of primitive messageId.
*
* @param session the session associated with the request
- * @param messageId the id of the request
+ * @param abandonedId the id of the request
* @return the request in session for id or null if request has completed
*/
public Request getOutstandingRequest( IoSession session, int abandonedId )
@@ -280,11 +246,12 @@
* @param allowAnonymous true if anonymous requests will create anonymous
* InitialContext if one is not present for the operation
* @return the InitialContext or null
+ * @throws NamingException if something goes wrong
*/
public LdapContext getLdapContext( IoSession session, Control[] connCtls, boolean allowAnonymous )
throws NamingException
{
- LdapContext ctx = null;
+ LdapContext ctx;
synchronized ( contexts )
{
@@ -313,6 +280,7 @@
}
else
{
+ //noinspection unchecked
Hashtable<String, Object> cloned = ( Hashtable<String, Object> ) env.clone();
cloned.put( Context.SECURITY_AUTHENTICATION, "none" );
cloned.remove( Context.SECURITY_PRINCIPAL );
@@ -323,7 +291,7 @@
// the context came up non null so we binded explicitly and op now is not bind
else if ( ctx != null && allowAnonymous )
{
- ServerLdapContext slc = null;
+ ServerLdapContext slc;
if ( !( ctx instanceof ServerLdapContext ) )
{
@@ -356,10 +324,11 @@
* @param session the client's key
* @param connCtls connection controls if any to use if creating anon context
* @return the InitialContext or null
+ * @throws NamingException if something goes wrong
*/
public LdapContext getLdapContextOnRootDSEAccess( IoSession session, Control[] connCtls ) throws NamingException
{
- LdapContext ctx = null;
+ LdapContext ctx;
synchronized ( contexts )
{
@@ -381,6 +350,7 @@
}
else
{
+ //noinspection unchecked
Hashtable<String, Object> cloned = ( Hashtable<String, Object> ) env.clone();
cloned.put( Context.SECURITY_AUTHENTICATION, "none" );
cloned.remove( Context.SECURITY_PRINCIPAL );
@@ -420,7 +390,7 @@
contexts.remove( session );
}
- Map<Integer, Request> reqmap = null;
+ Map<Integer, Request> reqmap;
synchronized ( requests )
{
@@ -432,12 +402,8 @@
return;
}
- Iterator<Request> list = reqmap.values().iterator();
-
- while ( list.hasNext() )
+ for ( Request request : reqmap.values() )
{
- Request request = list.next();
-
if ( request instanceof AbandonableRequest )
{
( ( AbandonableRequest ) request ).abandon();
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsDialog.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsDialog.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsDialog.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/OutstandingRequestsDialog.java Sun Oct 7 23:52:45 2007
@@ -43,27 +43,34 @@
{
private static final long serialVersionUID = -3777123348215825711L;
private static final AbandonableRequest[] EMPTY_REQUEST_ARRAY = new AbandonableRequest[0];
- private JPanel jContentPane = null;
- private JPanel jPanel = null;
- private JScrollPane jScrollPane = null;
- private JTable jTable = null;
- private JPanel jPanel1 = null;
- private JButton jButton = null;
+ private JPanel jContentPane;
+ private JPanel jPanel;
+ private JScrollPane jScrollPane;
+ private JTable jTable;
+ private JPanel jPanel1;
+ private JButton jButton;
final IoSession session;
- private JPanel jPanel2 = null;
- private JTextArea jTextArea = null;
- private JButton jButton1 = null;
- private JButton jButton2 = null;
+ final SessionRegistry registry;
+
+ private JPanel jPanel2;
+ private JTextArea jTextArea;
+ private JButton jButton1;
+ private JButton jButton2;
/**
* This is the default constructor
+ * @param owner the owning frame
+ * @param session the MINA IoSession to get outstanding requests for
+ * @param sessionRegistry the session registry
*/
- public OutstandingRequestsDialog(JFrame owner, IoSession session)
+ public OutstandingRequestsDialog( JFrame owner, IoSession session, SessionRegistry sessionRegistry )
{
super( owner, true );
this.session = session;
+ this.registry = sessionRegistry;
+
StringBuffer buf = new StringBuffer();
buf.append( "Outstanding Requests: " );
buf.append( ( ( InetSocketAddress ) session.getRemoteAddress() ).getHostName() );
@@ -76,8 +83,6 @@
/**
* This method initializes this
- *
- * @return void
*/
private void initialize()
{
@@ -179,10 +184,11 @@
private void setRequestsModel()
{
AbandonableRequest[] requests;
- Map reqsMap = SessionRegistry.getSingleton().getOutstandingRequests( session );
+ Map reqsMap = registry.getOutstandingRequests( session );
if ( reqsMap != null )
{
requests = new AbandonableRequest[reqsMap.size()];
+ //noinspection unchecked
requests = ( AbandonableRequest[] ) reqsMap.values().toArray( requests );
}
else
@@ -320,7 +326,7 @@
AbandonableRequest req = ( ( OutstandingRequestsModel ) jTable.getModel() )
.getAbandonableRequest( row );
req.abandon();
- SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId() );
+ registry.removeOutstandingRequest( session, req.getMessageId() );
setRequestsModel();
}
} );
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/gui/SessionsFrame.java Sun Oct 7 23:52:45 2007
@@ -61,51 +61,47 @@
public class SessionsFrame extends JFrame
{
- private static final Logger log = LoggerFactory.getLogger( SessionsFrame.class );
+ private static final Logger LOG = LoggerFactory.getLogger( SessionsFrame.class );
private static final long serialVersionUID = -863445561454536133L;
private static final String REFRESH_COMMAND = "Refresh";
boolean isServiceBound = true;
private IoSession requestor;
private IoHandler ldapProvider;
- private JPanel jContentPane = null;
- private JPanel mainPanel = null;
- private JScrollPane sessionsPane = null;
- private JTable sessionsTable = null;
- private JPanel filterPanel = null;
- private JButton filterButton = null;
- private JTextField filterText = null;
- private JMenuBar menuBar = null;
- private JMenu menuFile = null;
- private JMenuItem exitItem = null;
- private JMenu menuSession = null;
- private JMenuItem closeItem = null;
- private JMenu menuSendNoD = null;
- private JMenuItem unavailableItem = null;
- private JMenuItem protocolErrorItem = null;
- private JMenuItem strongAuthRequiredItem = null;
- private JPanel southPanel = null;
- private JMenuItem showRequests = null;
- // private JPopupMenu popupMenu = null;
- // private JMenuItem jMenuItem = null;
- // private JMenu jMenu = null;
- // private JMenuItem jMenuItem1 = null;
- // private JMenuItem jMenuItem2 = null;
- // private JMenuItem jMenuItem3 = null;
- // private JMenuItem jMenuItem4 = null;
- private JButton refreshButton = null;
+ private JPanel jContentPane;
+ private JPanel mainPanel;
+ private JScrollPane sessionsPane;
+ private JTable sessionsTable;
+ private JPanel filterPanel;
+ private JButton filterButton;
+ private JTextField filterText;
+ private JMenuBar menuBar;
+ private JMenu menuFile;
+ private JMenuItem exitItem;
+ private JMenu menuSession;
+ private JMenuItem closeItem;
+ private JMenu menuSendNoD;
+ private JMenuItem unavailableItem;
+ private JMenuItem protocolErrorItem;
+ private JMenuItem strongAuthRequiredItem;
+ private JPanel southPanel;
+ private JMenuItem showRequests;
+ private JButton refreshButton;
private IoSession selected;
- private JMenuItem unbindItem = null;
- private JMenuItem bindItem = null;
+ private JMenuItem unbindItem;
+ private JMenuItem bindItem;
+ private SessionRegistry registry;
+
-
/**
* This is the default constructor
+ * @param registry the session registry
*/
- public SessionsFrame()
+ public SessionsFrame( SessionRegistry registry )
{
super();
+ this.registry = registry;
initialize();
}
@@ -194,35 +190,7 @@
{
sessionsTable = new JTable();
sessionsTable.setSelectionMode( javax.swing.ListSelectionModel.SINGLE_SELECTION );
- // sessionsTable.addMouseListener( new java.awt.event.MouseAdapter()
- // {
- // public void mouseReleased(java.awt.event.MouseEvent e)
- // {
- // if ( e.getButton() == MouseEvent.BUTTON3 )
- // {
- // if ( popupMenu == null )
- // {
- // popupMenu = SessionsFrame.this.getSessionsPopupMenu();
- // }
- // popupMenu.setVisible( false );
- // }
- // }
- //
- // public void mousePressed(java.awt.event.MouseEvent e)
- // {
- // if ( e.getButton() == MouseEvent.BUTTON3 )
- // {
- // if ( popupMenu == null )
- // {
- // popupMenu = SessionsFrame.this.getSessionsPopupMenu();
- // }
- // Point location = e.getComponent().getLocationOnScreen();
- // popupMenu.setLocation( location.x + e.getPoint().x, location.y + e.getPoint().y );
- // popupMenu.setVisible( true );
- // }
- // }
- // } );
- sessionsTable.setModel( new SessionsModel( SessionRegistry.getSingleton().getSessions() ) );
+ sessionsTable.setModel( new SessionsModel( registry.getSessions() ) );
sessionsTable.getSelectionModel().addListSelectionListener( new ListSelectionListener()
{
public void valueChanged( ListSelectionEvent e )
@@ -394,14 +362,14 @@
{
public void actionPerformed( java.awt.event.ActionEvent e )
{
- SessionRegistry.getSingleton().terminateSession( selected );
+ registry.terminateSession( selected );
try
{
Thread.sleep( 250 );
}
catch ( InterruptedException e1 )
{
- log.error( "", e1 );
+ LOG.error( "", e1 );
}
refresh();
}
@@ -452,7 +420,7 @@
}
catch ( InterruptedException e1 )
{
- log.error( "", e1 );
+ LOG.error( "", e1 );
}
refresh();
}
@@ -484,7 +452,7 @@
}
catch ( InterruptedException e1 )
{
- log.error( "", e1 );
+ LOG.error( "", e1 );
}
refresh();
}
@@ -518,7 +486,7 @@
}
catch ( Exception e1 )
{
- log.error( "", e1 );
+ LOG.error( "", e1 );
}
refresh();
}
@@ -578,7 +546,8 @@
{
public void actionPerformed( java.awt.event.ActionEvent e )
{
- OutstandingRequestsDialog dialog = new OutstandingRequestsDialog( SessionsFrame.this, selected );
+ OutstandingRequestsDialog dialog =
+ new OutstandingRequestsDialog( SessionsFrame.this, selected, registry );
dialog.addWindowListener( new WindowAdapter()
{
public void windowClosed( WindowEvent e )
@@ -707,7 +676,7 @@
{
public void actionPerformed( java.awt.event.ActionEvent e )
{
- if ( e.getActionCommand() == REFRESH_COMMAND )
+ if ( e.getActionCommand().equals( REFRESH_COMMAND ) )
{
refresh();
}
@@ -720,8 +689,8 @@
private void refresh()
{
- log.info( "Refreshing Sessions UI" );
- sessionsTable.setModel( new SessionsModel( SessionRegistry.getSingleton().getSessions() ) );
+ LOG.info( "Refreshing Sessions UI" );
+ sessionsTable.setModel( new SessionsModel( registry.getSessions() ) );
closeItem.setEnabled( false );
menuSendNoD.setEnabled( false );
showRequests.setEnabled( false );
@@ -755,11 +724,11 @@
+ "\nSelecting yes will send both. Cancel will abort unbind.",
"Send graceful disconnect before disconnect notice?", JOptionPane.YES_NO_CANCEL_OPTION );
IoAcceptor acceptor = ( IoAcceptor ) requestor.getService();
- List sessions = new ArrayList( acceptor.getManagedSessions( requestor.getServiceAddress() ) );
+ List<IoSession> sessions = new ArrayList<IoSession>(
+ acceptor.getManagedSessions( requestor.getServiceAddress() ) );
if ( input == JOptionPane.CANCEL_OPTION )
{
- return;
}
else if ( input == JOptionPane.NO_OPTION )
{
@@ -772,7 +741,6 @@
+ requestor.getLocalAddress() + " has been successfully unbound.", "Success!",
JOptionPane.INFORMATION_MESSAGE );
refresh();
- return;
}
else
{
@@ -783,13 +751,13 @@
if ( dialog.isSendCanceled() )
{
- log.debug( "GracefulShutdown was canceled." );
+ LOG.debug( "GracefulShutdown was canceled." );
JOptionPane.showMessageDialog( SessionsFrame.this, "Shutdown has been canceled.",
"Graceful Shutdown Aborted", JOptionPane.OK_OPTION );
return;
}
- log.debug( "GracefulShutdown parameters captured." );
+ LOG.debug( "GracefulShutdown parameters captured." );
int timeOffline = dialog.getTimeOffline();
int delay = dialog.getDelay();
GracefulDisconnect graceful = new GracefulDisconnect( timeOffline, delay );
@@ -867,7 +835,7 @@
}
catch ( IOException e1 )
{
- log.error( "failed to rebind ldap service", e1 );
+ LOG.error( "failed to rebind ldap service", e1 );
JOptionPane.showMessageDialog( SessionsFrame.this, e1.getMessage(), "Error encountered!",
JOptionPane.ERROR_MESSAGE );
}
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java Sun Oct 7 23:52:45 2007
@@ -22,7 +22,6 @@
import org.apache.directory.shared.ldap.message.AbandonRequest;
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
/**
@@ -31,7 +30,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public abstract class AbandonHandler implements MessageHandler
+public abstract class AbandonHandler extends AbstractLdapHandler
{
public final void messageReceived( IoSession session, Object request ) throws Exception
{
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbstractLdapHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbstractLdapHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbstractLdapHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbstractLdapHandler.java Sun Oct 7 23:52:45 2007
@@ -20,14 +20,15 @@
package org.apache.directory.server.ldap.support;
-import javax.naming.NamingException;
-import javax.naming.ldap.LdapContext;
-
-import org.apache.directory.shared.ldap.message.MutableControl;
-
+import org.apache.directory.server.ldap.LdapProtocolProvider;
+import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.message.Message;
+import org.apache.directory.shared.ldap.message.MutableControl;
import org.apache.mina.handler.demux.MessageHandler;
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
/**
* An abstract class to handle common methods used by all the handlers
@@ -37,7 +38,28 @@
*/
public abstract class AbstractLdapHandler implements MessageHandler
{
- /**
+ private LdapProtocolProvider protocolProvider;
+
+
+ public final LdapProtocolProvider getProtocolProvider()
+ {
+ return protocolProvider;
+ }
+
+
+ public final void setProtocolProvider( LdapProtocolProvider provider )
+ {
+ this.protocolProvider = provider;
+ }
+
+
+ public final SessionRegistry getSessionRegistry()
+ {
+ return this.protocolProvider.getRegistry();
+ }
+
+
+ /**
* Return an array containing the controls for this message.
*
* @param context The context in which we will store teh found controls
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAbandonHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAbandonHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAbandonHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAbandonHandler.java Sun Oct 7 23:52:45 2007
@@ -20,7 +20,6 @@
package org.apache.directory.server.ldap.support;
-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;
@@ -52,7 +51,7 @@
return;
}
- Request abandonedRequest = SessionRegistry.getSingleton().getOutstandingRequest( session, abandonedId );
+ Request abandonedRequest = getSessionRegistry().getOutstandingRequest( session, abandonedId );
if ( abandonedRequest == null )
{
@@ -71,7 +70,7 @@
}
( ( AbandonableRequest ) abandonedRequest ).abandon();
- if ( SessionRegistry.getSingleton().removeOutstandingRequest( session, abandonedId ) == null )
+ if ( getSessionRegistry().removeOutstandingRequest( session, abandonedId ) == null )
{
if ( LOG.isWarnEnabled() )
{
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAddHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAddHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAddHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAddHandler.java Sun Oct 7 23:52:45 2007
@@ -66,7 +66,7 @@
try
{
- LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
+ LdapContext ctx = getSessionRegistry().getLdapContext( session, null, true );
if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
{
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java Sun Oct 7 23:52:45 2007
@@ -23,7 +23,6 @@
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.jndi.ServerLdapContext;
import org.apache.directory.server.ldap.LdapConfiguration;
-import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.server.ldap.support.bind.BindHandlerChain;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.*;
@@ -31,7 +30,6 @@
import org.apache.directory.shared.ldap.util.ExceptionUtils;
import org.apache.mina.common.IoSession;
import org.apache.mina.handler.chain.IoHandlerCommand;
-import org.apache.mina.handler.demux.MessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -62,8 +60,6 @@
/** Definition of SIMPLE and STRONG authentication constants */
private static final String SIMPLE_AUTHENTICATION_LEVEL = "simple";
- //private static final String STRONG_AUTHENTICATION_LEVEL = "strong";
-
/** An empty Contol array used to get back the controls if any */
private static final MutableControl[] EMPTY_CONTROL = new MutableControl[0];
@@ -78,7 +74,7 @@
public void setDirectoryService( DirectoryService directoryService )
{
- saslBindHandler = new BindHandlerChain( directoryService );
+ saslBindHandler = new BindHandlerChain( directoryService, getSessionRegistry() );
}
@@ -89,8 +85,11 @@
* - the credentials : principal's password, if auth level is 'simple'
* - the authentication level : either 'simple' or 'strong'
* - how to handle referral : either 'ignore' or 'throw'
+ * @param bindRequest the bind request object
+ * @param authenticationLevel the level of the authentication
+ * @return the environment for the session
*/
- private Hashtable<String, Object> getEnvironment( IoSession session, BindRequest bindRequest, String authenticationLevel )
+ private Hashtable<String, Object> getEnvironment( BindRequest bindRequest, String authenticationLevel )
{
LdapDN principal = bindRequest.getName();
@@ -107,7 +106,7 @@
}
// clone the environment first then add the required security settings
- Hashtable<String, Object> env = SessionRegistry.getSingleton().getEnvironmentByCopy();
+ Hashtable<String, Object> env = getSessionRegistry().getEnvironmentByCopy();
// Store the principal
env.put( Context.SECURITY_PRINCIPAL, principal );
@@ -136,11 +135,16 @@
/**
* Create the Context associated with the BindRequest.
+ *
+ * @param bindRequest the bind request
+ * @param env the environment to create the context with
+ * @param session the MINA IoSession
+ * @return the ldap context for the session
*/
private LdapContext getLdapContext( IoSession session, BindRequest bindRequest, Hashtable<String, Object> env )
{
LdapResult result = bindRequest.getResultResponse().getLdapResult();
- LdapContext ctx = null;
+ LdapContext ctx;
try
{
@@ -159,6 +163,7 @@
}
else
{
+ //noinspection SuspiciousToArrayCall
MutableControl[] connCtls = bindRequest.getControls().values().toArray( EMPTY_CONTROL );
ctx = new InitialLdapContext( env, connCtls );
}
@@ -206,6 +211,9 @@
* This method handle a 'simple' authentication. Of course, the 'SIMPLE' mechanism
* must have been allowed in the configuration, otherwise an error is thrown.
*
+ * @param bindRequest the bind request
+ * @param session the mina IoSession
+ * @throws NamingException if the bind fails
*/
private void handleSimpleAuth( IoSession session, BindRequest bindRequest ) throws NamingException
{
@@ -228,7 +236,7 @@
}
// Initialize the environment which will be used to create the context
- Hashtable<String, Object> env = getEnvironment( session, bindRequest, SIMPLE_AUTHENTICATION_LEVEL );
+ Hashtable<String, Object> env = getEnvironment( bindRequest, SIMPLE_AUTHENTICATION_LEVEL );
// Now, get the context
LdapContext ctx = getLdapContext( session, bindRequest, env );
@@ -238,7 +246,7 @@
{
ServerLdapContext newCtx = ( ServerLdapContext ) ctx.lookup( "" );
setRequestControls( newCtx, bindRequest );
- SessionRegistry.getSingleton().setLdapContext( session, newCtx );
+ getSessionRegistry().setLdapContext( session, newCtx );
bindResult.setResultCode( ResultCodeEnum.SUCCESS );
BindResponse response = ( BindResponse ) bindRequest.getResultResponse();
response.addAll( newCtx.getResponseControls() );
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultCompareHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultCompareHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultCompareHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultCompareHandler.java Sun Oct 7 23:52:45 2007
@@ -26,7 +26,6 @@
import javax.naming.ldap.LdapContext;
import org.apache.directory.server.core.jndi.ServerLdapContext;
-import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.CompareRequest;
import org.apache.directory.shared.ldap.message.LdapResult;
@@ -59,7 +58,7 @@
try
{
- LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
+ LdapContext ctx = getSessionRegistry().getLdapContext( session, null, true );
ServerLdapContext newCtx = ( ServerLdapContext ) ctx.lookup( "" );
if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultDeleteHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultDeleteHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultDeleteHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultDeleteHandler.java Sun Oct 7 23:52:45 2007
@@ -59,7 +59,7 @@
try
{
- LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
+ LdapContext ctx = getSessionRegistry().getLdapContext( session, null, true );
if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
{
ctx.addToEnvironment( Context.REFERRAL, "ignore" );
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultExtendedHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultExtendedHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultExtendedHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultExtendedHandler.java Sun Oct 7 23:52:45 2007
@@ -56,7 +56,7 @@
{
try
{
- handler.handleExtendedOperation( session, SessionRegistry.getSingleton(), req );
+ handler.handleExtendedOperation( session, getSessionRegistry(), req );
}
catch ( Exception e )
{
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyDnHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyDnHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyDnHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyDnHandler.java Sun Oct 7 23:52:45 2007
@@ -25,7 +25,6 @@
import javax.naming.ReferralException;
import javax.naming.ldap.LdapContext;
-import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.constants.JndiPropertyConstants;
import org.apache.directory.shared.ldap.exception.LdapException;
import org.apache.directory.shared.ldap.message.LdapResult;
@@ -90,7 +89,7 @@
{
try
{
- LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
+ LdapContext ctx = getSessionRegistry().getLdapContext( session, null, true );
if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
{
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyHandler.java Sun Oct 7 23:52:45 2007
@@ -59,7 +59,7 @@
try
{
- LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
+ LdapContext ctx = getSessionRegistry().getLdapContext( session, null, true );
if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
{
ctx.addToEnvironment( Context.REFERRAL, "ignore" );
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java Sun Oct 7 23:52:45 2007
@@ -35,7 +35,6 @@
import org.apache.directory.server.core.jndi.ServerLdapContext;
import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.ldap.LdapConfiguration;
-import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.directory.shared.ldap.constants.JndiPropertyConstants;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.exception.LdapException;
@@ -150,7 +149,7 @@
retAttrs.addAll( req.getAttributes() );
// add the search request to the registry of outstanding requests for this session
- SessionRegistry.getSingleton().addOutstandingRequest( session, req );
+ getSessionRegistry().addOutstandingRequest( session, req );
// check the attributes to see if a referral's ref attribute is included
if ( retAttrs.size() > 0 && !retAttrs.contains( SchemaConstants.REF_AT ) )
@@ -174,7 +173,7 @@
// bypass checks to disallow anonymous binds for search on RootDSE with base obj scope
if ( isRootDSESearch )
{
- LdapContext unknown = SessionRegistry.getSingleton().getLdapContextOnRootDSEAccess( session, null );
+ LdapContext unknown = getSessionRegistry().getLdapContextOnRootDSEAccess( session, null );
if ( !( unknown instanceof ServerLdapContext ) )
{
@@ -188,7 +187,7 @@
// all those search operations are subject to anonymous bind checks when anonymous binda are disallowed
else
{
- LdapContext unknown = SessionRegistry.getSingleton().getLdapContext( session, null, true );
+ LdapContext unknown = getSessionRegistry().getLdapContext( session, null, true );
if ( !( unknown instanceof ServerLdapContext ) )
{
@@ -228,19 +227,6 @@
String msg = "Bind failure: Anonymous binds have been disabled!";
result.setErrorMessage( msg );
session.write( req.getResultResponse() );
- //TM long t1 = System.nanoTime();
- //TM
- //TM synchronized (lock)
- //TM {
- //TM cumul += (t1 - t0);
- //TM count++;
- //TM
- //TM if ( count % 1000L == 0)
- //TM {
- //TM System.out.println( "Search cost : " + (cumul/count) );
- //TM cumul = 0L;
- //TM }
- //TM }
return;
}
@@ -290,7 +276,8 @@
}
if ( list.hasMore() )
{
- Iterator it = new SearchResponseIterator( req, ctx, list, controls.getSearchScope(), session );
+ Iterator it = new SearchResponseIterator( req, ctx, list, controls.getSearchScope(),
+ session, getSessionRegistry() );
while ( it.hasNext() )
{
Response resp = ( Response ) it.next();
@@ -302,20 +289,6 @@
if ( rcode != ResultCodeEnum.SUCCESS )
{
session.write( resp );
- //TM long t1 = System.nanoTime();
- //TM
- //TM synchronized( lock )
- //TM {
- //TM cumul += (t1 - t0);
- //TM count++;
- //TM
- //TM if ( count % 1000L == 0)
- //TM {
- //TM System.out.println( "Search cost : " + (cumul/count) );
- //TM cumul = 0L;
- //TM }
- //TM }
-
return;
}
// if search was fine then we returned all entries so now
@@ -334,20 +307,9 @@
}
// now we process entries for ever as they change
- PersistentSearchListener handler = new PersistentSearchListener( ctx, session, req );
+ PersistentSearchListener handler = new PersistentSearchListener( getSessionRegistry(),
+ ctx, session, req );
ctx.addNamingListener( req.getBase(), req.getFilter().toString(), controls, handler );
- //TM long t1 = System.nanoTime();
- //TM synchronized( lock )
- //TM {
- //TM cumul += (t1 - t0);
- //TM count++;
- //TM
- //TM if ( count % 1000L == 0)
- //TM {
- //TM System.out.println( "Search cost : " + (cumul/count) );
- //TM cumul = 0L;
- //TM }
- //TM }
return;
}
@@ -367,7 +329,8 @@
if ( list.hasMore() )
{
- Iterator it = new SearchResponseIterator( req, ctx, list, controls.getSearchScope(), session );
+ Iterator it = new SearchResponseIterator( req, ctx, list, controls.getSearchScope(),
+ session, getSessionRegistry() );
while ( it.hasNext() )
{
session.write( it.next() );
@@ -398,7 +361,7 @@
}
while ( e.skipReferral() );
session.write( req.getResultResponse() );
- SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId() );
+ getSessionRegistry().removeOutstandingRequest( session, req.getMessageId() );
}
catch ( NamingException e )
{
@@ -450,7 +413,7 @@
{
session.write( resultResponse );
}
- SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId() );
+ getSessionRegistry().removeOutstandingRequest( session, req.getMessageId() );
}
finally
{
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultUnbindHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultUnbindHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultUnbindHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultUnbindHandler.java Sun Oct 7 23:52:45 2007
@@ -45,11 +45,9 @@
public void unbindMessageReceived( IoSession session, UnbindRequest request ) throws Exception
{
- SessionRegistry registry = SessionRegistry.getSingleton();
-
try
{
- LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, false );
+ LdapContext ctx = getSessionRegistry().getLdapContext( session, null, false );
if ( ctx != null )
{
@@ -59,8 +57,8 @@
}
ctx.close();
}
- registry.terminateSession( session );
- registry.remove( session );
+ getSessionRegistry().terminateSession( session );
+ getSessionRegistry().remove( session );
}
catch ( NamingException e )
{
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/PersistentSearchListener.java Sun Oct 7 23:52:45 2007
@@ -65,17 +65,21 @@
*/
class PersistentSearchListener implements ObjectChangeListener, NamespaceChangeListener, AbandonListener
{
- private static final Logger log = LoggerFactory.getLogger( SearchHandler.class );
+ private static final Logger LOG = LoggerFactory.getLogger( SearchHandler.class );
final ServerLdapContext ctx;
final IoSession session;
final SearchRequest req;
final PersistentSearchControl control;
+ final SessionRegistry registry;
+
/** Speedup for logs */
- private static final boolean IS_DEBUG = log.isDebugEnabled();
+ private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
- PersistentSearchListener(ServerLdapContext ctx, IoSession session, SearchRequest req)
+ PersistentSearchListener( SessionRegistry registry, ServerLdapContext ctx, IoSession session, SearchRequest req )
{
+ this.registry = registry;
this.session = session;
this.req = req;
req.addAbandonListener( this );
@@ -115,7 +119,7 @@
}
catch ( NamingException e )
{
- log.error( "Attempt to remove listener from context failed", e );
+ LOG.error( "Attempt to remove listener from context failed", e );
}
/*
@@ -135,7 +139,7 @@
return;
}
- SessionRegistry.getSingleton().removeOutstandingRequest( session, new Integer( req.getMessageId() ) );
+ registry.removeOutstandingRequest( session, new Integer( req.getMessageId() ) );
String msg = "failed on persistent search operation";
if ( IS_DEBUG )
@@ -143,7 +147,7 @@
msg += ":\n" + req + ":\n" + ExceptionUtils.getStackTrace( evt.getException() );
}
- ResultCodeEnum code = null;
+ ResultCodeEnum code;
if ( evt.getException() instanceof LdapException )
{
@@ -322,7 +326,7 @@
}
catch ( NamingException e )
{
- log.error( "failed to properly abandon this persistent search", e );
+ LOG.error( "failed to properly abandon this persistent search", e );
}
}
}
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchResponseIterator.java Sun Oct 7 23:52:45 2007
@@ -64,18 +64,20 @@
*/
class SearchResponseIterator implements Iterator
{
- private static final Logger log = LoggerFactory.getLogger( SearchResponseIterator.class );
+ private static final Logger LOG = LoggerFactory.getLogger( SearchResponseIterator.class );
private final SearchRequest req;
private final ServerLdapContext ctx;
private final NamingEnumeration underlying;
private final IoSession session;
+ private final SessionRegistry registry;
private SearchResponseDone respDone;
- private boolean done = false;
+ private boolean done;
private Object prefetched;
private final int scope;
/** Speedup for logs */
- private static final boolean IS_DEBUG = log.isDebugEnabled();
+ private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
/**
* Creates a search response iterator for the resulting enumeration
@@ -83,15 +85,20 @@
*
* @param req the search request to generate responses to
* @param underlying the underlying JNDI enumeration containing SearchResults
+ * @param ctx the context where search is applied
+ * @param registry the session registry
+ * @param scope the scope of the search
+ * @param session the session of the issuer of the search
*/
public SearchResponseIterator( SearchRequest req, ServerLdapContext ctx, NamingEnumeration underlying, int scope,
- IoSession session )
+ IoSession session, SessionRegistry registry )
{
this.req = req;
this.ctx = ctx;
this.scope = scope;
this.underlying = underlying;
this.session = session;
+ this.registry = registry;
try
{
@@ -137,6 +144,7 @@
}
catch ( Throwable t )
{
+ LOG.error( "Encountered error while trying to close underlying enumeration", t );
}
prefetched = null;
@@ -149,7 +157,7 @@
}
else
{
- SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId() );
+ registry.removeOutstandingRequest( session, req.getMessageId() );
}
}
catch ( NamingException e )
@@ -160,6 +168,7 @@
}
catch ( Exception e2 )
{
+ LOG.error( "Encountered error while trying to close underlying enumeration", e );
}
respDone = getResponse( req, e );
@@ -191,7 +200,7 @@
throw nsee;
}
- SearchResult result = null;
+ SearchResult result;
// if we're done we got nothing to give back
if ( done )
@@ -240,12 +249,13 @@
}
catch ( Throwable t )
{
+ LOG.error( "Encountered error while trying to close underlying enumeration", t );
}
respDone = ( SearchResponseDone ) req.getResultResponse();
respDone.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
prefetched = null;
- SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId() );
+ registry.removeOutstandingRequest( session, req.getMessageId() );
return next;
}
}
@@ -257,6 +267,7 @@
}
catch ( Throwable t )
{
+ LOG.error( "Encountered error while trying to close underlying enumeration", t );
}
prefetched = null;
@@ -269,7 +280,7 @@
* local variable for the following call to next()
*/
Attribute ref = result.getAttributes().get( SchemaConstants.REF_AT );
- boolean isReferral = false;
+ boolean isReferral;
try
{
@@ -277,7 +288,7 @@
}
catch ( NamingException e )
{
- log.error( "failed to determine if " + result.getName() + " is a referral", e );
+ LOG.error( "failed to determine if " + result.getName() + " is a referral", e );
throw new RuntimeException( e );
}
@@ -291,7 +302,7 @@
}
catch ( NamingException e )
{
- log.error( "failed to lookup ref attribute for " + result.getName(), e );
+ LOG.error( "failed to lookup ref attribute for " + result.getName(), e );
throw new RuntimeException( e );
}
}
@@ -307,7 +318,7 @@
}
catch ( InvalidNameException ine )
{
- log.error( "Invalid object name : " + result.getName(), ine);
+ LOG.error( "Invalid object name : " + result.getName(), ine);
throw new RuntimeException( ine );
}
@@ -327,13 +338,14 @@
}
catch ( NamingException e1 )
{
- log.error( "failed to access referral url." );
+ LOG.error( "failed to access referral url." );
try
{
underlying.close();
}
catch ( Throwable t )
{
+ LOG.error( "Encountered error while trying to close underlying enumeration", t );
}
prefetched = null;
@@ -356,7 +368,7 @@
}
catch ( LdapURLEncodingException e )
{
- log
+ LOG
.error( "Bad URL (" + val + ") for ref in " + result.getName()
+ ". Reference will be ignored." );
try
@@ -365,6 +377,7 @@
}
catch ( Throwable t )
{
+ LOG.error( "Encountered error while trying to close underlying enumeration", t );
}
prefetched = null;
@@ -433,7 +446,7 @@
}
SearchResponseDone resp = ( SearchResponseDone ) req.getResultResponse();
- ResultCodeEnum code = null;
+ ResultCodeEnum code;
if ( e instanceof LdapException )
{
@@ -459,7 +472,7 @@
}
}
- SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId() );
+ registry.removeOutstandingRequest( session, req.getMessageId() );
return resp;
}
}
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java Sun Oct 7 23:52:45 2007
@@ -22,7 +22,6 @@
import org.apache.directory.shared.ldap.message.UnbindRequest;
import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
/**
@@ -32,7 +31,7 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$
*/
-public abstract class UnbindHandler implements MessageHandler
+public abstract class UnbindHandler extends AbstractLdapHandler
{
public final void messageReceived( IoSession session, Object request ) throws Exception
{
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/BindHandlerChain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/BindHandlerChain.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/BindHandlerChain.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/BindHandlerChain.java Sun Oct 7 23:52:45 2007
@@ -21,6 +21,7 @@
import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.ldap.SessionRegistry;
import org.apache.mina.handler.chain.IoHandlerChain;
@@ -32,14 +33,16 @@
{
/**
* Creates a new instance of BindHandlerChain.
+ * @param directoryService the directory core service
+ * @param registry the session registry for MINA IoSessions
*/
- public BindHandlerChain( DirectoryService directoryService )
+ public BindHandlerChain( DirectoryService directoryService, SessionRegistry registry )
{
addLast( "configureChain", new ConfigureChain() );
addLast( "chainGuard", new ChainGuard() );
addLast( "handleSasl", new HandleSasl( directoryService ) );
addLast( "handleSimple", new HandleSimple() );
- addLast( "getLdapContext", new GetLdapContext() );
+ addLast( "getLdapContext", new GetLdapContext( registry ) );
addLast( "returnSuccess", new ReturnSuccess() );
}
}
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GetLdapContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GetLdapContext.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GetLdapContext.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/bind/GetLdapContext.java Sun Oct 7 23:52:45 2007
@@ -49,18 +49,24 @@
*/
public class GetLdapContext implements IoHandlerCommand
{
- private static final Logger log = LoggerFactory.getLogger( GetLdapContext.class );
-
+ private static final Logger LOG = LoggerFactory.getLogger( GetLdapContext.class );
private static final MutableControl[] EMPTY = new MutableControl[0];
+ private final SessionRegistry registry;
+
+
+ public GetLdapContext( SessionRegistry registry )
+ {
+ this.registry = registry;
+ }
+
public void execute( NextCommand next, IoSession session, Object message ) throws Exception
{
Hashtable env = getEnvironment( session, message );
-
BindRequest request = ( BindRequest ) message;
LdapResult result = request.getResultResponse().getLdapResult();
- LdapContext ctx = null;
+ LdapContext ctx;
try
{
@@ -78,11 +84,12 @@
}
else
{
+ //noinspection SuspiciousToArrayCall
MutableControl[] connCtls = request.getControls().values().toArray( EMPTY );
ctx = new InitialLdapContext( env, connCtls );
}
- SessionRegistry.getSingleton().setLdapContext( session, ctx );
+ registry.setLdapContext( session, ctx );
// add the bind response controls
request.getResultResponse().addAll( ctx.getResponseControls() );
@@ -106,7 +113,7 @@
String msg = "Bind failed: " + e.getMessage();
- if ( log.isDebugEnabled() )
+ if ( LOG.isDebugEnabled() )
{
msg += ":\n" + ExceptionUtils.getStackTrace( e );
msg += "\n\nBindRequest = \n" + request.toString();
@@ -121,6 +128,7 @@
result.setErrorMessage( msg );
session.write( request.getResultResponse() );
+ //noinspection UnusedAssignment
ctx = null;
}
}
@@ -138,12 +146,12 @@
String sessionMechanism = ( String ) session.getAttribute( "sessionMechanism" );
String authenticationLevel = getAuthenticationLevel( sessionMechanism );
- log.debug( "{} {}", Context.SECURITY_PRINCIPAL, principal );
- log.debug( "{} {}", Context.SECURITY_CREDENTIALS, credentials );
- log.debug( "{} {}", Context.SECURITY_AUTHENTICATION, authenticationLevel );
+ LOG.debug( "{} {}", Context.SECURITY_PRINCIPAL, principal );
+ LOG.debug( "{} {}", Context.SECURITY_CREDENTIALS, credentials );
+ LOG.debug( "{} {}", Context.SECURITY_AUTHENTICATION, authenticationLevel );
// clone the environment first then add the required security settings
- Hashtable<String, Object> env = SessionRegistry.getSingleton().getEnvironmentByCopy();
+ Hashtable<String, Object> env = registry.getEnvironmentByCopy();
env.put( Context.SECURITY_PRINCIPAL, principal );
if ( credentials != null )
Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/LaunchDiagnosticUiHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/LaunchDiagnosticUiHandler.java?rev=582729&r1=582728&r2=582729&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/LaunchDiagnosticUiHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/extended/LaunchDiagnosticUiHandler.java Sun Oct 7 23:52:45 2007
@@ -117,7 +117,7 @@
}
}
- SessionsFrame sessions = new SessionsFrame();
+ SessionsFrame sessions = new SessionsFrame( ldapProvider.getRegistry() );
sessions.setRequestor( requestor );
sessions.setLdapProvider( ldapProvider.getHandler() );
Point pos = getCenteredPosition( sessions );