Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.net
Class AcceptPort

java.lang.Object
  extended by com.jivesoftware.forum.net.AcceptPort

public class AcceptPort
extends java.lang.Object

Represents and manages a network accept port. Accept ports know what port/address to bind to, have and verify their accept policies, and allow a generic mechanism for opening and closing ports for accepting connections. The accept port implementation accepts incoming connections but never reads from them.


Constructor Summary
AcceptPort(ConnectionManager connectionManager, java.lang.String configPrefixName)
          Loads an existing accept port from the configuration property object that uses the given connection manager.
AcceptPort(ConnectionManager connectionManager, java.lang.String configPrefixName, java.net.InetAddress bindAddress, int bindport)
          Constructs an new accept port with the given bind address and port that uses the given connection manager and save the settings to the configuration property object.
 
Method Summary
 void close()
          Closes the port by closing the accept thread (if needed).
 ConnectionMonitor getAcceptMonitor()
          Obtain the monitor watching the basic behavior of this AcceptPort.
 AcceptPolicy getAcceptPolicy()
          The accept policy specific to this accept port.
 java.net.InetAddress getAddress()
          Returns the inet address that will be used.
 ConnectionMonitor getConnectMonitor()
          Obtain the monitor watching the accepted connection behavior of this AcceptPort.
 ConnectionMonitor getDisconnectMonitor()
          Obtain the monitor watching the rejected connection behavior of this AcceptPort.
 int getPort()
          Returns the port number this accept port will use.
 long getUptime()
          Returns the number of milliseconds the accept port has been open or -1 if the accept port is closed.
 boolean isSecure()
          Returns true if this accept port generates natively secure connections.
 void open()
          Opens the port by starting up an accept thread (if needed).
 void remove()
          Closes the AcceptPort and removes it from service.
 void setAddress(java.net.InetAddress address)
          Sets the inet address that will be used.
 void setPort(int port)
          Sets the port number this accept port will use.
 void setSecure(boolean secure)
          Sets the security status of this connection.
 java.lang.String toString()
          Generates a string representation of this port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AcceptPort

public AcceptPort(ConnectionManager connectionManager,
                  java.lang.String configPrefixName)
           throws java.io.IOException
Loads an existing accept port from the configuration property object that uses the given connection manager.

Parameters:
connectionManager - the connection manager that will handle connections produced by the accept port
configPrefixName - the name of the jive property this port is saved to.
Throws:
java.io.IOException - if there was problem initializing the port.

AcceptPort

public AcceptPort(ConnectionManager connectionManager,
                  java.lang.String configPrefixName,
                  java.net.InetAddress bindAddress,
                  int bindport)
Constructs an new accept port with the given bind address and port that uses the given connection manager and save the settings to the configuration property object.

Newly created accept ports always are created closed. Callers must manually open the port to begin accepting connections.

Parameters:
connectionManager - the connection manager that will. handle connections produced by this accept port.
bindAddress - the address the new port should bind to.
bindport - the port number the new should bind to.
configPrefixName - the name of the jive property this port is saved to.
Method Detail

isSecure

public boolean isSecure()
Returns true if this accept port generates natively secure connections.

Returns:
true if the port is secure (e.g. SSL/TLS).

setSecure

public void setSecure(boolean secure)
Sets the security status of this connection. Essentially determines if an SSLServerSocket should be used. Secure accept ports natively create SSL/TLS secured sockets. However, since many protocols support SASL, connections that are not created securely, can be later secured by negotiating TLS.

Parameters:
secure - true if the port is secure (e.g. SSL/TLS)

getPort

public int getPort()
Returns the port number this accept port will use.

Returns:
The port number this accept port uses

setPort

public void setPort(int port)
Sets the port number this accept port will use. If the port is open the port will automatically be closed before changing the port number. The port will NOT be automatically re-opened once the port number is changed.

Parameters:
port - the port number for this port to use.

getAddress

public java.net.InetAddress getAddress()
Returns the inet address that will be used. The inet address can be either a particular address representing a network interface the accept port binds to, or null if any/all interfaces should be used. Although the inet address becomes set once the underlying server socket is bound, this method will continue to return null if the target is any/all. Use the Connections produced by the accept port to determine the local interface any particular connection is attached to.

Returns:
the inet address this port is bound to, or null if any/all.

setAddress

public void setAddress(java.net.InetAddress address)
Sets the inet address that will be used. The inet address can be either a particular address representing a network interface the accept port binds to, or null if any/all interfaces should be used. Although the inet address becomes set once the underlying server socket is bound, this method will continue to return null if the target is any/all. Use the Connections produced by the accept port to determine the local interface any particular connection is attached to.

If the port is open the port will automatically be closed before changing the address. The port will NOT be automatically re-opened once the address is changed.

Parameters:
address - the inet address this port is bound to, or null if any/all.

getUptime

public long getUptime()
Returns the number of milliseconds the accept port has been open or -1 if the accept port is closed.

Returns:
the number of milliseconds the accept port has been open or -1 if closed

open

public void open()
          throws java.io.IOException,
                 java.lang.SecurityException,
                 java.lang.IllegalArgumentException
Opens the port by starting up an accept thread (if needed).

Throws:
java.io.IOException - If the the port is already bound or otherwise failed to open
java.lang.SecurityException - If the security manager refuses the operation
java.lang.IllegalArgumentException - If the InetAddress is not valid on this machine

close

public void close()
           throws java.io.IOException
Closes the port by closing the accept thread (if needed).

Throws:
java.io.IOException - if the the port is already bound or otherwise failed to open.

remove

public void remove()
            throws java.io.IOException

Closes the AcceptPort and removes it from service.

Throws:
java.io.IOException - if there was a problem closing the connection.

getAcceptPolicy

public AcceptPolicy getAcceptPolicy()

The accept policy specific to this accept port.

Incoming accept requests are evaluated with the AcceptPort's AcceptPolicy. The AcceptManager only checks this accept policy when deciding whether to connect or reject incoming sockets. Most accept port specific accept policies should use the results of the global AcceptManager AcceptPolicy in determining the overall accept response.

Returns:
the accept policy for the accept port.

getAcceptMonitor

public ConnectionMonitor getAcceptMonitor()

Obtain the monitor watching the basic behavior of this AcceptPort.

Counts the raw connections accepted before the accept policy is applied and the sockets are added to the ConnectionManager or they are disconnected because they fail to pass the accept policy.

Returns:
the accept monitor watching this accept port.

getConnectMonitor

public ConnectionMonitor getConnectMonitor()

Obtain the monitor watching the accepted connection behavior of this AcceptPort.

Returns:
the connection monitor watching this accept port.

getDisconnectMonitor

public ConnectionMonitor getDisconnectMonitor()

Obtain the monitor watching the rejected connection behavior of this AcceptPort.

Returns:
the connection monitor watching this accept port.

toString

public java.lang.String toString()

Generates a string representation of this port.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of this port.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.