directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r370453 - in /directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol: ./ gui/ support/ support/extended/
Date Thu, 19 Jan 2006 09:51:20 GMT
Author: akarasulu
Date: Thu Jan 19 01:51:15 2006
New Revision: 370453

URL: http://svn.apache.org/viewcvs?rev=370453&view=rev
Log:
added simple session UI for testing and diagnosing issues with the serve

Added:
    directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/
    directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/OutstandingRequestsDialog.java
  (with props)
    directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/OutstandingRequestsModel.java
  (with props)
    directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/SessionsFrame.java
  (with props)
    directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/SessionsModel.java
  (with props)
Modified:
    directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/SessionRegistry.java
    directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java
    directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/extended/LaunchDiagnosticUiHandler.java

Modified: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/SessionRegistry.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/SessionRegistry.java?rev=370453&r1=370452&r2=370453&view=diff
==============================================================================
--- directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/SessionRegistry.java
(original)
+++ directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/SessionRegistry.java
Thu Jan 19 01:51:15 2006
@@ -68,6 +68,11 @@
      */
     public static SessionRegistry getSingleton()
     {
+        if ( s_singleton == null )
+        {
+            s_singleton = new SessionRegistry( new Hashtable() );
+        }
+
         return s_singleton;
     }
 
@@ -135,6 +140,7 @@
             if ( reqmap == null )
             {
                 reqmap = new HashMap();
+                requests.put( session, reqmap );
             }
             reqmap.put( new Integer( req.getMessageId() ), req );
         }
@@ -214,6 +220,18 @@
         Map reqmap = ( Map ) requests.get( session );
         if ( reqmap == null ) return null;
         return ( Request ) reqmap.get( id );
+    }
+    
+    
+    public IoSession[] getSessions()
+    {
+        IoSession[] sessions;
+        synchronized ( contexts )
+        {
+            sessions = new IoSession[contexts.size()];
+            sessions = ( IoSession[] ) contexts.keySet().toArray( sessions );
+        }
+        return sessions;
     }
     
     

Added: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/OutstandingRequestsDialog.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/OutstandingRequestsDialog.java?rev=370453&view=auto
==============================================================================
--- directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/OutstandingRequestsDialog.java
(added)
+++ directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/OutstandingRequestsDialog.java
Thu Jan 19 01:51:15 2006
@@ -0,0 +1,307 @@
+package org.apache.ldap.server.protocol.gui;
+
+
+import java.awt.BorderLayout;
+import java.net.InetSocketAddress;
+import java.util.Map;
+
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JDialog;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JButton;
+
+import org.apache.ldap.common.message.AbandonableRequest;
+import org.apache.ldap.server.protocol.SessionRegistry;
+import org.apache.mina.common.IoSession;
+import javax.swing.JTextArea;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+
+public class OutstandingRequestsDialog extends JDialog
+{
+    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;
+
+    final IoSession session;
+    private JPanel jPanel2 = null;
+    private JTextArea jTextArea = null;
+    private JButton jButton1 = null;
+    private JButton jButton2 = null;
+
+    
+    /**
+     * This is the default constructor
+     */
+    public OutstandingRequestsDialog( JFrame owner, IoSession session )
+    {
+        super( owner, true );
+        this.session = session;
+        StringBuffer buf = new StringBuffer();
+        buf.append( "Outstanding Requests: " );
+        buf.append( ( ( InetSocketAddress ) session.getRemoteAddress() ).getHostName() );
+        buf.append( ":" );
+        buf.append( ( ( InetSocketAddress ) session.getRemoteAddress() ).getPort() );
+        setTitle( buf.toString() );
+        initialize();
+    }
+
+
+    /**
+     * This method initializes this
+     * 
+     * @return void
+     */
+    private void initialize()
+    {
+        this.setSize(549, 341);
+        this.setContentPane( getJContentPane() );
+    }
+
+
+    /**
+     * This method initializes jContentPane
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJContentPane()
+    {
+        if ( jContentPane == null )
+        {
+            jContentPane = new JPanel();
+            jContentPane.setLayout( new BorderLayout() );
+            jContentPane.add(getJPanel(), java.awt.BorderLayout.CENTER);
+        }
+        return jContentPane;
+    }
+
+
+    /**
+     * This method initializes jPanel	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getJPanel()
+    {
+        if ( jPanel == null )
+        {
+            jPanel = new JPanel();
+            jPanel.setLayout(new BorderLayout());
+            jPanel.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
+            jPanel.add(getJPanel1(), java.awt.BorderLayout.SOUTH);
+            jPanel.add(getJPanel2(), java.awt.BorderLayout.NORTH);
+        }
+        return jPanel;
+    }
+
+
+    /**
+     * This method initializes jScrollPane	
+     * 	
+     * @return javax.swing.JScrollPane	
+     */
+    private JScrollPane getJScrollPane()
+    {
+        if ( jScrollPane == null )
+        {
+            jScrollPane = new JScrollPane();
+            jScrollPane.setViewportView(getJTable());
+        }
+        return jScrollPane;
+    }
+
+
+    /**
+     * This method initializes jTable	
+     * 	
+     * @return javax.swing.JTable	
+     */
+    private JTable getJTable()
+    {
+        if ( jTable == null )
+        {
+            jTable = new JTable();
+        }
+
+        setRequestsModel();
+        jTable.getSelectionModel().addListSelectionListener( new ListSelectionListener()
{
+            public void valueChanged(ListSelectionEvent e)
+            {
+                int row = jTable.getSelectedRow();
+                if ( row > -1 )
+                {
+                    jButton2.setEnabled( true );
+                    AbandonableRequest req = ( ( OutstandingRequestsModel ) jTable.getModel()
).getAbandonableRequest( row );
+                    jTextArea.setText( req.toString() );
+                    jTextArea.setEnabled( true );
+                }
+                else
+                {
+                    jButton2.setEnabled( false );
+                    jTextArea.setText( "" );
+                    jTextArea.setEnabled( false );
+                }
+            }});
+        return jTable;
+    }
+
+    
+    private void setRequestsModel()
+    {
+        AbandonableRequest[] requests; 
+        Map reqsMap = SessionRegistry.getSingleton().getOutstandingRequests( session );
+        if ( reqsMap != null )
+        {
+            requests = new AbandonableRequest[reqsMap.size()];
+            requests = ( AbandonableRequest[] ) reqsMap.values().toArray( requests );
+        }
+        else
+        {
+            requests = EMPTY_REQUEST_ARRAY;
+        }
+        
+        jTable.setModel( new OutstandingRequestsModel( requests ) );
+    }
+
+
+    /**
+     * This method initializes jPanel1	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getJPanel1()
+    {
+        if ( jPanel1 == null )
+        {
+            jPanel1 = new JPanel();
+            jPanel1.add(getJButton(), null);
+            jPanel1.add(getJButton1(), null);
+        }
+        return jPanel1;
+    }
+
+
+    /**
+     * This method initializes jButton	
+     * 	
+     * @return javax.swing.JButton	
+     */
+    private JButton getJButton()
+    {
+        if ( jButton == null )
+        {
+            jButton = new JButton();
+            jButton.setText("Done");
+            jButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed(java.awt.event.ActionEvent e)
+                {
+                    OutstandingRequestsDialog.this.setVisible( false );
+                    OutstandingRequestsDialog.this.dispose();
+                }
+            } );
+        }
+        return jButton;
+    }
+
+
+    /**
+     * This method initializes jPanel2	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getJPanel2()
+    {
+        if ( jPanel2 == null )
+        {
+            jPanel2 = new JPanel();
+            jPanel2.setLayout(new BorderLayout());
+            jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Request",

+                javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, 
+                javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
+            jPanel2.add(getJButton2(), java.awt.BorderLayout.WEST);
+            jPanel2.add(getJTextArea(), java.awt.BorderLayout.CENTER);
+        }
+        return jPanel2;
+    }
+
+
+    /**
+     * This method initializes jTextArea	
+     * 	
+     * @return javax.swing.JTextArea	
+     */
+    private JTextArea getJTextArea()
+    {
+        if ( jTextArea == null )
+        {
+            jTextArea = new JTextArea();
+        }
+        
+        jTextArea.setEnabled( false );
+        jTextArea.setEditable( false );
+        return jTextArea;
+    }
+
+
+    /**
+     * This method initializes jButton1	
+     * 	
+     * @return javax.swing.JButton	
+     */
+    private JButton getJButton1()
+    {
+        if ( jButton1 == null )
+        {
+            jButton1 = new JButton();
+            jButton1.setText("Refresh");
+            jButton1.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed(java.awt.event.ActionEvent e)
+                {
+                    setRequestsModel();
+                    jTextArea.setText( "" );
+                    jTextArea.setEnabled( false );
+                    jButton2.setEnabled( false );
+                }
+            } );
+        }
+        return jButton1;
+    }
+
+
+    /**
+     * This method initializes jButton2	
+     * 	
+     * @return javax.swing.JButton	
+     */
+    private JButton getJButton2()
+    {
+        if ( jButton2 == null )
+        {
+            jButton2 = new JButton();
+            jButton2.setText("Abandon");
+            jButton2.setEnabled( false );
+            jButton2.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed(java.awt.event.ActionEvent e)
+                {
+                    int row = jTable.getSelectedRow();
+                    AbandonableRequest req = ( ( OutstandingRequestsModel ) jTable.getModel()
).getAbandonableRequest( row );
+                    req.abandon();
+                    SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId()
);
+                    setRequestsModel();
+                }
+            } );
+        }
+        return jButton2;
+    }
+}  //  @jve:decl-index=0:visual-constraint="10,10"

Propchange: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/OutstandingRequestsDialog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/OutstandingRequestsModel.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/OutstandingRequestsModel.java?rev=370453&view=auto
==============================================================================
--- directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/OutstandingRequestsModel.java
(added)
+++ directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/OutstandingRequestsModel.java
Thu Jan 19 01:51:15 2006
@@ -0,0 +1,79 @@
+package org.apache.ldap.server.protocol.gui;
+
+
+import javax.swing.event.TableModelListener;
+import javax.swing.table.TableModel;
+
+import org.apache.ldap.common.message.AbandonableRequest;
+
+
+public class OutstandingRequestsModel implements TableModel
+{
+    final String[] columns = new String[] { "messageId", "type" };
+    final Class[] columnClasses = new Class[] { Integer.class, String.class };
+    final AbandonableRequest[] requests;
+
+    
+    OutstandingRequestsModel( AbandonableRequest[] requests )
+    {
+        this.requests = requests;
+    }
+
+    AbandonableRequest getAbandonableRequest( int row )
+    {
+        return requests[row];
+    }
+    
+    public int getRowCount()
+    {
+        return requests.length;
+    }
+
+    public int getColumnCount()
+    {
+        return columns.length;
+    }
+
+    public String getColumnName( int columnIndex )
+    {
+        return columns[columnIndex];
+    }
+
+    public Class getColumnClass( int columnIndex )
+    {
+        return columnClasses[columnIndex];
+    }
+
+    public boolean isCellEditable( int rowIndex, int columnIndex )
+    {
+        return false;
+    }
+
+    public Object getValueAt( int rowIndex, int columnIndex )
+    {
+        AbandonableRequest req = requests[rowIndex];
+        
+        switch( columnIndex )
+        {
+            case( 0 ):
+                return new Integer( req.getMessageId() );
+            case( 1 ):
+                return req.getType().toString();
+            default:
+                throw new IndexOutOfBoundsException( "column index max is " + ( columns.length
- 1 ) );
+        }
+    }
+
+    public void setValueAt(Object aValue, int rowIndex, int columnIndex)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void addTableModelListener(TableModelListener l)
+    {
+    }
+
+    public void removeTableModelListener(TableModelListener l)
+    {
+    }
+}

Propchange: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/OutstandingRequestsModel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/SessionsFrame.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/SessionsFrame.java?rev=370453&view=auto
==============================================================================
--- directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/SessionsFrame.java
(added)
+++ directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/SessionsFrame.java
Thu Jan 19 01:51:15 2006
@@ -0,0 +1,688 @@
+package org.apache.ldap.server.protocol.gui;
+
+
+import java.awt.BorderLayout;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import javax.swing.JPanel;
+import javax.swing.JFrame;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.JButton;
+import javax.swing.BoxLayout;
+import javax.swing.JTextField;
+import javax.swing.JMenuBar;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+
+import org.apache.ldap.common.message.ResultCodeEnum;
+import org.apache.ldap.common.message.extended.NoticeOfDisconnect;
+import org.apache.ldap.server.protocol.SessionRegistry;
+import org.apache.mina.common.IoSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+public class SessionsFrame extends JFrame
+{
+    private static final Logger log = LoggerFactory.getLogger( SessionsFrame.class );
+    private static final long serialVersionUID = -863445561454536133L;
+    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 IoSession selected;
+    
+    
+    /**
+     * This is the default constructor
+     */
+    public SessionsFrame()
+    {
+        super();
+        initialize();
+    }
+
+
+    /**
+     * This method initializes this
+     * 
+     * @return void
+     */
+    private void initialize()
+    {
+        this.setSize(789, 436);
+        this.setJMenuBar( getMainMenuBar() );
+        this.setContentPane( getJContentPane() );
+        this.setTitle("Sessions");
+        this.addWindowListener( new java.awt.event.WindowAdapter()
+        {
+            public void windowClosing(java.awt.event.WindowEvent e)
+            {
+                SessionsFrame.this.setVisible( false );
+                SessionsFrame.this.dispose();
+            }
+        } );
+    }
+
+
+    /**
+     * This method initializes jContentPane
+     * 
+     * @return javax.swing.JPanel
+     */
+    private JPanel getJContentPane()
+    {
+        if ( jContentPane == null )
+        {
+            jContentPane = new JPanel();
+            jContentPane.setLayout( new BorderLayout() );
+            jContentPane.add(getMainPanel(), java.awt.BorderLayout.CENTER);
+        }
+        return jContentPane;
+    }
+
+
+    /**
+     * This method initializes jPanel	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getMainPanel()
+    {
+        if ( mainPanel == null )
+        {
+            mainPanel = new JPanel();
+            mainPanel.setLayout(new BorderLayout());
+            mainPanel.add(getFilterPanel(), java.awt.BorderLayout.NORTH);
+            mainPanel.add(getSessionsPane(), java.awt.BorderLayout.CENTER);
+            mainPanel.add(getSouthPanel(), java.awt.BorderLayout.SOUTH);
+        }
+        return mainPanel;
+    }
+
+
+    /**
+     * This method initializes jScrollPane	
+     * 	
+     * @return javax.swing.JScrollPane	
+     */
+    private JScrollPane getSessionsPane()
+    {
+        if ( sessionsPane == null )
+        {
+            sessionsPane = new JScrollPane();
+            sessionsPane.setName("jScrollPane");
+            sessionsPane.setViewportView(getSessionsTable());
+        }
+        return sessionsPane;
+    }
+
+
+    /**
+     * This method initializes jTable	
+     * 	
+     * @return javax.swing.JTable	
+     */
+    private JTable getSessionsTable()
+    {
+        if ( sessionsTable == null )
+        {
+            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.getSelectionModel().addListSelectionListener( new ListSelectionListener()
{
+                public void valueChanged(ListSelectionEvent e)
+                {
+                    int row = sessionsTable.getSelectedRow();
+                    if ( row == -1 )
+                    {
+                        selected = null;
+                    }
+                    else 
+                    {
+                        selected = ( ( SessionsModel ) sessionsTable.getModel() ).getIoSession(
row );
+                        closeItem.setEnabled( true );
+                        menuSendNoD.setEnabled( true );
+                        showRequests.setEnabled( true );
+                    }
+                }
+            });
+        }
+        return sessionsTable;
+    }
+
+
+    /**
+     * This method initializes jPanel	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getFilterPanel()
+    {
+        if ( filterPanel == null )
+        {
+            filterPanel = new JPanel();
+            filterPanel.setLayout(new BoxLayout(getFilterPanel(), BoxLayout.X_AXIS));
+            filterPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
+            filterPanel.add(getFilterButton(), null);
+            filterPanel.add(getFilterText(), null);
+        }
+        return filterPanel;
+    }
+
+
+    /**
+     * This method initializes jButton	
+     * 	
+     * @return javax.swing.JButton	
+     */
+    private JButton getFilterButton()
+    {
+        if ( filterButton == null )
+        {
+            filterButton = new JButton();
+            filterButton.setText("Filter");
+        }
+        return filterButton;
+    }
+
+
+    /**
+     * This method initializes jTextField	
+     * 	
+     * @return javax.swing.JTextField	
+     */
+    private JTextField getFilterText()
+    {
+        if ( filterText == null )
+        {
+            filterText = new JTextField();
+        }
+        return filterText;
+    }
+
+
+    /**
+     * This method initializes jJMenuBar	
+     * 	
+     * @return javax.swing.JMenuBar	
+     */
+    private JMenuBar getMainMenuBar()
+    {
+        if ( menuBar == null )
+        {
+            menuBar = new JMenuBar();
+            menuBar.add(getMenuFile());
+            menuBar.add(getMenuSession());
+        }
+        return menuBar;
+    }
+
+
+    /**
+     * This method initializes jMenu	
+     * 	
+     * @return javax.swing.JMenu	
+     */
+    private JMenu getMenuFile()
+    {
+        if ( menuFile == null )
+        {
+            menuFile = new JMenu();
+            menuFile.setText("File");
+            menuFile.add(getExitItem());
+        }
+        return menuFile;
+    }
+
+
+    /**
+     * This method initializes jMenuItem	
+     * 	
+     * @return javax.swing.JMenuItem	
+     */
+    private JMenuItem getExitItem()
+    {
+        if ( exitItem == null )
+        {
+            exitItem = new JMenuItem();
+            exitItem.setText("exit");
+            exitItem.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed(java.awt.event.ActionEvent e)
+                {
+                    SessionsFrame.this.setVisible( false );
+                    SessionsFrame.this.dispose();
+                }
+            } );
+        }
+        return exitItem;
+    }
+
+
+    /**
+     * This method initializes jMenu	
+     * 	
+     * @return javax.swing.JMenu	
+     */
+    private JMenu getMenuSession()
+    {
+        if ( menuSession == null )
+        {
+            menuSession = new JMenu();
+            menuSession.setText("Session");
+            menuSession.add(getCloseItem());
+            closeItem.setEnabled( false );
+            menuSession.add(getMenuSendNoD());
+            menuSendNoD.setEnabled( false );
+            menuSession.add(getShowRequests());
+            showRequests.setEnabled( false );
+        }
+        return menuSession;
+    }
+
+
+    /**
+     * This method initializes jMenuItem	
+     * 	
+     * @return javax.swing.JMenuItem	
+     */
+    private JMenuItem getCloseItem()
+    {
+        if ( closeItem == null )
+        {
+            closeItem = new JMenuItem();
+            closeItem.setText("close");
+            closeItem.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed(java.awt.event.ActionEvent e)
+                {
+                    SessionRegistry.getSingleton().terminateSession( selected );
+                    try
+                    {
+                        Thread.sleep( 250 );
+                    }
+                    catch ( InterruptedException e1 )
+                    {
+                        log.error( "", e1 );
+                    }
+                    refresh();
+                }
+            } );
+        }
+        return closeItem;
+    }
+
+    
+    /**
+     * This method initializes jMenu	
+     * 	
+     * @return javax.swing.JMenu	
+     */
+    private JMenu getMenuSendNoD()
+    {
+        if ( menuSendNoD == null )
+        {
+            menuSendNoD = new JMenu();
+            menuSendNoD.setText("Send NoD");
+            menuSendNoD.add(getUnavailableItem());
+            menuSendNoD.add(getProtocolErrorItem());
+            menuSendNoD.add(getStrongAuthRequiredItem());
+        }
+        return menuSendNoD;
+    }
+
+
+    /**
+     * This method initializes jMenuItem	
+     * 	
+     * @return javax.swing.JMenuItem	
+     */
+    private JMenuItem getUnavailableItem()
+    {
+        if ( unavailableItem == null )
+        {
+            unavailableItem = new JMenuItem();
+            unavailableItem.setText("unavailable");
+            unavailableItem.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed(java.awt.event.ActionEvent e)
+                {
+                    selected.write( new NoticeOfDisconnect( ResultCodeEnum.UNAVAILABLE )
); 
+                    try
+                    {
+                        Thread.sleep( 250 );
+                    }
+                    catch ( InterruptedException e1 )
+                    {
+                        log.error( "", e1 );
+                    }
+                    refresh();
+                }
+            } );
+        }
+        return unavailableItem;
+    }
+
+
+    /**
+     * This method initializes jMenuItem	
+     * 	
+     * @return javax.swing.JMenuItem	
+     */
+    private JMenuItem getProtocolErrorItem()
+    {
+        if ( protocolErrorItem == null )
+        {
+            protocolErrorItem = new JMenuItem();
+            protocolErrorItem.setText("protocolError");
+            protocolErrorItem.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed(java.awt.event.ActionEvent e)
+                {
+                    selected.write( new NoticeOfDisconnect( ResultCodeEnum.PROTOCOLERROR
) ); 
+                    try
+                    {
+                        Thread.sleep( 250 );
+                    }
+                    catch ( InterruptedException e1 )
+                    {
+                        log.error( "", e1 );
+                    }
+                    refresh();
+                }
+            } );
+        }
+        return protocolErrorItem;
+    }
+
+
+    /**
+     * This method initializes jMenuItem	
+     * 	
+     * @return javax.swing.JMenuItem	
+     */
+    private JMenuItem getStrongAuthRequiredItem()
+    {
+        if ( strongAuthRequiredItem == null )
+        {
+            strongAuthRequiredItem = new JMenuItem();
+            strongAuthRequiredItem.setText("strongAuthRequired");
+            strongAuthRequiredItem.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed(java.awt.event.ActionEvent e)
+                {
+                    selected.write( new NoticeOfDisconnect( ResultCodeEnum.STRONGAUTHREQUIRED
) ); 
+                    try
+                    {
+                        Thread.sleep( 250 );
+                    }
+                    catch ( InterruptedException e1 )
+                    {
+                        log.error( "", e1 );
+                    }
+                    refresh();
+                }
+            } );
+        }
+        return strongAuthRequiredItem;
+    }
+
+
+//    /**
+//     * This method initializes jPopupMenu	
+//     * 	
+//     * @return javax.swing.JPopupMenu	
+//     */
+//    private JPopupMenu getSessionsPopupMenu()
+//    {
+//        if ( popupMenu == null )
+//        {
+//            popupMenu = new JPopupMenu();
+//            popupMenu.add(getJMenuItem());
+//            popupMenu.add(getJMenu());
+//            popupMenu.add(getJMenuItem4());
+//        }
+//        return popupMenu;
+//    }
+
+
+    /**
+     * This method initializes jPanel	
+     * 	
+     * @return javax.swing.JPanel	
+     */
+    private JPanel getSouthPanel()
+    {
+        if ( southPanel == null )
+        {
+            southPanel = new JPanel();
+            southPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
+            southPanel.add(getRefreshButton(), null);
+        }
+        return southPanel;
+    }
+
+
+    /**
+     * This method initializes jMenuItem	
+     * 	
+     * @return javax.swing.JMenuItem	
+     */
+    private JMenuItem getShowRequests()
+    {
+        if ( showRequests == null )
+        {
+            showRequests = new JMenuItem();
+            showRequests.setText("show requests");
+            showRequests.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed(java.awt.event.ActionEvent e)
+                {
+                    OutstandingRequestsDialog dialog = new OutstandingRequestsDialog( SessionsFrame.this,
selected );
+                    dialog.addWindowListener( new WindowAdapter() {
+                        public void windowClosed(WindowEvent e)
+                        {
+                            e.getWindow().dispose();
+                        }
+                    });
+                    dialog.setVisible( true );
+                }
+            } );
+        }
+        return showRequests;
+    }
+
+
+//    /**
+//     * This method initializes jMenuItem	
+//     * 	
+//     * @return javax.swing.JMenuItem	
+//     */
+//    private JMenuItem getJMenuItem()
+//    {
+//        if ( jMenuItem == null )
+//        {
+//            jMenuItem = new JMenuItem();
+//            jMenuItem.setText("close");
+//        }
+//        return jMenuItem;
+//    }
+//
+//
+//    /**
+//     * This method initializes jMenu	
+//     * 	
+//     * @return javax.swing.JMenu	
+//     */
+//    private JMenu getJMenu()
+//    {
+//        if ( jMenu == null )
+//        {
+//            jMenu = new JMenu();
+//            jMenu.setText("Send NoD");
+//            jMenu.add(getJMenuItem1());
+//            jMenu.add(getJMenuItem2());
+//            jMenu.add(getJMenuItem3());
+//        }
+//        return jMenu;
+//    }
+//
+//
+//    /**
+//     * This method initializes jMenuItem1	
+//     * 	
+//     * @return javax.swing.JMenuItem	
+//     */
+//    private JMenuItem getJMenuItem1()
+//    {
+//        if ( jMenuItem1 == null )
+//        {
+//            jMenuItem1 = new JMenuItem();
+//            jMenuItem1.setText("unavailable");
+//        }
+//        return jMenuItem1;
+//    }
+//
+//
+//    /**
+//     * This method initializes jMenuItem2	
+//     * 	
+//     * @return javax.swing.JMenuItem	
+//     */
+//    private JMenuItem getJMenuItem2()
+//    {
+//        if ( jMenuItem2 == null )
+//        {
+//            jMenuItem2 = new JMenuItem();
+//            jMenuItem2.setText("protocolError");
+//        }
+//        return jMenuItem2;
+//    }
+//
+//
+//    /**
+//     * This method initializes jMenuItem3	
+//     * 	
+//     * @return javax.swing.JMenuItem	
+//     */
+//    private JMenuItem getJMenuItem3()
+//    {
+//        if ( jMenuItem3 == null )
+//        {
+//            jMenuItem3 = new JMenuItem();
+//            jMenuItem3.setText("strongAuthRequired");
+//        }
+//        return jMenuItem3;
+//    }
+//
+//
+//    /**
+//     * This method initializes jMenuItem4	
+//     * 	
+//     * @return javax.swing.JMenuItem	
+//     */
+//    private JMenuItem getJMenuItem4()
+//    {
+//        if ( jMenuItem4 == null )
+//        {
+//            jMenuItem4 = new JMenuItem();
+//            jMenuItem4.setText("show requests");
+//        }
+//        return jMenuItem4;
+//    }
+
+
+    private static final String REFRESH_COMMAND = "Refresh";
+    /**
+     * This method initializes jButton2	
+     * 	
+     * @return javax.swing.JButton	
+     */
+    private JButton getRefreshButton()
+    {
+        if ( refreshButton == null )
+        {
+            refreshButton = new JButton();
+            refreshButton.setText( REFRESH_COMMAND );
+            refreshButton.addActionListener( new java.awt.event.ActionListener()
+            {
+                public void actionPerformed(java.awt.event.ActionEvent e)
+                {
+                    if ( e.getActionCommand() == REFRESH_COMMAND )
+                    {
+                        refresh();
+                    }
+                }
+            } );
+        }
+        return refreshButton;
+    }
+
+    
+    private void refresh()
+    {
+        log.info( "Refreshing Sessions UI" );
+        sessionsTable.setModel( new SessionsModel( SessionRegistry.getSingleton().getSessions()
) );
+        closeItem.setEnabled( false );
+        menuSendNoD.setEnabled( false );
+        showRequests.setEnabled( false );
+    }
+}  //  @jve:decl-index=0:visual-constraint="10,10"

Propchange: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/SessionsFrame.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/SessionsModel.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/SessionsModel.java?rev=370453&view=auto
==============================================================================
--- directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/SessionsModel.java
(added)
+++ directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/SessionsModel.java
Thu Jan 19 01:51:15 2006
@@ -0,0 +1,85 @@
+package org.apache.ldap.server.protocol.gui;
+
+
+import java.net.InetSocketAddress;
+
+import javax.swing.event.TableModelListener;
+import javax.swing.table.TableModel;
+
+import org.apache.mina.common.IoSession;
+
+
+public class SessionsModel implements TableModel
+{
+    final String[] columns = new String[] { "client address", "client port", "server address",
"server port" };
+    final Class[] columnClasses = new Class[] { String.class, Integer.class, String.class,
Integer.class };
+    final IoSession[] sessions;
+
+    
+    SessionsModel( IoSession[] sessions )
+    {
+        this.sessions = sessions;
+    }
+
+    IoSession getIoSession( int row )
+    {
+        return sessions[row];
+    }
+    
+    public int getRowCount()
+    {
+        return sessions.length;
+    }
+
+    public int getColumnCount()
+    {
+        return columns.length;
+    }
+
+    public String getColumnName( int columnIndex )
+    {
+        return columns[columnIndex];
+    }
+
+    public Class getColumnClass( int columnIndex )
+    {
+        return columnClasses[columnIndex];
+    }
+
+    public boolean isCellEditable( int rowIndex, int columnIndex )
+    {
+        return false;
+    }
+
+    public Object getValueAt( int rowIndex, int columnIndex )
+    {
+        IoSession session = sessions[rowIndex];
+        
+        switch( columnIndex )
+        {
+            case( 0 ):
+                return ( ( InetSocketAddress ) session.getRemoteAddress() ).getHostName();
+            case( 1 ):
+                return new Integer( ( ( InetSocketAddress ) session.getRemoteAddress() ).getPort()
);
+            case( 2 ):
+                return ( ( InetSocketAddress ) session.getLocalAddress() ).getHostName();
+            case( 3 ):
+                return new Integer( ( ( InetSocketAddress ) session.getLocalAddress() ).getPort()
);
+            default:
+                throw new IndexOutOfBoundsException( "column index max is " + ( columns.length
- 1 ) );
+        }
+    }
+
+    public void setValueAt(Object aValue, int rowIndex, int columnIndex)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    public void addTableModelListener(TableModelListener l)
+    {
+    }
+
+    public void removeTableModelListener(TableModelListener l)
+    {
+    }
+}

Propchange: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/gui/SessionsModel.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java?rev=370453&r1=370452&r2=370453&view=diff
==============================================================================
--- directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java
(original)
+++ directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java
Thu Jan 19 01:51:15 2006
@@ -248,6 +248,7 @@
                 StringBuffer buf = new StringBuffer();
                 req.getFilter().printToBuffer( buf );
                 ctx.addNamingListener( req.getBase(), buf.toString(), controls, handler );
+                SessionRegistry.getSingleton().addOutstandingRequest( session, req );
                 return;
             }
             
@@ -302,6 +303,7 @@
             }
             while( e.skipReferral() );
             session.write( req.getResultResponse() );
+            SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId()
);
             return;
         }
         catch( NamingException e )
@@ -357,10 +359,10 @@
             {
                 session.write( it.next() );
             }
+            SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId()
);
         }
         finally
         {
-            SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId()
);
             if ( list != null )
             {
                 try { list.close(); } catch( NamingException e ){ log.error("failed on list.close()",
e ); } 

Modified: directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/extended/LaunchDiagnosticUiHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/extended/LaunchDiagnosticUiHandler.java?rev=370453&r1=370452&r2=370453&view=diff
==============================================================================
--- directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/extended/LaunchDiagnosticUiHandler.java
(original)
+++ directory/trunks/apacheds/protocols/ldap/src/main/java/org/apache/ldap/server/protocol/support/extended/LaunchDiagnosticUiHandler.java
Thu Jan 19 01:51:15 2006
@@ -35,6 +35,7 @@
 import org.apache.ldap.server.partition.impl.btree.gui.PartitionFrame;
 import org.apache.ldap.server.protocol.ExtendedOperationHandler;
 import org.apache.ldap.server.protocol.SessionRegistry;
+import org.apache.ldap.server.protocol.gui.SessionsFrame;
 import org.apache.mina.common.IoSession;
 
 
@@ -78,6 +79,8 @@
                 }
             }
             
+            SessionsFrame sessions = new SessionsFrame();
+            sessions.setVisible( true );
             return;
         }
 



Mime
View raw message