Project JXTA

net.jxta.impl.protocol
Class TCPAdv

java.lang.Object
  extended by net.jxta.document.Advertisement
      extended by net.jxta.document.ExtendableAdvertisement
          extended by net.jxta.protocol.TransportAdvertisement
              extended by net.jxta.impl.protocol.TCPAdv

public class TCPAdv
extends TransportAdvertisement

Provides configuration parameters for the JXTA TCP Message Transport.


Nested Class Summary
static class TCPAdv.Instantiator
          Our instantiator
 
Field Summary
 
Fields inherited from class net.jxta.protocol.TransportAdvertisement
protocol
 
Method Summary
static String getAdvertisementType()
          Returns the identifying type of this Advertisement.
 String getAdvType()
          
 String getConfigMode()
          returns the config mode.
 Document getDocument(MimeMediaType encodeAs)
          
 int getEndPort()
          Return the highest port on which the TCP Transport will listen if configured to do so.
 String[] getIndexFields()
          
 String getInterfaceAddress()
          Returns the interface which the TCP transport will use.
 String getMulticastAddr()
          returns the multicastaddr
 int getMulticastPort()
          returns the multicastport
 int getMulticastSize()
          returns the multicastsize
 boolean getMulticastState()
          Determine whether multicast if off or not
 int getPort()
          Returns the port on which the TCP Transport will listen if configured to do so.
 boolean getPublicAddressOnly()
          Returns the state of whether to only use public address returns boolean true if set to use "Public Address Only"
 String getServer()
          Returns the public address
 int getStartPort()
          Return the lowest port on which the TCP Transport will listen if configured to do so.
protected  boolean handleElement(Element raw)
          
 boolean isClientEnabled()
          Returns the configuration for outbound connections.
 boolean isServerEnabled()
          Returns the configuration for inbound connections.
 void setClientEnabled(boolean enabled)
          Sets the configuration for outbound connections.
 void setConfigMode(String mode)
          set the config mode.
 void setEndPort(int end)
          Sets the highest port on which the TCP Transport will listen if configured to do so.
 void setInterfaceAddress(String ia)
          Sets the interface which the TCP transport will use.
 void setMulticastAddr(String multicastaddr)
          set the multicastaddr
 void setMulticastPort(int multicastport)
          set the multicastport
 void setMulticastSize(int multicastsize)
          set the multicastsize
 void setMulticastState(boolean newState)
          Enable or disable multicast.
 void setPort(int port)
          Sets the port on which the TCP Transport will listen if configured to do so.
 void setPublicAddressOnly(boolean only)
          Sets the state of whether to only use public address
 void setServer(String address)
          Set the public address.
 void setServerEnabled(boolean enabled)
          Sets the configuration for inbound connections.
 void setStartPort(int start)
          Sets the lowest port on which the TCP Transport will listen if configured to do so.
 
Methods inherited from class net.jxta.protocol.TransportAdvertisement
getBaseAdvType, getID, getProtocol, setProtocol
 
Methods inherited from class net.jxta.document.Advertisement
clone, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getAdvertisementType

public static String getAdvertisementType()
Returns the identifying type of this Advertisement.

Note: This is a static method. It cannot be used to determine the runtime type of an advertisment. ie.

      Advertisement adv = module.getSomeAdv();
      String advType = adv.getAdvertisementType();
  

This is wrong and does not work the way you might expect. This call is not polymorphic and calls Advertiement.getAdvertisementType() no matter what the real type of the advertisment.

Returns:
String the type of advertisement

getAdvType

public String getAdvType()

Overrides:
getAdvType in class Advertisement

getInterfaceAddress

public String getInterfaceAddress()
Returns the interface which the TCP transport will use.

Returns:
The interface to use. May be a DNS name or an IP Address.

setInterfaceAddress

public void setInterfaceAddress(String ia)
Sets the interface which the TCP transport will use.

Parameters:
ia - The interface to use. May be a DNS name or an IP Address.

getPort

public int getPort()
Returns the port on which the TCP Transport will listen if configured to do so. If a port range is specified then this the preference. Valid values are -1, 0 and 1-65535. The -1 value is used to signify that there is no port preference and any port in range will be used. The 0 specifies that the Socket API dynamic port allocation should be used. For values 1-65535 the value specifies the required port on which the TCP tranport will listen.

Returns:
the port

setPort

public void setPort(int port)
Sets the port on which the TCP Transport will listen if configured to do so. If a port range is specified then this the preference. Valid values are -1, 0 and 1-65535. The -1 value is used to signify that there is no port preference and any port in range will be used. The 0 specifies that the Socket API dynamic port allocation should be used. For values 1-65535 the value specifies the required port on which the TCP tranport will listen.

Parameters:
port - the port on which to listen.

getStartPort

public int getStartPort()
Return the lowest port on which the TCP Transport will listen if configured to do so. Valid values are -1, 0 and 1-65535. The -1 value is used to signify that the port range feature should be disabled. The 0 specifies that the Socket API dynamic port allocation should be used. For values 1-65535 the value must be equal to or less than the value used for end port.

Returns:
the lowest port on which to listen.

setStartPort

public void setStartPort(int start)
Sets the lowest port on which the TCP Transport will listen if configured to do so. Valid values are -1, 0 and 1-65535. The -1 value is used to signify that the port range feature should be disabled. The 0 specifies that the Socket API dynamic port allocation should be used. For values 1-65535 the value must be equal to or less than the value used for end port.

Parameters:
start - the lowest port on which to listen.

getEndPort

public int getEndPort()
Return the highest port on which the TCP Transport will listen if configured to do so. Valid values are -1, 0 and 1-65535. The -1 value is used to signify that the port range feature should be disabled. The 0 specifies that the Socket API dynamic port allocation should be used. For values 1-65535 the value must be equal to or greater than the value used for start port.

Returns:
the highest port on which to listen.

setEndPort

public void setEndPort(int end)
Sets the highest port on which the TCP Transport will listen if configured to do so. Valid values are -1, 0 and 1-65535. The -1 value is used to signify that the port range feature should be disabled. The 0 specifies that the Socket API dynamic port allocation should be used. For values 1-65535 the value must be equal to or greater than the value used for start port.

Parameters:
the - highest port on which to listen.

getMulticastState

public boolean getMulticastState()
Determine whether multicast if off or not

Returns:
boolean current multicast state

setMulticastState

public void setMulticastState(boolean newState)
Enable or disable multicast.

Parameters:
multicastState - the desired state.

getMulticastAddr

public String getMulticastAddr()
returns the multicastaddr

Returns:
string multicastaddr

setMulticastAddr

public void setMulticastAddr(String multicastaddr)
set the multicastaddr

Parameters:
multicastaddr - set multicastaddr

getMulticastPort

public int getMulticastPort()
returns the multicastport

Returns:
string multicastport

setMulticastPort

public void setMulticastPort(int multicastport)
set the multicastport

Parameters:
multicastport - set multicastport

getMulticastSize

public int getMulticastSize()
returns the multicastsize

Returns:
integer containting the multicast size

setMulticastSize

public void setMulticastSize(int multicastsize)
set the multicastsize

Parameters:
multicastsize - set multicast size

getServer

public String getServer()
Returns the public address

Returns:
string public address

setServer

public void setServer(String address)
Set the public address. That is, a the address of a server socket to connect to from the outside. Argument is in the form host:port

Parameters:
address - address

isClientEnabled

public boolean isClientEnabled()
Returns the configuration for outbound connections.

Returns:
true if outbound connections are allowed otherwise false

setClientEnabled

public void setClientEnabled(boolean enabled)
Sets the configuration for outbound connections.

Parameters:
enabled - true if outbound connections are allowed otherwise false

isServerEnabled

public boolean isServerEnabled()
Returns the configuration for inbound connections.

Returns:
true if inbound connections are allowed otherwise false

setServerEnabled

public void setServerEnabled(boolean enabled)
Sets the configuration for inbound connections.

Parameters:
enabled - true if inbound connections are allowed otherwise false

getConfigMode

public String getConfigMode()
returns the config mode. That is, how the user prefers to configure the interface address: "auto", "manual"

Returns:
string config mode

setConfigMode

public void setConfigMode(String mode)
set the config mode. That is, how the user prefers to configure the interface address: "auto", "manual" This is just a pure config item. It is never in published advs. The TCP transport strips it when it initializes.

Parameters:
mode - Can be "auto", "manual" other settings will act as the default which is "auto".

getPublicAddressOnly

public boolean getPublicAddressOnly()
Returns the state of whether to only use public address returns boolean true if set to use "Public Address Only"


setPublicAddressOnly

public void setPublicAddressOnly(boolean only)
Sets the state of whether to only use public address

Parameters:
only - true to use "Public Address Only"

handleElement

protected boolean handleElement(Element raw)

Overrides:
handleElement in class ExtendableAdvertisement

getDocument

public Document getDocument(MimeMediaType encodeAs)

Overrides:
getDocument in class ExtendableAdvertisement

getIndexFields

public final String[] getIndexFields()

Specified by:
getIndexFields in class Advertisement

JXTA J2SE