org.instantreality.InstantIO
Class WebNode

java.lang.Object
  extended by org.instantreality.InstantIO.Namespace
      extended by org.instantreality.InstantIO.Node
          extended by org.instantreality.InstantIO.WebNode
All Implemented Interfaces:
InSlot.Listener, OutSlot.Listener

public final class WebNode
extends Node

Allows to control the InstantIO system simply by using a web browser. The WebNode opens a web server that allows to get information about the data flow graph as well as modifying the graph, i.e. adding or removing nodes or routes.

The following example demonstrates how to open a web interface on port 8080. To access the web interface, simply start a web browser and enter the URL "http://localhost:8080/" into the address bar when the web interface is running on the same machine as the web browser. When the web interface is running on another machine, you have to replace "localhost" by the name of that machine. Do not forget to open any firewall running on the machine the web interface is running on, otherwise you won't be able to connect to the interface from other machines!

 WebNode webNode = new WebNode();
 webNode.setPort(8080);
 
 // The following call automatically enables the WebNode
 // and starts the web interface:
 Root.the().addNamespace(webNode);
 

Author:
Patrick Dähne

Nested Class Summary
 
Nested classes/interfaces inherited from class org.instantreality.InstantIO.Namespace
Namespace.Listener
 
Field Summary
static Field[] fields
          Defines the fields of the WebNode.
 
Fields inherited from class org.instantreality.InstantIO.Node
NODE_DISABLED, NODE_ERROR, NODE_RUNNING, NODE_SLEEPING
 
Constructor Summary
WebNode()
          Creates a new WebNode object.
 
Method Summary
 java.net.InetAddress getAddress()
          Returns the address the web server is listening at for clients.
 int getLogSize()
          Returns the number of entries in the log.
 java.lang.String getPassword()
          Returns the password of the web node.
 int getPort()
          Returns the port the web server is listening at for clients.
 java.lang.String getUserId()
          Returns the user ID of the web node.
protected  void initialize()
          Initializes the web node.
 void setAddress(java.net.InetAddress address)
          Sets the address the web server is listening at for clients.
 void setLogSize(int logSize)
          Sets the number of entries in the log.
 void setPassword(java.lang.String password)
          Sets the password of the web node.
 void setPort(int port)
          Sets the port the web server is listening at for clients.
 void setUserId(java.lang.String userId)
          Sets the user ID of the web node.
protected  void shutdown()
          Shuts down the web node.
 NodeType type()
          Returns meta information about the web node.
 
Methods inherited from class org.instantreality.InstantIO.Node
addLog, getDetailedInfo, getFieldNames, getFieldValue, getLog, getShortInfo, getState, newData, setFieldValue, setState, setState, start, startInSlot, startOutSlot, stop, stopInSlot, stopOutSlot, typeName
 
Methods inherited from class org.instantreality.InstantIO.Namespace
addExternalRoute, addInSlot, addListener, addNamespace, addNamespace, addOutSlot, addRoute, clear, clearExternalRoutes, clearNamespaces, clearRoutes, dirty, disable, dispose, enable, enabled, finalize, getBaseURL, getLabel, removeExternalRoute, removeInSlot, removeListener, removeNamespace, removeOutSlot, removeRoute, saveState, setBaseURL, setDirty, setFieldValues
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fields

public static final Field[] fields
Defines the fields of the WebNode.

Constructor Detail

WebNode

public WebNode()
Creates a new WebNode object.

Method Detail

setAddress

public void setAddress(java.net.InetAddress address)
Sets the address the web server is listening at for clients. When you open a web server, you have to specify the address of a network interface as well as a port. The address and the port are part of the URL you have to enter into the address bar of your web browser when you open the connection to the web interface. E.g. when your web server is listening on a machine named "mymachine" under the port number 8080, you have to enter the URL "http://mymachine:8080/".

The default value for the address is the empty string, which means that the web server listens at all available network interfaces. You have to set the address only under very rare circumstances where you want to limit the web server to a specific network interface.

Parameters:
address - The address the web server is listening at.
See Also:
getAddress(), setPort(int), getPort()

getAddress

public java.net.InetAddress getAddress()
Returns the address the web server is listening at for clients. When you open a web server, you have to specify the address of a network interface as well as a port. The address and the port are part of the URL you have to enter into the address bar of your web browser when you open the connection to the web interface. E.g. when your web server is listening on a machine named "mymachine" under the port number 8080, you have to enter the URL "http://mymachine:8080/".

The default value for the address is the empty string, which means that the web server listens at all available network interfaces. You have to set the address only under very rare circumstances where you want to limit the web server to a specific network interface.

Returns:
The address the web server is listening at.
See Also:
setAddress(java.net.InetAddress), setPort(int), getPort()

setPort

public void setPort(int port)
Sets the port the web server is listening at for clients. When you open a web server, you have to specify the address of a network interface as well as a port. The address and the port are part of the URL you have to enter into the address bar of your web browser when you open the connection to the web interface. E.g. when your web server is listening on a machine named "mymachine" under the port number 8080, you have to enter the URL "http://mymachine:8080/".

The port is a number between 0 and 65535, inclusively. When you specify a port number of 0 (the default), the operating system automatically selects a free port. Port numbers below 1024 are reserved for the operating system, i.e. on many systems you need to have root rights to open a web server on such a port. Ports starting at 1024 are usually available for user processes - but you have to make sure that the port number you choose is actually free!

Parameters:
port - The port the web server is listening at.
See Also:
getPort(), setAddress(java.net.InetAddress), getAddress()

getPort

public int getPort()
Returns the port the web server is listening at for clients. When you open a web server, you have to specify the address of a network interface as well as a port. The address and the port are part of the URL you have to enter into the address bar of your web browser when you open the connection to the web interface. E.g. when your web server is listening on a machine named "mymachine" under the port number 8080, you have to enter the URL "http://mymachine:8080/".

The port is a number between 0 and 65535, inclusively. When you specify a port number of 0 (the default), the operating system automatically selects a free port. Port numbers below 1024 are reserved for the operating system, i.e. on many systems you need to have root rights to open a web server on such a port. Ports starting at 1024 are usually available for user processes - but you have to make sure that the port number you choose is actually free!

Returns:
The port the web server is listening at.
See Also:
setPort(int), setAddress(java.net.InetAddress), getAddress()

setUserId

public void setUserId(java.lang.String userId)
Sets the user ID of the web node. You can protect the access to the web server by a user ID and a password, i.e. when you try to open the web interface, the browser will show a dialog where you have to enter the user ID and the password. By default both user ID and password are empty, which means that password protection is disabled.

Parameters:
userId - The user ID.
See Also:
getUserId(), setPassword(java.lang.String), getPassword()

getUserId

public java.lang.String getUserId()
Returns the user ID of the web node. You can protect the access to the web server by a user ID and a password, i.e. when you try to open the web interface, the browser will show a dialog where you have to enter the user ID and the password. By default both user ID and password are empty, which means that password protection is disabled.

Returns:
The user ID.
See Also:
setUserId(java.lang.String), setPassword(java.lang.String), getPassword()

setPassword

public void setPassword(java.lang.String password)
Sets the password of the web node. You can protect the access to the web server by a user ID and a password, i.e. when you try to open the web interface, the browser will show a dialog where you have to enter the user ID and the password. By default both user ID and password are empty, which means that password protection is disabled.

Parameters:
password - The password.
See Also:
getPassword(), setUserId(java.lang.String), getUserId()

getPassword

public java.lang.String getPassword()
Returns the password of the web node. You can protect the access to the web server by a user ID and a password, i.e. when you try to open the web interface, the browser will show a dialog where you have to enter the user ID and the password. By default both user ID and password are empty, which means that password protection is disabled.

Returns:
The password.
See Also:
setPassword(java.lang.String), setUserId(java.lang.String), getUserId()

setLogSize

public void setLogSize(int logSize)
Sets the number of entries in the log. The web server keeps a log of all connections. You can see that log when you request the page "/log.html". You can control the number of entries in this log via the logSize parameter. By default, the logSize is 0, which means that logging is disabled.

Parameters:
logSize - The number of entries in the log.
See Also:
getLogSize()

getLogSize

public int getLogSize()
Returns the number of entries in the log. The web server keeps a log of all connections. You can see that log when you request the page "/log.html". You can control the number of entries in this log via the logSize parameter. By default, the logSize is 0, which means that logging is disabled.

Returns:
The number of entries in the log.
See Also:
setLogSize(int)

initialize

protected void initialize()
Initializes the web node.

Overrides:
initialize in class Node

shutdown

protected void shutdown()
Shuts down the web node.

Overrides:
shutdown in class Node

type

public NodeType type()
Returns meta information about the web node.

Specified by:
type in class Node
Returns:
A NodeType object that contains meta information.