net.jini.discovery
Class LookupDiscovery.DecodeAnnouncementTask

java.lang.Object
  extended by net.jini.discovery.LookupDiscovery.DecodeAnnouncementTask
All Implemented Interfaces:
TaskManager.Task, Runnable
Enclosing class:
LookupDiscovery

private class LookupDiscovery.DecodeAnnouncementTask
extends Object
implements TaskManager.Task

Task which decodes received multicast announcement packets. This is separated into a task to allow the AnnouncementListener thread to quickly loop and receive new announcement packets; the act of decoding packets may involve relatively slow cryptographic operations such as signature verification, and would impede the packet receiving loop if it were performed inline.


Field Summary
private  DatagramPacket datagram
           
 
Constructor Summary
LookupDiscovery.DecodeAnnouncementTask(DatagramPacket datagram)
          Creates a task for decoding the given multicast announcement packet.
 
Method Summary
private  void doRun()
          Decodes this task's multicast announcement packet.
private  boolean newSeqNum(long currentNum, long oldNum)
          Returns true if currentNum is a new sequence number that needs to be inspected.
 void run()
          Restore the privileged context and run
 boolean runAfter(List tasks, int size)
          No ordering
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

datagram

private final DatagramPacket datagram
Constructor Detail

LookupDiscovery.DecodeAnnouncementTask

public LookupDiscovery.DecodeAnnouncementTask(DatagramPacket datagram)
Creates a task for decoding the given multicast announcement packet.

Method Detail

run

public void run()
Restore the privileged context and run

Specified by:
run in interface Runnable

doRun

private void doRun()
Decodes this task's multicast announcement packet. If the constraints for decoding multicast announcements are satisfied and the announcement merits further processing, an appropriate object is added to the pendingDiscoveries set, and control is transferred to a UnicastDiscoveryTask.


newSeqNum

private boolean newSeqNum(long currentNum,
                          long oldNum)
Returns true if currentNum is a new sequence number that needs to be inspected. A -1 occurs if the announcement had no sequence number (for e.g. DiscoveryV1) or the service had been discovered through unicast discovery. REMIND: Ideally the message should have a flag which indicates no sequence number instead of overloading the -1 value


runAfter

public boolean runAfter(List tasks,
                        int size)
No ordering

Specified by:
runAfter in interface TaskManager.Task
Parameters:
tasks - the tasks to consider. A read-only List, with all elements instanceof Task.
size - elements with index less than size should be considered


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.