|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.rmi.server.RMISocketFactory
util.rmi.VpnSocketFactory
public class VpnSocketFactory
This class allows the usage of a custom RMI Socket Factory for all registry
services. It is intended to replace the standard rmiregistry
tool in the case of a VPN network, where the server is accessed by
local clients
within a local subnetwork, which is part of a bigger VPN network. These
clients connect to the server using its 'true' IP address, they must be
fast and reliable. Other clients connecting via the VPN address are
intended mainly for monitoring purpose. Their connection is slow and
prone to failures.
On startup, the System property VPNHOSTS is searched, and if
pointing to a resolvable resource, this resource is loaded as a
String-toString mapping. If the property is not set, DEFVPNMAP
is used. The only thing that chances is the client socket factory, in
a way that, if originating from within the local subnet, determined by
comparing the main server IP with the local host name of the client and
matching for the first three IP bytes, nothing is changed, but if connecting
from the outside, the mapping address is used.
On STELLA, this class is used for the servers in Tenerife:
161.72.132.72 links to 141.33.210.38
161.72.132.71 links to 141.33.210.34
For problems related to java.rmi.ServerError see
RegistryLister,
Serialized Form| Nested Class Summary | |
|---|---|
static class |
VpnSocketFactory.Rmiregistry
Starts an RMI-registry on the default port, setting the default socket factory to our implementation. |
| Field Summary | |
|---|---|
private static RMISocketFactory |
def
The default socket factory that was active before we get selected. |
private static String[][] |
DEFVPNMAP
Default mapping of IP server addresses to VPN hosts, new 2011. |
static String |
JAVAHOST
The java system property java.rmi.server.hostname. |
private static InetAddress |
local
The local IP address. |
private static VpnSocketFactory |
mysockfac
The only running instance, created at class-load. |
private static long |
serialVersionUID
|
static String |
VPNHOSTS
The name of the system property that points to a valid mapping. |
private Map<String,String> |
vpnmap
The mapping to use for IP server names to VPN connect names. |
| Constructor Summary | |
|---|---|
private |
VpnSocketFactory()
On construct, we scan for the VPNHOSTS property. |
| Method Summary | |
|---|---|
ServerSocket |
createServerSocket(int port)
The server socket is unchanged from the defaults. |
Socket |
createSocket(String host,
int port)
Creates the client socket. |
boolean |
equals(Object obj)
|
static Remote |
exportObject(Remote obj)
We replace the unicast export by a unicast export using our factory. |
static Remote |
exportObject(Remote obj,
int port)
We replace the unicast export by a unicast export using our factory. |
private static Map<String,String> |
fileLoad(File file)
Loads properties from the given file. |
private static Map<String,String> |
fileLoad(String filename)
Loads properties from the given file. |
private static Map<String,String> |
fromResourceBundle(ResourceBundle prop)
Scans a resource bundle for it's keys and re-maps them. |
private String |
getDomain(InetAddress ip)
From the inet address supplied, we grep the domain as a string. |
int |
hashCode()
|
private static Map<String,String> |
load(InputStream in)
Loads properties from an input stream. |
private static Map<String,String> |
load(URL url)
Loads properties from an URL. |
private static Map<String,String> |
scanSystem(String key)
Scans a system resource and returns it as a String-toString mapping. |
| Methods inherited from class java.rmi.server.RMISocketFactory |
|---|
getDefaultSocketFactory, getFailureHandler, getSocketFactory, setFailureHandler, setSocketFactory |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String VPNHOSTS
public static final String JAVAHOST
java.rmi.server.hostname.
private static final String[][] DEFVPNMAP
private static final RMISocketFactory def
private static final long serialVersionUID
private static InetAddress local
private Map<String,String> vpnmap
private static VpnSocketFactory mysockfac
| Constructor Detail |
|---|
private VpnSocketFactory()
VPNHOSTS property. If not
present, we use the default mapping in DEFVPNMAP.
| Method Detail |
|---|
public static Remote exportObject(Remote obj)
throws RemoteException
RemoteException
public static Remote exportObject(Remote obj,
int port)
throws RemoteException
RemoteExceptionprivate static Map<String,String> scanSystem(String key)
private static Map<String,String> fromResourceBundle(ResourceBundle prop)
private static Map<String,String> fileLoad(String filename)
private static Map<String,String> fileLoad(File file)
private static Map<String,String> load(URL url)
private static Map<String,String> load(InputStream in)
public ServerSocket createServerSocket(int port)
throws IOException
createServerSocket in interface RMIServerSocketFactorycreateServerSocket in class RMISocketFactoryIOException
public Socket createSocket(String host,
int port)
throws IOException
createSocket in interface RMIClientSocketFactorycreateSocket in class RMISocketFactoryIOExceptionpublic int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Objectprivate String getDomain(InetAddress ip)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||