Inserts an already created (and initialized) protocol into the protocol list. Sets the links to the protocols above and below correctly and adjusts the linked list of protocols accordingly. Note that this method may change the value of top_prot or bottom_prot. @param prot The protocol to be inserted
(Protocol prot, Position position, String neighbor_prot)
| 513 | * @exception Exception Will be thrown when the new protocol cannot be created, or inserted. |
| 514 | */ |
| 515 | public void insertProtocol(Protocol prot, Position position, String neighbor_prot) throws Exception { |
| 516 | if(neighbor_prot == null) throw new IllegalArgumentException("neighbor_prot is null"); |
| 517 | Protocol neighbor=findProtocol(neighbor_prot); |
| 518 | if(neighbor == null) |
| 519 | throw new IllegalArgumentException("protocol " + neighbor_prot + " not found in " + printProtocolSpec(false)); |
| 520 | |
| 521 | if(position == Position.BELOW && neighbor instanceof TP) |
| 522 | throw new IllegalArgumentException("Cannot insert protocol " + prot.getName() + " below transport protocol"); |
| 523 | |
| 524 | insertProtocolInStack(prot, neighbor, position); |
| 525 | } |
| 526 | |
| 527 | |
| 528 | public void insertProtocolInStack(Protocol prot, Protocol neighbor, Position position) { |