APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.rmi.transport.tcp

public Class TCPEndpoint

extends Object
implements Endpoint
Class Inheritance
All Implemented Interfaces
sun.rmi.transport.Endpoint
Imports
java.io.DataInput, .DataOutput, .IOException, .ObjectInput, .ObjectOutput, java.lang.reflect.Proxy, java.net.InetAddress, .ServerSocket, .Socket, java.rmi.ConnectIOException, .RemoteException, java.rmi.server.RMIClientSocketFactory, .RMIServerSocketFactory, .RMISocketFactory, java.util.Collection, .HashMap, .HashSet, .LinkedList, .Map, .Set, sun.rmi.runtime.Log, .RuntimeUtil, sun.rmi.transport.Channel, .Endpoint, .Target, .Transport

TCPEndpoint represents some communication endpoint for an address space (VM).
Author
Ann Wollrath

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
TCPEndpoint.FQDN

The class FQDN encapsulates a routine that makes a best effort attempt to retrieve the fully qualified domain name of the local host.

Field Summary

Modifier and TypeField and Description
private final RMIClientSocketFactory
csf

custom client socket factory (null if not custom factory)

private static final int
private static final int
private String
host

IP address or host name

private int
listenPort

if local, the port number to listen on

private static final Map<TCPEndpoint, LinkedList<TCPEndpoint>>
localEndpoints

maps an endpoint key containing custom socket factories to their own unique endpoint

private static String
localHost

the local host name

private static boolean
localHostKnown

true if real local host name is known yet

private int
port

port number

private final RMIServerSocketFactory
ssf

custom server socket factory (null if not custom factory)

private TCPTransport
transport

if local, the transport object associated with this endpoint

Constructor Summary

AccessConstructor and Description
public
TCPEndpoint(String host, int port)

Create an endpoint for a specified host and port.

public
TCPEndpoint(String host, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)

Create a custom socket factory endpoint for a specified host and port.

Method Summary

Modifier and TypeMethod and Description
private static Collection<TCPTransport>
allKnownTransports()

Returns the current list of known transports.

private static RMISocketFactory
public boolean
equals(Object obj)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public void
exportObject(Target target)

Implements sun.rmi.transport.Endpoint.exportObject.

Export the object to accept incoming calls.

private static boolean
public Channel
getChannel()

Implements sun.rmi.transport.Endpoint.getChannel.

Returns a channel for this (remote) endpoint.

public RMIClientSocketFactory
getClientSocketFactory()

Get the client socket factory associated with this endpoint.

public String
getHost()

Returns address for endpoint

private static String
getHostnameProperty()

Returns the value of the java.rmi.server.hostname property.

public Transport
getInboundTransport()

Implements sun.rmi.transport.Endpoint.getInboundTransport.

Returns the transport for incoming connections to this endpoint, if this endpoint was created as a server endpoint (using getLocalEndpoint).

private static int
getInt(String name, int def)

public int
getListenPort()

Returns the port that this endpoint's inbound transport listens on, if this endpoint was created as a server endpoint (using getLocalEndpoint).

public static TCPEndpoint
getLocalEndpoint(int port)

Get an endpoint for the local address space on specified port.

public static TCPEndpoint
public Transport
getOutboundTransport()

Implements sun.rmi.transport.Endpoint.getOutboundTransport.

Returns transport for making connections to remote endpoints; (here, the default transport at port 0 is used).

public int
getPort()

Returns the port for this endpoint.

public RMIServerSocketFactory
getServerSocketFactory()

Get the server socket factory associated with this endpoint.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

pack-priv ServerSocket
newServerSocket()

Return new server socket to listen for connections on this endpoint.

pack-priv Socket
newSocket()

Open and return new client socket connection to endpoint.

public static TCPEndpoint
read(ObjectInput
the input stream
in
)

Get the endpoint from the input stream.

public static TCPEndpoint
readHostPortFormat(DataInput
the input stream
in
)

Create a new endpoint from input stream data.

private static String
resampleLocalHost()

Resamples the local hostname and returns the possibly-updated local hostname.

pack-priv static void
setDefaultPort(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)

Set the port of the (shared) default endpoint object.

pack-priv static void
setLocalHost(String host)

Set the local host name, if currently unknown.

public static void
shedConnectionCaches()

Release idle outbound connections to reduce demand on I/O resources.

public String
toString()

Overrides java.lang.Object.toString.

Return string representation for endpoint.

public void
write(ObjectOutput out)

Write endpoint to output stream.

public void
writeHostPortFormat(DataOutput out)

Write endpoint to output stream in older format used by UnicastRef for JDK1.1 compatibility.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

csfback to summary
private final RMIClientSocketFactory csf

custom client socket factory (null if not custom factory)

FORMAT_HOST_PORTback to summary
private static final int FORMAT_HOST_PORT
FORMAT_HOST_PORT_FACTORYback to summary
private static final int FORMAT_HOST_PORT_FACTORY
hostback to summary
private String host

IP address or host name

listenPortback to summary
private int listenPort

if local, the port number to listen on

localEndpointsback to summary
private static final Map<TCPEndpoint, LinkedList<TCPEndpoint>> localEndpoints

maps an endpoint key containing custom socket factories to their own unique endpoint

localHostback to summary
private static String localHost

the local host name

localHostKnownback to summary
private static boolean localHostKnown

true if real local host name is known yet

portback to summary
private int port

port number

ssfback to summary
private final RMIServerSocketFactory ssf

custom server socket factory (null if not custom factory)

transportback to summary
private TCPTransport transport

if local, the transport object associated with this endpoint

Constructor Detail

TCPEndpointback to summary
public TCPEndpoint(String host, int port)

Create an endpoint for a specified host and port. This should not be used by external classes to create endpoints for servers in this VM; use getLocalEndpoint instead.

TCPEndpointback to summary
public TCPEndpoint(String host, int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)

Create a custom socket factory endpoint for a specified host and port. This should not be used by external classes to create endpoints for servers in this VM; use getLocalEndpoint instead.

Method Detail

allKnownTransportsback to summary
private static Collection<TCPTransport> allKnownTransports()

Returns the current list of known transports. The returned list is an unshared collection of Transports, including all transports which may have channels to remote endpoints.

chooseFactoryback to summary
private static RMISocketFactory chooseFactory()
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

exportObjectback to summary
public void exportObject(Target target) throws RemoteException

Implements sun.rmi.transport.Endpoint.exportObject.

Export the object to accept incoming calls.

getBooleanback to summary
private static boolean getBoolean(String name)
getChannelback to summary
public Channel getChannel()

Implements sun.rmi.transport.Endpoint.getChannel.

Returns a channel for this (remote) endpoint.

getClientSocketFactoryback to summary
public RMIClientSocketFactory getClientSocketFactory()

Get the client socket factory associated with this endpoint.

getHostback to summary
public String getHost()

Returns address for endpoint

getHostnamePropertyback to summary
private static String getHostnameProperty()

Returns the value of the java.rmi.server.hostname property.

getInboundTransportback to summary
public Transport getInboundTransport()

Implements sun.rmi.transport.Endpoint.getInboundTransport.

Returns the transport for incoming connections to this endpoint, if this endpoint was created as a server endpoint (using getLocalEndpoint).

getIntback to summary
private static int getInt(String name, int def)
getListenPortback to summary
public int getListenPort()

Returns the port that this endpoint's inbound transport listens on, if this endpoint was created as a server endpoint (using getLocalEndpoint). If this endpoint was created for the default/anonymous port, then this method returns zero even if the transport has started listening.

getLocalEndpointback to summary
public static TCPEndpoint getLocalEndpoint(int port)

Get an endpoint for the local address space on specified port. If port number is 0, it returns shared default endpoint object whose host name and port may or may not have been determined.

getLocalEndpointback to summary
public static TCPEndpoint getLocalEndpoint(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)
getOutboundTransportback to summary
public Transport getOutboundTransport()

Implements sun.rmi.transport.Endpoint.getOutboundTransport.

Returns transport for making connections to remote endpoints; (here, the default transport at port 0 is used).

getPortback to summary
public int getPort()

Returns the port for this endpoint. If this endpoint was created as a server endpoint (using getLocalEndpoint) for a default/anonymous port and its inbound transport has started listening, this method returns (instead of zero) the actual bound port suitable for passing to clients.

getServerSocketFactoryback to summary
public RMIServerSocketFactory getServerSocketFactory()

Get the server socket factory associated with this endpoint.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
newServerSocketback to summary
pack-priv ServerSocket newServerSocket() throws IOException

Return new server socket to listen for connections on this endpoint.

newSocketback to summary
pack-priv Socket newSocket() throws RemoteException

Open and return new client socket connection to endpoint.

readback to summary
public static TCPEndpoint read(ObjectInput in) throws IOException, ClassNotFoundException

Get the endpoint from the input stream.

Parameters
in:ObjectInput

the input stream

Exceptions
IOException:
If id could not be read (due to stream failure)
readHostPortFormatback to summary
public static TCPEndpoint readHostPortFormat(DataInput in) throws IOException

Create a new endpoint from input stream data.

Parameters
in:DataInput

the input stream

resampleLocalHostback to summary
private static String resampleLocalHost()

Resamples the local hostname and returns the possibly-updated local hostname.

setDefaultPortback to summary
pack-priv static void setDefaultPort(int port, RMIClientSocketFactory csf, RMIServerSocketFactory ssf)

Set the port of the (shared) default endpoint object. When first created, it contains port 0 because the transport hasn't tried to listen to get assigned a port, or if listening failed, a port hasn't been assigned from the server.

setLocalHostback to summary
pack-priv static void setLocalHost(String host)

Set the local host name, if currently unknown.

shedConnectionCachesback to summary
public static void shedConnectionCaches()

Release idle outbound connections to reduce demand on I/O resources. All transports are asked to release excess connections.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Return string representation for endpoint.

writeback to summary
public void write(ObjectOutput out) throws IOException

Write endpoint to output stream.

writeHostPortFormatback to summary
public void writeHostPortFormat(DataOutput out) throws IOException

Write endpoint to output stream in older format used by UnicastRef for JDK1.1 compatibility.

sun.rmi.transport.tcp back to summary

private Class TCPEndpoint.FQDN

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

The class FQDN encapsulates a routine that makes a best effort attempt to retrieve the fully qualified domain name of the local host.
Author
Laird Dornin

Field Summary

Modifier and TypeField and Description
private String
private String
reverseLookup

strings in which we can store discovered fqdn

Constructor Summary

AccessConstructor and Description
private
FQDN(String hostAddress)

Method Summary

Modifier and TypeMethod and Description
pack-priv static String
attemptFQDN(InetAddress localAddr)

Do our best to obtain a fully qualified hostname for the local host.

private void
getFQDN()

Method that that will start a thread to wait to retrieve a fully qualified domain name from a name service.

private synchronized String
public void
run()

Implements java.lang.Runnable.run.

thread to query a name service for the fqdn of this host.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hostAddressback to summary
private String hostAddress
reverseLookupback to summary
private String reverseLookup

strings in which we can store discovered fqdn

Constructor Detail

FQDNback to summary
private FQDN(String hostAddress)

Method Detail

attemptFQDNback to summary
pack-priv static String attemptFQDN(InetAddress localAddr) throws UnknownHostException

Do our best to obtain a fully qualified hostname for the local host. Perform the following steps to get a localhostname: 1. InetAddress.getLocalHost().getHostName() - if contains '.' use as FQDN 2. if no '.' query name service for FQDN in a thread

Note

We query the name service for an FQDN by creating an InetAddress via a stringified copy of the local ip address; this creates an InetAddress with a null hostname. Asking for the hostname of this InetAddress causes a name service lookup. 3. if name service takes too long to return, use ip address 4. if name service returns but response contains no '.' default to ipaddress.

getFQDNback to summary
private void getFQDN()

Method that that will start a thread to wait to retrieve a fully qualified domain name from a name service. The spawned thread may never return but we have marked it as a daemon so the vm will terminate appropriately.

getHostback to summary
private synchronized String getHost()
runback to summary
public void run()

Implements java.lang.Runnable.run.

thread to query a name service for the fqdn of this host.