| 1 | package dmg.cells.nucleus; |
| 2 | |
| 3 | public class DelayedReply implements Reply |
| 4 | { |
| 5 | private CellEndpoint _endpoint; |
| 6 | private CellMessage _envelope; |
| 7 | |
| 8 | public synchronized void deliver(CellEndpoint endpoint, CellMessage envelope) |
| 9 | { |
| 10 | if (endpoint == null || envelope == null) |
| 11 | throw new IllegalArgumentException("Arguments must not be null"); |
| 12 | _endpoint = endpoint; |
| 13 | _envelope = envelope; |
| 14 | notifyAll(); |
| 15 | } |
| 16 | |
| 17 | public synchronized void send(Object msg) |
| 18 | throws SerializationException, |
| 19 | NoRouteToCellException, |
| 20 | InterruptedException |
| 21 | { |
| 22 | while (_endpoint == null || _envelope == null) |
| 23 | wait(); |
| 24 | _envelope.setMessageObject(msg); |
| 25 | _endpoint.sendMessage(_envelope); |
| 26 | } |
| 27 | } |