| | |
| | | private String pwd; |
| | | private ServerStatusDescriptor lastDescriptor; |
| | | private boolean stopPooling; |
| | | private Thread t; |
| | | private Thread poolingThread; |
| | | private HashSet<ServerStatusChangeListener> listeners = |
| | | new HashSet<ServerStatusChangeListener>(); |
| | | private boolean starting; |
| | |
| | | public void startPooling() |
| | | { |
| | | stopPooling = false; |
| | | t = new Thread(new Runnable() |
| | | poolingThread = new Thread(new Runnable() |
| | | { |
| | | public void run() |
| | | { |
| | |
| | | } |
| | | } |
| | | }); |
| | | t.start(); |
| | | poolingThread.start(); |
| | | } |
| | | |
| | | /** |
| | | * Stop pooling the server status. This method does not block the thread |
| | | * that called it. |
| | | * |
| | | */ |
| | | public void stopPooling() |
| | | { |
| | | stopPooling = true; |
| | | try |
| | | { |
| | | onLineConf.closeConnection(); |
| | | poolingThread.interrupt(); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | this.dn = dn; |
| | | this.pwd = pwd; |
| | | if ((ldapUrl != null) && (t != null) && t.isAlive() && !stopPooling) |
| | | if ((ldapUrl != null) && (poolingThread != null) && |
| | | poolingThread.isAlive() && !stopPooling) |
| | | { |
| | | /* If we are pooling, stop the pooling update the connection information |
| | | * and restart the pooling. Set the stopPooling boolean to true to |
| | |
| | | * |
| | | */ |
| | | stopPooling = true; |
| | | t.interrupt(); |
| | | poolingThread.interrupt(); |
| | | try |
| | | { |
| | | t.join(5000); |
| | | poolingThread.join(5000); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | /* This should not happen: this thread should not be interrupted. */ |
| | | t.printStackTrace(); |
| | | } |
| | | t = null; |
| | | poolingThread = null; |
| | | onLineConf.setConnectionInfo(ldapUrl, dn, pwd); |
| | | startPooling(); |
| | | } |