jist.swans.app
Class AppJava

java.lang.Object
  extended by jist.swans.app.AppJava
All Implemented Interfaces:
JistAPI.Proxiable, JistAPI.Timeless, AppInterface, AppInterface.TcpApp, AppInterface.ThreadedApp, AppInterface.UdpApp

public class AppJava
extends java.lang.Object
implements AppInterface, AppInterface.TcpApp, AppInterface.UdpApp, AppInterface.ThreadedApp

Entity harness for standard Java applications.

Since:
SWANS1.0

Nested Class Summary
static interface AppJava.Runnable
           
 
Nested classes/interfaces inherited from interface jist.swans.app.AppInterface
AppInterface.TcpApp, AppInterface.ThreadedApp, AppInterface.UdpApp
 
Constructor Summary
AppJava(java.lang.Class app)
          Create new Java application harness.
AppJava(java.lang.String app)
          Create new Java application harness.
 
Method Summary
 SimtimeThread getCurrentThread()
          Get current thread from thread context.
 AppInterface getProxy()
          Return self-referencing entity proxy.
 TransInterface.TransTcpInterface getTcpEntity()
          Return application TCP entity.
 TransInterface.TransUdpInterface getUdpEntity()
          Return application UDP entity.
 void receive(Message msg, NetAddress src, MacAddress lastHop, byte macId, NetAddress dst, byte priority, byte ttl)
          Receive a message from network layer.
 void run()
          Run application.
 void run(java.lang.String[] args)
          Run application.
 void setCurrentThread(SimtimeThread thread)
          Set current thread in thread context.
 void setTcpEntity(TransInterface.TransTcpInterface tcp)
          Set application TCP entity.
 void setUdpEntity(TransInterface.TransUdpInterface udp)
          Set application UDP entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AppJava

public AppJava(java.lang.Class app)
        throws java.lang.NoSuchMethodException
Create new Java application harness.

Parameters:
app - main class of Java application
Throws:
java.lang.NoSuchMethodException - unable to find main method in application class

AppJava

public AppJava(java.lang.String app)
        throws java.lang.ClassNotFoundException,
               java.lang.NoSuchMethodException
Create new Java application harness.

Parameters:
app - name of Java application class
Throws:
java.lang.ClassNotFoundException - unable to load application class
java.lang.NoSuchMethodException - unable to find main method in application class
Method Detail

receive

public void receive(Message msg,
                    NetAddress src,
                    MacAddress lastHop,
                    byte macId,
                    NetAddress dst,
                    byte priority,
                    byte ttl)
Description copied from interface: AppInterface
Receive a message from network layer.

Specified by:
receive in interface AppInterface
Parameters:
msg - message received
src - source network address
lastHop - source link address
macId - incoming interface
dst - destination network address
priority - packet priority
ttl - packet time-to-live

getProxy

public AppInterface getProxy()
Return self-referencing entity proxy.

Returns:
self-referencing entity proxy

setUdpEntity

public void setUdpEntity(TransInterface.TransUdpInterface udp)
Set application UDP entity.

Parameters:
udp - udp entity

getUdpEntity

public TransInterface.TransUdpInterface getUdpEntity()
Return application UDP entity.

Specified by:
getUdpEntity in interface AppInterface.UdpApp
Returns:
application UDP entity

setTcpEntity

public void setTcpEntity(TransInterface.TransTcpInterface tcp)
Set application TCP entity.

Parameters:
tcp - tcp entity

getTcpEntity

public TransInterface.TransTcpInterface getTcpEntity()
Return application TCP entity.

Specified by:
getTcpEntity in interface AppInterface.TcpApp
Returns:
application TCP entity

setCurrentThread

public void setCurrentThread(SimtimeThread thread)
Set current thread in thread context.

Specified by:
setCurrentThread in interface AppInterface.ThreadedApp

getCurrentThread

public SimtimeThread getCurrentThread()
Get current thread from thread context.

Specified by:
getCurrentThread in interface AppInterface.ThreadedApp
Returns:
thread entity

run

public void run(java.lang.String[] args)
Run application.

Specified by:
run in interface AppInterface
Parameters:
args - command-line parameters

run

public void run()
Run application.

Specified by:
run in interface AppInterface