307 private synchronized void waitWhileReading() throws InterruptedException {
308 while (reading)
309 wait();
310 }
311
312 private final Socket socket;
313 private InputStream socketInput;
314 private OutputStream socketOutput;
315 private String name;
316 private boolean reading;
317 private Object data;
318 private boolean closed;
319 }
320
321
322 class Entries {
323 synchronized boolean contains(Entry e) {
324 return v.contains(e);
325 }
326
327 synchronized Enumeration elements() {
328 return ((Vector)(v.clone())).elements();
329 }
330
331 synchronized void add(final Entry e) {
332 v.addElement(e);
333 notifyAddedToPool(e);
334 notifyAll();
335 Runnable r = new Runnable() {
336 public void run() {
337 e.readAhead();
338 }
339 };
340 Thread t = new Thread(r, "ActiveAgentPool.EntryWatcher" + entryWatcherCount++);
341 t.start();
342 }
343
344 synchronized boolean remove(Entry e) {
345 if (v.contains(e)) {
346 v.removeElement(e);
347 notifyRemovedFromPool(e);
348 return true;
573 }
574 }
575 // perhaps need a better reporting channel here
576 System.err.println("too many errors opening socket for remote socket pool");
577 System.err.println("server thread exiting");
578
579 synchronized (this) {
580 if (serverSocket == ss)
581 serverSocket = null;
582 }
583 }
584 finally {
585 closeNoExceptions(ss);
586 }
587
588 }
589
590 /**
591 * Get an enumeration of the entries currently in the active agent pool.
592 */
593 Enumeration elements() {
594 return entries.elements();
595 }
596
597 /**
598 * Add an observer to monitor events.
599 * @param o The observer to be added.
600 */
601 public void addObserver(Observer o) {
602 entries.addObserver(o);
603 }
604
605
606 /**
607 * Remove an observer that had been previously registered to monitor events.
608 * @param o The observer to be removed..
609 */
610 public void deleteObserver(Observer o) {
611 entries.deleteObserver(o);
612 }
613
|
307 private synchronized void waitWhileReading() throws InterruptedException {
308 while (reading)
309 wait();
310 }
311
312 private final Socket socket;
313 private InputStream socketInput;
314 private OutputStream socketOutput;
315 private String name;
316 private boolean reading;
317 private Object data;
318 private boolean closed;
319 }
320
321
322 class Entries {
323 synchronized boolean contains(Entry e) {
324 return v.contains(e);
325 }
326
327 synchronized Enumeration<Connection> elements() {
328 return ((Vector<Connection>)(v.clone())).elements();
329 }
330
331 synchronized void add(final Entry e) {
332 v.addElement(e);
333 notifyAddedToPool(e);
334 notifyAll();
335 Runnable r = new Runnable() {
336 public void run() {
337 e.readAhead();
338 }
339 };
340 Thread t = new Thread(r, "ActiveAgentPool.EntryWatcher" + entryWatcherCount++);
341 t.start();
342 }
343
344 synchronized boolean remove(Entry e) {
345 if (v.contains(e)) {
346 v.removeElement(e);
347 notifyRemovedFromPool(e);
348 return true;
573 }
574 }
575 // perhaps need a better reporting channel here
576 System.err.println("too many errors opening socket for remote socket pool");
577 System.err.println("server thread exiting");
578
579 synchronized (this) {
580 if (serverSocket == ss)
581 serverSocket = null;
582 }
583 }
584 finally {
585 closeNoExceptions(ss);
586 }
587
588 }
589
590 /**
591 * Get an enumeration of the entries currently in the active agent pool.
592 */
593 Enumeration<Connection> elements() {
594 return entries.elements();
595 }
596
597 /**
598 * Add an observer to monitor events.
599 * @param o The observer to be added.
600 */
601 public void addObserver(Observer o) {
602 entries.addObserver(o);
603 }
604
605
606 /**
607 * Remove an observer that had been previously registered to monitor events.
608 * @param o The observer to be removed..
609 */
610 public void deleteObserver(Observer o) {
611 entries.deleteObserver(o);
612 }
613
|