| 579 | |
| 580 | |
| 581 | public void insertProtocolAtTop(Protocol prot) { |
| 582 | if(prot == null) |
| 583 | throw new IllegalArgumentException("prot needs to be non-null"); |
| 584 | |
| 585 | // check if prot already exists (we cannot have more than 1 protocol of a given class) |
| 586 | Class<? extends Protocol> clazz=prot.getClass(); |
| 587 | Protocol existing_instance=findProtocol(clazz); |
| 588 | if(existing_instance != null) |
| 589 | return; |
| 590 | |
| 591 | top_prot.up_prot=prot; |
| 592 | prot.down_prot=top_prot; |
| 593 | prot.up_prot=this; |
| 594 | top_prot=prot; |
| 595 | Address local_address=getTransport() != null? getTransport().getAddress() : null; |
| 596 | if(local_address != null) |
| 597 | prot.setAddress(local_address); |
| 598 | log.debug("inserted %s at the top of the stack", prot); |
| 599 | } |
| 600 | |
| 601 | |
| 602 | /** |