All Packages  This Package  Class Hierarchy  Class Search  Index

Class edu.utah.janos.antsr.core.Application
java.lang.Object
   |
   +----edu.utah.janos.antsr.core.Entity
           |
           +----edu.utah.janos.antsr.core.Application

  Summary

public abstract class  Application
     extends edu.utah.janos.antsr.core.Entity
{
          // Fields 7
     private static final int DEFAULTRLIMIT;
     private static final int DEFAULT_TTL;
     public static final String[] defaults;
     private Node node;
     private final CommQueue packetQueue;
     private short port;
     private int ttl;

          // Constructors 1
     public Application();

          // Methods 15
     public int getDefaultResources();
     public int getDefaultTTL();
     final CommQueue getPacketQueue();
     public short getPort();
     public void receive(Capsule);
     public boolean send(Capsule);
     public boolean send(Capsule, int);
     public void setArgs(KeyArgs) throws InvalidKeyArgsException;
     public void setDefaultResources(int);
     public void setDefaultTTL(int);
     void setNode(Node);
     void setPort(int);
     public abstract void start() throws Exception;
     public Node thisNode();
     public String toString();
}

Abstract node application. An Application is an end-point for capsules. Capsules are sent and received via the Node associated with the Application.

Applications understand the '-port' KeyArg for setting their port address on the Node. If no '-port' is provided an available port will be found and allocated to the Application. getPort() will retrieve the port number.

Applications are started after the Node has completed initialization.

Author:
David Wetherall


  Cross Reference

Extended By:
MobileApplication, MulticastApplication, PingApplication, PongApplication, DynamicRouteApp





  Fields

· packetQueue

Summary  |  Top
   private final CommQueue packetQueue

A queue to accept packets for the application. The protocol for use is to send the MID, followed by the packet bytes.


· defaults

Summary  |  Top
   public static final String[] defaults

Default KeyArgs for an application. Sets port to 0.


· node

Summary  |  Top
   private Node node

The Node associated with this application. All Capsules are sent via and recieved from this Node.

See Also: setNode, getNode


· DEFAULTRLIMIT

Summary  |  Top
   private static final int DEFAULTRLIMIT
Note: DEFAULTRLIMIT is deprecatedPlease use DEFAULT_TTL instead.

The default default resource limit for packets sent by an Application.


· DEFAULT_TTL

Summary  |  Top
   private static final int DEFAULT_TTL

The default TTL for packets sent by this application.


· ttl

Summary  |  Top
   private int ttl

The default resource limit for Capsules sent by this application.

See Also: setDefaultResources, getDefaultResources


· port

Summary  |  Top
   private short port

The port for this application. This is the identifier by which remote nodes can send capsules to this application: the address determines the Node, and the port determines the application.

Set by the '-port' KeyArg. Defaults to 0.

Is read-only after being set by '-port' (the read-only semantics are required by Node.detachApplication()).

See Also: attachApplication, detachApplication


  Constructors

· Application

Summary  |  Top

   public Application() 

All applications must have a no-arg constructor as the Node invokes Class.newInstance() to create the application.



  Methods

· getDefaultTTL

Summary  |  Top
   public int getDefaultTTL() 


· setDefaultTTL

Summary  |  Top
   public void setDefaultTTL(int ttl) 


· getDefaultResources

Summary  |  Top
   public int getDefaultResources() 
Note: getDefaultResources() is deprecateduse getDefaultTTL()



· setDefaultResources

Summary  |  Top
   public void setDefaultResources(int r) 
Note: setDefaultResources() is deprecateduse setDefaultTTL(int)



· getPort

Summary  |  Top
   public short getPort() 


· setPort

Summary  |  Top
   void setPort(int p) 

Set this application's port. Only invoked by Node.attachApplication() if this app didn't request a specific port number.



· thisNode

Summary  |  Top
   public Node thisNode() 

Return the Node interface customized for this application.



· setNode

Summary  |  Top
   void setNode(Node node) 

Assign the node interface to this application. Done only in AppBooster.run().

See Also: run



· send

Summary  |  Top
   public boolean send(Capsule cap, 
                       int ttl) 

Send the given capsule with the given resource limit.

The capsule is primed (that is, the 'from address' and ttl are set), and then sent via the associated Node.

Parameter Description
cap the Capsule to send. XXX state of Xdr?
ttl the TTL to give the Capsule.

See Also: send, prime



· send

Summary  |  Top
   public boolean send(Capsule cap) 

Send the given capsule.

The capsule is primed with the default TTL (this.ttl) then, the capsule is sent via the associated Node.

See Also: ttl, prime, send



· receive

Summary  |  Top
   public void receive(Capsule cap) 

Callback for packets that are delivered to this application. This does nothing, so the default behavior for the application is to drop delivered packets on the floor.

Parameter Description
cap the Capsule that got delivered. XXX state of Xdr?



· start

Summary  |  Top
   public abstract void start()  throws Exception

Start this Application rolling. This is invoked once by the Node after it has been initialized.

Note that implementations of start should just set things up. If the application wants to do things like send packets, this function should start a new thread to do that. Creating a GUI and associating callbacks is a good thing to do here.

XXX mostly stuff that could just be done in the no-arg constructor, no?



· setArgs

Summary  |  Top
   public void setArgs(KeyArgs k)  throws InvalidKeyArgsException

Parse command line arguments for this application. Understands the -port option.

It is guaranteed that this method will be invoked before the application starts running (i.e. shortly after the constructor is invoked).

Overrides:
setArgs in class Entity

See Also: port, ManagedObject



· getPacketQueue

Summary  |  Top
   final CommQueue getPacketQueue() 

Return the packet queue for this application



· toString

Summary  |  Top
   public String toString() 
Overrides:
toString in class Object


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7