-
-
Save niklas1375/a7f2ee76d2c387d5705b942fa99b37ba to your computer and use it in GitHub Desktop.
Connectivity Socket Factory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package my.infrastructure; | |
import java.io.IOException; | |
import java.net.InetAddress; | |
import java.net.Socket; | |
import java.net.UnknownHostException; | |
import javax.net.SocketFactory; | |
// service connection based on CFServiceFacade class https://gist.github.com/niklas1375/01254bcee0fb90a33e02c9ae1aca9701 | |
import my.util.ConnectivityService; | |
public class ConnectivitySocketFactory extends SocketFactory { | |
private ConnectivityService conn = new ConnectivityService(); | |
private String locationId; | |
public ConnectivitySocketFactory(String locationId) { | |
this.locationId = locationId; | |
} | |
@Override | |
public Socket createSocket() throws IOException { | |
return conn.getProxy(locationId); | |
} | |
@Override | |
public Socket createSocket(String host, int port) throws IOException, UnknownHostException { | |
return conn.getProxy(locationId); | |
} | |
@Override | |
public Socket createSocket(String host, int port, InetAddress localHost, int localPort) | |
throws IOException, UnknownHostException { | |
return conn.getProxy(locationId); | |
} | |
@Override | |
public Socket createSocket(InetAddress host, int port) throws IOException { | |
return conn.getProxy(locationId); | |
} | |
@Override | |
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) | |
throws IOException { | |
return conn.getProxy(locationId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment