diff options
author | Dmitriy Kargapolov <[email protected]> | 2015-01-31 23:18:23 -0500 |
---|---|---|
committer | Dmitriy Kargapolov <[email protected]> | 2015-01-31 23:22:21 -0500 |
commit | fd76d49c7d7bbed4775818390e47b958ee50f469 (patch) | |
tree | 196b0c358ab4f188a8498dfb8f255c8c4e47259f /lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java | |
parent | 8c93fcbb746be862e07db22b7406d370a12c39d2 (diff) | |
download | otp-fd76d49c7d7bbed4775818390e47b958ee50f469.tar.gz otp-fd76d49c7d7bbed4775818390e47b958ee50f469.tar.bz2 otp-fd76d49c7d7bbed4775818390e47b958ee50f469.zip |
jinterface: transport factory implementation
Transport factory basic implementation added. This makes possible
creating connections between nodes using ssh channels for example.
Default transport factory based on standart Socket/ServerSocket
classes is provided. Modifications are backward compatible.
Diffstat (limited to 'lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java')
-rw-r--r-- | lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java index 6f07d8171e..0a33984b31 100644 --- a/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java +++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/AbstractNode.java @@ -64,13 +64,14 @@ import java.net.UnknownHostException; * instead. * </p> */ -public class AbstractNode { +public class AbstractNode implements OtpTransportFactory { static String localHost = null; String node; String host; String alive; String cookie; static String defaultCookie = null; + final OtpTransportFactory transportFactory; // Node types static final int NTYPE_R6 = 110; // 'n' post-r5, all nodes @@ -146,21 +147,41 @@ public class AbstractNode { } } - protected AbstractNode() { + protected AbstractNode(final OtpTransportFactory transportFactory) { + this.transportFactory = transportFactory; } /** - * Create a node with the given name and the default cookie. + * Create a node with the given name and default cookie and transport + * factory. */ protected AbstractNode(final String node) { - this(node, defaultCookie); + this(node, defaultCookie, new OtpSocketTransportFactory()); } /** - * Create a node with the given name and cookie. + * Create a node with the given name, transport factory and the default + * cookie. + */ + protected AbstractNode(final String node, + final OtpTransportFactory transportFactory) { + this(node, defaultCookie, transportFactory); + } + + /** + * Create a node with the given name, cookie and default transport factory. */ protected AbstractNode(final String name, final String cookie) { + this(name, cookie, new OtpSocketTransportFactory()); + } + + /** + * Create a node with the given name, cookie and transport factory. + */ + protected AbstractNode(final String name, final String cookie, + final OtpTransportFactory transportFactory) { this.cookie = cookie; + this.transportFactory = transportFactory; final int i = name.indexOf('@', 0); if (i < 0) { @@ -268,4 +289,19 @@ public class AbstractNode { } return home; } + + public OtpTransport createTransport(final String addr, final int port) + throws IOException { + return transportFactory.createTransport(addr, port); + } + + public OtpTransport createTransport(final InetAddress addr, final int port) + throws IOException { + return transportFactory.createTransport(addr, port); + } + + public OtpServerTransport createServerTransport(final int port) + throws IOException { + return transportFactory.createServerTransport(port); + } } |